Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Prashanthns
Beginner
62 Views

Memory Alignment

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
62 Views

ILevi1
Valued Contributor I
62 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