Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ end

@inline groupsize(ctx) = __groupsize(ctx)
@inline ndrange(ctx) = __ndrange(ctx)
@inline Base.ndims(ctx) = ndims(__iterspace(ctx))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arrrrrrrr! Attack of the pirates!!! This is causing a lot of downstream breakage: can it not dispatch on ctx being a context object?

1 change: 1 addition & 0 deletions src/nditeration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ end
@inline workitems(range::NDRange{N, B, W}) where {N, B, W <: StaticSize} = CartesianIndices(get(W))::CartesianIndices{N}
@inline blocks(range::NDRange{N, B}) where {N, B <: DynamicSize} = range.blocks::CartesianIndices{N}
@inline blocks(range::NDRange{N, B}) where {N, B <: StaticSize} = CartesianIndices(get(B))::CartesianIndices{N}
@inline Base.ndims(::NDRange{N}) where {N} = N

import Base.iterate
@inline iterate(range::NDRange) = iterate(blocks(range))
Expand Down
1 change: 1 addition & 0 deletions test/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function compiler_testsuite(backend, ArrayT)
kernel = index(CPU(), DynamicSize(), DynamicSize())
iterspace = NDRange{1, StaticSize{(128,)}, StaticSize{(8,)}}();
ctx = KernelAbstractions.mkcontext(kernel, 1, nothing, iterspace, Val(KernelAbstractions.NoDynamicCheck()))
@test ndims(ctx) == 1
@test KernelAbstractions.__index_Global_NTuple(ctx, CartesianIndex(1)) == (1,)

A = ArrayT{Int}(undef, 1)
Expand Down
8 changes: 8 additions & 0 deletions test/nditeration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ function nditeration_testsuite()
let ndrange = NDRange{2, DynamicSize, DynamicSize}(CartesianIndices((256, 256)), CartesianIndices((32, 32)))
@test length(ndrange) == 256 * 256
@test all(p -> p[1] == p[2], zip(ndrange, CartesianIndices((256, 256))))
@test ndims(ndrange) == 2
end
let ndrange = NDRange{2, StaticSize{(256, 256)}, DynamicSize}(nothing, CartesianIndices((32, 32)))
@test length(ndrange) == 256 * 256
@test all(p -> p[1] == p[2], zip(ndrange, CartesianIndices((256, 256))))
@test ndims(ndrange) == 2
end
end

Expand Down Expand Up @@ -40,13 +42,15 @@ function nditeration_testsuite()
I = Tuple(I)
@test check(idx, i - 1, ntuple(i -> I[i] - 1, length(I))..., Dim_x, Dim_y)
end
@test ndims(ndrange) == 2
end
let ndrange = NDRange{2, DynamicSize, DynamicSize}(CartesianIndices((4, 4)), CartesianIndices((Dim_x, Dim_y)))
idx = linear_iteration(ndrange)
for (i, I) in zip(1:length(blocks(ndrange)), blocks(ndrange))
I = Tuple(I)
@test check(idx, i - 1, ntuple(i -> I[i] - 1, length(I))..., Dim_x, Dim_y)
end
@test ndims(ndrange) == 2
end

Dim_x = 32
Expand All @@ -58,13 +62,15 @@ function nditeration_testsuite()
I = Tuple(I)
@test check(idx, i - 1, ntuple(i -> I[i] - 1, length(I))..., Dim_x, Dim_y)
end
@test ndims(ndrange) == 2
end
let ndrange = NDRange{2, DynamicSize, DynamicSize}(CartesianIndices((4, 4 * 32)), CartesianIndices((Dim_x, Dim_y)))
idx = linear_iteration(ndrange)
for (i, I) in zip(1:length(blocks(ndrange)), blocks(ndrange))
I = Tuple(I)
@test check(idx, i - 1, ntuple(i -> I[i] - 1, length(I))..., Dim_x, Dim_y)
end
@test ndims(ndrange) == 2
end

Dim_x = 1
Expand All @@ -76,13 +82,15 @@ function nditeration_testsuite()
I = Tuple(I)
@test check(idx, i - 1, ntuple(i -> I[i] - 1, length(I))..., Dim_x, Dim_y)
end
@test ndims(ndrange) == 2
end
let ndrange = NDRange{2, DynamicSize, DynamicSize}(CartesianIndices((4 * 32, 4)), CartesianIndices((Dim_x, Dim_y)))
idx = linear_iteration(ndrange)
for (i, I) in zip(1:length(blocks(ndrange)), blocks(ndrange))
I = Tuple(I)
@test check(idx, i - 1, ntuple(i -> I[i] - 1, length(I))..., Dim_x, Dim_y)
end
@test ndims(ndrange) == 2
end
end
end
Loading