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

MKL memory allocation: Is there an mkl_realloc?

bstrouse
Beginner
429 Views
Hello,

I know that dynamic arrays being used by the Intel MKL functions needed to be allocated and deleted by the mkl_malloc and mkl_free. I was wondering if there was an mkl_realloc function provided in case you wanted to attempt and change the amount of memory allocated for a specific address stored inside a pointer.

Thanks.
0 Kudos
4 Replies
Chao_Y_Intel
Moderator
429 Views

Hello,

MKL only has the malloc functions, and no remalloc functions. mkl_malloc is calling the system malloc function, and it may allocate a little larger memory size, and make sure it can return the aligned the memory address. If you need to have a aligned remalloc function, I think may do something like that with system remalloc system call.

Thanks,
Chao

0 Kudos
bstrouse
Beginner
429 Views
So basically, I would have to write my own remalloc function to replace the standard one. If I wanted to do this, do I only need to make sure that remalloc is assigning chunks in multiples of the byte alignment (for example 16 bytes alignment)?

Thanks,
Blake
0 Kudos
Chao_Y_Intel
Moderator
429 Views

Blake,

I just have quick search, in windows, the system runtime library provide the API: _aligned_realloc:
http://msdn.microsoft.com/en-us/library/y69db7sx(v=VS.71).aspx

Thanks,
Chao

0 Kudos
TimP
Honored Contributor III
429 Views

I just have quick search, in windows, the system runtime library provide the API: _aligned_realloc:
http://msdn.microsoft.com/en-us/library/y69db7sx(v=VS.71).aspx

Then you should use the corresponding Microsoft aligned_malloc and free functions, in case the MKL definitions aren't fully compatible.
0 Kudos
Reply