Optimal number of threads per core

前端 未结 13 1878
忘掉有多难
忘掉有多难 2020-11-22 14:27

Let\'s say I have a 4-core CPU, and I want to run some process in the minimum amount of time. The process is ideally parallelizable, so I can run chunks of it on an infinite

相关标签:
13条回答
  • 2020-11-22 15:28

    I agree with @Gonzalo's answer. I have a process that doesn't do I/O, and here is what I've found:

    enter image description here

    Note that all threads work on one array but different ranges (two threads do not access the same index), so the results may differ if they've worked on different arrays.

    The 1.86 machine is a macbook air with an SSD. The other mac is an iMac with a normal HDD (I think it's 7200 rpm). The windows machine also has a 7200 rpm HDD.

    In this test, the optimal number was equal to the number of cores in the machine.

    0 讨论(0)
提交回复
热议问题