Line | |
---|
1 | function [i1,i2]=parallelrange(rank,numprocs,globalsize)
|
---|
2 | %PARALLELRANGE - from a rank, and a number of processors, figure out a range, for parallel tasks.
|
---|
3 | %
|
---|
4 | % Usage:
|
---|
5 | % [i1,i1]=parallelrange(rank,numprocs,globalsize)
|
---|
6 |
|
---|
7 | num_local_rows=zeros(numprocs,1);
|
---|
8 |
|
---|
9 | for i=1:numprocs,
|
---|
10 | %we use floor. we under distribute rows. The rows left are then redistributed, therefore resulting in a more even distribution.
|
---|
11 | num_local_rows(i)=floor(globalsize/numprocs);
|
---|
12 | end
|
---|
13 |
|
---|
14 |
|
---|
15 | %There may be some rows left. Distribute evenly.
|
---|
16 | row_rest=globalsize - numprocs*floor(globalsize/numprocs);
|
---|
17 |
|
---|
18 | for i=1:row_rest,
|
---|
19 | num_local_rows(i)=num_local_rows(i)+1;
|
---|
20 | end
|
---|
21 |
|
---|
22 | i1=sum(num_local_rows(1:rank-1))+1;
|
---|
23 | i2=i1+num_local_rows(rank)-1;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.