at.dms.kjc.spacedynamic
Class Simulator

java.lang.Object
  extended by at.dms.kjc.spacedynamic.Simulator
Direct Known Subclasses:
FineGrainSimulator, NoSimulator, SimpleSimulator, WorkBasedSimulator

public abstract class Simulator
extends Object


Field Summary
protected  HashMap<FlatNode,JoinerScheduleNode> currentJoinerCode
          the curent node in the joiner schedule we are working on
 HashMap<FlatNode,JoinerScheduleNode> initJoinerCode
          FlatNode->JoinerScheduleNode, the receiving/sending schedule for the joiner for init
 HashMap<Object,StringBuffer> initSchedules
          ComputeNode->StringBuffer, the init switch schedule for this tile
protected  boolean initSimulation
          true if we are simulating the init schedule
protected  HashMap<FlatNode,JoinerScheduleNode> joinerCode
          the current joiner code we are working on (steady or init)
protected  JoinerSimulator joinerSimulator
          joinerSimulator gives the receiving schedule for each joiner
protected  Layout layout
           
protected  RawChip rawChip
           
protected  SpdStaticStreamGraph ssg
           
 HashMap<FlatNode,JoinerScheduleNode> steadyJoinerCode
          FlatNode->JoinerScheduleNode, the receiving/sending schedule for the joiner for steady
 HashMap<Object,StringBuffer> steadySchedules
          ComputeNode->StringBuffer, the steady switch schedule for this tile
protected  HashMap<Object,StringBuffer> switchSchedules
          The current switch schedule we are working on
protected  FlatNode toplevel
           
 
Constructor Summary
Simulator(SpdStaticStreamGraph ssg, JoinerSimulator joinerSimulator)
           
 
Method Summary
protected  void addJoinerCode(FlatNode fire, JoinerScheduleNode code)
           
protected  void asm(ComputeNode fire, HashMap<ComputeNode,ComputeNode> previous, HashMap<ComputeNode,HashSet> next)
          Create switch assembly code for to route one item from
abstract  boolean canFire(FlatNode node, HashMap<FlatNode,Integer> executionCounts, SimulationCounter counters)
           
protected  int consumedItems(FlatNode fire, SimulationCounter counters, HashMap<FlatNode,Integer> executionCounts)
          return how many items a node consumes (pop's) for one firing given the current state of the simulation
protected  void decrementExecutionCounts(FlatNode fire, HashMap<FlatNode,Integer> executionCounts, SimulationCounter counters)
          Give that a node has just fired, update the simulation state
protected abstract  int fireJoiner(FlatNode fire, SimulationCounter counters, HashMap<FlatNode,Integer> executionCounts)
          this method should fire a joiner, assuming the joiner can fire, and update the simulation state
protected  int fireMe(FlatNode fire, SimulationCounter counters, HashMap<FlatNode,Integer> executionCounts)
          consume the data and return the number of items produced
protected  void generateSwitchCode(FlatNode fire, List<FlatNode> dests)
          generate the switch code for 1 data item given the list of destinations we do not want to duplicate items until neccessary, so we have to keep track of all the routes and then generate the switch code this way we can route multiple dests per route instruction
protected  int itemsNeededToFire(FlatNode fire, SimulationCounter counters, HashMap<FlatNode,Integer> executionCounts)
          given a node
static boolean needSimulator(SpdStaticStreamGraph ssg)
           
abstract  void simulate()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

initSchedules

public HashMap<Object,StringBuffer> initSchedules
ComputeNode->StringBuffer, the init switch schedule for this tile


steadySchedules

public HashMap<Object,StringBuffer> steadySchedules
ComputeNode->StringBuffer, the steady switch schedule for this tile


initJoinerCode

public HashMap<FlatNode,JoinerScheduleNode> initJoinerCode
FlatNode->JoinerScheduleNode, the receiving/sending schedule for the joiner for init


steadyJoinerCode

public HashMap<FlatNode,JoinerScheduleNode> steadyJoinerCode
FlatNode->JoinerScheduleNode, the receiving/sending schedule for the joiner for steady


ssg

protected SpdStaticStreamGraph ssg

toplevel

protected FlatNode toplevel

joinerSimulator

protected JoinerSimulator joinerSimulator
joinerSimulator gives the receiving schedule for each joiner


layout

protected Layout layout

rawChip

protected RawChip rawChip

initSimulation

protected boolean initSimulation
true if we are simulating the init schedule


switchSchedules

protected HashMap<Object,StringBuffer> switchSchedules
The current switch schedule we are working on


joinerCode

protected HashMap<FlatNode,JoinerScheduleNode> joinerCode
the current joiner code we are working on (steady or init)


currentJoinerCode

protected HashMap<FlatNode,JoinerScheduleNode> currentJoinerCode
the curent node in the joiner schedule we are working on

Constructor Detail

Simulator

public Simulator(SpdStaticStreamGraph ssg,
                 JoinerSimulator joinerSimulator)
Method Detail

simulate

public abstract void simulate()

canFire

public abstract boolean canFire(FlatNode node,
                                HashMap<FlatNode,Integer> executionCounts,
                                SimulationCounter counters)

needSimulator

public static boolean needSimulator(SpdStaticStreamGraph ssg)
Returns:
true if we need switch code for this graph, otherwise we can just use the dynamic network because there are no overlapping routes and no splitters or joiners

asm

protected void asm(ComputeNode fire,
                   HashMap<ComputeNode,ComputeNode> previous,
                   HashMap<ComputeNode,HashSet> next)
Create switch assembly code for to route one item from
fire
to the dests.
previous
is a hashmap from ComputeNode -> ComputeNode that maps a node to its previous hop,
next
is similiar...


generateSwitchCode

protected void generateSwitchCode(FlatNode fire,
                                  List<FlatNode> dests)
generate the switch code for 1 data item given the list of destinations we do not want to duplicate items until neccessary, so we have to keep track of all the routes and then generate the switch code this way we can route multiple dests per route instruction


itemsNeededToFire

protected int itemsNeededToFire(FlatNode fire,
                                SimulationCounter counters,
                                HashMap<FlatNode,Integer> executionCounts)
given a node
fire
and the current state of the simulation, return how many items are necessary for the node to fire.


decrementExecutionCounts

protected void decrementExecutionCounts(FlatNode fire,
                                        HashMap<FlatNode,Integer> executionCounts,
                                        SimulationCounter counters)
Give that a node has just fired, update the simulation state


consumedItems

protected int consumedItems(FlatNode fire,
                            SimulationCounter counters,
                            HashMap<FlatNode,Integer> executionCounts)
return how many items a node consumes (pop's) for one firing given the current state of the simulation


fireMe

protected int fireMe(FlatNode fire,
                     SimulationCounter counters,
                     HashMap<FlatNode,Integer> executionCounts)
consume the data and return the number of items produced


addJoinerCode

protected void addJoinerCode(FlatNode fire,
                             JoinerScheduleNode code)

fireJoiner

protected abstract int fireJoiner(FlatNode fire,
                                  SimulationCounter counters,
                                  HashMap<FlatNode,Integer> executionCounts)
this method should fire a joiner, assuming the joiner can fire, and update the simulation state