mapss.dif.mdsdf.sched
Class MDSchedule

java.lang.Object
  extended by mocgraph.sched.ScheduleElement
      extended by mocgraph.sched.Schedule
          extended by mapss.dif.mdsdf.sched.MDSchedule

public class MDSchedule
extends mocgraph.sched.Schedule

The schedule class for multi-dimensional dataflow. This class extends from mocgraph.sched.Schedule for supporting multi-dimensional (MD or m-d) iteration counts.

The "iteration count" is still in one-dimensional because it is inherited from mocgraph.sched.ScheduleElement. The new variable "multi-dimensional iteration count" is created for specifying multi-dimensional iteration count.

Suppose that R = [r1, r2, ..., rM] is a multi-dimensional iteration count, where Mis the dimensionality. Then r = r1 * r2 * ... * rM is the converted version of original one-dimensional iteration count.

Use setMDIterationCount(int[]) and getMDIterationCount() to set and get R = [r1, r2, ..., rM]. r = r1 * r2 * ... * rM will automatically be computed. Using setIterationCount(int) will cause an error but using getIterationCount() will return r = r1 * r2 * ... * rM.

Each schedule element in the MDSchedule must has the same dimension as the MDSchedule. The dimension of iteration count of the MDSchedule must be also consistent with the dimension of the MDSchedule. As a result, MDSchedule(int) is the most recommended constructor because it sets the dimension during initialization. An user can also call setDimension(int) to set the dimension of the MDSchedule if he uses other constructors. Once the dimension is set, it cannot be changed. The reason to force this constraint is to prevent the schedule elements have different dimenisons than the parent schedule.

This class represents a multi-dimensional static schedule of firing elements invocation. An instance of this class is returned by the scheduler of a multi-dimensional dataflow model to represent order of firing element firings in the model. A schedule consists of a list of schedule elements and the number of times the schedule should repeat.

Each element of the schedule is represented by an instance of the MDFiring or MDSchedule. Each element may correspond to a number of firings of a single firing element (represented by the MDFiring class) or an entire sub-schedule (represented by a hierarchically contained instance of this class). This nesting allows this concise representation of looped schedules. The nesting can be arbitrarily deep, but must be a tree where the leaf nodes represent firings. It is up to the scheduler to enforce this requirement.

The add() and remove() methods are used to add or remove schedule elements. Only elements of type MDSchedule or MDFiring can be added to the schedule list. The iteration count is set by the setMDIterationCount(int[]) method. If this method is not invoked, a default value of {1} will be used.

Take a look of an example. Suppose that we have a MDSDF graph containing actors A, B, C, and D, with the firing order [1,8]A [8,1]B [2,2]([2,1]C [1,2]D). The code to create this schedule appears below.

       MDSchedule S1 = new MDSchedule(2);
       MDFiring FA = new MDFiring();
       MDFiring FB = new MDFiring();
       MDSchedule S2 = new MDSchedule(2);
       MDFiring FC = new MDFiring();
       MDFiring FD = new MDFiring();
       
       FA.setFiringElement(A);
       int[] itA = {1,8};
       FA.setMDIterationCount(itA);
       FB.setFiringElement(B);
       int[] itB = {8,1};
       FB.setMDIterationCount(itB);
       S1.add(FA);
       S1.add(FB);
       
       FC.setFiringElement(C);
       int[] itC = {2,1};
       FC.setMDIterationCount(itC);
       FD.setFiringElement(D);
       int[] itD = {1,2};
       FD.setMDIterationCount(itD);
       S2.add(FC)
       S2.add(FD);
       int[] itS2 = {2,2};
       S2.setMDIterationCount(itS2);
       
       S1.add(S2);
   

Version:
$Id: MDSchedule.java 1687 2007-05-08 01:38:09Z jerryhsu $
Author:
Chia-Jui Hsu
See Also:
MDFiring, Schedule, ScheduleElement

Field Summary
 
Fields inherited from class mocgraph.sched.Schedule
_schedule
 
Fields inherited from class mocgraph.sched.ScheduleElement
_parent
 
Constructor Summary
MDSchedule()
          Construct a multi-dimensional schedule with iteration count {1} and an empty schedule list.
MDSchedule(java.lang.Class firingElementClass)
          Construct a multi-dimensional schedule with iteration count {1} and an empty schedule list.
MDSchedule(int dimension)
          Construct a multi-dimensional schedule with multi-dimensional iteration count set to int[dimension] with all elements equal to one, and an empty schedule list.
 
