Skip to content

Support for more than 3 indices #214

Description

@TakeTwiceDailey

Currently, it seems that @parallel and @parallel_indices are limited to launching kernels with 3 or less indices.

This can be worked around by instead launching over a linear index for simple kernels, like this simple copy operation:

@parallel_indices (linear_index) function copy!(Un,U)
    U[linear_index]  = Un[linear_index]
    return
end

which works with arbitrary rank arrays. My use case for this is a 3D simulation that is set up with many connected blocks. I would like one index to set the block number, and the other three indices to label the 3D point in the array of that block. I can set up simple kernels like the above, but I can't do more complicated things like a subset operation:

@parallel_indices (block,xi,yi,zi) function copy!(Un,U)
    U[block,xi,yi,zi]  = Un[block,xi,yi,zi]
    return
end

@parallel (1:6,5:n-4,5:n-4,5:n-4) copy!(Un,U)

that only affects the interior region of all 6 blocks for example. Instead, I have to write a loop that launches 6 separate @parallel kernels.

Another thing that would be nice is to launch a kernel over a given list of indices. Sometimes a simple Cartesian subset is not adequate, and I need to launch a kernel over a more complicated subset of indices in an array. I could just run a kernel over all indices and set up an if statement in the kernel to exit if it isn't in the given subset, but I am worried about branch divergence on GPU.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions