1

I have the following code:

ParallelTable[
 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?

Jan Eerland
  • 2,001
  • 10
  • 17
  • 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 Jan 10 '20 at 10:51
  • @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 Eerland Jan 10 '20 at 10:57
  • So how many cores does the processor have? Maybe 6? – Henrik Schumacher Jan 10 '20 at 10:59
  • @HenrikSchumacher yes 6 cores and 12 threads – Jan Eerland Jan 10 '20 at 11:03
  • As I said, Mathematica does not care about hyperthreads. So 6 cores is the maximum that can be used by Mathematica. – Henrik Schumacher Jan 10 '20 at 11:04
  • 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 Jan 10 '20 at 11:07
  • @HenrikSchumacher So I can not speed up my calculation, that is the conclusion? – Jan Eerland Jan 10 '20 at 11:29
  • 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 Jan 10 '20 at 11:49
  • 1
    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 Jan 10 '20 at 20:05

1 Answers1

3

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.

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263