Optimal number of threads per core

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

    The answer depends on the complexity of the algorithms used in the program. I came up with a method to calculate the optimal number of threads by making two measurements of processing times Tn and Tm for two arbitrary number of threads ‘n’ and ‘m’. For linear algorithms, the optimal number of threads will be N = sqrt ( (mn(Tm*(n-1) – Tn*(m-1)))/(nTn-mTm) ) .

    Please read my article regarding calculations of the optimal number for various algorithms: pavelkazenin.wordpress.com

提交回复
热议问题