OpenCL* for CPU
Ask questions and share information on Intel® SDK for OpenCL™ Applications and OpenCL™ implementations for Intel® CPU.
Announcements
This forum covers OpenCL* for CPU only. OpenCL* for GPU questions can be asked in the GPU Compute Software forum. Intel® FPGA SDK for OpenCL™ questions can be ask in the FPGA Intel® High Level Design forum.

Intel OpenCL not found only when running as Matlab module

Chris_Juelg
Beginner
503 Views

My Linux system has both Intel i7 CPU and Nvidia Geforce GPU, and both work fine as OpenCL platforms outside of matlab mex modules.

But when compiled and run as a Matlab MEX module only the Nvidia OpenCL Platform will show up, and clGetPlatformIds will return just one platform (the nvidia one).

Using the current Intel OpenCL release ( 4.4.0.117 ) in combination with Matlab R2012b on openSUSE 2012.2.

 

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

 

The libOpenCL loaded during matlab mex execution is the current libOpenCL by Intel. Both ICDs are where they should be within /etc/OpenCL/vendors.


The OP in this thread has the same problem: 
http://stackoverflow.com/questions/24602945/opencl-and-mex-files-error/24701285

 

Thank you for any suggestions.

0 Kudos
2 Replies
Yuri_K_Intel
Employee
503 Views
Hi Chris, 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
Please, tell me if this works for you. Thanks, Yuri
0 Kudos
Chris_Juelg
Beginner
503 Views

Thanks, that did it.

Changing ~/.matlab7rc.sh to prefix LD_LIBRARY_PATH with /opt/intel/opencl-1.2-4.4.0.117/lib64/ did not solve the problem,
but with "LD_PRELOAD=/opt/intel/opencl-1.2-4.4.0.117/lib64/libtbb.so matlab" it works like a charm.

A more permanent fix would be to replace the libtbb.so in  $MATLAB_ROOT/bin/glnxa64/libtbb.so.2 with a link to the current one from the Intel OpenCL Runtime.

0 Kudos
Reply