@@ -50,7 +50,7 @@ synchronize(backend)
50
50
```
51
51
"""
52
52
macro kernel (expr)
53
- return __kernel (expr, #= generate_cpu =# true , #= force_inbounds=# false , #= unsafe_indicies=# false )
53
+ return __kernel (expr, #= force_inbounds=# false , #= unsafe_indicies=# false )
54
54
end
55
55
56
56
"""
@@ -66,18 +66,20 @@ This allows for two different configurations:
66
66
67
67
!!! warn
68
68
This is an experimental feature.
69
+
70
+ !!! note
71
+ `cpu={true, false}` is deprecated for KernelAbstractions 1.0
69
72
"""
70
73
macro kernel (ex... )
71
74
if length (ex) == 1
72
- return __kernel (ex[1 ], true , false , false )
75
+ return __kernel (ex[1 ], false , false )
73
76
else
74
- generate_cpu = true
75
77
unsafe_indicies = false
76
78
force_inbounds = false
77
79
for i in 1 : (length (ex) - 1 )
78
80
if ex[i] isa Expr && ex[i]. head == :(= ) &&
79
81
ex[i]. args[1 ] == :cpu && ex[i]. args[2 ] isa Bool
80
- generate_cpu = ex[i] . args[ 2 ]
82
+ # deprecated
81
83
elseif ex[i] isa Expr && ex[i]. head == :(= ) &&
82
84
ex[i]. args[1 ] == :inbounds && ex[i]. args[2 ] isa Bool
83
85
force_inbounds = ex[i]. args[2 ]
@@ -94,7 +96,7 @@ macro kernel(ex...)
94
96
)
95
97
end
96
98
end
97
- return __kernel (ex[end ], generate_cpu, force_inbounds, unsafe_indicies)
99
+ return __kernel (ex[end ], force_inbounds, unsafe_indicies)
98
100
end
99
101
end
100
102
@@ -190,6 +192,8 @@ After releasing the memory of an array, it should no longer be accessed.
190
192
"""
191
193
function unsafe_free! end
192
194
195
+ unsafe_free! (:: AbstractArray ) = return
196
+
193
197
# ##
194
198
# Kernel language
195
199
# - @localmem
@@ -254,6 +258,9 @@ For storage that only persists between `@synchronize` statements, an `MArray` ca
254
258
instead.
255
259
256
260
See also [`@uniform`](@ref).
261
+
262
+ !!! note
263
+ `@private` is deprecated for KernelAbstractions 1.0
257
264
"""
258
265
macro private (T, dims)
259
266
if dims isa Integer
269
276
270
277
Creates a private local of `mem` per item in the workgroup. This can be safely used
271
278
across [`@synchronize`](@ref) statements.
279
+
280
+ !!! note
281
+ `@private` is deprecated for KernelAbstractions 1.0
272
282
"""
273
283
macro private (expr)
274
284
return esc (expr)
279
289
280
290
`expr` is evaluated outside the workitem scope. This is useful for variable declarations
281
291
that span workitems, or are reused across `@synchronize` statements.
292
+
293
+ !!! note
294
+ `@uniform` is deprecated for KernelAbstractions 1.0
282
295
"""
283
296
macro uniform (value)
284
297
return esc (value)
@@ -330,6 +343,8 @@ Access the hidden context object used by KernelAbstractions.
330
343
!!! warn
331
344
Only valid to be used from a kernel with `cpu=false`.
332
345
346
+ !!! note
347
+ `@context` will be supported on all backends in KernelAbstractions 1.0
333
348
```
334
349
function f(@context, a)
335
350
I = @index(Global, Linear)
@@ -478,31 +493,11 @@ Abstract type for all GPU based KernelAbstractions backends.
478
493
479
494
!!! note
480
495
New backend implementations **must** sub-type this abstract type.
481
- """
482
- abstract type GPU <: Backend end
483
-
484
- """
485
- CPU(; static=false)
486
-
487
- Instantiate a CPU (multi-threaded) backend.
488
-
489
- ## Options:
490
- - `static`: Uses a static thread assignment, this can be beneficial for NUMA aware code.
491
- Defaults to false.
492
- """
493
- struct CPU <: Backend
494
- static:: Bool
495
- CPU (; static:: Bool = false ) = new (static)
496
- end
497
-
498
- """
499
- isgpu(::Backend)::Bool
500
496
501
- Returns true for all [`GPU`](@ref) backends.
497
+ !!! note
498
+ `GPU` will be removed in KernelAbstractions v1.0
502
499
"""
503
- isgpu (:: GPU ) = true
504
- isgpu (:: CPU ) = false
505
-
500
+ abstract type GPU <: Backend end
506
501
507
502
"""
508
503
get_backend(A::AbstractArray)::Backend
@@ -518,12 +513,9 @@ function get_backend end
518
513
# Should cover SubArray, ReshapedArray, ReinterpretArray, Hermitian, AbstractTriangular, etc.:
519
514
get_backend (A:: AbstractArray ) = get_backend (parent (A))
520
515
521
- get_backend (:: Array ) = CPU ()
522
-
523
516
# Define:
524
517
# adapt_storage(::Backend, a::Array) = adapt(BackendArray, a)
525
518
# adapt_storage(::Backend, a::BackendArray) = a
526
- Adapt. adapt_storage (:: CPU , a:: Array ) = a
527
519
528
520
"""
529
521
allocate(::Backend, Type, dims...)::AbstractArray
@@ -743,7 +735,7 @@ Partition a kernel for the given ndrange and workgroupsize.
743
735
return iterspace, dynamic
744
736
end
745
737
746
- function construct (backend:: Backend , :: S , :: NDRange , xpu_name:: XPUName ) where {Backend <: Union{CPU, GPU} , S <: _Size , NDRange <: _Size , XPUName}
738
+ function construct (backend:: Backend , :: S , :: NDRange , xpu_name:: XPUName ) where {Backend <: GPU , S <: _Size , NDRange <: _Size , XPUName}
747
739
return Kernel {Backend, S, NDRange, XPUName} (backend, xpu_name)
748
740
end
749
741
@@ -760,6 +752,10 @@ include("compiler.jl")
760
752
function __workitems_iterspace end
761
753
function __validindex end
762
754
755
+ # for reflection
756
+ function mkcontext end
757
+ function launch_config end
758
+
763
759
include (" macros.jl" )
764
760
765
761
# ##
829
825
end
830
826
831
827
# CPU backend
828
+ include (" pocl/pocl.jl" )
829
+ using . POCL
830
+ export POCLBackend
832
831
833
- include ( " cpu.jl " )
832
+ const CPU = POCLBackend
834
833
835
834
# precompile
836
835
PrecompileTools. @compile_workload begin
@@ -844,19 +843,4 @@ PrecompileTools.@compile_workload begin
844
843
end
845
844
end
846
845
847
- if ! isdefined (Base, :get_extension )
848
- using Requires
849
- end
850
-
851
- @static if ! isdefined (Base, :get_extension )
852
- function __init__ ()
853
- @require EnzymeCore = " f151be2c-9106-41f4-ab19-57ee4f262869" include (" ../ext/EnzymeExt.jl" )
854
- end
855
- end
856
-
857
- if ! isdefined (Base, :get_extension )
858
- include (" ../ext/LinearAlgebraExt.jl" )
859
- include (" ../ext/SparseArraysExt.jl" )
860
- end
861
-
862
846
end # module
0 commit comments