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

mkl_peak_mem_usage does not reset ?

Konstantinos_K_
Beginner
331 Views

Hello!

i am using mkl_peak_mem_usage to measure mkl memory usage and despite i use mkl_peak_mem_usage(MKL_PEAK_MEM_RESET) , the counters are not zero. For example : 

mkl_peak_mem_usage(MKL_PEAK_MEM_RESET) ; // reset peak

printf( "memory peak : %lld\n", mkl_peak_mem_usage(MKL_PEAK_MEM_RESET)  ); // print peak and reset again

// do some calculations

printf( "memory peak : %lld\n", mkl_peak_mem_usage(MKL_PEAK_MEM_RESET)  ); // print new peak and reset

the first peak print is 45MB, the second peak print is 75MB and a custom calculation of memory needed in "do some calculations" is 75-45=30MB

my code is threaded using pthreads, and i also clear the mkl buffers using mkl_free_buffers and mkl_thread_free_buffers

i have initialized with  mkl_peak_mem_usage(MKL_PEAK_MEM_ENABLE) at the start of my code

is there some error in mkl_peak_mem_usage or maybe i do something wrong?

Thanks!

 

 

0 Kudos
2 Replies
Gennady_F_Intel
Moderator
331 Views

Konstantinos, I am not sure understand what is the problem. Do you expect that the second time mkl_peak_mem_usage should return the same memory peak as a the first time? May be when you //do some calculation the second time, then this calculation required exactly 75 Mb of memory?   you also can have a look at the example - MKLROOT/examples/servicefuncsc/source/servicefuncs.c 

 

 

0 Kudos
Konstantinos_K_
Beginner
331 Views

Gennady,

From what i understand the code should behave as :

mkl_peak_mem_usage(MKL_PEAK_MEM_ENABLE) ; // enable counting

// various lines of code with allocations, deallocations, threading etc

mkl_peak_mem_usage(MKL_PEAK_MEM_RESET) ; // should reset  counters

printf( "memory peak : %lld\n", mkl_peak_mem_usage(MKL_PEAK_MEM)  ); // should print 0 (?)

// do some calculations   (requires 30MB with a custom measure)

printf( "memory peak : %lld\n", mkl_peak_mem_usage(MKL_PEAK_MEM)  ); // should print 30MB

// various lines of code with allocations, deallocations, threading etc

mkl_peak_mem_usage(MKL_PEAK_MEM_DISABLE); // disable counting

is this correct?

instead the output is :

1st print : 45MB

2nd print : 75MB

it is like the call to mkl_peak_mem_usage(MKL_PEAK_MEM_RESET) does not reset peak memory to zero. If that is it's purpose of course.

0 Kudos
Reply