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

Issue with mkl_malloc

Ahmadi__Afshin
498 Views

Hey guys,

I have an issue with mkl_malloc function. I have a simple program that does some mathematical calculations and works with no issue. However, when I add the following lines to my program, SOMETIMES it gets stuck at mkl_malloc without throwing any error and I have to force close the program. Any idea what could be the problem?

******** System Specifications ***********

Windows 7 / 64 bit

Intel Parallel XE Studio 2018

Visual Studio Enterprise 2017

********* Added Code *************

#include "mkl.h"

double *A;

A = (double *)mkl_malloc(100*100 * sizeof(double), 64);

 

0 Kudos
3 Replies
Jing_Xu
Employee
498 Views

How do you compile your code? Following https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor? Or use the automatic switches that are integrated into VS 2017?

If you can upload a test case, it will be helpful for investigation.

0 Kudos
Gennady_F_Intel
Moderator
498 Views

+pls also play with mkl example - servicefuncs.c ( <mklroot>\examples\servicefuncsc\source\ ). this example shows how to call many of mkl service routines inluding mkl_malloc. You may try to build it from command line ( makefile works for win system too ) or add this example to VS and check how this will work on your side.

0 Kudos
Zhen_Z_Intel
Employee
498 Views

Hi,

Please check if your program totally allocate memory above 2G? mkl_malloc may crash if you accessing too many memory once time, or allocate and free too many times which may lead to memory fragmentation. Please also try with aligned_malloc in stdlib, if you can meet same problem? If so, please change to use c standard malloc or aligned_malloc, otherwise, it probably because your program remains memory leak or memory out of range problem.

Best regards,
Fiona

0 Kudos
Reply