Skip to content

Commit 49a3e07

Browse files
committed
new GPUArrays interface for KA transition
1 parent 7f725c0 commit 49a3e07

File tree

1 file changed

+3
-39
lines changed

1 file changed

+3
-39
lines changed

src/gpuarrays.jl

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# GPUArrays.jl interface
22

3+
import KernelAbstractions
4+
import KernelAbstractions: Backend
35

46
#
57
# Device functionality
@@ -8,9 +10,7 @@
810

911
## execution
1012

11-
struct CuArrayBackend <: AbstractGPUBackend end
12-
13-
struct CuKernelContext <: AbstractKernelContext end
13+
struct CuArrayBackend <: Backend end
1414

1515
@inline function GPUArrays.launch_heuristic(::CuArrayBackend, f::F, args::Vararg{Any,N};
1616
elements::Int, elements_per_thread::Int) where {F,N}
@@ -24,39 +24,3 @@ struct CuKernelContext <: AbstractKernelContext end
2424
launch_configuration(kernel.fun; max_threads=256)
2525
end
2626
end
27-
28-
@inline function GPUArrays.gpu_call(::CuArrayBackend, f::F, args::TT, threads::Int,
29-
blocks::Int; name::Union{String,Nothing}) where {F,TT}
30-
@cuda threads blocks name f(CuKernelContext(), args...)
31-
end
32-
33-
34-
## on-device
35-
36-
# indexing
37-
38-
GPUArrays.blockidx(ctx::CuKernelContext) = blockIdx().x
39-
GPUArrays.blockdim(ctx::CuKernelContext) = blockDim().x
40-
GPUArrays.threadidx(ctx::CuKernelContext) = threadIdx().x
41-
GPUArrays.griddim(ctx::CuKernelContext) = gridDim().x
42-
43-
# memory
44-
45-
@inline function GPUArrays.LocalMemory(::CuKernelContext, ::Type{T}, ::Val{dims}, ::Val{id}
46-
) where {T, dims, id}
47-
ptr = CUDA._shmem(Val(id), T, Val(prod(dims)))
48-
ptr = reinterpret(LLVMPtr{T, AS.Shared}, ptr)
49-
CuDeviceArray{T,length(dims),AS.Shared}(ptr, dims)
50-
end
51-
52-
# synchronization
53-
54-
@inline GPUArrays.synchronize_threads(::CuKernelContext) = sync_threads()
55-
56-
57-
58-
#
59-
# Host abstractions
60-
#
61-
62-
GPUArrays.backend(::Type{<:CuArray}) = CuArrayBackend()

0 commit comments

Comments
 (0)