About built-in vector types in CUDA?

About built-in vector types in CUDA?

How is the vector-types in CUDA maps to its memory address?

e.g. considering an array of int4 (assuming no alignment issues):

int4 S[100];

Then I cast it into an array of int:

int32_t * S1 = reinterpret_cast<int32_t *>(S);

Then can I assume that S1[0]=S[0].x, S1[1]=S[0].y, S1[2]=S[0].z, S1[3]=S[0].w, S1[4]=S[1].x…?

review the definitions in vector_types.h, which should answer any questions you have, since the vector types are all defined there.

On a standard linux install, that is at /usr/local/cuda/include/vector_types.h

For example, int4 is defined as:

struct device_builtin builtin_align(16) int4
{
int x, y, z, w;
};

So it is a struct definition, with x first, then y, then z, then w. You should be able to use standard C language rules to answer any questions about casting.