Difference between revisions of "Proc"

From Mesham
Jump to navigationJump to search
(Created page with '== Syntax == proc n where ''n'' is a variable or value == Semantics == This will limit execution of a block to a certain process == Example == proc 0 { print["Hello f…')
 
m (9 revisions imported)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
== Syntax ==
 
== Syntax ==
  
proc n
+
proc n<br>
 +
{<br>
 +
process body<br>
 +
}
  
where ''n'' is a variable or value
+
where ''n'' is a variable or value known at compile time.
  
 
== Semantics ==
 
== Semantics ==
  
This will limit execution of a block to a certain process
+
This will limit execution of a block to a certain process whose rank is guaranteed to be that specified.<br><br>
 +
''Note:'' A variable declared within a proc block and allocated multiple will in fact, by inference, be allocated to the group of processes which contains a single process who's rank is the same as the proc block's.
  
 
== Example ==
 
== Example ==
  
  proc 0
+
  #include <io>
  {
+
  function void main() {
     print["Hello from 0\n"];
+
     proc 0 {
 +
      print("Hello from 0\n");
 +
    };
 +
 +
    proc 1 {
 +
      print("hello from 1\n");
 +
    };
 
  };
 
  };
  
proc 1
+
The code example will run on two processes, the first will display the message ''Hello from 0'', whilst the second will output the message ''hello from 1''.
{
 
    print["hello from 1\n"];
 
};
 
 
 
The code example will run on two processes, the first will display the message 'Hello from 0'', whilst the second will output the message ''hello from 1''.
 
  
 +
''Since: Version 0.41b''
 
[[Category:Parallel]]
 
[[Category:Parallel]]

Latest revision as of 15:44, 15 April 2019

Syntax

proc n
{
process body
}

where n is a variable or value known at compile time.

Semantics

This will limit execution of a block to a certain process whose rank is guaranteed to be that specified.

Note: A variable declared within a proc block and allocated multiple will in fact, by inference, be allocated to the group of processes which contains a single process who's rank is the same as the proc block's.

Example

#include <io>
function void main() {
   proc 0 {
      print("Hello from 0\n");
   };

   proc 1 {
      print("hello from 1\n");
   };
};

The code example will run on two processes, the first will display the message Hello from 0, whilst the second will output the message hello from 1.

Since: Version 0.41b