Skip to content

Add more support for N dimensions #3955

@AlexanderSinn

Description

@AlexanderSinn

Some codes, such as HiPACE++, use a different number of dimensions in different parts of the code. Currently, AMREX_SPACEDIM has to be chosen as the maximum number of dimensions used, with the other places in the code not utilizing the extra dimensions by assigning a size of 1 to them. This can be very confusing, and in the case of ParallelFor and Array4 can lead to a slight performance loss. Additionally, it might be useful to have more than 3 dimensions sometimes. For example, a 3D loop with tiling on GPU could be implemented with a 6D ParallelFor.

This can be achieved by replacing the AMREX_SPACEDIM macro with a template parameter that specifies the number of dimensions.

I would volunteer to start working on this by converting IntVect to IntVectND<> and adding using IntVect = IntVectND<AMREX_SPACEDIM>;. Currently IntVect relies hevily on AMREX_D_TERM. This can be replaced by sfinae, if constexpr or for loops that will usually get unrolled since the bounds are known at compile time.

Later on, the same can be done for other types such as RealVect, Box, Geometry, Array4, as well as ParallelFor.

Even if not everything will be converted (BoxArray, MultiFab might require too much effort), just having N-dimensional indexing would be very useful.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions