Skip to content

Commit 48c6b8b

Browse files
committed
Tests
1 parent 0636279 commit 48c6b8b

File tree

1 file changed

+48
-4
lines changed

1 file changed

+48
-4
lines changed

src/intrinsics.jl

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,18 +160,62 @@ Used for certain algorithm optimizations.
160160
"""
161161
multiprocessor_count(_) = 0
162162

163-
# TODO: docstring
164-
# kiconvert(::NewBackend, arg)
163+
"""
164+
kiconvert(::NewBackend, arg)
165+
166+
This function is called for every argument to be passed to a kernel, allowing it to be
167+
converted to a GPU-friendly format.
168+
169+
!!! note
170+
Backend implementations **must** implement:
171+
```
172+
kiconvert(::NewBackend, arg)
173+
```
174+
"""
165175
function kiconvert end
166176

167-
# TODO: docstring
168-
# KI.kifunction(::NewBackend, f::F, tt::TT=Tuple{}; name=nothing, kwargs...) where {F,TT}
177+
"""
178+
KI.kifunction(::NewBackend, f::F, tt::TT=Tuple{}; name=nothing, kwargs...) where {F,TT}
179+
180+
Low-level interface to compile a function invocation for the currently-active GPU, returning
181+
a callable kernel object. For a higher-level interface, use [`@kikernel`](@ref).
182+
183+
Currently, only `kifunction` only supports the `name` keyword argument as it is the only one
184+
by all backends.
185+
186+
Keyword arguments:
187+
- `name`: override the name that the kernel will have in the generated code
188+
189+
!!! note
190+
Backend implementations **must** implement:
191+
```
192+
kifunction(::NewBackend, f::F, tt::TT=Tuple{}; name=nothing, kwargs...) where {F,TT}
193+
```
194+
"""
169195
function kifunction end
170196

171197
const MACRO_KWARGS = [:launch]
172198
const COMPILER_KWARGS = [:name]
173199
const LAUNCH_KWARGS = [:numworkgroups, :workgroupsize]
174200

201+
"""
202+
@kikernel backend workgroupsize=... numworkgroups=... [kwargs...] func(args...)
203+
204+
High-level interface for executing code on a GPU.
205+
206+
The `@kikernel` macro should prefix a call, with `func` a callable function or object that
207+
should return nothing. It will be compiled to a function native to the specified `backend`
208+
upon first use, and to a certain extent arguments will be converted and managed automatically
209+
using `kiconvert`. Finally, if `launch=true`, the newly created callable kernel object is
210+
called and launched according to the specified `backend`.
211+
212+
There are a few keyword arguments that influence the behavior of `@kikernel`:
213+
214+
- `launch`: whether to launch this kernel, defaults to `true`. If `false`, the returned
215+
kernel object should be launched by calling it and passing arguments again.
216+
- `name`: the name of the kernel in the generated code. Defaults to an automatically-
217+
generated name.
218+
"""
175219
macro kikernel(backend, ex...)
176220
call = ex[end]
177221
kwargs = map(ex[1:end-1]) do kwarg

0 commit comments

Comments
 (0)