Thread overview | |||||
---|---|---|---|---|---|
|
November 16, 2009 alignment for data not being struct members? | ||||
---|---|---|---|---|
| ||||
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; ? |
November 17, 2009 Re: alignment for data not being struct members? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Trass3r | 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
|
November 17, 2009 Re: alignment for data not being struct members? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | 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.
|
Copyright © 1999-2021 by the D Language Foundation