Difference between pages "Template:ElementTypeCommunication" and "Single"

From Mesham
(Difference between pages)
Jump to navigationJump to search
 
 
Line 1: Line 1:
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.
+
== Syntax ==
 +
single[type]
 +
single[on[process]]
  
 +
where ''type'' is optional
  
{| border="1" cellspacing="0" cellpadding="5" align="center"
+
== Semantics ==
! Assigned Variable
 
! Assigning Variable
 
! Semantics
 
|-
 
| multiple[]
 
| multiple[]
 
| local assignment
 
|-
 
| single[on[i]]
 
| multiple[]
 
| individual processes write values to process i
 
|-
 
| multiple[]
 
| single[on[i]]
 
| individual processes read values 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 ====
+
Will allocate a variable to a specific process. Most commonly combined with the ''on'' type which specifies the process to allocated to, but not required if this can be inferred. Additionally the programmer will place a distribution type within ''single'' if dealing with distributed arrays.
  
  var a:Int;
+
== Example ==
var b:Int :: allocated[single[on[2]]];
+
 
var p;
+
  function void main() {
par p from 0 to 3 {
+
    var i:Int :: allocated[single[on[1]]];
    if (p==2) b:=p;
 
    a:=b;
 
    sync;
 
 
  };
 
  };
  
 +
In this example variable ''i'' is declared as an integer and allocated on process 1.
 +
 +
''Since: Version 0.41b''
  
This code will result in each process reading the value of ''b'' from process 2  and then writing this 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]''.
+
[[Category:Type Library]]
 +
[[Category:Compound Types]]
 +
[[Category:Allocation Types]]

Revision as of 14:27, 15 April 2013

Syntax

single[type] single[on[process]]

where type is optional

Semantics

Will allocate a variable to a specific process. Most commonly combined with the on type which specifies the process to allocated to, but not required if this can be inferred. Additionally the programmer will place a distribution type within single if dealing with distributed arrays.

Example

function void main() {
   var i:Int :: allocated[single[on[1]]];
};

In this example variable i is declared as an integer and allocated on process 1.

Since: Version 0.41b