- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using mkl example from the manual. However, the values returned from MKL_Mem_stat is just 0. Why?
Code is here:
double *a, *b, *c;
int n, i;
double alpha, beta;
MKL_INT64 AllocatedBytes;
int N_AllocatedBuffers;
alpha = 1.1; beta = -1.2;
n = 1000;
a = (double*)MKL_malloc(n*n*sizeof(double),128);
b = (double*)MKL_malloc(n*n*sizeof(double),128);
c = (double*)MKL_malloc(n*n*sizeof(double),128);
for (i=0;i<(n*n);i++) {
a = (double)(i+1);
b = (double)(-i-1);
c = 0.0;
}
//dgemm("N","N",&n,&n,&n,α,a,&n,b,&n,β,c,&n);
AllocatedBytes = MKL_Mem_Stat(&N_AllocatedBuffers);
printf("\\nDGEMM uses %ld bytes in %d buffers \\n",(long)AllocatedBytes,N_AllocatedBuffers);
MKL_FreeBuffers();
AllocatedBytes = MKL_Mem_Stat(&N_AllocatedBuffers);
printf("MKL_FreeBuffers uses %ld bytes in %d buffers \\n",(long)AllocatedBytes,N_AllocatedBuffers);
if (AllocatedBytes > 0) {
printf("\\nMKL memory leak!");
printf("\\nAfter MKL_FreeBuffers there are %ld bytes in %d buffers",
(long)AllocatedBytes,N_AllocatedBuffers);
}
MKL_free(a);
MKL_free(b);
MKL_free(c);
return 0;
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
I noticed this following line is commented:
//dgemm("N","N",&n,&n,&n,α,a,&n,b,&n,β,c,&n);
MKL_Mem_Stat() will compuate the internal MKL buffer (when call dgemm()) it will use. To improve the performance, MKL has memory manager that may allocate some memory buffers used by MKL functions. MKL_Mem_Stat() will return the memory used the the memory buffer.
Thanks,
Chao
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Or MKL_malloc doesn't really allocat until it is used?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
MKL_Mem_Stat tracks the internal memory allocate by the MKL computation functions. These memory buffers are not visible to the users. For MKL_malloc, it is used by user to allocate the memory externally. Users can this call to allocate the memory by themselves, and use MKL_free the free these memory. It is actually allocate the memory.
Thanks,
Chao
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
if (AllocatedBytes > 0) { printf("\nMKL memory leak!");
..
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page