digitalmars.D.learn - alignment for data not being struct members?
- Trass3r (30/30) Nov 16 2009 Well, OpenCL requires all types to be naturally aligned.
- bearophile (4/8) Nov 17 2009 Show this problem in the main D newsgroup and ask for align(n) to work o...
- Trass3r (2/4) Nov 17 2009 Thank you, I've done so.
Well, OpenCL requires all types to be naturally aligned. The D specs state: "AlignAttribute is ignored when applied to declarations that are not struct members." Could there arise any problems translating the following /* * Vector types * * Note: OpenCL requires that all types be naturally aligned. * This means that vector types must be naturally aligned. * For example, a vector of four floats must be aligned to * a 16 byte boundary (calculated as 4 * the natural 4-byte * alignment of the float). The alignment qualifiers here * will only function properly if your compiler supports them * and if you don't actively work to defeat them. For example, * in order for a cl_float4 to be 16 byte aligned in a struct, * the start of the struct must itself be 16-byte aligned. * * Maintaining proper alignment is the user's responsibility. */ typedef double cl_double2[2] __attribute__((aligned(16))); typedef double cl_double4[4] __attribute__((aligned(32))); typedef double cl_double8[8] __attribute__((aligned(64))); typedef double cl_double16[16] __attribute__((aligned(128))); into just alias double[2] cl_double2; alias double[4] cl_double4; alias double[8] cl_double8; alias double[16] cl_double16; ?
Nov 16 2009
Trass3r:typedef double cl_double2[2] __attribute__((aligned(16))); typedef double cl_double4[4] __attribute__((aligned(32))); typedef double cl_double8[8] __attribute__((aligned(64))); typedef double cl_double16[16] __attribute__((aligned(128)));Show this problem in the main D newsgroup and ask for align(n) to work on stack-allocated arrays/structs too. Bye, bearophile
Nov 17 2009
bearophile schrieb:Show this problem in the main D newsgroup and ask for align(n) to work on stack-allocated arrays/structs too.Thank you, I've done so.
Nov 17 2009