Skip to content

Commit 8e50847

Browse files
michel2323vchuravy
andauthored
Support new functionality from KA 0.9.32 (#2774)
Co-authored-by: Valentin Churavy <[email protected]>
1 parent 253f6b3 commit 8e50847

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ ExprTools = "0.1"
6363
GPUArrays = "11.2.1"
6464
GPUCompiler = "0.24, 0.25, 0.26, 0.27, 1"
6565
GPUToolbox = "0.2"
66-
KernelAbstractions = "0.9.2"
66+
KernelAbstractions = "0.9.32"
6767
LLVM = "9.1"
6868
LLVMLoopInfo = "1"
6969
LazyArtifacts = "1"

src/CUDAKernels.jl

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ Adapt.adapt_storage(::KA.CPU, a::Union{CuArray,CUSPARSE.AbstractCuSparseArray})
3838
## memory operations
3939

4040
function KA.copyto!(::CUDABackend, A, B)
41-
A isa Array && CUDA.pin(A)
42-
B isa Array && CUDA.pin(B)
43-
4441
GC.@preserve A B begin
4542
destptr = pointer(A)
4643
srcptr = pointer(B)
@@ -50,6 +47,25 @@ function KA.copyto!(::CUDABackend, A, B)
5047
return A
5148
end
5249

50+
function KA.pagelock!(::CUDABackend, A::Array)
51+
CUDA.pin(A)
52+
return nothing
53+
end
54+
55+
## device operations
56+
57+
function KA.ndevices(::CUDABackend)
58+
return ndevices()
59+
end
60+
61+
function KA.device(::CUDABackend)
62+
deviceid(CUDA.active_state().device) + 1
63+
end
64+
65+
function KA.device!(::CUDABackend, id::Int32)
66+
device!(id - 1)
67+
end
68+
5369
## kernel launch
5470

5571
function KA.mkcontext(kernel::KA.Kernel{CUDABackend}, _ndrange, iterspace)

0 commit comments

Comments
 (0)