copy to __constant__ by cudaMemcpyToSymbol


I defined a structure as
struct XXX
int a;
int b;
float4 vector_a;
float4 vector_b;
int c;
int d;


and declare an constant through constant

When I try to copy from host to device’s constant value through cudaMemcpyToSymbol,
but the struct’s vector_a(b) and scalar c/d seems are not copied to. Can anyone please
explain the reason? Thanks!

The cudaMemcpyToSymbol function takes a different number of args when compared to cudaMemcpy. See if you have given the args correctly – most importantly the “size”


This is the memory alignment issue. float4 structure was declared as align(16).