Utilities

Aether.Utils.for_each!Function
for_each!(
    f,
    architecture::Aether.Architectures.AbstractArchitecture,
    ri::AbstractUnitRange,
    rj::AbstractUnitRange,
    rk::AbstractUnitRange,
    rm::AbstractUnitRange;
    workgroup
)

Apply f(i, j, k, m) in parallel over the index box ri × rj × rk × rm (i fastest, meshblock m slowest). Ranges may start anywhere — interior is:ie, faces is:ie+1, halo-inclusive, negative. Asynchronous: call synchronize(architecture) before timing or reading results on the host.

Do-block closures must not capture non-const globals (that breaks GPU compilation); build them inside a function.

using Aether

A = zeros(4, 3, 2, 1, 2);

for_each!(CPU(), 1:4, 1:3, 1:2, 1:2) do i, j, k, m
    A[i, j, k, 1, m] = i + 10j + 100k + 1000m
end

synchronize(CPU())
A[4, 3, 2, 1, 2]

# output
2234.0
source