qutip/QuantumToolbox.jl

CUDA Extension

ytdHuang opened this issue · 0 comments

  • Support CUDA functions e.g., cu()
  • Multiple dispatch for different type of Arrays

We can define the function as

cu(A::QuantumObject{<:AbstractArray{T}}; word_size::Int=32) where T<:Number

The keyword argument word_size can decide whether to change the element type for the output.
For example,

julia> H = sigmax()
Quantum Object:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=true
2×2 SparseMatrixCSC{ComplexF64, Int64} with 2 stored entries:
           1.0+0.0im
 1.0+0.0im          

julia> cu(H)
Quantum Object:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=true
2×2 CuSparseMatrixCSC{ComplexF32, Int32} with 2 stored entries:
           1.0+0.0im
 1.0+0.0im          

julia> cu(H, word_size=64)
Quantum Object:   type=Operator   dims=[2]   size=(2, 2)   ishermitian=true
2×2 CuSparseMatrixCSC{ComplexF64, Int64} with 2 stored entries:
           1.0+0.0im
 1.0+0.0im