@@ -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 )
53
+ return __kernel (expr, #= force_inbounds=# false )
54
54
end
55
55
56
56
"""
@@ -65,17 +65,19 @@ This allows for two different configurations:
65
65
66
66
!!! warn
67
67
This is an experimental feature.
68
+
69
+ !!! note
70
+ `cpu={true, false}` is deprecated for KernelAbstractions 1.0
68
71
"""
69
72
macro kernel (ex... )
70
73
if length (ex) == 1
71
- return __kernel (ex[1 ], true , false )
74
+ return __kernel (ex[1 ], false )
72
75
else
73
- generate_cpu = true
74
76
force_inbounds = false
75
77
for i in 1 : (length (ex) - 1 )
76
78
if ex[i] isa Expr && ex[i]. head == :(= ) &&
77
79
ex[i]. args[1 ] == :cpu && ex[i]. args[2 ] isa Bool
78
- generate_cpu = ex[i] . args[ 2 ]
80
+ # deprecated
79
81
elseif ex[i] isa Expr && ex[i]. head == :(= ) &&
80
82
ex[i]. args[1 ] == :inbounds && ex[i]. args[2 ] isa Bool
81
83
force_inbounds = ex[i]. args[2 ]
@@ -88,7 +90,7 @@ macro kernel(ex...)
88
90
)
89
91
end
90
92
end
91
- return __kernel (ex[end ], generate_cpu, force_inbounds)
93
+ return __kernel (ex[end ], force_inbounds)
92
94
end
93
95
end
94
96
@@ -184,6 +186,8 @@ After releasing the memory of an array, it should no longer be accessed.
184
186
"""
185
187
function unsafe_free! end
186
188
189
+ unsafe_free! (:: AbstractArray ) = return
190
+
187
191
# ##
188
192
# Kernel language
189
193
# - @localmem
@@ -248,6 +252,9 @@ For storage that only persists between `@synchronize` statements, an `MArray` ca
248
252
instead.
249
253
250
254
See also [`@uniform`](@ref).
255
+
256
+ !!! note
257
+ `@private` is deprecated for KernelAbstractions 1.0
251
258
"""
252
259
macro private (T, dims)
253
260
if dims isa Integer
263
270
264
271
Creates a private local of `mem` per item in the workgroup. This can be safely used
265
272
across [`@synchronize`](@ref) statements.
273
+
274
+ !!! note
275
+ `@private` is deprecated for KernelAbstractions 1.0
266
276
"""
267
277
macro private (expr)
268
278
return esc (expr)
273
283
274
284
`expr` is evaluated outside the workitem scope. This is useful for variable declarations
275
285
that span workitems, or are reused across `@synchronize` statements.
286
+
287
+ !!! note
288
+ `@uniform` is deprecated for KernelAbstractions 1.0
276
289
"""
277
290
macro uniform (value)
278
291
return esc (value)
@@ -324,6 +337,8 @@ Access the hidden context object used by KernelAbstractions.
324
337
!!! warn
325
338
Only valid to be used from a kernel with `cpu=false`.
326
339
340
+ !!! note
341
+ `@context` will be supported on all backends in KernelAbstractions 1.0
327
342
```
328
343
function f(@context, a)
329
344
I = @index(Global, Linear)
@@ -472,31 +487,11 @@ Abstract type for all GPU based KernelAbstractions backends.
472
487
473
488
!!! note
474
489
New backend implementations **must** sub-type this abstract type.
475
- """
476
- abstract type GPU <: Backend end
477
-
478
- """
479
- CPU(; static=false)
480
-
481
- Instantiate a CPU (multi-threaded) backend.
482
-
483
- ## Options:
484
- - `static`: Uses a static thread assignment, this can be beneficial for NUMA aware code.
485
- Defaults to false.
486
- """
487
- struct CPU <: Backend
488
- static:: Bool
489
- CPU (; static:: Bool = false ) = new (static)
490
- end
491
-
492
- """
493
- isgpu(::Backend)::Bool
494
490
495
- Returns true for all [`GPU`](@ref) backends.
491
+ !!! note
492
+ `GPU` will be removed in KernelAbstractions v1.0
496
493
"""
497
- isgpu (:: GPU ) = true
498
- isgpu (:: CPU ) = false
499
-
494
+ abstract type GPU <: Backend end
500
495
501
496
"""
502
497
get_backend(A::AbstractArray)::Backend
@@ -512,12 +507,9 @@ function get_backend end
512
507
# Should cover SubArray, ReshapedArray, ReinterpretArray, Hermitian, AbstractTriangular, etc.:
513
508
get_backend (A:: AbstractArray ) = get_backend (parent (A))
514
509
515
- get_backend (:: Array ) = CPU ()
516
-
517
510
# Define:
518
511
# adapt_storage(::Backend, a::Array) = adapt(BackendArray, a)
519
512
# adapt_storage(::Backend, a::BackendArray) = a
520
- Adapt. adapt_storage (:: CPU , a:: Array ) = a
521
513
522
514
"""
523
515
allocate(::Backend, Type, dims...)::AbstractArray
@@ -737,7 +729,7 @@ Partition a kernel for the given ndrange and workgroupsize.
737
729
return iterspace, dynamic
738
730
end
739
731
740
- function construct (backend:: Backend , :: S , :: NDRange , xpu_name:: XPUName ) where {Backend <: Union{CPU, GPU} , S <: _Size , NDRange <: _Size , XPUName}
732
+ function construct (backend:: Backend , :: S , :: NDRange , xpu_name:: XPUName ) where {Backend <: GPU , S <: _Size , NDRange <: _Size , XPUName}
741
733
return Kernel {Backend, S, NDRange, XPUName} (backend, xpu_name)
742
734
end
743
735
@@ -754,6 +746,10 @@ include("compiler.jl")
754
746
function __workitems_iterspace end
755
747
function __validindex end
756
748
749
+ # for reflection
750
+ function mkcontext end
751
+ function launch_config end
752
+
757
753
include (" macros.jl" )
758
754
759
755
# ##
823
819
end
824
820
825
821
# CPU backend
822
+ include (" pocl/pocl.jl" )
823
+ using . POCL
824
+ export POCLBackend
826
825
827
- include ( " cpu.jl " )
826
+ const CPU = POCLBackend
828
827
829
828
# precompile
830
829
PrecompileTools. @compile_workload begin
@@ -838,19 +837,4 @@ PrecompileTools.@compile_workload begin
838
837
end
839
838
end
840
839
841
- if ! isdefined (Base, :get_extension )
842
- using Requires
843
- end
844
-
845
- @static if ! isdefined (Base, :get_extension )
846
- function __init__ ()
847
- @require EnzymeCore = " f151be2c-9106-41f4-ab19-57ee4f262869" include (" ../ext/EnzymeExt.jl" )
848
- end
849
- end
850
-
851
- if ! isdefined (Base, :get_extension )
852
- include (" ../ext/LinearAlgebraExt.jl" )
853
- include (" ../ext/SparseArraysExt.jl" )
854
- end
855
-
856
840
end # module
0 commit comments