Speculative evaluation begins with the identification of parallelism. Annotations satisfy the present objectives, and provide the flexibility for indicating sparks precisely where desired without any loss of generality.
The single par annotation does not provide sufficient expression to enable effective
speculative evaluation. There is no capacity to indicate the speculative priority or granularity of the annotated expression. There is no capacity to indicate data locality information or the identity/number of the processing element on which the annotated expression should be evaluated. There is no way of preventing processing element domination (see Section 7·4·4). Finally, there is no way of naming an expression for tracing purposes.
To remedy this situation the set of implemented annotations has been expanded. The annotations implemented as part of GPH are presented in Table 7·1.
The values of ANYWHERE (–1) for n and NONE (0) for f represent “don’t care” values
and, together with the values of DYNAMIC (0) for i and 50 for g, are the defaults used
in the annotations. A value of HERE (0) for n represents ‘the current processing
element’ and prevents the spark from being transferred to another processing element through load distribution.
An overview of the difference the annotations make to the sparking process follows. This process is represented abstractly in Figure 7·1 as “Spark a Thread” and is
summarised pictorially in some additional detail in Figure 7·2.
The first form of annotation given in Table 7·1 is usually the minimum available in parallel implementations. Some systems (notably those by Plasmeijer and van Eekelen [Plasmeijer and van Eekelen 1993] and Mattson [Mattson 1993a], and GranSim [Loidl
Chapter Seven: Effective Management of Speculative Evaluation 1998]) include speculative priorities. See Chapter Six for more information on the annotations provided in other systems.
Table 7·1: Full set of implemented GPH parallelism annotations.
par p e the value of expression p may be calculated in
parallel with expression e
parPri g p e the value of expression p may be calculated in
parallel at priority g with expression e
parAtPE n p e the value of expression p may be calculated in
parallel on processing element n with expression e
parName i p e the value of expression p with identity number i
may be calculated in parallel with expression e
parFamily f p e the value of expression p belonging to family f
may be calculated in parallel with expression e
parFull i n f g p e the value of expression p belonging to family f
and having identity number i may be calculated in
parallel at priority g on processing element n with
expression e
The second form provides speculative priorities and is also provided in GranSim [Loidl 1998] (where the annotation indicates a cost or granularity measure of the annotated expression).
The third speculative annotation allows the user to indicate which threads should, for granularity reasons, be executed locally, or which, for data dependency reasons, should be executed on a particular remote processing element. For some programs and hardware configurations such an annotation could help ensure improved performance [van Eekelen, Huitema, Nöcker, and Plasmeijer 1993] without the need for complicated static analysis. Concurrent Clean [van Eekelen et al. 1993] is the only other system that allows the user to specify a destination for execution, although a similar annotation is also in the GranSim simulator [Loidl 1998] and in para-functional programming [Hudak 1986 and 1991]. The specified processing element number indicates the processing element on which the spark is to be evaluated (see Section 7·3·3). This annotation is included for reasons of performance. Some threads have high data dependencies and
Y Processor Field is Specifically Not the ID of the Current PE? Extracted Spark Send TASK Message N Spark Pool is Empty? Pack Spark Create Thread Based on Extracted Spark Y N Family Field is NONE? Add Thread to Runnable Thread Pool in Position Determined by its Priority Y N Spark’s Graph Closure is Completely Unevaluated? Family Field of Next Spark is Different from that
of New Thread? Extract Next Spark
from Spark Pool
N N Y Y Done is TRUE? N Done=FALSE Done=TRUE Y
Chapter Seven: Effective Management of Speculative Evaluation therefore should be executed near their data and not on distant processing elements. Small threads, on the other hand, may not warrant movement at all as the cost of doing so may outweigh the cost of local execution — hence the HERE-valued parameter.
The fourth annotation facilitates the rudimentary labelling of an expression with a numeric value. This value can be displayed during debugging et cetera for tracing
purposes. It can also be used to associate the numeric identity of the parent thread with the spark — this is done when the spark is created if the parameter has a value of
DYNAMIC. This numeric parent identity is distinct to the parent thread’s TSO identity
(which is discussed in Section 7·3·6), the parent thread’s name (which is discussed in Section 7·3·4), and the parents thread’s global identity that forms part of the dynamic thread hierarchy management (which is discussed in Section 7·4·5).
The fifth speculative annotation provides a performance enhancing mechanism for identifying mutually exclusive threads that are related by the fact that they each may contribute to the same result. When some or all of these identified threads are to be evaluated on the same processing element they form a thread family. Within the thread family, each thread is scheduled in a time-sliced round-robin fashion.
The final annotation facilitates combinations of all of the above for complete flexibility. The inclusion of all the forms of speculative annotation given in Table 7·1 is advocated. The second and sixth forms provide levels of priority so that speculative threads that appear more closely linked to the final program outcome can be executed before threads that seem less important. A speculative evaluation system that facilitates the updating of speculative priorities will ensure that the most important threads will be executed first at all times.