Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

In good old Mathematica versions (5.2, 6.0), matrix multiplication was automatically done in parallel. For example, on an 8-core machine, define two square real matrices:

m1 = Table[Random[Real], {256}, {256}];
m2 = Table[Random[Real], {256}, {256}];

The total CPU time used in all cores to compute a dot product is:

Tsingle = Timing[m1.m2][[1]]

0.010999 Second

The real time needed for the calculation is:

Tparallel = AbsoluteTiming[m1.m2][[1]]

0.001546 Second

For large matrices, the ratio is almost equal to the number of cores (8):

Tsingle / Tparallel

7.114489004

Repeating the same calculation in newer Mathematica versions (8.0, 9.0) gives Tsingle equal to Tparallel, which seems to indicate that new Mathematica versions dropped automatic parallelization of the Dot command. Is this true?
I would be thankful if anyone can advise how to regain this functionality, i.e. compute Dot products in parallel (automatically or manually).

share|improve this question
2  
This may be due to changes in how timing works, see the documentation: "On certain computer systems with several CPUs, the Mathematica kernel may sometimes spawn additional threads on different CPUs. On some operating systems, Timing may ignore these additional threads. On other operating systems, it may give the total time spent in all threads, which may exceed the result from AbsoluteTiming." –  s0rce Nov 2 '13 at 23:22
3  
It is still done in parallel, but you should use RandomReal and not Table because the former produces a packed array while the latter does not. By the way, a 256-by-256 matrix is not really big enough for parallelization to be particularly noticeable, so you should test with a larger matrix as well. For any remaining discrepancies, I agree with @s0rce's comment. –  Oleksandr R. Nov 2 '13 at 23:24
add comment

1 Answer

Not really an answer but too long for a comment, Timing doesn't appear different then AbsoluteTiming, I have 9.0.1 on Win7 x64.

n = 2^12;
m1 = RandomReal[1, {n, n}];
m2 = RandomReal[1, {n, n}];
Tsingle = Timing[m1.m2;][[1]]
Tparallel = AbsoluteTiming[m1.m2;][[1]]
Tsingle/Tparallel
1.435209
1.589091
0.90316
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.