views:

90

answers:

1

I'm looking at using SSE and I gather aligning data on 16byte boundaries is recommended. There are two cases to consider:

float data[4];

struct myystruct
{
 float x,y,z,w;
};

I'm not sure the first case can be done explicitly, though there's perhaps a compiler option I could use? In the second case I remember being able to control packing in old versions of GCC several years back, is this still possible?

+2  A: 

For static array, you can use

__declspec(align(16)) float data[4];

For dynamically allocated array, use _aligned_malloc and _aligned_free. To control structure elements alignment, use #pragma pack.

Alex Farber