14
$\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$
3
  • $\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
    Commented Aug 30, 2013 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
    Commented Aug 30, 2013 at 13:38
  • $\begingroup$ Is there a list of which functions automatically multithread? $\endgroup$
    – SPPearce
    Commented Mar 3, 2017 at 19:47

1 Answer 1

17
$\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$
13
  • $\begingroup$ MKL libraries? I don't have an idea about "MKL libraries". What is this? $\endgroup$
    – matheorem
    Commented Aug 30, 2013 at 13:40
  • $\begingroup$ Math kernel library is used by for example Solve. $\endgroup$
    – Kuba
    Commented Aug 30, 2013 at 13:43
  • $\begingroup$ Its kind of an all in one math antibiotic for your Intel processor kernel ;) $\endgroup$ Commented Aug 30, 2013 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
    Commented Aug 30, 2013 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
    Commented Aug 30, 2013 at 13:57

Your Answer

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

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