Method Summary
 void add(int index, mocgraph.sched.ScheduleElement element)
          Insert the specified schedule element at the specified position in the schedule list.
 void add(mocgraph.sched.ScheduleElement element)
          Append the specified schedule element to the end of the schedule list.
 int getDimension()
          Get the dimension of this MDSchedule.
 int[] getMDIterationCount()
          Get the multi-dimensional iteration count for this multi-dimensional schedule.
 void setDimension(int dimension)
          Set the dimension of this schedule.
 void setIterationCount(int count)
          Invalidate ScheduleElement.setIterationCount(int).
 void setMDIterationCount(int[] iteration)
          Set the multi-dimensional iteration count for this multi-dimensional schedule.
 java.lang.String toParenthesisString(java.util.Map nameMap, java.lang.String delimiter)
          Print the schedule in a nested parenthesis style.
 java.lang.String toString()
          Output a string representation of this Schedule.
 
Methods inherited from class mocgraph.sched.Schedule
appearanceCount, firingElementIterator, firingIterator, firings, get, iterator, lexicalOrder, maxAppearanceCount, remove, size
 
Methods inherited from class mocgraph.sched.ScheduleElement
_getVersion, _incrementVersion, firingElementClass, getIterationCount, getParent, setParent, toParenthesisString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MDSchedule

public MDSchedule()
Construct a multi-dimensional schedule with iteration count {1} and an empty schedule list.


MDSchedule

public MDSchedule(java.lang.Class firingElementClass)
Construct a multi-dimensional schedule with iteration count {1} and an empty schedule list. If this constructor is used, ScheduleElements containing firing elements of the given class would only be accepted as next elements for this schedule.

Parameters:
firingElementClass - The given class type.

MDSchedule

public MDSchedule(int dimension)
Construct a multi-dimensional schedule with multi-dimensional iteration count set to int[dimension] with all elements equal to one, and an empty schedule list. Is is very recommended to use this constructor or use setDimension(int) after initialization.

Parameters:
dimension - The dimension of this schedule.
Throws:
MDScheduleException - If dimension is less than one.
Method Detail

add

public void add(mocgraph.sched.ScheduleElement element)
Append the specified schedule element to the end of the schedule list. This element must be an instance of MDFiring or MDSchedule and has the same dimension.

Overrides:
add in class mocgraph.sched.Schedule
Parameters:
element - The MDFiring or MDSchedule object to add.
Throws:
MDScheduleException - If element is not instanceof MDFiring or MDSchedule, or if element has dimension different than the dimension of this schedule.

add

public void add(int index,
                mocgraph.sched.ScheduleElement element)
Insert the specified schedule element at the specified position in the schedule list. This element must be an instance of MDFiring or MDSchedule and has the same dimension.

Overrides:
add in class mocgraph.sched.Schedule
Parameters:
index - The index at which the specified element is to be inserted.
element - The MDFiring or MDSchedule object to add.
Throws:
If - element is not instanceof MDFiring or MDSchedule, or if element has dimension different than the dimension of this schedule.
java.lang.IndexOutOfBoundsException - If the specified index is out of range (index < 0 || index > size()).

getDimension

public int getDimension()
Get the dimension of this MDSchedule.

Returns:
The dimension of this MDFiring.

getMDIterationCount

public int[] getMDIterationCount()
Get the multi-dimensional iteration count for this multi-dimensional schedule.

Returns:
The multi-dimensional iteration count for this multi-dimensional schedule.

setDimension

public void setDimension(int dimension)
Set the dimension of this schedule. If the existing multi-dimensional iteration count is in the same dimension, it is remain unchanged. Otherwise, the multi-dimensional iteration count will be set to a new int[dimension] with all elements equal to one.

Parameters:
dimension - The new dimension of this schedule.
Throws:
MDScheduleException - If dimension is less than one or the dimension of this schedule has been set.

setIterationCount

public void setIterationCount(int count)
Invalidate ScheduleElement.setIterationCount(int). Use setMDIterationCount(int[]) instead.

Overrides:
setIterationCount in class mocgraph.sched.ScheduleElement
Parameters:
count -
Throws:
MDScheduleException - Throws exception in all case.

setMDIterationCount

public void setMDIterationCount(int[] iteration)
Set the multi-dimensional iteration count for this multi-dimensional schedule.

Parameters:
iteration - The multi-dimensional iteration count for this multi-dimensional firing.
Throws:
MDScheduleException - If iteration is not equal to the dimension of this schedule.

toParenthesisString

public java.lang.String toParenthesisString(java.util.Map nameMap,
                                            java.lang.String delimiter)
Print the schedule in a nested parenthesis style.

Overrides:
toParenthesisString in class mocgraph.sched.Schedule
Parameters:
nameMap - The map from firing elements to their short names.
delimiter - The delimiter between iterands.
Returns:
A nested parenthesis expression of the schedule.

toString

public java.lang.String toString()
Output a string representation of this Schedule.

Overrides:
toString in class mocgraph.sched.Schedule
Returns:
Return a string representation of this Schedule.