Difference between revisions of "Par"

From Mesham
Jump to navigationJump to search
m
m (10 revisions imported)
 
(2 intermediate revisions by the same user not shown)
Line 9: Line 9:
  
 
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. Variables declared to be multiply allocated within parallel scope, such as a par block, will automatically be allocated just to the subgroup of processes within that scope.<br><br>
 
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. Variables declared to be multiply allocated within parallel scope, such as a par block, will automatically be allocated just to the subgroup of processes within that scope.<br><br>
''Note:'' There is no guarantee as to the ranks of the processes involved within a par block and such as block will be distributed over the ranks which are most appropriate at that time.<br>
+
''Note:'' There is no guarantee as to the ranks of the processes involved within a par block and such as block will be distributed over the ranks which are most appropriate at that time.
''Note:'' This is a blocking construct and regardless of arguments involves all processes who will either ignore it or execute the block.
 
  
 
== Example ==
 
== Example ==
  
 
  #include <io>
 
  #include <io>
  var p;
+
  function void main() {
par p from 0 to 9 {
+
    var p;
    print("Hello world\n");
+
    par p from 0 to 9 {
 +
      print("Hello world\n");
 +
    };
 
  };
 
  };
  

Latest revision as of 15:44, 15 April 2019

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. Variables declared to be multiply allocated within parallel scope, such as a par block, will automatically be allocated just to the subgroup of processes within that scope.

Note: There is no guarantee as to the ranks of the processes involved within a par block and such as block will be distributed over the ranks which are most appropriate at that time.

Example

#include <io>
function void main() {
   var p;
   par p from 0 to 9 {
      print("Hello world\n");
   };
};

The code fragment will involve 10 processes (0 to 9 inclusive) and each will display a Hello world message.

Since: Version 0.41b