1

I have a project that requires lots of image processing and wanted to add GPU support to speed things up.

I was wondering if i compiled my matlab into c++ shared library and called it from within OpenCL program, does that mean that the matlab code is going to be run on GPU?

omarzouk
  • 933
  • 10
  • 23

4 Answers4

1

My own (semi-educated) guess is that you are going to find this very difficult to do. But, others have trodden the same path. This paper might be a good place to start your research. And Googling turned up Accelereyes and a couple of references to items on the Mathworks File Exchange which you might want to follow up.

High Performance Mark
  • 77,191
  • 7
  • 105
  • 161
  • 1
    Accelereyes is for NVIDIA cards only, i'm using ATI The iptatiproject project seems promising, i'll check it out thanks – omarzouk Jul 03 '10 at 17:49
  • 1
    yikes!!!! just as i feared, i'll have to write the algorithms by hand in order to be able to do it using OpenCL. I mean this way i'll be just better off using c++ and not matlab, cause all i'll have left from matlab is just some matrix datastructures :D though i was wondering how Accelereyes did their wrapper for nvidia hmmm – omarzouk Jul 03 '10 at 18:31
  • Accelereyes is just a wrapper that overloads the basic operators of matrices like multiplication, inversion etc. to have them executed on GPU instead, this of course does give a very good boost but its not the most efficient way of doing things since the algorithms themselves r not written to take full advantage of the parallel capabilities of the GPU like using parallel sort algorithms instead of iterative or recursive ones, but this means a whole rewrite of the matlab library :D – omarzouk Jul 10 '10 at 21:54
1

Everything in jacket is written in c/ c++ / cuda. Infact we now have a beta version libjacket (http://www.accelereyes.com/downloadLibjacket) which can be used to extend not just matlab but other languages if you are willing.

@OSaad Most of our functions are the fastest options out there. Be it in C or matlab.

Pavan Yalamanchili
  • 12,021
  • 2
  • 35
  • 55
0

The Parallel Computing Toolbox in the upcoming release R2010b (due September 1st) supports GPU processing for several functions. Unfortunately, it only supports CUDA (version 1.3 and later), so with an ATI graphics card, you're out of luck. However, you may just want to buy a dedicated GPU, anyway.

Jonas
  • 74,690
  • 10
  • 137
  • 177
0

Typically, if you can write your Matlab code in a "vectorized" way, then the packages like AccelerEyes and Jacket have a reasonable chance of making things run on the GPU. You can verify this to some extent beforehand by checking whether Matlab itself is able to run on multiple cores on the CPU (these days Matlab will use multiple cores if things are parallelizable in an obvious way).

If that doesn't work, then you need to drop down to C/C++ via mex and then, from there, call OpenCL yourself. Mex is how Matlab talks to C code, so you write C code that is called by Matlab (and receives the matrices, etc), then initialises and calls OpenCL. This is more work, but may be your only route (and, even if the automated packages work to some extent, this approach can still give more speedups because you can be smarter about memory management, for example, if you know what your are doing).

andrew cooke
  • 45,717
  • 10
  • 93
  • 143