Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

Memory Alignment

Prashanthns
Beginner
137 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
Andreas_Klaedtke
Beginner
137 Views
ILevi1
Valued Contributor I
137 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.
Reply