1
votes

I am constantly running across a problem for a week. I don't know what the issue could be. Hope you could help me. Thank you in advance.

So here is brief description of the issue.

I am trying to use OpenCL and Mex code. The Mex part of the code reads a matlab .dat file and the opencl part of code further runs the code on Intel CPU as of now, though future plan would be to run it on a GPU. The Intel PLatform is being detected on just a normal OPENCL code ( without mex)(platforms 1,Devices 1). But on using the OPenCL with Mex, OpenCl fails to recognize the Intel Platform ( platforms found 0 , error :1001).

Just by including the MEX part of the code the number of platforms shown is zero. I am using matlab Compile runtime (MCR) to compile the mex files.

make :

mpicxx -fPIC -L/opt/intel/opencl-1.2-4.4.0.117/lib64 -L/usr/local/MATLAB/MATLAB_Compiler_Runtime/v83/bin/glnxa64 test.cpp -o test -lOpenCL -I/usr/include/CL  -lmat -lmx -lmex -I/usr/local/MATLAB/MATLAB_Compiler_Runtime/v83/extern/include -Wl,-rpath,/opt/intel/opencl-1.2-4.4.0.117/lib64,-rpath,/usr/local/MATLAB/MATLAB_Compiler_Runtime/v83/bin/glnxa64

Is there some problem with the way I am linking the files?

2

2 Answers

1
votes

Most probably what happens is the following. MATLAB ships with some version of tbb (Intel Threading Building Blocks) library and this version is older than the one required by Intel OpenCL CPU runtime. When you run standalone OpenCL application the correct version of TBB is loaded (the one that comes with OpenCL runtime), but when MATLAB starts it loads its own version of TBB.

So, one solution would be to use LD_PRELOAD before starting MATLAB, like so:

$ LD_PRELOAD=/opt/intel/opencl-1.2-4.4.0.117/lib64/libtbb.so matlab
0
votes

Same Problem here: Any C/C++ Program not running as a MEX module will see the Intel OpenCL Platform AND the Nvidia OpenCL Platform. But while inside a MEX module only the Nvidia OpenCL Platform will show up.

Using the same Intel OpenCL release ( 4.4.0.117 ) in combination with Matlab R2012b on openSUSE 2012.2. I assume you are using Matlab 2014a.

The same problem exists when using the inofficial Matlab OpenCL Toolbox:

wiki

download

To replicate:

  • unzip, fix path for OpenCL headers and libOpenCL in make.m
  • run matlab and go to directory with make.m, then type:
  • make
  • opencl_info = opencl()
  • opencl_info.platforms

Edit:

Yuri is right, as soon as you preload the correct libtbb.so it works.

You could also replace the libtbb.so in your $MATLABROOT/bin/glnxa64/libtbb.so.2 with a link to the current one from the Intel OpenCL Runtime.