Software Archive
Read-only legacy content
17061 Discussions

How to ALLOCATE memory aligned on 32-byte boundary

michael-a-carr
Beginner
818 Views
How can I ALLOCATE an array so that it aligned with a 32-byte boundary? I need to do this for optimum performance when calling Intel's vectorized math libraries...

thanks!
0 Kudos
1 Reply
Steven_L_Intel1
Employee
818 Views
You can't specify alignment with ALLOCATE. Best I can recommend is to malloc n+32 bytes, add 31 to the base address and then AND off the low five bits. Assign this to an integer POINTER for your array pointer. Don't forget to save the original allocated address for the free/

Steve
0 Kudos
Reply