Difference between pages "Commgroup" and "Array"

From Mesham
(Difference between pages)
Jump to navigationJump to search
m (6 revisions imported)
 
 
Line 1: Line 1:
== Syntax ==
+
---- Syntax ----
  
commgroup[process list]
+
array[type,d1$,d2$,...,dn]
  
== Semantics ==
+
---- Semantics ----
  
Specified within the multiple type, will limit memory allocation (and variable communication) to the processes within the list given in this type's arguments. This type will ensure that the communications group processes exist. All variables marked in this way are private to their local processes.
+
An array, where ''type'' is the element type, followed by the dimensions. The programmer can provide any number of dimensions to create an n dimension array. Default is row major allocation (although this can be overridden via types.) In order to access an element of an array, the programmer can either use the traditional ''name[index]'' syntax or, alternatively ''name#index'' which is preferred
  
== Example ==
+
---- Communication ----
  
  function void main() {
+
When an array variable is assigned to another, depending on where each variable is allocated to, there may be communication to achieve this assignment. The table details the communication rules for this assignment ''assigned variable := assigning variable''. As with the element type, default communication of arrays is safe.
    var i:Int :: allocated[multiple[commgroup[1,3]]];
 
};
 
  
In this example there are a number processes, but only 1 and 3 have variable ''i'' allocated to them. This type would have also ensured that process two (and zero) exists for there to be a process three.
+
{| border="1" cellspacing="0" cellpadding="5" align="center"
 +
! Assigned Variable
 +
! Assigning Variable
 +
! Semantics
 +
|-
 +
| multiple[]
 +
| multiple[]
 +
| local assignment
 +
|-
 +
| single[on[i]]
 +
| multiple[]
 +
| local assignment on 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
 +
|}
 +
 
 +
---- Example ----
 +
 
 +
var a:array[String,2] :: allocated[multiple[]];
 +
(a#0):="Hello";
 +
(a#1):="World";
 +
print[(a#0)," ",(a#1),"\n"];
 +
 
 +
This example will declare variable ''a'' to be an array of 2 Strings. Then the first location in the array will be set to ''Hello'' and the second location set to ''World''. Lastly the code will display on stdio both these array string locations followed by newline.
  
''Since: Version 0.5''
 
  
 
[[Category:Type Library]]
 
[[Category:Type Library]]
[[Category:Compound Types]]
+
[[Category:Composite Types]]
[[Category:Allocation Types]]
+
[[Category:Collection Types]]

Revision as of 19:16, 10 January 2010


Syntax ----

array[type,d1$,d2$,...,dn]


Semantics ----

An array, where type is the element type, followed by the dimensions. The programmer can provide any number of dimensions to create an n dimension array. Default is row major allocation (although this can be overridden via types.) In order to access an element of an array, the programmer can either use the traditional name[index] syntax or, alternatively name#index which is preferred


Communication ----

When an array variable is assigned to another, depending on where each variable is allocated to, there may be communication to achieve this assignment. The table details the communication rules for this assignment assigned variable := assigning variable. As with the element type, default communication of arrays is safe.

Assigned Variable Assigning Variable Semantics
multiple[] multiple[] local assignment
single[on[i]] multiple[] local assignment on 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

Example ----

var a:array[String,2] :: allocated[multiple[]];
(a#0):="Hello";
(a#1):="World";
print[(a#0)," ",(a#1),"\n"];

This example will declare variable a to be an array of 2 Strings. Then the first location in the array will be set to Hello and the second location set to World. Lastly the code will display on stdio both these array string locations followed by newline.