Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

mkl_realloc alignment

DarioMangoni
Beginner
943 Views

Hi,
I'm facing a problem probably due to misalignment so I decided to use mkl_*alloc with Parallel Direct Sparse Solver.

The solver needs 64byte alignment that is succesfully obtained my mkl_malloc/mkl_calloc specifying the alignment parameter.
Unfortunately this is not possible with mkl_realloc: its default is a simple 16byte alignment and nothing can be done to bypass this default behaviour.
Any workaround?

Thanks,
Dario

0 Kudos
5 Replies
Gennady_F_Intel
Moderator
943 Views

voidmkl_realloc (void *ptrsize_t size);  If ptr is NULL, the function works as mkl_malloc !

0 Kudos
DarioMangoni
Beginner
943 Views

Sorry, maybe I didn't specify that I WANT to reallocate that vector! If I didn't want to, I'd use mkl_malloc!
If I use mkl_realloc to reallocate, the address is no more 64byte aligned!

I can create another array with mkl_malloc and then copy the data, but the memory peak (mkl_peak_mem_usage()) is incredibly higher than using mkl_realloc.

Another question... does mkl_realloc try to "expand" the current array before moving it elsewhere?

0 Kudos
Gennady_F_Intel
Moderator
943 Views

thanks for the issue. mkl_realloc doesn't remember the alignment of the "original" array but it must to keep this alignment. We will fix this into one of the next releases/updates.

 

0 Kudos
Gennady_F_Intel
Moderator
943 Views

the problem has been fixed in MKL v.11.3.1

0 Kudos
Eugene_S_1
Beginner
943 Views

Please amend the documentation on mkl_realloc by explicitly stating that alignment is preserved. Now it says nothing about the alignment of a new buffer.

0 Kudos
Reply