 Threads - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

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

Threads

 Add
 a parallel implementation of add

 Calling Sequence Add( f, i = m..n ) Add( f, i = x ) Add( f, i in x ) Add[ tasksize = s ]( ... )

Parameters

 f - (expression) i - (name) m, n - numeric values x - (expression) s - (optional, posint) maximum task size

Description

 • The Add command is a parallel implementation of the add command. For a complete description of the calling sequence of Add see the add help page.
 • Add is implemented using the Task programming model.
 • Add attempts to determine how to divide the input into separate tasks to spread the work across all available cores.  However in some situations Add 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. Add will divide the input into tasks that compute at most tasksize elements within a single task.

Examples

 > $\mathrm{with}\left(\mathrm{Threads}\right):$
 > $\mathrm{Add}\left({i}^{2},i=1..5\right)$
 ${55}$ (1)
 > $L≔\left[\mathrm{seq}\left(i,i=1..5\right)\right]$
 ${L}{≔}\left[{1}{,}{2}{,}{3}{,}{4}{,}{5}\right]$ (2)
 > $\mathrm{Add}\left({i}^{2},i=L\right)$
 ${55}$ (3)
 > $\mathrm{Add}\left(a\left[i\right]{x}^{i},i=0..5\right)$
 ${{a}}_{{5}}{}{{x}}^{{5}}{+}{{a}}_{{4}}{}{{x}}^{{4}}{+}{{a}}_{{3}}{}{{x}}^{{3}}{+}{{a}}_{{2}}{}{{x}}^{{2}}{+}{{a}}_{{1}}{}{x}{+}{{a}}_{{0}}$ (4)
 > $\mathrm{Add}\left(i,i=\mathrm{\infty }..0\right)$
 ${0}$ (5)

 See Also