Grid
Barrier
block until all processes have reached this routine
Calling Sequence
Description
Examples
Compatibility
Barrier()
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.
In this example nodes with a higher node number get more work to do than 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:
GridLaunch⁡dosome,numnodes=4
0, "done" 1, "done" 2, 100000 2, "done" 3, 100000 3, 200000 3, 300000 3, 400000 3, 500000 3, 600000
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:
GridLaunch⁡doall,numnodes=4
1, "done" 0, "done" 3, 100000 2, 100000 2, "done" 3, 200000 3, 300000 3, 400000 3, 500000 3, 600000 3, 700000 3, 800000 3, 900000 3, 1000000 3, "done"
The Grid[Barrier] command was introduced in Maple 15.
For more information on Maple 15 changes, see Updates in Maple 15.
See Also
Grid:-Launch
Grid:-Setup
Download Help Document