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

Last change on this file since 9368 was 9368, checked in by Mathieu Morlighem, 14 years ago

some cleanup

File size: 699 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:
5% [i1,i1]=parallelrange(rank,numprocs,globalsize)
6
7num_local_rows=zeros(numprocs,1);
8
9for 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);
12end
13
14
15%There may be some rows left. Distribute evenly.
16row_rest=globalsize - numprocs*floor(globalsize/numprocs);
17
18for i=1:row_rest,
19 num_local_rows(i)=num_local_rows(i)+1;
20end
21
22i1=sum(num_local_rows(1:rank-1))+1;
23i2=i1+num_local_rows(rank)-1;
Note: See TracBrowser for help on using the repository browser.