Skip to content

Commit 6394148

Browse files
committed
Launch interface
1 parent 84d0c68 commit 6394148

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

src/KernelAbstractions.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,10 @@ Declare storage that is local to a workgroup.
244244
"""
245245
macro localmem(T, dims)
246246
# Stay in sync with CUDAnative
247-
id = gensym("static_shmem")
247+
# id = gensym("static_shmem")
248248

249249
return quote
250-
$SharedMemory($(esc(T)), Val($(esc(dims))), Val($(QuoteNode(id))))
250+
$SharedMemory($(esc(T)), Val($(esc(dims))))#, Val($(QuoteNode(id))))
251251
end
252252
end
253253

@@ -814,7 +814,8 @@ include("macros.jl")
814814
###
815815

816816
function Scratchpad end
817-
SharedMemory(t::Type{T}, dims::Val{Dims}, id::Val{Id}) where {T, Dims, Id} = KernelIntrinsics.localmemory(t, dims, id)
817+
# SharedMemory(t::Type{T}, dims::Val{Dims}, id::Val{Id}) where {T, Dims, Id} = KernelIntrinsics.localmemory(t, dims, id)
818+
SharedMemory(t::Type{T}, dims::Val{Dims}) where {T, Dims} = KernelIntrinsics.localmemory(t, dims)
818819

819820
__synchronize() = KernelIntrinsics.barrier()
820821

src/intrinsics.jl

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,47 @@ Returns the unique group ID.
5151
"""
5252
function get_group_id end
5353

54-
function localmemory end
54+
"""
55+
localmemory(T, dims)
56+
57+
Declare memory that is local to a workgroup.
58+
59+
!!! note
60+
Backend implementations **must** implement:
61+
```
62+
localmemory(T::DataType, ::Val{Dims}) where {T, Dims}
63+
```
64+
As well as the on-device functionality.
65+
"""
66+
localmemory(::Type{T}, dims) where T = localmemory(T, Val(dims))
67+
# @inline localmemory(::Type{T}, dims::Val{Dims}) where {T, Dims} = localmemory(T, dims, Val(gensym("static_shmem")))
68+
5569
function barrier()
5670
error("Group barrier used outside kernel or not captured")
5771
end
5872
function print end
5973

74+
75+
"""
76+
KIKernel{Backend, BKern}
77+
78+
KIKernel closure struct that is used to represent the backend
79+
kernel on the host.
80+
81+
!!! note
82+
Backend implementations **must** implement:
83+
```
84+
KI.KIKernel(::NewBackend, f, args...; kwargs...)
85+
(kernel::KIKernel{<:NewBackend})(args...; numworkgroups=nothing, workgroupsize=nothing)
86+
```
87+
As well as the on-device functionality.
88+
"""
89+
struct KIKernel{Backend, BKern}
90+
backend::Backend
91+
kern::BKern
92+
end
93+
94+
function kernel_max_work_group_size end
95+
function max_work_group_size end
96+
function multiprocessor_count end
6097
end

src/pocl/backend.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ end
178178

179179
## Shared and Scratch Memory
180180

181-
@device_override @inline function KI.localmemory(::Type{T}, ::Val{Dims}, ::Val{Id}) where {T, Dims, Id}
181+
@device_override @inline function KI.localmemory(::Type{T}, ::Val{Dims}) where {T, Dims}
182182
ptr = POCL.emit_localmemory(T, Val(prod(Dims)))
183183
CLDeviceArray(Dims, ptr)
184184
end

0 commit comments

Comments
 (0)