Is there a possibility to have a Struct-of-Array layout for MultiFab? #4720
-
|
As I saw in the code and changelog, the particle mode supports SoA and AoS, but it seems that the MultiFab does only support AoS. The way I understand it currently is as follows: for (MFIter mfi(outputs); mfi.isValid(); ++mfi) {
const Box &box = mfi.validbox();
auto _mf = my_multifab.array(mfi);
ParallelFor(box, [=] AMREX_GPU_DEVICE(int i, int j, int k) {
// do something with _mf(i, j, k, n) with n being in the range of the components
});
}When going into the type of _mf (Array4), the operator overload of template <class U=T, std::enable_if_t<!std::is_void_v<U>,int> = 0>
[[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
U& operator() (int i, int j, int k, int n) const noexcept {
#if defined(AMREX_DEBUG) || defined(AMREX_BOUND_CHECK)
index_assert(i,j,k,n);
#endif
return p[(i-begin.x)+(j-begin.y)*jstride+(k-begin.z)*kstride+n*nstride];
}Thank you in advance for your responses and understanding! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
|
Could you clarify what you mean by AoS and SoA? For a MultiFab, |
Beta Was this translation helpful? Give feedback.
nstride is larger than all the other strides, making it the outermost component (SoA). AoS would be if nstride is equal to 1 and istride > 1.