@CompileStatic class MultiCoreEngine
MultiCoreEngine creates a process network comprising a gpp.skeletons.matrix.MultiCoreRoot together with a number of gpp.skeletons.matrix.MultiCoreNode processes. The goal of the complete process network is to undertake operations on one or more large matrices by partitioning the matrix operations over the node processes. The matrix data structure is shared among all the processes, thus the data structure has to be partitioned in such a way that every process can read all the elelemnts in the matrix but only one of the nodes can write to one of the partitions. The matrix has to have sufficient space to store intermediate results. At the ned of each iteration dat will be transferred from the intermediate space to the original space for the next iteration.
The processing can be organised as a fixed number of iterations or can be terminated when a termianl condition has been reached. The object that contains the matrix will also require other structures such as a means of defining the partitions into which the matrix is subdivided.
The MultiCoreRoot process has been designed to read a stream of data objects comprising one or more matrices. The structure of the input file is user defined. An example can be found in gpp_demos.jacobi. The Emit process will access the matrix data structure in order to read the input file and then to create the data object.
The MultiCoreEngine can also process arrays of objects which similarly have to be partitioned. An example showing this is given in gpp_demos.solarSystem and the equivalent matrix version is given in gpp_demos.nbody both of which solve the same N-body problem.
The methods required by the matrix data object are:
initMethod (List d) called by Emit to initialise the data object, d contains any required parameteres
createMethod (List d) called by Emit to populate the data object from the input file, d contains any required parameteres
partitionMethod (nodes) creates the partition ranges based on the size of the matric and the number of nodes
errorMethod (errorMargin) determines whether the end of iterations has been reached, returns boolean,
true if the iteration needs to be repeated, false otherwise
calaculationMethod (nodeIndex) undertakes the required calculation on the partition identified by nodeIndex
updateMethod () copies the latest update to the matrix into the normal space
input
- The channel from which input objects are readoutput
- The channel to which processed objects are writtennodes
- The number of the MultiCoreNode processes in the networkiterations
- The number of times the process will iterateerrorMargin
- The value used to determine whether the termination condition has been reached.
Only one of iterations or errorMargin may be specified.finalOut
- If true only the final processed object is written to output. If false the current state
of each iteration of the processed object is output. The default value is true.partitionMethod
- The method that determines the partitions into which the matrix will be partitioned. It has a single paramter,
the number of nodes. Each partition will be indexed by the node subscript. Called in MultiCoreRoot.calculationMethod
- The method that undertakes the required operation on the matrix.
It has a single parameter, the index of the node. Called in MultiCoreNode. It reads from all parts of the matrix, if required, and
writes to a dedicated area of the matrix corresponding to the node's partition. In the update phase these node specific
areas will be copied into designated area of the matrix.errorMethod
- The method, called in MultiCoreRoot, that determines whether the termiantion condition has been reached.
It has a single parameter, errorMargin. It returns true if the process should be repeated and false if the termination
condition has been reached.updateMethod
- The method, called in MultiCoreRoot, that copies a set of intermediate results into the location where
they are accessed during the calculationMethod.logPhaseName
- an optional string property, which, if specified, indicates that the process should be logged
otherwise the process will not be loggedlogPropertyName
- the name of a property in the matrix object that will uniquely identify an instance of the object.
LogPropertyName must be specified if logPhaseName is specifiedType | Name and description |
---|---|
String |
calculationMethod |
double |
errorMargin |
String |
errorMethod |
boolean |
finalOut |
ChannelInput |
input |
int |
iterations |
String |
logPhaseName |
String |
logPropertyName |
int |
nodes |
ChannelOutput |
output |
String |
partitionMethod |
String |
updateMethod |
Constructor and description |
---|
MultiCoreEngine
() |
GPP - Groovy Parallel Patterns generated 18-09-2017 by Jon Kerridge, Edinburgh Napier University - j.kerridge@napier.ac.uk