map a procedure over a dataset, using separate processes
Map( f, expr )
Map( f, expr, arg1, arg2, ..., argN )
Map[tasksize=s]( f, expr, ... )
procedure or function
arg1, ..., argN
(optional) further arguments to f
The Map command applies f to the operands or elements of expr in parallel. This is similar to Threads[Map] except that application of f is done in separate processes, rather than separate threads.
The Map command applies f to the operands or elements of expr in parallel. A typical calling sequence is Map(f, [1,2,...,n]) which applies f to each element of the given list to form the new list, [f(1), f(2), ..., f(n)]. Similarly, Map(f,[1,2,...,n],a,b) will return [f(1,a,b), f(2,a,b), ..., f(n,a,b)], using the extra arguments to Map in each call to f. Computation of each f(i) will be evenly distributed across all available nodes.
The Map command is similar to the top-level map command, and the Threads[Map] commands. The top-level seq command evaluates the entire sequence serially. The Threads[Map] command evaluates elements of the sequence in parallel on separate threads within the same process. The Grid[Map] command evaluates elements of the sequence in parallel on separate processes, and potentially on different machines.
The Map command attempts to initialize remote compute nodes by looking for named values inside of f and assigning those same names in the remote compute nodes. The expr parameter is not searched. If it depends on values that are not fully defined on the remote nodes, use the Grid:-Set command before calling Map to set those values. Similarly, Grid:-Set may be needed to complete the definition of f, in particular, when f is a procedure that calls other locally defined procedures.
Map will always try to use all compute nodes. It will typically subdivide the request into many more tasks than there are available nodes. This helps to more evenly distribute the load when the run-time of processing different requests is unevenly distributed. However, in some situations, Map may not choose the optimal size. In particular, when there are a large number of short-running tasks, doing more work in the remote nodes in each task may be more efficient. In this case, you can specify the task size using the tasksize option. Map will divide the input into tasks that compute at most tasksize elements within a single task.
Setting infolevel[Grid:-Map] := 3; will enable output of information messages relating to the progress of the computation.
When using "hpc" or "mpi" modes, Map is designed to be called on all the nodes of a parallel computation, whereupon the result will only be available on node 0. If the resulting Maple expression is required for further computation on other nodes, it must be sent there explicitly using Send and Receive.
Map is a high-level command which uses Send and Receive calls. Therefore, evaluation of f should not involve other Send and Receive calls.
Because Map has to transfer portions of expr to each node, it will not be efficient when called with a trivial procedure f.
The result of a Map computation will only be available on node 0. If the resulting Maple expression is required for further computation on other nodes, it must be sent there explicitly using Send and Receive.
This example shows some simple calling sequences
In this example we define two procedures such that Map will not be able to automatically find all definitions to send to external nodes. The remote operation is not fully defined.
The myfunc1 procedure was not defined in the external nodes. It needs to be set.
In this example the work required for the computation at j=1 is much less than the computation at j=9. The sequence of heavy computations at the end of the list is may require an adjustment to the default tasksize
The Grid[Map] command was introduced in Maple 15.
For more information on Maple 15 changes, see Updates in Maple 15.
The Grid[Map] command was updated in Maple 2015.
The s parameter was introduced in Maple 2015.
For more information on Maple 2015 changes, see Updates in Maple 2015.
Download Help Document
What kind of issue would you like to report? (Optional)