Allocation of objects and processes

\label{des/ext/alloc} \dlpindex{allocation} In the examples given, no attention has been paid to the issue of allocating (instances of) objects and the actual distribution of computation over the available resources. When a new instance of an object is created, it can be allocated to a particular processor node by a statement of the form \dlpindex{\newobjectatexpr} where N is a so-called node expression denoting a particular processor node and obj is either the name of an object or a constructor, that is an object name with arguments. In addition it is possible to split off a process to evaluate a goal on a particular node by the statement G@N where G is a goal and N is a node number. The meaning of a goal G@N is given by the clause \dlpindex{\goalatexpr} G@N :- O = new(self@N), Q = O!G, Q?. Such a goal may be used only for passive objects.

Node expressions

\dlpindex{node expressions} refer to a processor of the parallel machine on which the system runs. The parallel machine for which our system is intended is assumed to have a limited number of processor nodes that are connected with each other by a communication network. The programmer can refer to each of n processors by its number, $0,...,n-1. To permit a more refined strategy of allocating processes and resources, node expressions may be used, from which a processor number can be calculated. Apart from viewing the network as a linear sequence of processors, the programmer may regard the configuration as an (imaginary) tree, or as a grid of processors.

Tree organization

A node expression of the form \dlpindex{\attreeexpr} []
I0:I1:...:I_n denotes, with the branching degree (by default) fixed to two, the processor associated with the node in the tree reached by following the path I1,...,I_n from I0. The association of processor numbers with nodes of the tree is done by counting the nodes of tree breadth first. For example the expression $0:1:2:1, giving the path $1,2,1 from 0, gives the processor number 9. As an example of how such node expressions can be used to distribute the computation load over the available processors, consider the following variant of the quicksort program presented earlier. \lprog{qsort}{ .ds qsort1.pl } When splitting off two processes for sorting the sublists, the processes are allocated on the successor nodes of the current node, as long as sufficient processors are available. More refined strategies may be encoded by including tests on the length of the lists.

Matrix organization

The processor topology may also be viewed as a matrix with certain dimensions (say a square array of dimension 4 for 16 processors). The programmer can index this matrix by expressions of the form \dlpindex{\atmatrixexpr} []
N1 # N2 which allows the distribution of the load over the available processors by moving, for instance, north from N1 # N2 to N1 # N2 + 1, over the matrix. Abbreviations such as north, west and so on are provided to facilitate these kinds of turtle movements over the matrix of processors. Cf.  [Sh84].