mapss.dif
Class DIFScheduleUtilities

java.lang.Object
  extended by mapss.dif.DIFScheduleUtilities

public class DIFScheduleUtilities
extends java.lang.Object

Utilities for DIF schedules. The utility tools are for deriving the associated graph elements from a schedule.

Version:
$Id: DIFScheduleUtilities.java 409 2007-05-13 19:47:16Z plishker $
Author:
Mingyung Ko, Chia-Jui Hsu

Constructor Summary
protected DIFScheduleUtilities()
          A protected constructor to prevent the object to be accidentally created and allow more specialized schedule classes to extend from.
 
Method Summary
static java.util.List actorFirings(mocgraph.sched.ScheduleElement scheduleElement)
          Return an actor firing sequence given by the schedule element.
static mocgraph.sched.ScheduleElement cloneScheduleElement(mocgraph.sched.ScheduleElement element)
          Clone a schedule element.
static int clusterRepetitions(mocgraph.sched.ScheduleElement scheduleElement)
          Compute the repetitions as if the scheduled actors are treated as a cluster.
static int codeSize(mocgraph.sched.ScheduleElement sched)
          A simplified code size computation for a given schedule.
static int codeSize(mocgraph.sched.ScheduleElement sched, java.util.Map sizeMap, int loopCodeSize)
          Compute the (inlined) code size of a given schedule.
static boolean compareScheduleByActorFirings(mocgraph.sched.ScheduleElement s1, mocgraph.sched.ScheduleElement s2)
          Compare two schedules by their flattened actor firings.
static boolean compareScheduleByStructure(mocgraph.sched.ScheduleElement s1, mocgraph.sched.ScheduleElement s2)
          Compare two schedules by their looping structures.
static java.util.Collection crossingEdges(mocgraph.sched.ScheduleElement sched1, mocgraph.sched.ScheduleElement sched2, DIFGraph graph)
          Get the induced crossing edges between two schedule elements.
static java.util.Map generateNameMap(DIFGraph graph)
          Generate a map that maps Node object to its String name.
static DIFGraph inducedGraph(mocgraph.sched.ScheduleElement scheduleElement, DIFGraph graph)
          Get the induced DIF graph from the schedule element.
static mocgraph.sched.Schedule topSortToSchedule(java.util.List topSort)
          Convert a topological sorting order to a schedule for instances of SingleRateGraph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DIFScheduleUtilities

protected DIFScheduleUtilities()
A protected constructor to prevent the object to be accidentally created and allow more specialized schedule classes to extend from.

Method Detail

actorFirings

public static java.util.List actorFirings(mocgraph.sched.ScheduleElement scheduleElement)
Return an actor firing sequence given by the schedule element. The actor firings returned have the same order as ScheduleElement.firingElementIterator(). Therefore, the functionality can be viewed as a List version of firingElementIterator.

Clarification: Actor firings are in the type of Node, not Firing.

Parameters:
scheduleElement - The schedule element.

cloneScheduleElement

public static mocgraph.sched.ScheduleElement cloneScheduleElement(mocgraph.sched.ScheduleElement element)
Clone a schedule element.

Parameters:
The - original schedule element.
Returns:
The cloned schedule element.

clusterRepetitions

public static int clusterRepetitions(mocgraph.sched.ScheduleElement scheduleElement)
Compute the repetitions as if the scheduled actors are treated as a cluster. It is equal to GCD value of all the actors' repetitions. See also SDFGraph.clusterRepetitions(Collection)

Parameters:
scheduleElement - The schedule element.
Returns:
The cluster repetitions.

codeSize

public static int codeSize(mocgraph.sched.ScheduleElement sched)
A simplified code size computation for a given schedule. All actors are assumed to have code size 1, and loop size with 0. This is a good way to get the total number of actor appearances for a schedule.

Parameters:
sched - The schedule.
Returns:
The code size.

codeSize

public static int codeSize(mocgraph.sched.ScheduleElement sched,
                           java.util.Map sizeMap,
                           int loopCodeSize)
Compute the (inlined) code size of a given schedule. A map from actors to corresponding code sizes as well as the code size overhead for loops have to be specified.

Parameters:
sched - The schedule.
sizeMap - The map from actors to code size (in class Integer).
loopCodeSize - The code size for loops.
Returns:
The code size.

compareScheduleByActorFirings

public static boolean compareScheduleByActorFirings(mocgraph.sched.ScheduleElement s1,
                                                    mocgraph.sched.ScheduleElement s2)
Compare two schedules by their flattened actor firings. Two schedules are equivalent in that they share the same number and sequence of actor firings.

Clarification: Actor firings are in the type of Node, not Firing.

Parameters:
s1 - The first schedule.
s2 - The second schedule.
Returns:
True if the two schedules have the same firing sequence; false otherwise.

compareScheduleByStructure

public static boolean compareScheduleByStructure(mocgraph.sched.ScheduleElement s1,
                                                 mocgraph.sched.ScheduleElement s2)
Compare two schedules by their looping structures. At each loop level, the comparison happens in the order: number of iterations, number of iterands, type of iterand, and iterand body (recursive comparison).

Parameters:
s1 - The first schedule.
s2 - The second schedule.
Returns:
True if the two schedules have the same looping hierarchy; false otherwise.

crossingEdges

public static java.util.Collection crossingEdges(mocgraph.sched.ScheduleElement sched1,
                                                 mocgraph.sched.ScheduleElement sched2,
                                                 DIFGraph graph)
Get the induced crossing edges between two schedule elements. A schedule element usually represents a cluster of actors. This method is to calculate the crossing edges between two actor clusters induced from the schedule elements. See also inducedGraph(ScheduleElement, DIFGraph).

Parameters:
sched1 - The first schedule element.
sched2 - The second schedule element.
graph - The original graph in which to get the crossing edges.
Returns:
The crossing edges.

generateNameMap

public static java.util.Map generateNameMap(DIFGraph graph)
Generate a map that maps Node object to its String name. This method is used for mocgraph.sched.Schedule.toParenthesisString( Map, String). Note that, each node in the input DIFGraph graph should have its name.

Parameters:
graph - The DIFGraph or subclass of DIFGraph instance.
Returns:
The map that maps Node object to its String name.

inducedGraph

public static DIFGraph inducedGraph(mocgraph.sched.ScheduleElement scheduleElement,
                                    DIFGraph graph)
Get the induced DIF graph from the schedule element. A schedule element indicates the firing sequence of a certain cluster of DIF actors. This method is to get the graph induced by the cluster.

Parameters:
scheduleElement - The schedule element.
graph - The original/parent graph to induce the subgraph.
Returns:
The induced graph.

topSortToSchedule

public static mocgraph.sched.Schedule topSortToSchedule(java.util.List topSort)
Convert a topological sorting order to a schedule for instances of SingleRateGraph. This method does not check any error between the order and the associated graph. Users need to make sure that the order contains the desired graph nodes.

Parameters:
topSort - The topological sorting order.
Returns:
A schedule.