Here is a comment that reads " you must align all arrays and structs that are used on the device". I have seen a lot PMACC_ALIGN in the code to align all members of structs used on device but, as pointed out by @sbastrakov, this is mostly old code. Does someone knows if this is still required and if when?
Maybe @ax3l,@psychocoderHPC know something about it?
So to clarify, I just noticed that this macro is mostly used in the core, presumably older, code, and not in plugins. Hence not sure how that "must" should be interpreted.
@psychocoderHPC could you comment on this question?
I strongly suggest to keep using PMACC_ALIGN. I think we need to evaluate if we can remove it. Removing is simpler than adding it because you need to check the full code base.
Side effects of non aligned types are byte copies in our code e.g. https://github.com/ComputationalRadiationPhysics/picongpu/issues/88
The linked issue shows this behavior for very old architecture which is not supported anymore but as soon as your class/struct has bool and int member mixed I still expect this issue.
Here you can find some more information about CUDA alignment requirements: https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#device-memory-accesses
Note: our data type float3_32 is not aligned to 16byte, we only align the members. But if you put a float3_32 as member in a self defined struct and you use PMACC_ALIGN you will have a 16byte aligned type.
// will be aligned to 16 byte
struct foo
{
PMACC_ALIGN(bar, float3_32);
};