diff --git a/docs/src/api.md b/docs/src/api.md index 826cd7455..09b5eb9b9 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -72,6 +72,12 @@ KernelAbstractions.ndrange KernelAbstractions.backend ``` +### Index loops + +```@docs +foreach_index +``` + ## Reflection To look at the code a backend actually generates, wrap a kernel launch in one of the diff --git a/docs/src/index.md b/docs/src/index.md index 9342c32fc..4105c5430 100644 --- a/docs/src/index.md +++ b/docs/src/index.md @@ -153,6 +153,8 @@ end - The `CPU` backend runs kernels on as many threads as Julia was started with (`julia -t`), like the thread-based `CPU` backend of 0.9 did, and no longer on one thread per hardware thread. Set `JULIA_KA_CPU_THREADS` to use a different number of threads; see [`CPU`](@ref). +- `foreach_index(f, A)` runs `f` once per index of the array `A` without writing a kernel out, + and `foreach_index(f, backend, indices)` once per index in a range or `CartesianIndices`. ## Semantic differences diff --git a/docs/src/kernels.md b/docs/src/kernels.md index e1bf57a8b..5d6df509f 100644 --- a/docs/src/kernels.md +++ b/docs/src/kernels.md @@ -255,3 +255,44 @@ and `@ndrange()` returns the extents. Obtain the backend from an array with [`get_backend`](@ref) and always call [`synchronize`](@ref) before reading results on the host. See the [Quickstart](@ref) for a full walkthrough and the Examples section of the manual for larger patterns. + +## Loops without a kernel + +A kernel whose body is a loop over the indices of an array needs none of the kernel language +beyond the index itself. [`foreach_index`](@ref) launches such a loop directly, with one work item +per index of `eachindex(y, x)`: + +```julia +function scale!(y, x) + foreach_index(y, x) do i + @inbounds y[i] = 2 * x[i] + 1 + end + return y +end +``` + +The body is an ordinary Julia function, and it receives the index a `for i in eachindex(y, x)` +loop would: a linear index if the arrays have `IndexLinear` style, a `CartesianIndex` otherwise. +Passing every array the body indexes makes sure the index is valid for each, and that they all +live on the same backend. The launch is asynchronous like any other, and bounds checks are not +elided. + +To loop over other indices than those of an array, give the backend and the index space, a range +or a `CartesianIndices` like an `ndrange`. The body then receives these indices as they are, +e.g. those of the interior of a matrix: + +```julia +function smooth!(B, A) + interior = CartesianIndices((2:size(A, 1)-1, 2:size(A, 2)-1)) + foreach_index(get_backend(A), interior) do I + i, j = Tuple(I) + @inbounds B[I] = (A[i-1, j] + A[i+1, j] + A[i, j-1] + A[i, j+1]) / 4 + end + return B +end +``` + +Because the body becomes a kernel, every value it captures must have a known type — which is why +the examples wrap the loop in a function, and why the body must not assign to a captured variable. +Write the kernel out with [`@kernel`](@ref) when it needs more than an index: workgroup-level +indices, local memory, or synchronization. diff --git a/src/KernelAbstractions.jl b/src/KernelAbstractions.jl index c7c9c5504..dca8dda3e 100644 --- a/src/KernelAbstractions.jl +++ b/src/KernelAbstractions.jl @@ -6,6 +6,7 @@ export @index, @groupsize, @ndrange export @print export Backend, CPU export synchronize, get_backend, allocate +export foreach_index import PrecompileTools @@ -614,6 +615,7 @@ end include("macros.jl") include("spawn.jl") +include("foreach_index.jl") ### # Backends/Interface diff --git a/src/backend_launch.jl b/src/backend_launch.jl index fbd5cfd8d..28e49b997 100644 --- a/src/backend_launch.jl +++ b/src/backend_launch.jl @@ -26,7 +26,8 @@ mkcontext(kernel::Kernel, I, _ndrange, iterspace, ::Dynamic) where {Dynamic} = Normalize the launch arguments of `kernel`, and partition the `ndrange`. Returns the `ndrange` (`nothing` if it's static), the `workgroupsize` (`nothing` if it will be tuned), the iteration space and whether it needs bounds checks. If the workgroup size will be -tuned, the iteration space is preliminary: it uses the `ndrange` as the workgroup size. +tuned, the iteration space is preliminary: it uses the extents of the `ndrange` as the +workgroup size. """ function launch_config(kernel::Kernel, _ndrange, _workgroupsize) if _ndrange isa Integer @@ -37,8 +38,8 @@ function launch_config(kernel::Kernel, _ndrange, _workgroupsize) end iterspace, dynamic = if workgroupsize(kernel) <: DynamicSize && _workgroupsize === nothing - # use the ndrange as preliminary workgroupsize for autotuning - partition(kernel, _ndrange, something(_ndrange, static_ndrange(kernel))) + # use the extents of the ndrange as preliminary workgroupsize for autotuning + partition(kernel, _ndrange, extents(something(_ndrange, static_ndrange(kernel)))) else # this also checks that a given ndrange agrees with a static one partition(kernel, _ndrange, _workgroupsize) diff --git a/src/foreach_index.jl b/src/foreach_index.jl new file mode 100644 index 000000000..e029fdfd8 --- /dev/null +++ b/src/foreach_index.jl @@ -0,0 +1,169 @@ +# One work item per index of an index space. +# +# The index space is carried by the `ndrange`, so the kernels take no argument besides the +# function: `@index(Global, Cartesian)` already returns the index of the `ndrange`, including +# the offset of an index space that does not start at 1. +# +# `f` is inlined on purpose: an out-of-line call to a closure can spill its captures to local +# memory on some backends. + +@kernel function foreach_index_linear_kernel(f) + I = @index(Global, Cartesian) + @inline f(I[1]) +end + +@kernel function foreach_index_cartesian_kernel(f) + I = @index(Global, Cartesian) + @inline f(I) +end + +# A zero-dimensional index space has a single index. Launched as a one-dimensional `ndrange`, as +# a workgroup size has at least one dimension. +@kernel function foreach_index_zerodim_kernel(f) + @inline f(CartesianIndex()) +end + +# The index spaces an `ndrange` can express: a range of integers, or a product of them. +const UnitCartesianIndices{N} = CartesianIndices{N, <:NTuple{N, AbstractUnitRange{Int}}} + +foreach_index_kernel(backend, ::AbstractUnitRange{<:Integer}) = foreach_index_linear_kernel(backend) +foreach_index_kernel(backend, ::UnitCartesianIndices) = foreach_index_cartesian_kernel(backend) +foreach_index_kernel(backend, ::CartesianIndices{0}) = foreach_index_zerodim_kernel(backend) +foreach_index_kernel(backend, indices) = throw( + ArgumentError( + "`foreach_index` needs an index space that is a range of integers or a `CartesianIndices` of such ranges, got a `$(typeof(indices))`" + ) +) + +# A captured variable that is assigned to after the closure was created, or in it, is stored in +# a `Core.Box`, which a kernel cannot access. That fails to compile with an error about the +# kernel's arguments, so catch it here with one about the variable. +@inline function check_captures(f::F) where {F} + has_box(fieldtypes(F)) && boxed_capture_error(f) + return +end + +# (`any` would not be folded by Julia 1.10) +has_box(::Tuple{}) = false +has_box(Ts::Tuple) = first(Ts) === Core.Box || has_box(Base.tail(Ts)) + +@noinline function boxed_capture_error(::F) where {F} + names = [fieldname(F, i) for i in 1:fieldcount(F) if fieldtype(F, i) === Core.Box] + vars = join(("`$name`" for name in names), ", ", " and ") + throw( + ArgumentError( + "`foreach_index` cannot run a function that captures a variable that is reassigned " * + "($vars): Julia stores such a variable in a box, which a kernel cannot access. " * + "Capture a variable that is not reassigned instead, e.g. by wrapping the loop in " * + "`let $(first(names)) = $(first(names))`, and write results to an array." + ) + ) +end + +foreach_index_ndrange(indices) = indices +foreach_index_ndrange(::CartesianIndices{0}) = 1 + +""" + foreach_index(f, A::AbstractArray, Bs::AbstractArray...) + foreach_index(f, backend::Backend, indices) + +Call `f(i)` once for every index `i` of the arrays `A, Bs...`, or for every index `i` in `indices`, +with one work item per index. Returns `nothing`; the iterations run asynchronously. + +This is a `for` loop over indices without a kernel to write out: the body is an ordinary Julia +function, which becomes the body of a kernel. + +```julia +function scale!(y, x) + foreach_index(y, x) do i + @inbounds y[i] = 2 * x[i] + 1 + end + return y +end + +scale!(y, x) +synchronize(get_backend(y)) +``` + +The first form runs on the backend of the arrays, which must all have the same one, over +`eachindex(A, Bs...)`: `f` receives the index that a `for i in eachindex(A, Bs...)` loop would, +a linear index if the arrays have `IndexLinear` style and a `CartesianIndex` otherwise. Pass +every array that the body indexes with `i`, so that the index is valid for each of them. Ranges, +`CartesianIndices` and `LinearIndices`, and views or reshapes of them, have no backend and run +on that of the other arrays; if none of the arrays has a backend, use the second form. + +The second form runs on `backend`, over the given `indices`: a range of integers such as +`1:n` or `axes(A, 2)`, for which `f` receives an `Int`, or a `CartesianIndices` of such ranges, +for which `f` receives a `CartesianIndex`. Indices that do not start at 1 are passed on as +they are, so this iterates, e.g., the interior of a 2-D array `A`: + +```julia +foreach_index(get_backend(A), CartesianIndices((2:size(A, 1)-1, 2:size(A, 2)-1))) do I + ... +end +``` + +The iterations run concurrently and in no particular order, so they must not race on the +same memory. The value `f` returns is ignored. Like any other kernel launch, `foreach_index` +returns before the iterations have finished: call [`synchronize`](@ref) before reading their +results on the host. Bounds checks are not elided, so write `@inbounds` in the body where it is +warranted, as in a hand-written kernel. + +The keyword argument `workgroupsize` sets the workgroup size of the launch; by default the +backend chooses it. + +# Extended help + +`f` is subject to the same restrictions as a kernel: every value it captures must be of a known +type. Closing over a variable of the enclosing *global* scope leaves its type unknown and fails +to compile (typically with `unsupported dynamic function invocation`), which is why the example +above wraps the loop in a function. + +For the same reason `f` cannot capture a variable that is assigned to after `f` is created, or +in `f`, as Julia then boxes the variable. Bind the value to a new variable (e.g. with `let`) +for `f` to capture, and accumulate results into an array, with an atomic update if the indices +race. + +On the `CPU` backend `foreach_index` also launches a kernel, compiled for every new `f`. For a +loop that runs once, or over few indices, a threaded loop (`Threads.@threads`) is cheaper. + +See also [`@kernel`](@ref) to write the kernel out, which is what to reach for when the body +needs more of the kernel language than an index (workgroup-level indices, local memory, or +synchronization). +""" +function foreach_index(f::F, backend::Backend, indices; workgroupsize = nothing) where {F} + kernel = foreach_index_kernel(backend, indices) + check_captures(f) + isempty(indices) && return nothing + kernel(f; ndrange = foreach_index_ndrange(indices), workgroupsize) + return nothing +end + +# The backend of the arrays passed to `foreach_index`. Ranges, `CartesianIndices` and +# `LinearIndices` are computed rather than stored, as are Base's views, reshapes and permutations +# of them: they have no backend and do not decide the one the loop runs on. This is what +# AcceleratedKernels.jl does. +array_backend(A::AbstractArray) = get_backend(A) +array_backend(::Union{AbstractRange, CartesianIndices, LinearIndices}) = nothing +array_backend(A::Union{SubArray, Base.ReshapedArray, PermutedDimsArray}) = array_backend(parent(A)) + +common_backend() = nothing +common_backend(A, Bs...) = merge_backend(array_backend(A), common_backend(Bs...)) + +merge_backend(::Nothing, ::Nothing) = nothing +merge_backend(a, ::Nothing) = a +merge_backend(::Nothing, b) = b +function merge_backend(a, b) + a == b || throw(ArgumentError("`foreach_index` needs arrays with the same backend, got arrays on $a and on $b")) + return a +end + +function foreach_index(f::F, A::AbstractArray, Bs::AbstractArray...; workgroupsize = nothing) where {F} + backend = common_backend(A, Bs...) + backend === nothing && throw( + ArgumentError( + "`foreach_index` cannot determine a backend from arrays that are not stored, such as ranges; pass it explicitly, as in `foreach_index(f, backend, eachindex(A, Bs...))`" + ) + ) + return foreach_index(f, backend, eachindex(A, Bs...); workgroupsize) +end diff --git a/src/nditeration.jl b/src/nditeration.jl index 30a2238ab..d588f713d 100644 --- a/src/nditeration.jl +++ b/src/nditeration.jl @@ -18,7 +18,7 @@ axis(r::Base.OneTo) = Int(length(r)) axis(r::AbstractUnitRange) = UnitRange{Int}(r) extent(n::Integer) = Int(n) -extent(r::AbstractUnitRange) = length(r) +extent(r::AbstractUnitRange) = Int(length(r)) axis_offset(::Integer) = 0 axis_offset(r::AbstractUnitRange) = first(r) - 1 @@ -31,7 +31,7 @@ a `CartesianIndices`, a single range, or an integer. """ extents(t::Tuple) = map(extent, t) extents(ci::CartesianIndices) = size(ci) -extents(r::AbstractUnitRange) = (length(r),) +extents(r::AbstractUnitRange) = (extent(r),) extents(n::Integer) = (Int(n),) """ diff --git a/test/foreach_index.jl b/test/foreach_index.jl new file mode 100644 index 000000000..725e96c06 --- /dev/null +++ b/test/foreach_index.jl @@ -0,0 +1,273 @@ +using KernelAbstractions +using KernelAbstractions: @atomic +using Adapt +using Test + +# An `IndexLinear` array whose `axes1` does not start at 1, so that `eachindex` returns a +# range of linear indices with an offset. +struct OffsetVec{T, A <: AbstractVector{T}} <: AbstractVector{T} + data::A + r::Base.IdentityUnitRange{UnitRange{Int}} +end +OffsetVec(data::AbstractVector, off::Int) = OffsetVec(data, Base.IdentityUnitRange((1 + off):(length(data) + off))) +Base.size(v::OffsetVec) = size(v.data) +Base.axes(v::OffsetVec) = (v.r,) +Base.IndexStyle(::Type{<:OffsetVec}) = IndexLinear() +Base.@propagate_inbounds Base.getindex(v::OffsetVec, i::Int) = v.data[i - first(v.r) + 1] +Base.@propagate_inbounds Base.setindex!(v::OffsetVec, x, i::Int) = (v.data[i - first(v.r) + 1] = x) +KernelAbstractions.get_backend(v::OffsetVec) = KernelAbstractions.get_backend(v.data) +Adapt.adapt_structure(to, v::OffsetVec) = OffsetVec(adapt(to, v.data), v.r) + +# The loop bodies live in functions so that their captures have known types, as the +# `foreach_index` docstring requires. + +function foreach_index_copy!(dst, src) + foreach_index(dst, src) do i + @inbounds dst[i] = src[i] + end + return dst +end + +function foreach_index_copy_from_first!(src, dst) + foreach_index(src, dst) do i + @inbounds dst[i] = src[i] + end + return dst +end + +function foreach_index_copy_backend!(dst, src, backend) + foreach_index(backend, eachindex(src)) do i + @inbounds dst[i] = src[i] + end + return dst +end + +function foreach_index_copy_workgroupsize!(dst, src, workgroupsize) + foreach_index(src; workgroupsize) do i + @inbounds dst[i] = src[i] + end + return dst +end + +function foreach_index_fill_index!(v) + foreach_index(v) do i + @inbounds v[i] = i + end + return v +end + +function foreach_index_mark!(out, itr) + foreach_index(itr) do I + @inbounds out[I] += 1 + end + return out +end + +function foreach_index_sum_range!(out, range, backend) + foreach_index(backend, range) do i + @inbounds @atomic out[1] += i % eltype(out) + end + return out +end + +# Record every index of the index space `indices` in `out`, an array indexed from 1. +function foreach_index_record!(out, backend, indices; workgroupsize = nothing) + offset = first(indices) - oneunit(first(indices)) + foreach_index(backend, indices; workgroupsize) do I + @inbounds out[I - offset] = I + end + return out +end + +function foreach_index_testsuite(Backend, AT) + backend = Backend() + + @testset "linear index space" begin + @testset "$(length(dims))-D" for dims in ((1024,), (32, 33), (4, 5, 6)) + src = AT(reshape(collect(1:prod(dims)), dims)) + dst = AT(zeros(Int, dims)) + @test foreach_index_copy!(dst, src) === dst + synchronize(backend) + @test Array(dst) == Array(src) + + # every index is visited exactly once + out = AT(zeros(Int, dims)) + foreach_index_mark!(out, src) + synchronize(backend) + @test all(isone, Array(out)) + end + end + + @testset "cartesian index space" begin + A = AT(zeros(Int, 8, 10)) + v = view(A, 1:2:8, 2:2:10) + @test eachindex(v) isa CartesianIndices + foreach_index_mark!(v, v) + synchronize(backend) + ref = zeros(Int, 8, 10) + ref[1:2:8, 2:2:10] .= 1 + @test Array(A) == ref + end + + @testset "offset linear index space" begin + v = OffsetVec(AT(zeros(Int, 10)), -3) + @test eachindex(v) == -2:7 + foreach_index_fill_index!(v) + synchronize(backend) + @test Array(v.data) == collect(-2:7) + end + + @testset "index space without device memory" begin + # a range carries no backend of its own, so it has to be given + # (32-bit atomics, as not every backend has 64-bit ones) + out = AT(zeros(Int32, 1)) + foreach_index_sum_range!(out, 1:100, backend) + synchronize(backend) + @test Array(out)[1] == sum(1:100) + end + + @testset "index space as given" begin + # the values of the index space, not its own indices + @testset "$(indices)" for indices in ( + 5:20, -3:4, Base.IdentityUnitRange(-3:4), Int32(2):Int32(9), UInt(2):UInt(9), + ) + out = AT(zeros(Int, length(indices))) + foreach_index_record!(out, backend, indices) + synchronize(backend) + @test Array(out) == collect(indices) + end + + # e.g. the interior of an array, with default and explicit workgroup sizes + @testset "$(indices), workgroupsize=$(workgroupsize)" for indices in ( + CartesianIndices((2:9, 2:7)), CartesianIndices((-1:3, 0:0, 4:6)), + ), workgroupsize in (nothing, 4, (4, 4)) + out = AT(fill(CartesianIndex(ntuple(_ -> 0, ndims(indices))), size(indices))) + foreach_index_record!(out, backend, indices; workgroupsize) + synchronize(backend) + @test Array(out) == collect(indices) + end + + # indices beyond the range of `Int32` + indices = (typemax(Int32) + 1):(typemax(Int32) + 10) + out = AT(zeros(Int, 10)) + foreach_index_record!(out, backend, indices) + synchronize(backend) + @test Array(out) == collect(indices) + end + + @testset "several arrays" begin + # linear indices if all arrays have them + A = AT(collect(reshape(1:12, 3, 4))) + B = AT(zeros(Int, 3, 4)) + foreach_index_copy!(B, A) + synchronize(backend) + @test Array(B) == Array(A) + + # Cartesian indices otherwise + C = AT(zeros(Int, 6, 4)) + v = view(C, 1:2:6, :) + @test eachindex(v, A) isa CartesianIndices + foreach_index_copy!(v, A) + synchronize(backend) + @test Array(C)[1:2:6, :] == Array(A) + @test all(iszero, Array(C)[2:2:6, :]) + + # arrays whose indices differ + @test_throws DimensionMismatch foreach_index_copy!(AT(zeros(Int, 4, 3)), view(C, 1:2:6, :)) + + # arrays on different backends + if get_backend(AT(Int[])) != get_backend(Int[]) + @test_throws ArgumentError foreach_index_copy!(AT(zeros(Int, 3)), zeros(Int, 3)) + end + + # ranges, and views of them, run on the backend of the other arrays + for r in (Base.OneTo(3), 4:6, view(reshape(1:12, 3, 4), :, 2)) + dst = AT(zeros(Int, 3)) + foreach_index_copy!(dst, r) + synchronize(backend) + @test Array(dst) == collect(r) + end + dst = AT(zeros(Int, 2, 3)) + foreach_index_copy!(dst, reshape(1:6, 2, 3)) + synchronize(backend) + @test Array(dst) == reshape(1:6, 2, 3) + dst = AT(zeros(Int, 2, 3)) + foreach_index_copy!(dst, LinearIndices((2, 3))) + synchronize(backend) + @test Array(dst) == collect(LinearIndices((2, 3))) + # ... also as the first argument + dst = AT(zeros(Int, 3)) + foreach_index_copy_from_first!(2:4, dst) + synchronize(backend) + @test Array(dst) == 2:4 + # ... and need one if there are no other arrays + @test_throws "pass it explicitly" foreach_index_copy!(1:3, 4:6) + end + + @testset "workgroupsize" begin + src = AT(collect(1:1000)) + dst = AT(zeros(Int, 1000)) + foreach_index_copy_workgroupsize!(dst, src, 8) + synchronize(backend) + @test Array(dst) == Array(src) + end + + @testset "explicit backend" begin + src = AT(collect(1:100)) + dst = AT(zeros(Int, 100)) + foreach_index_copy_backend!(dst, src, backend) + synchronize(backend) + @test Array(dst) == Array(src) + end + + @testset "zero-dimensional index space" begin + # a single index + @testset "workgroupsize=$(workgroupsize)" for workgroupsize in (nothing, 4) + out = AT(fill(CartesianIndex(1), 1)) + foreach_index(backend, CartesianIndices(()); workgroupsize) do I + @inbounds out[1] = CartesianIndex(length(I) + 2) + end + synchronize(backend) + @test Array(out) == [CartesianIndex(2)] + end + + A = AT(fill(1)) + foreach_index_fill_index!(A) + synchronize(backend) + @test Array(A)[] == 1 + end + + @testset "empty index space" begin + src = AT(Int[]) + dst = AT(Int[]) + @test foreach_index_copy!(dst, src) === dst + synchronize(backend) + @test isempty(Array(dst)) + + out = AT(zeros(Int32, 1)) + foreach_index_sum_range!(out, 5:4, backend) + foreach_index_record!(out, backend, CartesianIndices((1:2, 3:2))) + synchronize(backend) + @test Array(out) == [0] + end + + @testset "errors" begin + # index spaces that an `ndrange` cannot express, also when they are empty + @test_throws ArgumentError foreach_index(identity, backend, [1, 2, 3]) + @test_throws ArgumentError foreach_index(identity, backend, Int[]) + @test_throws ArgumentError foreach_index(identity, backend, 1:2:9) + @test_throws ArgumentError foreach_index(identity, backend, CartesianIndices((1:2:9, 1:3))) + @test_throws ArgumentError foreach_index(identity, backend, CartesianIndices((1:2:1, 1:3))) + @test_throws ArgumentError foreach_index(identity, backend, Dict(1 => 2)) + + # a function capturing a boxed variable + s = 1 + boxed = i -> s + s = 2 + @test_throws "reassigned (`s`)" foreach_index(boxed, backend, 1:3) + + # a collection that is not an array has no backend, and needs the second form + @test_throws MethodError foreach_index(identity, (1, 2, 3)) + end + return +end diff --git a/test/offsets.jl b/test/offsets.jl index 0367f6438..d8948ed4b 100644 --- a/test/offsets.jl +++ b/test/offsets.jl @@ -50,6 +50,23 @@ function offsets_testsuite(Backend, AT) @test Array(out) == ref end + @testset "dynamic workgroupsize" begin + # the workgroup size is tuned, starting from the extents of the ndrange + @testset for ndrange in (ranges, CartesianIndices(ranges)) + out = fresh() + offsets_fill_indices!(backend)(out, lo; ndrange) + synchronize(backend) + @test Array(out) == ref + end + + @testset for ndrange in (5:20, UInt(5):UInt(20)) + out = AT(zeros(Int, 16)) + offsets_fill_indices!(backend)(out, (5,); ndrange) + synchronize(backend) + @test Array(out) == 1:16 + end + end + @testset "mixed extents and ranges" begin out = fresh() offsets_fill_indices!(backend, (4, 4))(out, (1, 2); ndrange = (8, 2:11)) diff --git a/test/testsuite.jl b/test/testsuite.jl index 2e3d2ae10..1ce7e703d 100644 --- a/test/testsuite.jl +++ b/test/testsuite.jl @@ -35,6 +35,7 @@ include("unroll.jl") include("nditeration.jl") include("offsets.jl") include("launch.jl") +include("foreach_index.jl") include("copyto.jl") include("devices.jl") include("print_test.jl") @@ -85,6 +86,10 @@ function testsuite(backend, backend_str, backend_mod, AT, DAT; skip_tests = Set{ launch_testsuite(backend, AT; skip_tests) end + @conditional_testset "foreach_index" skip_tests begin + foreach_index_testsuite(backend, AT) + end + @conditional_testset "copyto!" skip_tests begin copyto_testsuite(backend, AT) end