Seq - Maple Help

Grid

 Seq
 generate a sequence, distributing computation over grid

 Calling Sequence Seq( f, i=m..n )) Seq( f, i=x )) Seq[tasksize=T]( f, i=... ))

Parameters

 f - any expression i - name m, n - numerical values x - expression T - posint

Description

 • The Seq command is used to construct a sequence of values in parallel. The most typical calling sequence is Seq(f(i), i = 1..n) which generates the sequence f(1), f(2), ..., f(n).  Computation of each f(i) will be evenly distributed across all available nodes.
 • The Seq command is similar to the top-level seq command, and the Threads[Seq] commands.  The top-level seq command evaluates the entire sequence serially.  The Threads[Seq] command evaluates elements of the sequence in parallel on separate threads within the same process.  The Grid:-Seq command evaluates elements of the sequence in parallel on separate processes, and potentially on different machines.
 • The Seq 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 i, m, n, and x parameters are not searched.  If those depend on values that are not fully defined on the remote nodes, use the Grid:-Set command before calling Seq 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.
 • Seq 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 Seq 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. Seq will divide the input into tasks that compute at most tasksize elements within a single task.
 • Seq is a high-level command that uses Send and Receive calls. Therefore, evaluation of f should not involve other Send and Receive calls.
 • Seq does not replicate the special evaluation rules of the Maple seq command. Structures with more than one dimension (like a Matrix) are not currently supported for the x parameter.
 • Setting infolevel[Grid:-Seq] := 3; will enable output of information messages relating to the progress of the computation.
 • When using "hpc" or "mpi" modes, Seq 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.

Examples

This example shows some simple calling sequences

 > $\left[\mathrm{Grid}:-\mathrm{Seq}\left(i,i=1..4\right)\right]$
 $\left[{1}{,}{2}{,}{3}{,}{4}\right]$ (1)
 > $A≔\mathrm{Array}\left(\left[1,2,3,4,5\right]\right)$
 ${A}{≔}\left[\begin{array}{ccccc}{1}& {2}& {3}& {4}& {5}\end{array}\right]$ (2)
 > $\left[\mathrm{Grid}:-\mathrm{Seq}\left(F\left(i\right),i=A\right)\right]$
 $\left[{F}{}\left({1}\right){,}{F}{}\left({2}\right){,}{F}{}\left({3}\right){,}{F}{}\left({4}\right){,}{F}{}\left({5}\right)\right]$ (3)

In this example, we define two procedures such that Seq will not be able to automatically find all definitions to send to external nodes. The remote operation is not fully defined.

 > $\mathrm{myfunc1}≔x↦{x}^{2}$
 ${\mathrm{myfunc1}}{≔}{x}{↦}{{x}}^{{2}}$ (4)
 > $\mathrm{myfunc2}≔x↦\mathrm{myfunc1}\left(x\right)+x$
 ${\mathrm{myfunc2}}{≔}{x}{↦}{\mathrm{myfunc1}}{}\left({x}\right){+}{x}$ (5)
 > $\left[\mathrm{Grid}:-\mathrm{Seq}\left(\mathrm{myfunc2}\left(i\right),i=1..3\right)\right]$
 $\left[{\mathrm{myfunc1}}{}\left({1}\right){+}{1}{,}{\mathrm{myfunc1}}{}\left({2}\right){+}{2}{,}{\mathrm{myfunc1}}{}\left({3}\right){+}{3}\right]$ (6)

The myfunc1 procedure was not defined in the external nodes. It needs to be set.

 > $\mathrm{Grid}:-\mathrm{Set}\left(\mathrm{myfunc1}\right)$
 > $\left[\mathrm{Grid}:-\mathrm{Seq}\left(\mathrm{myfunc2}\left(i\right),i=1..3\right)\right]$
 $\left[{2}{,}{6}{,}{12}\right]$ (7)

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 may require an adjustment to the default tasksize

 > $\mathrm{time}\left[\mathrm{real}\right]\left(\mathrm{Grid}:-\mathrm{Seq}\left(\mathrm{add}\left(i,i=1..{10}^{\mathrm{min}\left(7,j\right)}\right),j=1..9\right)\right)$
 ${1.095}$ (8)
 > $\mathrm{time}\left[\mathrm{real}\right]\left(\mathrm{Grid}:-\mathrm{Seq}\left['\mathrm{tasksize}'=1\right]\left(\mathrm{add}\left(i,i=1..{10}^{\mathrm{min}\left(7,j\right)}\right),j=1..9\right)\right)$
 ${1.323}$ (9)

Compatibility

 • The Grid[Seq] command was introduced in Maple 15.