Skip to content

Commit 42f17d6

Browse files
committed
Renaming
1 parent 298e807 commit 42f17d6

File tree

3 files changed

+30
-27
lines changed

3 files changed

+30
-27
lines changed

src/KernelAbstractions.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ Abstract type for all KernelAbstractions backends.
200200
abstract type Backend end
201201

202202
include("intrinsics.jl")
203-
import .KernelIntrinsics
204-
export KernelIntrinsics
203+
import .KernelIntrinsics: KernelIntrinsics, KI
204+
export KernelIntrinsics, KI
205205

206206
###
207207
# Kernel language
@@ -370,7 +370,7 @@ macro context()
370370
end
371371

372372
# Defined to keep cpu support for `__print`
373-
@generated function KernelIntrinsics._print(items...)
373+
@generated function KI._print(items...)
374374
str = ""
375375
args = []
376376

@@ -489,25 +489,25 @@ end
489489
###
490490

491491
@inline function __index_Local_Linear(ctx)
492-
return KernelIntrinsics.get_local_id().x
492+
return KI.get_local_id().x
493493
end
494494

495495
@inline function __index_Group_Linear(ctx)
496-
return KernelIntrinsics.get_group_id().x
496+
return KI.get_group_id().x
497497
end
498498

499499
@inline function __index_Global_Linear(ctx)
500-
return KernelIntrinsics.get_global_id().x
500+
return KI.get_global_id().x
501501
end
502502

503503
@inline function __index_Local_Cartesian(ctx)
504-
return @inbounds workitems(__iterspace(ctx))[KernelIntrinsics.get_local_id().x]
504+
return @inbounds workitems(__iterspace(ctx))[KI.get_local_id().x]
505505
end
506506
@inline function __index_Group_Cartesian(ctx)
507-
return @inbounds blocks(__iterspace(ctx))[KernelIntrinsics.get_group_id().x]
507+
return @inbounds blocks(__iterspace(ctx))[KI.get_group_id().x]
508508
end
509509
@inline function __index_Global_Cartesian(ctx)
510-
return @inbounds expand(__iterspace(ctx), KernelIntrinsics.get_group_id().x, KernelIntrinsics.get_local_id().x)
510+
return @inbounds expand(__iterspace(ctx), KI.get_group_id().x, KI.get_local_id().x)
511511
end
512512

513513
@inline __index_Local_NTuple(ctx, I...) = Tuple(__index_Local_Cartesian(ctx, I...))
@@ -833,11 +833,11 @@ include("macros.jl")
833833
###
834834

835835
function Scratchpad end
836-
SharedMemory(t::Type{T}, dims::Val{Dims}, id::Val{Id}) where {T, Dims, Id} = KernelIntrinsics.localmemory(t, dims)
836+
SharedMemory(t::Type{T}, dims::Val{Dims}, id::Val{Id}) where {T, Dims, Id} = KI.localmemory(t, dims)
837837

838-
__synchronize() = KernelIntrinsics.barrier()
838+
__synchronize() = KI.barrier()
839839

840-
__print(args...) = KernelIntrinsics._print(args...)
840+
__print(args...) = KI._print(args...)
841841

842842
# Utils
843843
__size(args::Tuple) = Tuple{args...}

src/intrinsics.jl

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
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
66
intrinsics 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
99
functionality that is shared amongst backends, while `KernelAbstractions` provides higher-level functionality
1010
such as writing kernels that work on arrays with an arbitrary number of dimensions, or convenience functions
1111
like allocating arrays on a backend.
1212
"""
1313
module KernelIntrinsics
1414

15+
const KI = KernelIntrinsics
16+
export KI
17+
1518
import ..KernelAbstractions: Backend
1619
import GPUCompiler: split_kwargs, assign_args!
1720

@@ -238,12 +241,12 @@ converting them to their device side representation.
238241
function 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
243246
Low-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
247250
by all backends.
248251
249252
Keyword 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

260263
const MACRO_KWARGS = [:launch]
261264
const COMPILER_KWARGS = [:name]
262265
const 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
267270
High-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
270273
should return nothing. It will be compiled to a function native to the specified `backend`
271274
upon first use, and to a certain extent arguments will be converted and managed automatically
272275
using `argconvert`. Finally, if `launch=true`, the newly created callable kernel object is
273276
called 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

src/pocl/backend.jl

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

142142
KI.argconvert(::POCLBackend, arg) = clconvert(arg)
143143

144-
function KI.gpufunction(::POCLBackend, f::F, tt::TT = Tuple{}; name = nothing, kwargs...) where {F, TT}
144+
function KI.kernel_function(::POCLBackend, f::F, tt::TT = Tuple{}; name = nothing, kwargs...) where {F, TT}
145145
kern = clfunction(f, tt; name, kwargs...)
146146
return KI.Kernel{POCLBackend, typeof(kern)}(POCLBackend(), kern)
147147
end

0 commit comments

Comments
 (0)