Grid - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Toolboxes : Grid Computing : Grid/Barrier

Grid

  

Barrier

  

block until all processes have reached this routine

 

Calling Sequence

Description

Examples

Compatibility

Calling Sequence

Barrier()

Description

• 

The Barrier command blocks all jobs initiated by the Launch command until all processes have executed the Barrier command.

• 

This is useful for synchronizing execution.  It can be used to force node 0 to wait for all other nodes to finish computing.

• 

This function is currently not available in "hpc" mode.

Examples

In this example nodes with a higher node number get more work to do that those with lower node numbers.  In fact, node 0 has virtually nothing to do and quickly exits.  Because the job is finished when node 0 is done, you will see very little or no output from the other nodes.

dosome := proc()
   uses Grid;
   local i, me;
   me := MyNode();
   for i from 1 to 10^(me+3) do
       if i mod 10^5 = 0 then
           print(me,i);
       end if;
   end do;
   print(me,"done");
end proc:

Grid[Launch]dosome,numnodes=4

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               0, "done"

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               1, "done"

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               3, 100000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               2, 100000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               2, "done"

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               3, 200000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               3, 300000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               3, 400000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               3, 500000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               3, 600000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               3, 700000

This procedure is identical to the one above except that a call to Barrier is added at the end of the procedure.  This will force all nodes to wait and synchronize around that point.  Unlike the previous example, this time every node has a chance to finish.

doall:= proc()
   uses Grid;
   local i, me;
   me := MyNode();
   for i from 1 to 10^(me+3) do
       if i mod 10^5 = 0 then
           print(me,i);
       end if;
   end do;
   print(me,"done");
   Barrier();
end proc:

Grid[Launch]doall,numnodes=4

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               0, "done"

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               1, "done"

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               2, 100000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               2, "done"

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               3, 100000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               3, 200000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               3, 300000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               3, 400000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               3, 500000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               3, 600000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               3, 700000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               3, 800000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               3, 900000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              3, 1000000

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               3, "done"

Compatibility

• 

The Grid[Barrier] command was introduced in Maple 15.

• 

For more information on Maple 15 changes, see Updates in Maple 15.

See Also

Grid

Grid[Launch]

Grid[Setup]

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam