How can I make use of multiple cores in Matlab linear algebra

7 views (last 30 days)
Hi!
I have tried some linear algebra code on computers with multiple processors and the results are somewhat disappointing.
On a 4 core 3 GHz i7 870. Only half of my CPU resources are used: E.i. 13% for 1 core, 25% for 2 cores and so on... The processor has hyper-threading does that have something to do with it? Or is it memory bandwidth issues.I tried to increase maxNumCompCores to more than 4 but without improvement.
Multiplying two 5000 x 5000 matrixes
Cores: CPU-use: Time
1: 13%: 20s
2: 25%: 10s
3: 38%: 7.4s
4: 50%: 5.6s
I also tried it on a 48 core (4 x 12 core AMD Opteron 6238, 2.6GHz) node on a cluster. (No info available about cpu usages.) Multiply two 5000 x 5000 matrixes:
Cores: Time
1: 48s
2: 25s
4: 21s
6: 15.6s
12: 8.0s
16: 7.5s
24: 4.3s
36: 4.3s
48: 2.4s
So, of some reason AMD has much worse performance compared to Intel and far from linear improvement with number of cores. I would be very grateful if someone could give me some insights on why.
/ Anders

Answers (2)

José-Luis
José-Luis on 16 Nov 2012
Edited: José-Luis on 16 Nov 2012
To give you a clear answer, it would be necessary to look at the source code, know what compiler the Mathworks used, what compiler options they gave, etc. I very much doubt they would be willing to share that information.
However it is always possible to speculate.
Maybe their compiler was more Intel than AMD friendly. Maybe the compiler did a better job of translating the source code to machine code for Intel than for AMD. What's an optimization for Intel might not be for AMD. Maybe their developers feel more at ease with Intel than AMD.
The percentages sound consistent. 1 core is 25% of the capacity for the Intel processor and it seems that it scales almost linearly. At some point, increasing the number of cores will decrease the performance due to some overheads. What exactly is the breaking point? Well, once again you need the source code. Did the Mathworks use OpenMP? MPI? Pthreads? Boost threads? Hard to say.
Unless you look under the hood or spend an insane amount of time trying to reverse engineer, I am afraid this is pretty much impossible to answer. I've been wrong before, but maybe someone else here will contribute.
Note that the size of the cache in your processors will also affect your performance. The bigger the better. And, of course, how much of an impact is difficult to determine without the source code. The speed is only one factor. If i was a betting man, I would say that the AMD processor has a smaller cache.

Ken Atwell
Ken Atwell on 17 Nov 2012
I believe that hyperthreading makes your system monitoring tool believe it has eight cores rather than four (real) core. For example, the Mac laptop I'm writing this on has two i5 cores, but the Activity Monitor shows activity for four, so MATLAB running maxed out on both cores seeming only uses half the computer.
Still, on the Intel box, you're getting close to linear speed up: 20 seconds down to 5.6 when moving from one to four cores -- that's great, right? Matrix multiplication is not embarrassingly parallel, so you should not expect perfectly linear speed up.

Categories

Find more on Linear Algebra in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!