Difference between revisions of "Template:ElementTypeCommunication"
Line 13: | Line 13: | ||
| single[on[i]] | | single[on[i]] | ||
| multiple[] | | multiple[] | ||
− | | | + | | communication onto process i |
|- | |- | ||
| multiple[] | | multiple[] | ||
Line 33: | Line 33: | ||
var b:Int :: allocated[single[on[2]]]; | var b:Int :: allocated[single[on[2]]]; | ||
var p; | var p; | ||
− | par p from 0 to 3 | + | par p from 0 to 3 { |
− | |||
if (p==2) b:=p; | if (p==2) b:=p; | ||
a:=b; | a:=b; | ||
Line 40: | Line 39: | ||
− | This code will result in a onesided broadcast (due to | + | This code will result in a onesided broadcast (due to no further type information present, this is the default behaviour of element types) where process 2 will broadcast its value of ''b'' to all other processes who will write it into ''a''. As already noted, in absence of allocation information the default of allocating to all processes is used. In this example the variable ''a'' can be assumed to additionally have the type ''allocated[multiple]''. |
Revision as of 16:20, 12 January 2013
When a variable is assigned to another, depending on where each variable is allocated to, there may be communication required to achieve this assignment. Table \ref{tab:eltypecomm} details the communication rules in the assignment \emph{assignmed variable := assigning variable}. If the communication is issued from MPMD programming style then this will be one sided. The default communication listed here is guaranteed to be safe, which may result in a small performance hit.
Assigned Variable | Assigning Variable | Semantics |
---|---|---|
multiple[] | multiple[] | local assignment |
single[on[i]] | multiple[] | communication onto process i |
multiple[] | single[on[i]] | broadcast from process i |
single[on[i]] | single[on[i]] | local assignment where i==i |
single[on[i]] | single[on[j]] | communication from j to i where i!=j |
Communication Example
var a:Int; var b:Int :: allocated[single[on[2]]]; var p; par p from 0 to 3 { if (p==2) b:=p; a:=b; };
This code will result in a onesided broadcast (due to no further type information present, this is the default behaviour of element types) where process 2 will broadcast its value of b to all other processes who will write it into a. As already noted, in absence of allocation information the default of allocating to all processes is used. In this example the variable a can be assumed to additionally have the type allocated[multiple].