Par

From Mesham
Revision as of 23:41, 3 January 2010 by Polas (talk | contribs) (Created page with '== Syntax == par p from a to b<br> {<br> par body<br> };<br> == Semantics == The parallel equivalent of the for loop, each iteration will execute concurrently on different pro…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Syntax

par p from a to b
{
par body
};

Semantics

The parallel equivalent of the for loop, each iteration will execute concurrently on different processes. This allows the programmer to write code MPMD style, with the limitation that bounds a and b must be known during compilation. All (variable sharing) communication in a par loop is performed using one sided communication, whereas variable sharing SPMD style is performed using synchronous communication for performance reasons.

Example

var p;
par p from 0 to 10
{
   print["Hello from process ",p,"\n"];
};

The code fragment will spawn 11 processes (0 to 10 inclusive) and each will display a message.