- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I tried to use SVD subroutines (LAPACKE_sbdsqr, LAPACKE_sbdsdc) in MKL, but encountered memory errors as "null pointer dereference or unaligned memory access". I used mkl_malloc to allocate all memory buffers for all inputs and outputs with alignment of 64 byte, and I'm pretty sure I allocated enough space for all inputs and outputs. Does anybody have idea about what might be wrong?
Thanks a lot!
Can
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Can,
I could not reproduce your problem, there's no problem about NULL/bad pointer for memory allocation on my side by using mkl_malloc, could you please provide a test case or your program that I could have a look. Please also check with your machine if there's enough space for your program. Thanks.
Best regards,
Fiona
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Fiona for your reply. Here is a simple program I used to test the subroutine bdsqr
The link option I used is like
-Wl,--start-group -L${IMKLHOME}/lib/intel64 -lmkl_intel_ilp64 -lmkl_sequential -lpthread\
-lmkl_core -lmkl_lapack95_ilp64 -Wl,--end-group
#include "mkl.h"
#include "mkl_lapacke.h"
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
float *mdiag=(float *) mkl_malloc(4*sizeof(float),64);
float *udiag=(float *) mkl_malloc(4*sizeof(float),64);
float *u=(float *) mkl_malloc(4*4*sizeof(float),64);
float *vt=(float *) mkl_malloc(4*4*sizeof(float),64);
float *c=(float *) mkl_malloc(4*4*sizeof(float),64);
memset(c,0,16*sizeof(float));
for (int i=0;i<4;++i) {
mdiag=1;
udiag=1;
c[i*4+i]=1;
}
int flag=LAPACKE_sbdsqr(LAPACK_COL_MAJOR,'U',4,4,4,4,mdiag,udiag,vt,4,u,4,c,4);
mkl_free(u);
mkl_free(vt);
mkl_free(mdiag);
mkl_free(udiag);
}
Is there anything wrong with the linking?
Thanks,
Can
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Can,
Seems no problem with your code. For your link line, you are going to use 64 integer lib, if so, please also compile with -DMKL_ILP64 option and you could remove lapack95 lib which is used for fortran95 interface. I recommend to use MKL advisor help to generate your own command. And I also wonder what's the version of MKL & Intel compiler you are using. Have you ever tried to replace mkl_malloc with basic glibc malloc function? What would be like if you just change mkl_malloc to malloc?
Best regards,
Fiona
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Fiona,
We found out that for our linux, we should link LP64 libraries instead of ILP64 ones. After changing the linked libraries, everything is fine.
Thank you again for your help!
Can

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page