-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathcompiler.jl
More file actions
33 lines (29 loc) · 1.45 KB
/
compiler.jl
File metadata and controls
33 lines (29 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
struct CompilerMetadata{StaticNDRange, CheckBounds, I, NDRange, Iterspace}
groupindex::I
ndrange::NDRange
iterspace::Iterspace
# CPU variant
function CompilerMetadata{NDRange, CB}(idx, ndrange, iterspace) where {NDRange, CB}
if ndrange !== nothing
ndrange = CartesianIndices(ndrange)
end
return new{NDRange, CB, typeof(idx), typeof(ndrange), typeof(iterspace)}(idx, ndrange, iterspace)
end
# GPU variante: index is given implicit
function CompilerMetadata{NDRange, CB}(ndrange, iterspace) where {NDRange, CB}
if ndrange !== nothing
ndrange = CartesianIndices(ndrange)
end
return new{NDRange, CB, Nothing, typeof(ndrange), typeof(iterspace)}(nothing, ndrange, iterspace)
end
end
@inline __iterspace(cm::CompilerMetadata) = cm.iterspace
@inline __groupindex(cm::CompilerMetadata) = cm.groupindex
@inline __groupsize(cm::CompilerMetadata) = size(workitems(__iterspace(cm)))
@inline __dynamic_checkbounds(::CompilerMetadata{NDRange, CB}) where {NDRange, CB} = CB <: DynamicCheck
@inline __ndrange(::CompilerMetadata{NDRange}) where {NDRange <: StaticSize} = CartesianIndices(get(NDRange))
@inline __ndrange(cm::CompilerMetadata{NDRange}) where {NDRange <: DynamicSize} = cm.ndrange
@inline __workitems_iterspace(ctx) = workitems(__iterspace(ctx))
@inline groupsize(ctx) = __groupsize(ctx)
@inline ndrange(ctx) = __ndrange(ctx)
@inline Base.ndims(ctx) = ndims(__iterspace(ctx))