11"""
2- # KernelIntrinics
2+ # ` KernelIntrinics`/`KI`
33
4- The `KernelIntrinics` module defines the API interface for backends to define various lower-level device and
5- host-side functionality. The `KernelIntrinsics ` intrinsics are used to define the higher-level device-side
4+ The `KernelIntrinics` (or `KI`) module defines the API interface for backends to define various lower-level device and
5+ host-side functionality. The `KI ` intrinsics are used to define the higher-level device-side
66intrinsics functionality in `KernelAbstractions`.
77
8- Both provide APIs for host and device-side functionality, but `KernelIntrinsics ` focuses on on lower-level
8+ Both provide APIs for host and device-side functionality, but `KI ` focuses on on lower-level
99functionality that is shared amongst backends, while `KernelAbstractions` provides higher-level functionality
1010such as writing kernels that work on arrays with an arbitrary number of dimensions, or convenience functions
1111like allocating arrays on a backend.
1212"""
1313module KernelIntrinsics
1414
15+ const KI = KernelIntrinsics
16+ export KI
17+
1518import .. KernelAbstractions: Backend
1619import GPUCompiler: split_kwargs, assign_args!
1720
@@ -238,12 +241,12 @@ converting them to their device side representation.
238241function argconvert end
239242
240243"""
241- KI.gpufunction (::NewBackend, f::F, tt::TT=Tuple{}; name=nothing, kwargs...) where {F,TT}
244+ KI.kernel_function (::NewBackend, f::F, tt::TT=Tuple{}; name=nothing, kwargs...) where {F,TT}
242245
243246Low-level interface to compile a function invocation for the currently-active GPU, returning
244- a callable kernel object. For a higher-level interface, use [`KernelIntrinsics .@kernel`](@ref).
247+ a callable kernel object. For a higher-level interface, use [`KI .@kernel`](@ref).
245248
246- Currently, only `gpufunction ` only supports the `name` keyword argument as it is the only one
249+ Currently, `kernel_function ` only supports the `name` keyword argument as it is the only one
247250by all backends.
248251
249252Keyword arguments:
@@ -252,35 +255,35 @@ Keyword arguments:
252255!!! note
253256 Backend implementations **must** implement:
254257 ```
255- gpufunction (::NewBackend, f::F, tt::TT=Tuple{}; name=nothing, kwargs...) where {F,TT}
258+ kernel_function (::NewBackend, f::F, tt::TT=Tuple{}; name=nothing, kwargs...) where {F,TT}
256259 ```
257260"""
258- function gpufunction end
261+ function kernel_function end
259262
260263const MACRO_KWARGS = [:launch ]
261264const COMPILER_KWARGS = [:name ]
262265const LAUNCH_KWARGS = [:numworkgroups , :workgroupsize ]
263266
264267"""
265- KernelIntrinsics .@kernel backend workgroupsize=... numworkgroups=... [kwargs...] func(args...)
268+ KI .@kernel backend workgroupsize=... numworkgroups=... [kwargs...] func(args...)
266269
267270High-level interface for executing code on a GPU.
268271
269- The `KernelIntrinsics .@kernel` macro should prefix a call, with `func` a callable function or object that
272+ The `KI .@kernel` macro should prefix a call, with `func` a callable function or object that
270273should return nothing. It will be compiled to a function native to the specified `backend`
271274upon first use, and to a certain extent arguments will be converted and managed automatically
272275using `argconvert`. Finally, if `launch=true`, the newly created callable kernel object is
273276called and launched according to the specified `backend`.
274277
275- There are a few keyword arguments that influence the behavior of `KernelIntrinsics .@kernel`:
278+ There are a few keyword arguments that influence the behavior of `KI .@kernel`:
276279
277280- `launch`: whether to launch this kernel, defaults to `true`. If `false`, the returned
278281 kernel object should be launched by calling it and passing arguments again.
279282- `name`: the name of the kernel in the generated code. Defaults to an automatically-
280283 generated name.
281284
282285!!! note
283- `KernelIntrinsics .@kernel` differs from the `KernelAbstractions` macro in that this macro acts
286+ `KI .@kernel` differs from the `KernelAbstractions` macro in that this macro acts
284287 a wrapper around backend kernel compilation/launching (such as `@cuda`, `@metal`, etc.). It is
285288 used when calling a function to be run on a specific backend, while `KernelAbstractions.@kernel`
286289 is used kernel definition for use with the original higher-level `KernelAbstractions` API.
@@ -342,7 +345,7 @@ macro kernel(backend, ex...)
342345 $ kernel_f = $ argconvert ($ backend, $ f_var)
343346 $ kernel_args = Base. map (x -> $ argconvert ($ backend, x), ($ (var_exprs... ),))
344347 $ kernel_tt = Tuple{Base. map (Core. Typeof, $ kernel_args)... }
345- $ kernel = $ gpufunction ($ backend, $ kernel_f, $ kernel_tt; $ (compiler_kwargs... ))
348+ $ kernel = $ kernel_function ($ backend, $ kernel_f, $ kernel_tt; $ (compiler_kwargs... ))
346349 if $ launch
347350 $ kernel ($ (var_exprs... ); $ (call_kwargs... ))
348351 end
0 commit comments