- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear users:
I am having trouble interfacing my intel mkl code with Matlab using the mex interface. I have a code that does a certain factorization based on the pivoted QR decomposition. It works fine when I compile the code by itself. However, I would like to make a mex code for other users. I have done this before and have been able to compile simple mex files with icc and mkl. However, now I have a problem. Perhaps someone here has ideas for me to try. I am trying to use the pivoted QR decomposition function and this is where my code fails:
m = nrows; n = ncols;
data = (double*)mxCalloc(nrows*ncols,sizeof(double));
Iarr = (lapack_int*)mxCalloc(n,sizeof(lapack_int));
tauarr = (double*)mxCalloc(min(m,n),sizeof(double));
LAPACKE_dgeqp3(LAPACK_COL_MAJOR, (lapack_int)nrows, (lapack_int)ncols, data, (lapack_int)nrows, Iarr, tauarr);
sometimes it simply segfaults (when mex file is run inside matlab). Other times it complains that parameter 8 to dgeqp3 is incorrect.
Intel MKL ERROR: Parameter 8 was incorrect on entry to DGEQP3.
Parameter 8 is not present in the lapacke function, it is the info parameter in the fortran routines. Notice that I initialize space using mxCalloc vs regular C calloc..
Here is how I compile my mex file:
#!/bin/bash
icc -c -DMX_COMPAT_32 -D_GNU_SOURCE -DMATLAB_MEX_FILE -I"/apps/matlab2014a/extern/include" -I"/apps/matlab2014a/simulink/include" -fexceptions -fPIC -fno-omit-frame-pointer -openmp -shared -O -DNDEBUG mex_code1.c -o mex_code1.o
icc -openmp -shared -L"/opt/intel/mkl/lib/intel64/" -I"/opt/intel/mkl/include/" /opt/intel/mkl/lib/intel64/libmkl_intel_lp64.a /opt/intel/mkl/lib/intel64/libmkl_intel_thread.a /opt/intel/mkl/lib/intel64/libmkl_core.a /opt/intel/mkl/lib/intel64/libmkl_blas95_lp64.a /opt/intel/mkl/lib/intel64/libmkl_lapack95_lp64.a -lmkl_rt -lmkl_core -lmkl_gnu_thread -lgomp -lpthread -Wl,--no-undefined -Wl,-rpath-link,apps/matlab2014a/bin/glnxa64 -O -Wl,--version-script,"apps/matlab2014a/extern/lib/glnxa64/mexFunction.map" mex_code1.o -L"apps/matlab2014a/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -o mex_code1.mexa64
rm -f mex_code1.o
I suspect the issue maybe in the compilation step (which compiles fine). As i mentioned, the code runs fine outside of the mex interface, when I replace back
all the mxCalloc calls by regular calloc.
thanks for your help
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
we have one article talking about Using Intel® MKL in MATLAB Executable (MEX) Files for your reference
i saw there are mixed mkl library in link line, You may remove some of them according to the MKL link adviser:
https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/
The compile option and linked library is like below
-openmp -I$(MKLROOT)/include
-Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_intel_lp64.a $(MKLROOT)/lib/intel64/libmkl_core.a $(MKLROOT)/lib/intel64/libmkl_intel_thread.a -Wl,--end-group -L$(CompilerPath) -liomp5 -lpthread -lm
let's see any change if with correct library.
Best Regards,
Ying
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your suggestions. I've tried a few things and now the mex file does not segfault, but still unable to execute the QR function. Here is the code I use in the mex file:
double *data = (double*)calloc(m*n,sizeof(double));
for(i=0; i<(m*n); i++){
data = 1.0;
}
Iarr = (lapack_int*)calloc(n,sizeof(lapack_int));
tauarr = (double*)calloc(min(m,n),sizeof(double));
LAPACKE_dgeqp3(LAPACK_COL_MAJOR, m, n, data, n, Iarr, tauarr);
Here is the error reported in matlab:
Intel MKL ERROR: Parameter 4 was incorrect on entry to DGEQP3
Here is how I compile the mex file:
#!/bin/bash
icc -c -DMKL_ILP64 -fPIC -fno-omit-frame-pointer -DMX_COMPAT_32 -I"/apps/matlab2014a/extern/include" -I"/apps/matlab2014a/simulink/include" -I"/opt/intel/mkl/include" -fexceptions -openmp -shared -O -DNDEBUG mex_code.c -o mex_code.o
icc -shared -openmp -I"/opt/intel/mkl/include/" -I"/opt/intel/include/" -L"/opt/intel/mkl/lib/intel64/" -L"/opt/intel/lib/intel64/" -lmkl_rt -lmkl_core -lblas -lmkl_gnu_thread -lgomp -liomp5 -lpthread -Wl,--no-undefined -Wl,-rpath-link,/apps/matlab2014a/bin/glnxa64 -O -Wl,--version-script,"/apps/matlab2014a/extern/lib/glnxa64/mexFunction.map" mex_code.o -L"/apps/matlab2014a/bin/glnxa64" -lm -lmx -lmex -lmat -lstdc++ -o mex_code.mexa64
rm -f mex_code.o
I couldn't get the linking/compiling to work with the way Ying suggested (it kept complaining about undefined references to cblas functions in my code etc), but the above seems to not link duplicate libraries. Notice that before I was trying to do QR on data passed from matlab (allocated via mxCalloc), now I am simply allocating data inside the mex file and passing it to the QR function. For some reason it still doesn't like it (though now it complains about parameter 4 the data vs parameter 8 which doesn't exist in this function).
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
It seem the parameter n is not correct when you have LAPACK_COL_MAJOR. lda INTEGER. The leading dimension of a; at least max(1, m)
How about change to m?
Regarding your link line, it look too complex to understand :).
If you need ILP 64 , while all Interge are 64bit , the mkl_rt need do run-time setting to align with ILP 64 interface. So please make sure LP64 or ILP64. by default, mkl_rt use LP64.
if you link mkl_rt (single Dynamic library) you don't need other mkl library. the -lmkl_core -lblas -lmkl_gnu_thread -lgomp -liomp5 is don't need.
If you'd like ILP64 dynamic link,
-L$(MKLROOT)/lib/intel64 -lmkl_intel_ilp64 -lmkl_core -lmkl_intel_thread -lpthread -lm -openmp should be enough.
You mentioned the static link : -Wl,--start-group $(MKLROOT)/lib/intel64/libmkl_intel_lp64.a $(MKLROOT)/lib/intel64/libmkl_core.a $(MKLROOT)/lib/intel64/libmkl_intel_thread.a -Wl,--end-group -lpthread -lm -openmp
some cblas symbols missing. could you copy the error detail or try write the library two/three times in below order.
$(MKLROOT)/lib/intel64/libmkl_intel_ilp64.a $(MKLROOT)/lib/intel64/libmkl_intel_thread.a $(MKLROOT)/lib/intel64/libmkl_core.a $(MKLROOT)/lib/intel64/libmkl_intel_thread.a $(MKLROOT)/lib/intel64/libmkl_core.a $(MKLROOT)/lib/intel64/libmkl_intel_thread.a $(MKLROOT)/lib/intel64/libmkl_core.a lpthread -lm -openmp and let me know how it works?
I may suggest to don't mix the dynamic and static library, intel thread and gnu thread library. Here is one article about libraries and linkage model of mkl for your reference
Best Regards,
Ying
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Numerix1: once you get the MKL calls corrected, be sure to pass a meaningful matrix to the GEQP3 routine. A matrix with all elements set to 1 is rank-deficient and, if you do not remember this, many mysterious errors can be encountered later in your program.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your suggestions. To start with, the m vs n is not the problem. I have just tested the following code:
srand(time(NULL));
double *data = (double*)calloc(m*n,sizeof(double));
for(i=0; i<(m*n); i++){
data = ((double) rand() / (RAND_MAX));
printf("data[%d] = %f\n", i, data);
}
Iarr = (lapack_int*)calloc(n,sizeof(lapack_int));
tauarr = (double*)calloc(min(m,n),sizeof(double));
LAPACKE_dgeqp3(LAPACK_COL_MAJOR, m, n, data, m, Iarr, tauarr);
and it still returns:
Intel MKL ERROR: Parameter 4 was incorrect on entry to DGEQP3. It is true that it should be m since it is column major format and that the matrix of all ones I used is rank-deficient thanks for pointing this out, I use now a random matrix and m, but it still gives the same error. I will try now to compile differently as suggested by Ying.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
Here is some more details on my problem. I've simplified my code to try to narrow down the problem (which I think is probably in the mex file compilation step). Here is my code:
#include <stdio.h> #include <stdlib.h> #include <time.h> #include "mkl.h" #include "mkl_lapacke.h" #include "matrix.h" #include "mex.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { int i, j, m, n; time_t start_time, end_time; double *pr; lapack_int *Iarr; double *tauarr; /* Check for proper number of arguments. */ if (nrhs != 1) mexErrMsgTxt("One input required, the matrix.\n"); srand(time(NULL)); /* get input parameters */ n = mxGetN(prhs[0]); m = mxGetM(prhs[0]); pr = mxGetPr(prhs[0]); double *data = (double*)calloc(m*n,sizeof(double)); for(i=0; i<(m*n); i++){ // neither of below options work (matlab data or in mex initialized data) //data = pr; data = ((double) rand() / (RAND_MAX)); } printf("the matrix is of size %d x %d\n", m, n); printf("call QR\n"); Iarr = (lapack_int*)calloc(n,sizeof(lapack_int)); tauarr = (double*)calloc(min(m,n),sizeof(double)); LAPACKE_dgeqp3(LAPACK_COL_MAJOR, m, n, data, m, Iarr, tauarr); printf("end calling QR\n"); free(data); free(Iarr); free(tauarr); return; }
Here the script that compiles this:
#!/bin/bash icc -c -DMKL_ILP64 -fPIC -fno-omit-frame-pointer -DMX_COMPAT_32 -I"/apps/matlab2014a/extern/include" -I"/apps/matlab2014a/simulink/include" -I"/opt/intel/mkl/include" -fexceptions -openmp -shared -O -DNDEBUG mex_code.c -o mex_code.o icc -shared -openmp -I"/opt/intel/mkl/include/" -I"/opt/intel/include/" -L"/opt/intel/mkl/lib/intel64/" -L"/opt/intel/lib/intel64/" -lmkl_rt -lpthread -Wl,--no-undefined -Wl,-rpath-link,/apps/matlab2014a/bin/glnxa64 -O -Wl,--version-script,"/apps/matlab2014a/extern/lib/glnxa64/mexFunction.map" id_code_mex1.o -L"/apps/matlab2014a/bin/glnxa64" -lm -lmx -lmex -lmat -lstdc++ -o mex_code.mexa64 rm -f mex_code.o
This compiles fine. Here the error in matlab:
>> M = rand(2,3);
>> mex_code(M)
the matrix is of size 2 x 3
call QR
Intel MKL ERROR: Parameter 8 was incorrect on entry to DGEQP3.
end calling QR
>>
When I try Ying's compilation suggestion I use the script:
#!/bin/bash icc -c -DMKL_ILP64 -fPIC -fno-omit-frame-pointer -DMX_COMPAT_32 -I"/apps/matlab2014a/extern/include" -I"/apps/matlab2014a/simulink/include" -I"/opt/intel/mkl/include" -fexceptions -openmp -shared -O -DNDEBUG mex_code.c -o mex_code.o icc -openmp -I"/opt/intel/mkl/include/" -I"/opt/intel/include/" -L"/opt/intel/mkl/lib/intel64/" -L"/opt/intel/lib/intel64/" -Wl,--start-group /opt/intel/mkl/lib/intel64/libmkl_intel_lp64.a /opt/intel/mkl/lib/intel64/libmkl_core.a /opt/intel/mkl/lib/intel64/libmkl_intel_thread.a /opt/intel/mkl/lib/intel64/libmkl_intel_lp64.a /opt/intel/mkl/lib/intel64/libmkl_blas95_lp64.a /opt/intel/mkl/lib/intel64/libmkl_lapack95_lp64.a -Wl,--end-group -liomp5 -lpthread -lm -Wl,--no-undefined -Wl,-rpath-link,/apps/matlab2014a/bin/glnxa64 -O -Wl,--version-script,"/apps/matlab2014a/extern/lib/glnxa64/mexFunction.map" mex_code.o -L"/apps/matlab2014a/bin/glnxa64" -lmx -lmex -lmat -lstdc++ -o mex_code.mexa64 rm -f mex_code.o
when I compile I get undefined reference to lapacke function:
$./compile_mex.sh
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../lib64/crt1.o: In function `_start':
/home/abuild/rpmbuild/BUILD/glibc-2.18/csu/../sysdeps/x86_64/start.S:118: undefined reference to `main'
mex_code.o: In function `mexFunction':
mex_code.c:(.text+0x139): undefined reference to `LAPACKE_dgeqp3'
matlab version 8.3.0.532 (R2014a)
icc version 14.0.3 (gcc version 4.8.0 compatibility)
I would be happy to try any suggestions. Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh and btw the undefined reference to main is b/c I missed the shared flag. Doing:
icc -shared -openmp -I
"/opt/intel/mkl/include/" ... (rest same as before) just gives me undefined reference to the lapacke routine:
mex_code.o: In function `mexFunction':
/mex_code.c:(.text+0x139): undefined reference to `LAPACKE_dgeqp3'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You probably guaranteed run-time failure by compiling with -DMKL_ILP64, which is for 8-byte integers, and then linking with LP64 libraries, which expect 4-byte integer arguments.
Your second attempt failed with "undefined reference to `main'" because you left out the -shared option when linking the MEX file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes thank you the main undefined is due to shared option. But when I change the flag to -DMKL_LP64 (from ILP64) I still get the error
Intel MKL ERROR: Parameter 8 was incorrect on entry to DGEQP3.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Note also that the problem is specific to lapacke functions. For example, doing cblas_dgemm seems to work ok.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Not many people here may use a system with the same OS, C compiler, MKL and Matlab as you, but the following may help. I have a 32-bit Matlab (2007b) on Windows 8.1-x64. I built a Mex file (DLL) with the following modification of your program:
#include <stdio.h> #include <stdlib.h> #include <time.h> #include "mkl.h" #include "mkl_lapacke.h" #include "matrix.h" #include "mex.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { int i, j, m, n; time_t start_time, end_time; double *pr; lapack_int *Iarr,info; double *tau,*pl; /* Check for proper number of arguments. */ if (nrhs != 1) mexErrMsgTxt("One input required, the matrix.\n"); srand(time(NULL)); /* get input parameters */ n = mxGetN(prhs[0]); m = mxGetM(prhs[0]); pr = mxGetPr(prhs[0]); printf("the matrix is of size %d x %d\n", m, n); printf("call QR\n"); Iarr = (lapack_int*)calloc(n,sizeof(lapack_int)); tau = (double*)calloc(min(m,n),sizeof(double)); info=LAPACKE_dgeqp3(LAPACK_COL_MAJOR, m, n, pr, m, Iarr, tau); printf("end calling QR, info = %d\n",info); for(i=0; i<m; i++)printf("%12.3e %12.3e %12.3e %2d %12.3e\n", pr,pr[i+3],pr[i+6],Iarr,tau); free(Iarr); free(tau); return; }
Invoking the Mex function from the Matlab command window gave:
>> A=[ 4.100e+000 -1.900e+000 -1.300e+000 1.200e+000 5.100e+000 -2.400e+000 -2.200e+000 3.500e+000 7.700e+000] A = 4.1000 -1.9000 -1.3000 1.2000 5.1000 -2.4000 -2.2000 3.5000 7.7000 >> dgeqp3(A) the matrix is of size 3 x 3 call QR end calling QR, info = 0 8.169e+000 2.103e+000 -3.079e+000 3 1.159e+000 2.534e-001 -6.119e+000 4.732e-001 2 1.999e+000 -8.131e-001 2.003e-002 3.659e+000 1 0.000e+000 >>
Perhaps, you can get this example running on your system, and then modify the source code to run your problem. Of course, you would also have to write code to get the results from the Mex context back to Matlab instead of printing to the console.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you a lot mecej4. What is your compile option?
HI numeric,
Could you please try to call lapacke_sgeqp3 or dgeqp3 direclty (include the work space query, i double parameter 8 is from lapacke_dgeqp3_work()) and see if any issues? (sorry, I haven't matlab at hand)
Best Regards,
Ying
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ying H (Intel) wrote:
What is your compile option?
I add the Matlab directories to %INCLUDE% and %LIB% within an IFort/Icl command window, then build the Mex file with the command
icl /Qmkl /LD dgeqp3.c libmx.lib libmex.lib /link /export:mexFunction
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi mecej4 and ying thanks a lot for your suggestions. First I tried mecej's approach- it seems to be same code but calling QR function on the matlab data so equivalent to:
double *data = (double*)mxCalloc(m*n,sizeof(double)); for(i=0; i<(m*n); i++){ data = pr; } Iarr = (lapack_int*)calloc(n,sizeof(lapack_int)); tauarr = (double*)calloc(min(m,n),sizeof(double)); LAPACKE_dgeqp3(LAPACK_COL_MAJOR, m, n, data, m, Iarr, tauarr); // should behave same as this:
LAPACKE_dgeqp3(LAPACK_COL_MAJOR, m, n, pr, m, Iarr, tauarr);
but this segfaults for me.. I am using Linux (I quote matlab and icc versions above, both very recent). Ying, could you please
explain what you mean by "Could you please try to call lapacke_sgeqp3 or dgeqp3 direclty " what do you mean directly? I have
tried calling it on data that I've initialized inside the mex file, but it segfaults or reports parameter 8.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I mean call dgeqp3( 9 parameter) directly instead of lapacke c interface.
dgeqp3(&m, &n, a, &lda, jpvt, tau, work, &lwork, &info)
Best Regards,
Ying
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Ying,
Thanks. I tried
Iarr = (lapack_int*)calloc(n,sizeof(lapack_int));
tauarr = (double*)calloc(min(m,n),sizeof(double));
double *lwork = (double*)malloc(2*(3*n+1)*sizeof(double));
LAPACKE_dgeqp3_work(LAPACK_COL_MAJOR, m, n,
data, m, Iarr,
tauarr, lwork, 2*(3*n+1) );
But this fails. Does dgeqp3 exist as a function in C? I thought it is only in fortran according to docs. I will look more carefully in includes/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Numerix1, with you posting different snippets of code and with us offering comments based on those snippets, we could go in circles for eons.
Please post complete source code and instructions to allow us to reproduce the problem. Avoid using random numbers for filling input matrices, since they are -- random and not reproducible.
The names dgeqp3, etc., are Fortran subroutines, but they can be called from C if the Fortran calling conventions are obeyed. Secondly, routines such as LAPACKE_dgeqp3 are simply wrapper routines that provide a natural C interface to the user and map to the matching Fortran routine. The LAPACKE routines do not actually do any linear algebra computations.
I tried your 2 X 3 example using the same Mex file as in #12, and obtained normal output:
>> M=rand(2,3) M = 0.8147 0.1270 0.6324 0.9058 0.9134 0.0975 >> dgeqp3(M) the matrix is of size 2 x 3 call QR end calling QR, info = 0 -1.218e+000 5.164e-001 2.156e-314 1 1.669e+000 4.455e-001 -4.954e-001 1.004e-314 2 0.000e+000
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, let me repost the code again (similar to #7 above) to clarify, sorry for any confusion.
#include <stdio.h> #include <stdlib.h> #include <time.h> #include "mkl.h" #include "mkl_lapacke.h" #include "matrix.h" #include "mex.h" void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { int i, j, m, n, k, solve_type;; time_t start_time, end_time; double *pr; lapack_int *Iarr; double *tauarr; /* Check for proper number of arguments. */ if (nrhs != 1) mexErrMsgTxt("One input required, the matrix.\n"); srand(time(NULL)); /* get input parameters */ n = mxGetN(prhs[0]); m = mxGetM(prhs[0]); pr = mxGetPr(prhs[0]); // can use mxCalloc here too.. double *data = (double*)calloc(m*n,sizeof(double)); for(i=0; i<(m*n); i++){ data = ((double) rand() / (RAND_MAX)); } printf("the matrix is of size %d x %d\n", m, n); printf("call QR\n"); Iarr = (lapack_int*)calloc(n,sizeof(lapack_int)); tauarr = (double*)calloc(min(m,n),sizeof(double)); // this doesn't work (calling on supplied matlab data) // matlab segfaults and exits LAPACKE_dgeqp3(LAPACK_COL_MAJOR, m, n, pr, m, Iarr, tauarr); // and this doesn't work either (calling on data declared in program) // no matter if calloc or mxCalloc was used, mxCalloc on data segfaults // calloc produces the error // Intel MKL ERROR: Parameter 8 was incorrect on entry to DGEQP3 // mxCalloc of data results in segfault LAPACKE_dgeqp3(LAPACK_COL_MAJOR, m, n, data, m, Iarr, tauarr); printf("after call to QR\n"); free(data); free(Iarr); free(tauarr); return; }
the compilation of the mex file is via the script:
#!/bin/bash icc -c -DMKL_LP64 -fPIC -fno-omit-frame-pointer -I"/apps/matlab2014a/extern/include" -I"/apps/matlab2014a/simulink/include" -I"/opt/intel/mkl/include" -fexceptions -openmp -shared -O -DNDEBUG mex_code.c -o mex_code.o icc -shared -openmp -I"/opt/intel/mkl/include/" -I"/opt/intel/include/" -L"/opt/intel/mkl/lib/intel64/" -L"/opt/intel/lib/intel64/" -lmkl_rt -lpthread -Wl,--no-undefined -Wl,-rpath-link,/apps/matlab2014a/bin/glnxa64 -O -Wl,--version-script,"/apps/matlab2014a/extern/lib/glnxa64/mexFunction.map" mex_code.o -L"/apps/matlab2014a/bin/glnxa64" -lm -lmx -lmex -lmat -lstdc++ -o mex_code.mexa64 rm -f mex_code.o
The error I get is either complain about parameter 8 if lapacke_dgeqp3 is called on data calloc'd in the program or segfault if called on data that's mxCalloc'd (or passed from matlab - pr).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried also (code snipped for full code above)
double *lwork = (double*)malloc(2*(3*n+1)*sizeof(double)); LAPACKE_dgeqp3_work(LAPACK_COL_MAJOR, m, n, data, m, Iarr, tauarr, lwork, 2*(3*n+1) );
which always segfaults (even if data is calloc'd or mxCalloc'd or data is replaced by pr).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
fails also if I try to query the workspace size
/* Query optimal working size */
double work_query;
lapack_int lwork = -1;
printf("work query..\n");
LAPACKE_dgeqp3_work( LAPACK_COL_MAJOR, m, n, data, m, Iarr, tauarr, &work_query, lwork );
printf("work query = %f\n", work_query);
I suspect the issue is with compilation. tried newest matlab prerelease 2014 b, same result. will attempt to call dgeqp3 directly.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page