4
$\begingroup$

I was trying to compute the time it takes for Eigensystem to evaluate while being inside a ParallelTable, as it is well-known LAPACK subroutine has an inbuilt Parallelization to it. And the difference in time for each individual in my i7 2 core(4 thread) laptop is not exactly doubled for parallelization as I would expect. In fact in some cases even after Parallelization the time taken is shown to be almost the same.

Sample codes below.

t1 = Table[AbsoluteTiming[Eigensystem[RandomComplex[1 + I, {m, m}]];], {m, 500,2000, 100}]

The output is as follows,

{{0.616350, Null}, {1.040216, Null}, {2.443462, Null}, {3.077764, Null}, {3.083748, Null}, {4.769239, Null}, {5.449419, Null}, {7.748267, Null}, {8.550121, Null}, {9.972316,  Null}, {12.643169, Null}, {14.768483, Null}, {17.071321,  Null}, {19.217578, Null}, {24.610150, Null}, {29.095810, Null}}

Then if I parallelize over two Kernels,

t1 = ParallelTable[{m, AbsoluteTiming[Eigensystem[RandomComplex[1 + I, {m, m}]];]}, {m,500, 2000, 100}]

The outputs

{{500, {1.218461, Null}}, {600, {2.030769, Null}}, {700, {2.952447, Null}}, {800, {3.999031, Null}}, {900, {5.233135, Null}}, {1000, {7.342015, Null}}, {1100, {9.122840,  Null}}, {1200, {15.801766, Null}}, {1300, {15.064459, Null}}, {1400, {20.560733, Null}}, {1500, {19.901539,  Null}}, {1600, {24.876738, Null}}, {1700, {28.118304, Null}}, {1800, {31.265851, Null}}, {1900, {25.806387, Null}}, {2000, {29.372562, Null}}}

It seems for larger system sizes the time difference is lower than expected.

This is important for me because I need to diagonalize about 20 13k x13k matrix, ignoring the constraint of RAM(which I have about 1TB), the machine is 64 core and since not Parallelizing was taking about 1.5 hrs for each diagonalization, I was wondering if I would parallelize it over 10 cores.

But this should not be efficient yet it seems it is, what is going on?

Edit:- Just to be clear, I expected ParallelTable to increase individual times of diagonalization for each system size since it doesn't have multicore available, while this is true for some system sizes, mostly smaller, for larger it does not seem to affect it much. This is the confusion.

$\endgroup$
3
  • $\begingroup$ Are you sure that it isn't already utilizing all available cores? Heavily parallelizable subroutines tend to automatically parallelize in Mathematica, and on my system Eigensystem definitely uses multiple cores. Putting Parallelize around it, as such, would not be expected to increase performance for large systems, because there just aren't more resources available. You can see performance increases in small scales if multiple small problems end up getting dispatched more efficiently though. $\endgroup$
    – eyorble
    Commented Jun 27, 2020 at 16:28
  • $\begingroup$ I expected performance to decrease actually for individual diagonalizations. But that does not happen, which is why I am tempted to use the Parallelize. This is contrary to our general belief which is exactly what you state. $\endgroup$ Commented Jun 27, 2020 at 16:31
  • $\begingroup$ Alright, I see where the confusion is now. That is definitely going against conventional wisdom as I understand it. $\endgroup$
    – eyorble
    Commented Jun 27, 2020 at 16:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.