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).
RandomReal
and notTable
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. $\endgroup$