Optimal number of threads per core

前端 未结 13 2031
忘掉有多难
忘掉有多难 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:26

    The ideal is 1 thread per core, as long as none of the threads will block.

    One case where this may not be true: there are other threads running on the core, in which case more threads may give your program a bigger slice of the execution time.

提交回复
热议问题