@@ -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)
@@ -316,6 +329,8 @@ Access the hidden context object used by KernelAbstractions.
316
329
!!! warn
317
330
Only valid to be used from a kernel with `cpu=false`.
318
331
332
+ !!! note
333
+ `@context` will be supported on all backends in KernelAbstractions 1.0
319
334
```
320
335
function f(@context, a)
321
336
I = @index(Global, Linear)
@@ -464,31 +479,11 @@ Abstract type for all GPU based KernelAbstractions backends.
464
479
465
480
!!! note
466
481
New backend implementations **must** sub-type this abstract type.
467
- """
468
- abstract type GPU <: Backend end
469
-
470
- """
471
- CPU(; static=false)
472
-
473
- Instantiate a CPU (multi-threaded) backend.
474
-
475
- ## Options:
476
- - `static`: Uses a static thread assignment, this can be beneficial for NUMA aware code.
477
- Defaults to false.
478
- """
479
- struct CPU <: Backend
480
- static:: Bool
481
- CPU (; static:: Bool = false ) = new (static)
482
- end
483
-
484
- """
485
- isgpu(::Backend)::Bool
486
482
487
- Returns true for all [`GPU`](@ref) backends.
483
+ !!! note
484
+ `GPU` will be removed in KernelAbstractions v1.0
488
485
"""
489
- isgpu (:: GPU ) = true
490
- isgpu (:: CPU ) = false
491
-
486
+ abstract type GPU <: Backend end
492
487
493
488
"""
494
489
get_backend(A::AbstractArray)::Backend
@@ -504,12 +499,9 @@ function get_backend end
504
499
# Should cover SubArray, ReshapedArray, ReinterpretArray, Hermitian, AbstractTriangular, etc.:
505
500
get_backend (A:: AbstractArray ) = get_backend (parent (A))
506
501
507
- get_backend (:: Array ) = CPU ()
508
-
509
502
# Define:
510
503
# adapt_storage(::Backend, a::Array) = adapt(BackendArray, a)
511
504
# adapt_storage(::Backend, a::BackendArray) = a
512
- Adapt. adapt_storage (:: CPU , a:: Array ) = a
513
505
514
506
"""
515
507
allocate(::Backend, Type, dims...)::AbstractArray
@@ -729,7 +721,7 @@ Partition a kernel for the given ndrange and workgroupsize.
729
721
return iterspace, dynamic
730
722
end
731
723
732
- function construct (backend:: Backend , :: S , :: NDRange , xpu_name:: XPUName ) where {Backend <: Union{CPU, GPU} , S <: _Size , NDRange <: _Size , XPUName}
724
+ function construct (backend:: Backend , :: S , :: NDRange , xpu_name:: XPUName ) where {Backend <: GPU , S <: _Size , NDRange <: _Size , XPUName}
733
725
return Kernel {Backend, S, NDRange, XPUName} (backend, xpu_name)
734
726
end
735
727
@@ -746,6 +738,10 @@ include("compiler.jl")
746
738
function __workitems_iterspace end
747
739
function __validindex end
748
740
741
+ # for reflection
742
+ function mkcontext end
743
+ function launch_config end
744
+
749
745
include (" macros.jl" )
750
746
751
747
# ##
815
811
end
816
812
817
813
# CPU backend
814
+ include (" pocl/pocl.jl" )
815
+ using . POCL
816
+ export POCLBackend
818
817
819
- include ( " cpu.jl " )
818
+ const CPU = POCLBackend
820
819
821
820
# precompile
822
821
PrecompileTools. @compile_workload begin
@@ -830,19 +829,4 @@ PrecompileTools.@compile_workload begin
830
829
end
831
830
end
832
831
833
- if ! isdefined (Base, :get_extension )
834
- using Requires
835
- end
836
-
837
- @static if ! isdefined (Base, :get_extension )
838
- function __init__ ()
839
- @require EnzymeCore = " f151be2c-9106-41f4-ab19-57ee4f262869" include (" ../ext/EnzymeExt.jl" )
840
- end
841
- end
842
-
843
- if ! isdefined (Base, :get_extension )
844
- include (" ../ext/LinearAlgebraExt.jl" )
845
- include (" ../ext/SparseArraysExt.jl" )
846
- end
847
-
848
832
end # module
0 commit comments