Using more than 6 kernels in ParallelTable function


I have the following code:

 If[IntegerQ@Sqrt[80892036 + 17994 x (1 + x) (-5995 + 5998 x)], x, 
  Nothing], {x, 6694300, 31072325}]

It uses 6 kernels to compute the result. Is it possible to speed it further up, by for example using more kernels?


Posted 2020-01-10T10:48:28.257

Reputation: 1 337

Question was closed 2020-01-12T14:34:12.873

Yes. But that depends (i) on your hardware and (ii) on your Mathematica license. Notice that Mathematica does not use nor count virtual cores, only physical ones. (Hyperthreading is usually pointless for well-written numerical code.) – Henrik Schumacher – 2020-01-10T10:51:08.077

@HenrikSchumacher what does it depend on for the hardware, I've an intel core i7 8gen and 32 gb of ddr4 ram. And I've the Professional version of Mathematica – Jan – 2020-01-10T10:57:33.377

So how many cores does the processor have? Maybe 6? – Henrik Schumacher – 2020-01-10T10:59:23.920

@HenrikSchumacher yes 6 cores and 12 threads – Jan – 2020-01-10T11:03:33.120

As I said, Mathematica does not care about hyperthreads. So 6 cores is the maximum that can be used by Mathematica. – Henrik Schumacher – 2020-01-10T11:04:43.107

Just to point out the bottleneck: These computations cannot be performed in machine integers because the numbers are too large. So the integer arithmetic has to be emulated in software. So without further mathematical tricks, this also cannot be compiled (which would be done by Table/ParallelTable automatically if possible). – Henrik Schumacher – 2020-01-10T11:07:09.483

@HenrikSchumacher So I can not speed up my calculation, that is the conclusion? – Jan – 2020-01-10T11:29:23.960

No. So far, we only know that it cannot be sped up by brute force. But there might be cleverer algorithms out there. – Henrik Schumacher – 2020-01-10T11:49:02.253


Please, if you use a brute force search to find solutions, use the fast square root options in this question. For example, results are returned 25 times faster by using sQ from @MichaelE2.

– KennyColnago – 2020-01-10T20:05:04.727



You can launch as many subkernels as you want (and as your license allows) using LaunchKernels. Mathematica launches as many as the number of CPU cores by default, but you can specify the exact number you want, and you can launch more.

Using more subkernels than the number of CPU cores you have will typically lead to no performance improvement at all. Sometimes it leads to worse performance. In rare cases, it may be worth doing with a hyperthreading CPU. I strongly recommend you do some benchmarks to verify that you do actually gain performance before launching more subkernels than the number of CPU cores.


Posted 2020-01-10T10:48:28.257

Reputation: 213 047