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

MKL with Armadillo Memory leaks

Gottkehaskamp
Beginner
739 Views

Hi,

for solving large systems of equations I use the Intel MKL library from the Intel oneAPI Base Toolkit, latest version, together with Armadillo, version 9.850 (latest version).

For testing, I wrote a small program in Visual Studio 2019:

------------------------------------------------------------------------------------------------------

#include "..\..\armadillo\include\armadillo"
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
using namespace arma; // ... Namespace for Aramdillo C++ Library
void main (void)
{
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
long n = 10;
mat A(n, n, fill::randu);
vec b(n, fill::randu);
vec x1 = solve(A, b);
}

------------------------------------------------------------------------------------------------------------

When the equation system size is small (e.g. n=10) everything works fine, when the system size is large (e.g. n=100) I always get memory leaks:

-------------------------------------------------------------------------------------------------------------

Dumping objects ->
{113} normal block at 0x0434B040, 4737552 bytes long.
Data: <@ 4 JH > 40 B0 34 04 00 00 00 10 4A 48 00 00 10 00 00
{112} normal block at 0x0424A4B0, 132 bytes long.
Data: < $ > B0 A4 24 04 00 00 00 84 00 00 00 10 00 00
{111} normal block at 0x04275CD8, 69648 bytes long.
Data: < $' > D8 5C 27 04 00 00 00 10 10 01 00 00 10 00 00

------------------------------------------------------------------------------------------------------------

The size of the memory leaks is independent of the equation system size. I use the following Intel "ia32" libraries: mkl_intel_c.lib mkl_sequential.lib mkl_core.lib. I get the memory leaks with both the MS-Visual C++ and the Intel C++ compiler.

Armadillo support said that the error must be in the Intel MKL.

Can anyone help me with this?

Regards,

Raimund

0 Kudos
7 Replies
AbhishekD_Intel
Moderator
708 Views

Hi Raimund,


Thanks for reaching out to us.

As this issue is more related to Intel MKL, we are moving this thread to Intel MKL Forum.


The Intel Math Kernel Library allocates and deallocates internal buffers to facilitate better performance, so that could be the reason for the memory leaks.

Try setting the MKL_DISABLE_FAST_MM environment variable to 1 or call the mkl_disable_fast_mm() function and let us know if you are getting the same memory leaks.



Warm Regards,

Abhishek



Gottkehaskamp
Beginner
655 Views

the first memory leak disappears, but the next two are still present:

{113} normal block at 0x03C38530, 132 bytes long.
Data: <0 > 30 85 C3 03 00 00 00 84 00 00 00 10 00 00
{112} normal block at 0x03C39958, 69648 bytes long.
Data: <X > 58 99 C3 03 00 00 00 10 01 00 00 10 00 00

Gottkehaskamp
Beginner
633 Views

It may be that this information helps:

the memory leaks only occur when linking statically
When linking using shared dll there are no memory leaks

AbhishekD_Intel
Moderator
576 Views

Hi Raimund,

 

Thanks for the details. We are also getting the same issue with static linking(ia32), whereas linking dynamically(ia32) gives no leaks. The issue is very much reproducible. We are looking into this behavior and will get back to you.

 

 

Warm Regards,

Abhishek

 

Khang_N_Intel
Employee
513 Views

Hi Raimund,

We will work with the engineering team and will address this issue.

Best,

Khang


VidyalathaB_Intel
Moderator
182 Views

Hi Raimund,


Thanks for your patience.


The memory leaks are occurring because of the absence of the mkl_free_buffers() function after calling MKL functions.


Please report this issue to Armadillo support and ask them to add mkl_free_buffers() after they call MKL functions.


Regards,

Vidya.


VidyalathaB_Intel
Moderator
126 Views

Hi,


As we haven't heard back from you we are closing this thread. Please post a new question if you need any additional assistance from Intel as this thread will no longer be monitored.


Regards,

Vidya.


Reply