Skip to content

Commit

Permalink
Add copy to and from functions
Browse files Browse the repository at this point in the history
  • Loading branch information
huiyuxie committed Aug 8, 2024
1 parent c228449 commit 453c845
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/solvers/common.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Define common functions for all solvers
# fixme: Dispatch different functions for Flaot64 and Float32 to improve performance, maybe exists a better way for Float32

Check warning on line 2 in src/solvers/common.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"Flaot" should be "Float".

# Copy matrices from host to device (Float64)
function copy_to_device!(du::PtrArray{Float64}, u::PtrArray{Float64})
Expand All @@ -9,9 +10,10 @@ function copy_to_device!(du::PtrArray{Float64}, u::PtrArray{Float64})
end

# Copy matrices from device to host (Float64)
function copy_to_host!(du::PtrArray{Float64}, u::PtrArray{Float64})
du = Array(du)
u = Array(u)
function copy_to_host!(du::CuArray{Float64}, u::CuArray{Float64})
# fixme: maybe direct PtrArray to CuArray conversion is possible
du = PtrArray(Array(du))
u = PtrArray(Array(u))

return (du, u)
end
1 change: 1 addition & 0 deletions src/solvers/solvers.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("common.jl")

0 comments on commit 453c845

Please sign in to comment.