57

AccelerEyes announced in December 2012 that it works with Mathworks on the GPU code and has discontinued its product Jacket for MATLAB:

http://blog.accelereyes.com/blog/2012/12/12/exciting-updates-from-accelereyes/

Unfortunately they do not sell Jacket licences anymore.

As far as I understand, the Jacket GPU Array solution based on ArrayFire was much faster than the gpuArray solution provided by MATLAB.

I started working with gpuArray, but I see that many functions are implemented poorly. For example a simple

myArray(:) = 0 

is very slow. I have written some custom CUDA-Kernels, but the poorly-implemented standard MATLAB functionality adds a lot of overhead, even if working with gpuArrays consistently throughout the code. I fixed some issues by replacing MATLAB code with hand written CUDA code - but I do not want to reimplement the MATLAB standard functionality.

Another feature I am missing is sparse GPU matrices.

So my questions are:

How do is speed up the badly implemented default GPU implementations provided by MATLAB? In particular, how do I speed up sparse matrix operations in MATLAB using the GPU?

Andrew Morton
  • 24,203
  • 9
  • 60
  • 84
Stiefel
  • 2,677
  • 3
  • 31
  • 42
  • 24
    Of course `myArray(:) = 0` is slow - it's moving loads of zeros from the CPU to the GPU for no reason. That doesn't mean MATLAB GPU capabilities are implemented poorly, it means you need to know how to use them; try `myArray = gpuArray.zeros(size(myArray))` instead. – Sam Roberts Jun 05 '13 at 16:48
  • 2
    Sam, myArray(:) = 0 should only move one integer from the CPU to the GPU - if implemented optimally. Using gpuArray.zeros() is even slower. For now I am using myArray = myArray - myArray which is faster - but still slow. I hope the Jacket functionality is coming with the next MATLAB release. – Stiefel Jun 10 '13 at 07:45
  • Have you tried emailing AccelerEyes or TMW to get an answer? – bla Jul 12 '13 at 00:02
  • 1
    Yes, AccelerEyes says they do not comment on MATHWORKS product releases. Also they are not allowed to give out any new JACKET licences. The next MATLAB release is probably in october. MATHWORKS support does not even know what I am talking about ;-) – Stiefel Jul 12 '13 at 07:32
  • 4
    What size array are you trying to allocate and finding it slow? Note that in recent releases of Parallel Computing Toolbox, some operations execute asynchronously. Also, "`a = a - a;`" does not necessarily result in an array of all zeros, so I would avoid this pattern (hint: what if 'a' contained `NaN` or `Inf`?). (And rather contact The MathWorks with the details of your performance problem). – Edric Jul 29 '13 at 11:40
  • The link to AccelerEyes announcement seem to be broken... –  Aug 02 '13 at 15:51
  • I hope Pavan Yalamanchili saw this question, and as a jacket user I'd appreciate any comment on that matter. Even "I can comment because..." – bla Aug 02 '13 at 18:18
  • @Robocop: The link still works for me... – Stiefel Aug 02 '13 at 20:21
  • 3
    Here's what I've been able to pick from the web (part 1): In 2011, MathWorks and AccelerEyes sued and counter-sued each other over intellectual property issues. MathWorks alleged patent infringement of their Parallel Computing Toolbox product by AcceleEyes' Jacket product [ http://www.scribd.com/doc/59765193/MathWorks-v-AccelerEyes-et-al]. – bla Aug 05 '13 at 17:07
  • 1
    (part 2): AccelerEyes alleged trade secret misappropriation by the same Parallel Computing Toolbox, as well as unfair and deceptive acts and practices, breach of contract, and unjust enrichment [ http://www.scribd.com/doc/130296250/AccelerEyes-Answer-and-Counterclaims-Against-MathWorks]. In December 2012, AccelerEyes and MathWorks appear to have settled their dispute out of court and to have started working together, as seen in AccelerEyes announcment that it works with Mathworks on the GPU code and has discontinued its product Jacket for MATLAB. – bla Aug 05 '13 at 17:07
  • (part 3): Matt J answered a similar question I've asked in TMW website, here is his answer: *" I've encountered similar obstacles finding out what's going on with the Jacket/MATLAB partnership. So far, only Accelereyes has been explicit and public that the software merge is actually going to take place. MATLAB sales reps didn't seem to even be aware of it. To me, it's a little suspicious that only one party acknowledges plans to team up. So, I have my doubts that the software merge is actually going to occur. – bla Aug 05 '13 at 17:08
  • (Part 4): Also, the partnership was supposedly a way to settle lawsuits between the two companies, but again Accelereyes news releases are the only testament to that that I can find. For all we know, MathWorks may have won those lawsuits and has no plans to team up with Accelereyes." – bla Aug 05 '13 at 17:09
  • Thanks natan for the great information. I read briefly through the accusation document. Sounds ridicuoulous to me. Patent '118 is about "Function values in computer programming languages having dynamic types and overloading". Also they accused Accelereyes using the term "MATLAB" on their website (which is difficult to avoid if you sell a package for MATLAB ;-) ). The whole thing does not cast a positive light on MATHWORKS. – Stiefel Aug 06 '13 at 07:30
  • There is also a discussion here: http://www.mathworks.it/matlabcentral/answers/83193 – Stiefel Aug 06 '13 at 07:41
  • You're asking two unrelated questions together here. This usually puts people off asking if they can only answer one of the questions. You're more likely to get useful answers if you edit your post down to a single, answerable question and create a new question post for any others you want to ask. – Dan Hulme Sep 07 '13 at 22:52
  • I rephrased the question into a technical question with two parts. – Stiefel Sep 10 '13 at 14:45
  • Given the apparent impossibility of an improvement using MATLAB, you might want to check out Octave. It's an open-source equivalent, and you could modify their code yourself. Whether releasing your modifications would be legal is not a question I can answer, however. It might be illegal both to keep modifications to yourself (under the GPL) and to release them (thus violating patents). But you could check it out, anyway. – Steve Westbrook Oct 02 '13 at 18:28
  • 2
    I was happen to be at a Matlab seminar yesterday, and ask Loren Shure and some other TMW people this question. They refused to comment and the best I could get is that "there is something in the pipeline"... – bla Oct 11 '13 at 18:03
  • When I used the GPU with MATLAB in the past, I wrote MEX (MATLAB C/C++) files that took in my CPU MATLAB arrays, copied them onto the GPU, then did everything I wanted with CUDA before copying them back. This is fast, but is obviously not as nice for prototyping because you have to write in C. This is why I switched to Python, where nice packages like Theano make it easy to get at the GPU. – hunse Oct 23 '13 at 15:54
  • Python has its own problems. Java works very well with CUDA and OpenCL. If only HotSpot would autovectorize, there'd be no sense in using anything else. – Aleksandr Dubinsky Dec 04 '13 at 08:57
  • I've talked with a friend that just installed the newest release (2014a) and said that the implementation of the gpu support got to the level of jacket. Maybe they finally got it in? – bla Mar 19 '14 at 03:13

2 Answers2

4

MATLAB does support CUDA based GPU. You have to access it from the "Parallel Computing Toolbox". Hope these 2 links also help:

Parallel Computing Toolbox Features

Key Features

  • Parallel for-loops (parfor) for running task-parallel algorithms on multiple processors
  • Support for CUDA-enabled NVIDIA GPUs
  • Full use of multicore processors on the desktop via workers that run locally
  • Computer cluster and grid support (with MATLAB Distributed Computing Server)
  • Interactive and batch execution of parallel applications
  • Distributed arrays and single program multiple data (spmd) construct for large dataset handling and data-parallel algorithms

MATLAB GPU Computing Support for NVIDIA CUDA-Enabled GPUs

Using MATLAB for GPU computing lets you accelerate your applications with GPUs more easily than by using C or Fortran. With the familiar MATLAB language you an take advantage of the CUDA GPU computing technology without having to learn the intricacies of GPU architectures or low-level GPU computing libraries.

You can use GPUs with MATLAB through Parallel Computing Toolbox, which supports:

  • CUDA-enabled NVIDIA GPUs with compute capability 2.0 or higher. For releases 14a and earlier, compute capability 1.3 is sufficient.
  • GPU use directly from MATLAB
  • Multiple GPUs on the desktop and computer clusters using MATLAB workers in Parallel Computing Toolbox and MATLAB Distributed Computing Server
Re Captcha
  • 3,125
  • 2
  • 22
  • 34
  • 3
    While these links may answer the question, you should avoid link-only answers and summarize or quote the articles, because links tend to decay over time. – pinckerman Nov 15 '13 at 12:31
3

I had the pleasure of attending a talk by John, the founder of AccelerEyes. They did not get the speedup because they just removed poorly written code and replaced it with code that saved a few bits here and there. Their speedup was mostly from exploiting the availability of cache and doing a lot of operations in-memory (GPU's). Matlab relied on transferring data between GPU and CPU, if I remember correctly, and hence the speedup was crazy.

dinwal
  • 467
  • 2
  • 14