Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
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.
7234 Discussions

What's the unit of the "alignment" argument of MKL_malloc?

llevrel
Beginner
1,127 Views
Hi,

I can't figure out the correct answer: bits or bytes? I first thought "bytes", because obviously one cannot align memory chunks bit-wise. But the MKL Reference Manual gives an example of MKL_malloc(...,128) (page 3274) and 128 bits==16 bytes, which is exactly what's advised in the User's Guide. So what?

Thanks in advance.
0 Kudos
5 Replies
Dmitry_B_Intel
Employee
1,127 Views
Bytes.

Thanks for noticing this inconsistency.
Dima
0 Kudos
llevrel
Beginner
1,127 Views
Good! So, why does the Reference Manual example use 128-byte alignment? I haven't noticed this "magic number" to be mentioned elsewhere...
0 Kudos
Dmitry_B_Intel
Employee
1,127 Views

This is an example demonstrating usage of MKL_malloc. Nothing particular about this number, except demonstrating that a 2-power alignment is expected. Aligning on cache-line boundary (64 bytes) would be more reasonable I admit.

0 Kudos
barragan_villanueva_
Valued Contributor I
1,127 Views
I'd like to add that sometimes page-boundary alignmentof data gives performace improvents in comparison with cache-line boundary.
0 Kudos
llevrel
Beginner
1,127 Views
Is there a way to get those numbers at compile time or run time? (Compiler intrinsic, system call...)
0 Kudos
Reply