source: issm/trunk/src/m/utils/Cluster/parallelrange.m@ 2189

Last change on this file since 2189 was 2189, checked in by Mathieu Morlighem, 16 years ago

minor diffs

File size: 691 bytes
Line 
1function [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: [i1,i1]=parallelrange(rank,numprocs,globalsize)
5%
6
7num_local_rows=zeros(numprocs,1);
8
9for i=1:numprocs,
10
11 %we use floor. we under distribute rows. The rows left are then redistributed, therefore resulting in a more even distribution.
12 num_local_rows(i)=floor(globalsize/numprocs);
13
14end
15
16
17%There may be some rows left. Distribute evenly.
18row_rest=globalsize - numprocs*floor(globalsize/numprocs);
19
20for i=1:row_rest,
21 num_local_rows(i)=num_local_rows(i)+1;
22end
23
24i1=sum(num_local_rows(1:rank-1))+1;
25i2=i1+num_local_rows(rank)-1;
Note: See TracBrowser for help on using the repository browser.