Software Archive
Read-only legacy content
17061 Discussions

Matlab mex and offload to mic (RH6, icc 15.0, Matlab R2015a)

PSivi__P_
Beginner
315 Views

Is it possible to offload a portion of code in a C mex file? I'm getting an error

offload error: cannot load library to the device 0 (error code 5)

and before continuing it would be nice to know if this is at all possible.

0 Kudos
1 Reply
Frances_R_Intel
Employee
315 Views

I don't know of anyone who has tried this. I do know that, by default, MATLAB uses the the Intel mkl library for BLAS and LAPACK routines when run on Intel processors and that there is an automatic offload option that can be used to allow the mkl library itself offload some of the work to the coprocessor. You can see the directions for enabling automatic offload here - https://software.intel.com/en-us/articles/using-intel-math-kernel-library-with-mathworks-matlab-on-intel-xeon-phi-coprocessor-system.

If you want to try your own offload code again, what I would suggest is - before you start MATLAB, set up your compiler environment using the scripts Intel provides for this. On Linux, it would be 'source /<compiler_installation_directory>/bin/compilervars.sh intel64'; on Windows, it would be '<compiler_installation_directory>\bin\compilervars.bat intel64'.

If this doesn't work, try creating a library with the offload code compiled outside of MATLAB. You will need to make sure your environment is properly set as above and use 'xiar –qoffload-build ar options archive member ...]' to build the library, then create one or more gateway routines that can be compiled with mex and used to call routines in the library.

If you discover anything interesting while you are working on this, let me know.

0 Kudos
Reply