How to specify alignment for global device variables in CUDA

六眼飞鱼酱① 提交于 2019-12-05 22:50:21
njuffa

See section 5.3.2 "Size and Alignment Requirement" of the "CUDA C Programming Guide", which can be found here:

The alignment requirement is automatically fulfilled for the built-in types of char, short, int, long, longlong, float, double like float2 or float4.

For structs, the size and alignment requirements can be enforced by the compiler using the alignment specifiers __align__(8) or __align__(16).

Example usage:

struct __align__(8) { 
    float r; 
    float i;
} complex_num;

Can you check if this works?

__device__ char __align__(4) str1 = "some pre-defined string";
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!