omlins / ParallelStencil.jl

Package for writing high-level code for parallel high-performance stencil computations that can be deployed on both GPUs and CPUs
BSD 3-Clause "New" or "Revised" License
316 stars 32 forks source link

Treat explicit parallel indices as aliases to INDICES #111

Closed omlins closed 1 year ago

omlins commented 1 year ago

Both ways of writing macros shown in the following are supported for usage in @parallel_indices:

macro compute(A)              esc(:($(INDICES[1]) + ($(INDICES[2])-1)*size($A,1))) end
macro compute_with_aliases(A) esc(:(ix            + (iz           -1)*size($A,1))) end

@parallel_indices (ix,iz) function write_indices!(A)
    A[ix,end,iz] = @compute_with_aliases(A);
    return
end

@parallel_indices (ix,iz) function write_indices!(A)
    A[ix,end,iz] = @compute(A);
    return
end