Go backward to 2.3 Distributed Factorization (Divide and Conquer) Go up to 2 Examples Go forward to 2.5 Visualization |
Distributed Maple allows a task to put data into a global pool for retrieval by other tasks.
d := dist[data]();
creates a new shared data object whose handle d
may be communicated to
other tasks. However, initially the data object is in an empty state; every
attempt to retrieve the value of the object by
v := dist[get](d);
will block the corresponding task. Only after some task has written a value into the shared data object by
dist[put](d, v);
the corresponding tasks are released to continue execution. A shared data object may be reset into the empty state by
dist[clear](d);
and thus reused for further synchronization. However, even without intermediate
clearing, the value of a shared data object may be reset by further
dist[put]
calls.
Since a shared data object may contain references to other shared objects,
continuous communication between tasks becomes possible via "streams" of
shared objects. For instance, the following code fragment starts a task
executing f(d)
where d
is a shared data object whose value
becomes either the empty list [ ]
or a tuple [v,r]
where
v
is the next value to be communicated and r
is a shared data
object that is constructed analogously.
d := dist[data](); t := dist[start](f, d); while not term(x) do r := dist[data](); dist[put](d, [x, r]); x := g(x); d := r; od; dist[put](d, []);
This concept allows to generate arbitrary networks of tasks that communicate
with each other via communication streams. However, in such situations the
standard scheduling mechanism (where a fixed set of Maple processes executes
an arbitrary number of tasks) does not suffice any longer because it relies on
an acyclic graph of task dependencies. If cyclic dependencies arise,
dist[process]
(with the same syntax as dist[start])
must be
applied to have the task be executed by a separate process. This process is
initialized with all the dist[all]
calls that have been previously
issued.
Then a construction like
becomes possible wheres1 := dist[data](); s2 := dist[data](); t1 := dist[process](f, s1, s2); t2 := dist[process](g, s2, s1);
s1
may be used for the transmission of values
from (the process executing) f
to (the process executing) g
and
s2
handles communication in the other direction. If the tasks were
created by the use of dist[start]
, then they might be scheduled on the
same Maple process yielding a deadlock.