skeleton
Class ParCompute

java.lang.Object
  extended by skeleton.Compute
      extended by skeleton.ParCompute
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable

public class ParCompute
extends Compute

This is the class used to provide user defined MDF graphs as (parts of) skeletons.
ParCompute items can be used where Compute items are. Unlike Compute items, requiring the user provides the Object compute(Object) method, the ParCompute items must be created providing a MdfGraph macro data flow graph, with a single token in input and a single token in output.
The computation of the ParCompute goes through the supplied graph rather than compiling MDF instructions using the compute method as opcode.

Sample use is as follows:

                Manager manager = new Manager(); 

                Compute inc1 = new Splitter();
                Dest d1 = new Dest(0, 2,Mdfi.NoGraphId);
                Dest d2 = new Dest(0, 3,Mdfi.NoGraphId);
                Dest[] dests = new Dest[2];
                dests[0] = d1;
                dests[1] = d2;
                Mdfi i1 = new Mdfi(manager,1,inc1,1,2,dests);

                Compute sq1 = new Square();
                Dest d3 = new Dest(0, 4, Mdfi.NoGraphId);
                Dest[] dests1 = new Dest[1];
                dests1[0] = d3;
                Mdfi i2 = new Mdfi(manager,2,sq1,1,1,dests1);

                Compute sq2 = new Square();
                Dest d4 = new Dest(1, 4, Mdfi.NoGraphId);
                Dest[] dests2 = new Dest[1];
                dests2[0] = d4;
                Mdfi i3 = new Mdfi(manager,3,sq1,1,1,dests2);

                Compute add = new Comp();
                Dest d5 = new Dest(0,Mdfi.NoInstrId, Mdfi.NoGraphId);
                Dest[] dests3 = new Dest[1];
                dests3[0] = d5;
                Mdfi i4 = new Mdfi(manager, 4, add, 1, 1, dests3);


                MdfGraph graph = new MdfGraph();
                graph.addInstruction(i1);
                graph.addInstruction(i2);
                graph.addInstruction(i3);
                graph.addInstruction(i4);

                ParCompute mdfg = new ParCompute(graph);

 
In this case a graph not expressible with the standard muskel skeletons is built.
The graph can be used in a farm, as an example, by telling
 Farm f = new Farm(mdfg);
 manager.setProgram(f);
 
or computed as is by telling
 manager.setProgram(mdfg);
 
just before issuing the manager.compute() call.

See Also:
Serialized Form

Constructor Summary
ParCompute(MdfGraph g)
          ParCompute nodes are created by passing an MDF graph as the node "program"
 
Method Summary
 java.lang.Object compute(java.lang.Object task)
          This is the method that has to be computed in order to implement the Compute interface.
 MdfGraph getMdfGraph()
          this is the method used to fetch the graph when compiling the class as a skeleton parameter
 
Methods inherited from class skeleton.Compute
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParCompute

public ParCompute(MdfGraph g)
ParCompute nodes are created by passing an MDF graph as the node "program"

Parameters:
g - the graph to be computed
Method Detail

compute

public java.lang.Object compute(java.lang.Object task)
This is the method that has to be computed in order to implement the Compute interface. It is currently null (actually, it always returns a null, but it can be derived interpreting on the fly the MDF graph.
Users can extend the class providing an actual method, but this will not be used but for computing the sequential program.

Specified by:
compute in class Compute
Parameters:
task - is the input task value
Returns:
the result of the computation

getMdfGraph

public MdfGraph getMdfGraph()
this is the method used to fetch the graph when compiling the class as a skeleton parameter

Returns:
the associated MDF graph implementing the wrapped code (may be parallel)