Evendist
Syntax
evendist[]
Semantics
Will distribute data blocks evenly amongst the processes. If there are too few processes then the blocks will wrap around, if there are too few blocks then not all processes will receive a block. The figure below illustrates even distribution of 10 blocks of data over 4 processes.
Example
function void main() { var a:array[Int,16,16] :: allocated[row[] :: horizontal[4] :: single[evendist[]]]; var b:array[Int,16,16] :: allocated[row[] :: vertical[4] :: single[evendist[]]]; var e:array[Int,16,16] :: allocated[row[] :: single[on[1]]]; var p; par p from 0 to 3 { var q:=b[p][2][3]; var r:=a[p][2][3]; var s:=b :: horizontal[][p][2][3]; }; a:=e; };
In this example (which involves 4 processors) there are three arrays declared, a, b and e. Array a is horizontally partitioned into 4 blocks, evenly distributed amongst the processors, whilst \emph b is vertically partitioned into 4 blocks and also evenly distributed amongst the processors. Array e is located on processor 1 only. All arrays are allocated row major. In the par loop, variables q, r and s are declared and assigned to be values at specific points in a processor's block. Because b is partitioned vertically and a horizontally, variable q is the value at b's block memory location 11, whilst r is the value at a's block memory location 35. On line 9, variable s is the value at b's block memory location 50 because, just for this expression, the programmer has used the horizontal type to take a horizontal view of the distributed array. It should be noted that in line 9, it is just the view of data that is changed, the underlying data allocation is not modified. In line 11 the assignment a:=e results in a scatter as per the definition of its declared type.
Since: Version 0.41b