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

Failed allocations in MKL SGEMM ok?

Daroo
Beginner
161 Views

I am using MKL (version 2024.2) for efficient C++ SGEMM functionality.  During my testing, I have found that sometimes the SGEMM processing seems to dynamically allocate memory during its execution. The thing that seems strange is that things seem to perform as expected whether the dynamic allocation was successful or whether it failed. In fact, it seems that if the dynamic allocation fails and a NULL pointer is returned, the SGEMM still functions nearly identically.

 

After some discussion about how this could be, we thought maybe there was an internal "fallback" - so perhaps it tries to do the dynamic allocation, and if it succeeds, it performs a more efficient SGEMM, but if the allocation fails, it just falls back to a less efficient version that doesn't rely on the extra memory.

 

Of course, this is just a guess, but we were hoping to get some confirmation about the internal workings if possible.  Mainly, we want to be sure that we don't just erroneously conclude that it is acceptable for the dynamic allocation to fail if there are ramifications beyond efficiency.

 

If there was any information about how failed dynamic allocations are handled within the SGEMM functionality, that would be nice to know too, if possible.

 

Thanks for your help!

0 Kudos
1 Reply
Andrew_Barker
Employee
45 Views

Some oneMKL routines do allocate temporary memory, and the library offers users some control over that, for example you can set a limit on the amount of temporary memory or even provide your own memory management functions. In many cases there is a fallback in case memory is limited or the memory allocation fails. If the oneMKL call succeeds with no error message you can assume everything was done correctly.

More info on memory management in oneMKL is available here.

0 Kudos
Reply