Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Memory Alignment

Prashanthns
Beginner
534 Views
Is there any way by which we can direct the compiler to align memory while allocating memory statically or dynamically ??
0 Kudos
2 Replies
levicki
Valued Contributor I
534 Views
For static allocation use __declspec(aligned(n)) where n is required alignment (16, 64, 128 bytes).

For dynamic allocation use functions such as _mm_malloc() and _mm_free() (they are defined with SIMD intrinsics).

For dynamic allocation in C++ code (i.e. when allocating objects of some class which have a member that shoudl be aligned) you need to override new and delete operators using placement new and delete.
0 Kudos
Reply