.cpp - .cu struct miss alignment problem on cuda for CPU or kernel functions struct, alignment

a problem with structures.

this structure does not work:

typedef struct MV_image_prop2 {
int2 box;
int2 boxtop;
float3 invA_r[3];
float3 invR_r[3];
float3 mt_r;
int m_max;
float4 P[3];
} MVssProp2;

I fill an array of this structure in a .cpp file and copy it contents to the GPU constant memory. Inside a kernel I do cuprintf of the structure then I find that some of the values are changed and a wrong alignment in the beginning.
if in a .cu file I run a cpu function that read a cpu mem pointer, I find wrong alignment also.

this solve the problem:

typedef struct MV_image_prop2 {
float4 P[3];
float3 invA_r[3];
float3 invR_r[3];
float3 mt_r;
union{
int2 dummym_max;
int m_max;
};
int2 box;
int2 boxtop;
} MVssProp2;

I tried struct align(16) and struct align(8) but it didn’t make any difference. is there any rule technique or advice with structure alignment for cuda or cpp-cuda compatibility?