11
$\begingroup$

There are some evaluations which are automatically parallelized or multithread if there are cores available.( for example, Eigenvalues)

But I don't want the evaluation to be automatically multithreaded, I want it to use only one core. How can I do it?

$\endgroup$
  • $\begingroup$ Notice that you can run 2 threads on one core too, only if you have multithreaded processor. But it is not the same thing as parallel computing. $\endgroup$ – Kuba Aug 30 '13 at 13:35
  • $\begingroup$ @Kuba Yeah! I always noticed this. Sometimes, my parallel evaluations automatically became several 50% cpu running, If there are other people running their calculation on the same remote computer $\endgroup$ – matheorem Aug 30 '13 at 13:38
  • $\begingroup$ Is there a list of which functions automatically multithread? $\endgroup$ – KraZug Mar 3 '17 at 19:47
13
$\begingroup$

For Eigenvalues this will work:

SetSystemOptions["ParallelOptions" -> "ParallelThreadNumber" -> 1]

For functions which are using MKL libraries you can also use:

SetSystemOptions["MKLThreads" -> 1]

Source

It is wrriten there that you can reset it to the defaults by "ParallelThreadNumber" -> $ProcessorCount. But if you have cores that can be multithreaded then this number can be greater than $ProcessorCount.

  • Somewhere in documentation center is example with "MKLThreads" (I know it from there) but I can't find it :) I appreciate link if someone knows it :).
$\endgroup$
  • $\begingroup$ MKL libraries? I don't have an idea about "MKL libraries". What is this? $\endgroup$ – matheorem Aug 30 '13 at 13:40
  • $\begingroup$ Math kernel library is used by for example Solve. $\endgroup$ – Kuba Aug 30 '13 at 13:43
  • $\begingroup$ Its kind of an all in one math antibiotic for your Intel processor kernel ;) $\endgroup$ – PlatoManiac Aug 30 '13 at 13:44
  • $\begingroup$ @Kuba It seems that it is undocumented? If I set it to one, After I restart the mathematica, can the value be back to one? $\endgroup$ – matheorem Aug 30 '13 at 13:45
  • 1
    $\begingroup$ @Kuba Oh, SetSystemOptions["MKLThreads" -> 1] actually works for the NIntegrate. My fault. Thank you for your help! But I still wish you could look at the post I mentioned, there are peculiarities which I can't understand. $\endgroup$ – matheorem Aug 30 '13 at 13:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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