Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

How to ALLOCATE memory aligned on 32-byte boundary

michael-a-carr
Beginner
1,280 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
1,280 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