How to share work roughly evenly between processes in MPI despite the array_size not being cleanly divisible by the number of processes?

前端 未结 7 1552
借酒劲吻你
借酒劲吻你 2021-01-04 10:25

Hi all, I have an array of length N, and I\'d like to divide it as best as possible between \'size\' processors. N/size has a remainder, e.g. 1000 array elements divided b

7条回答
  •  执笔经年
    2021-01-04 10:57

    Here's a closed-form solution.

    Let N = array length and P = number of processors.

    From j = 0 to P-1,

    Starting point of array on processor j = floor(N * j / P)

    Length of array on processor j = floor(N * (j + 1) / P) – floor(N * j / P)

提交回复
热议问题