## What’s new in MATLAB 2010b?

January 11th, 2011 | Categories: math software, matlab | Tags:

MATLAB 2010b was released a couple of months ago and, as usual, it comes with a whole range of new features, performance enhancements and all important bug fixes.  Within the MATLAB 2010b documentation, there are lists of the new functionality but I like to dig in a bit deeper and pick out one or two things that are of personal interest to me.

### 64 bit integer support

Back in April 2010, I was working with the NAG Toolbox for MATLAB which makes use of 64 bit integers on 64 bit machines and I learned that MATLAB 2010a and earlier didn’t support even the most basic of operations on 64 bit integers. For example, on MATLAB 2010a:

a=int64(10);
b=int64(20);
a+b
??? Undefined function or method 'plus' for input arguments of type 'int64'.

I’m happy to report that this has now been fixed and The Mathworks have implemented 18 basic operators for 64bit integer types including arithmetic, the colon operator, bsxfun and more.  This has made my life (and the lives of some of the people I support) MUCH easier and I really appreciate The Mathworks work on this one.

### Curve Fitting and Splines toolboxes merged

MATLAB has got a lot of toolboxes.  In fact, it’s got far too many in my opinion which makes the product more expensive and fragmented.  I have literally lost count of the amount of times someone has emailed me with a query like “I don’t suppose you have access to the XYZ toolbox because someone had sent me code that uses it and I can’t run it’  Quite frankly, it sucks.

So, when The Mathworks announce that they are merging the functionality of two related toolboxes into one, there is much rejoicing in Walking Randomly towers.  If The Mathworks would like to do some more toolbox merging then I have a couple of suggestions :)

### CUDA support in the Parallel Computing Toolbox

These days, the hotness in research computing is to do as much of your calculation as possible on your graphics card.  If handled correctly, the hunk of silicon that was originally designed to make games look pretty can speed up scientific calculations hundreds of times compared to dull old CPUs.  There is a great deal of interest in GP-GPU programming at Manchester University (my employer), so much so that we have set up a GPU-Club for our researchers.

Arguably, the leader in GP-GPU (General Purpose – Graphics Processing Unit) hardware is NVIDIA who are the developers of the CUDA programming framework.  Until now, CUDA support in MATLAB has been provided by third-parties such as Jacket (Commerical) or GP-You (free) but as of 2010b, there is now official support for CUDA GPUs in MATLAB’s parallel computing toolbox.  At the moment, it is not as well developed as products such as Jacket but I would lay bets that this will change in the not too distant future.

My early experiments with this new functionality have met with zero success but I have new hardware on the way and I am really looking forward to getting my teeth into this.

### Parallel Statistics

Parallel computing in MATLAB is more complicated than it should be.  Some functions make use of multicore processors automatically and you don’t need the parallel computing toolbox to feel the benefit.  On the other hand, there are an increasing number of functions in toolboxes such as statistics and optimisation, that additionally require the PCT in order to make maximum use of modern hardware.

The 2010b version of the statistics toolbox includes an extra 8 functions (candexch, cordexch, daugment, dcovary, nnmf, plsregress, rowexch and sequentialfs) that now make use of the PCT.  If you have the PCT, then this is wonderful news but if you don’t then there is nothing to see here.

### Faster trig functions when the argument is in degrees

The standard trigonometric functions such as sin, cos, tan and the like all work in radians but MATLAB also has several functions that accept their arguments in degrees: sind, cosd and tand for example.  In MATLAB 2010b these functions have been made significantly faster.  Lets see how much faster using my 3Ghz quad Core 2 Q9650 running Ubuntu 9.10

In MATLAB 2010a

x=rand(1,1000000)*360;
>> tic;y=cosd(x);toc
Elapsed time is 0.120207 seconds.


In MATLAB 2010b

x=rand(1,1000000)*360;
>> tic;y=cosd(x);toc
Elapsed time is 0.021256 seconds.


A speed up of around 5.6 times!  What’s more, I’ve already come across a user’s code in the wild where this optimisation made a real difference to their execution time.  As far as I can tell, the speed up comes from the fact that 2010a and below uses MATLAB code for these functions whereas 2010b and above uses mex files.

### What other bloggers say about MATLAB 2010b

1. I’m a defense industry guy and have been dissatisfied with fpgas for a long time and jumped on gpus early on.

“There is now official support for CUDA GPUs in MATLAB’s parallel computing toolbox. At the moment, it is not as well developed as products such as Jacket but I would lay bets that this will change in the not too distant future.”

Typically, I would agree with this statement, for companies other than the MathWorks.

After working with Jacket and PCT, I’d say that MathWorks will never get close to Jacket. This is because PCT is fundamentally flawed. Jacket is able to reduce many lines of M code efficiently into single GPU kernels. With PCT, every function is an individual kernel (i.e. mutliple kernels per line), which is a horrible thing to do on the GPU. In my experiments, this translates into an order of magnitude performance difference between the two approaches. This coupled with the fact that MW is building it into their already inefficient Java engine dampens my belief that PCT will ever really be useful on the GPU.

Also, I hear that the major GPU features of r2011a are indexing and convolutions. Jacket has had those for at least 3 years, I’ve been doing GPU stuff since the early days of Jacket. I just never expect that MW will do anything cutting edge or fast.

2. Hi Scott

At the moment I couldn’t comment either way – I don’t have access to 1.3 capable hardware (yet) so haven’t used the PCT. Could you post some code that explicitly demonstrates the order of magnitude difference between the two approaches please? That way I could perhaps see it for myself when I get the kit.

Cheers,
Mike

3. I’m with a defense company and we always get into big trouble if ppl find out that we posted code, which is stupid but that is a different story.

In my experiments, I simply piece together 10 lines of arithmetic and checkout the difference in timings.

A very similar experiement, which I’ve reproduced myself, is running the gpu Horner example (which I believe ships with r2010b) with Jacket and comparing the results. The accelereyes people posts results of this experiment on their website on that comparison page they have vs r2010b pct. I think there may be a blog post too on their site.

4. Hi guys,

I just installed Matlab2010b. I was using fine in the previous version KSDENSITY, but I can’t find it anywhere here… why has it been removed?

Thanks,
Sil

5. Hi Sil

ksdensity is part of the statistics toolbox. I guess your 2010b install didn’t include it.

Mike