Parallel.For not utilising all cores

后端 未结 2 985
-上瘾入骨i
-上瘾入骨i 2021-01-17 20:22

I\'m doing heavy mathematical computations using Math.Net Numerics parallely inside Parallel.For block.

When I run code in my local system

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-17 21:18

    From MSDN

    By default, For and ForEach will utilize however many threads the underlying scheduler provides, so changing MaxDegreeOfParallelism from the default only limits how many concurrent tasks will be used.

    The way I read the documentation: if the underlying scheduler only offers a single thread, then setting MaxDegreeOfParallelism > 1 will still result in a single thread.

提交回复
热议问题