Threads - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Programming : Multithreaded Programming : Threads/Map

Threads

 Map
 a parallel implementation of map

 Calling Sequence Map( fcn, expr, arg1, ..., argN ) Map[n]( fcn, arg1, ..., argn-1, expr, argn, ..., argN ) Map[evalhf]( fcn, expr, ... ) Map[inplace]( fcn, expr, ... ) Map[ tasksize = s ]( fcn, expr, ... )

Parameters

 fcn - (procedure or name) expr - any expression argi - (optional) further arguments to fcn n - (posint) s - (optional, posint) maximum task size

Description

 • The Map command is a parallel implementation of the map command. For a complete description of the calling sequence of Map, see the map help page.
 • Map is implemented using the Task programming model.
 • Map attempts to determine how to divide the input into separate tasks to spread the work across all available cores.  However in some situations Map may not choose the optimal size.  In particular a small number of long running tasks may not be spread evenly over all threads.  In this case, you can specify the maximum task size using the tasksize option. Map will divide the input into tasks that compute at most tasksize elements within a single task.

Examples

 > $\mathrm{with}\left(\mathrm{Threads}\right):$
 > $\mathrm{Map}\left(f,x+yz\right)$
 ${f}{}\left({y}{}{z}\right){+}{f}{}\left({x}\right)$ (1)
 > $\mathrm{Map}\left(f,yz\right)$
 ${f}{}\left({y}\right){}{f}{}\left({z}\right)$ (2)
 > $\mathrm{Map}\left(f,\left\{a,b,c\right\}\right)$
 $\left\{{f}{}\left({a}\right){,}{f}{}\left({b}\right){,}{f}{}\left({c}\right)\right\}$ (3)
 > $\mathrm{Map}\left(x↦{x}^{2},x+y\right)$
 ${{x}}^{{2}}{+}{{y}}^{{2}}$ (4)
 > Map( proc( x, y ) x^2+y end proc, [ 1, 2, 3, 4], 2 );
 $\left[{3}{,}{6}{,}{11}{,}{18}\right]$ (5)

 See Also