at.dms.kjc.spacetime
Class RawComputeCodeStore

java.lang.Object
  extended by at.dms.kjc.backendSupport.ComputeCodeStore<RawTile>
      extended by at.dms.kjc.spacetime.RawComputeCodeStore
All Implemented Interfaces:
SIRCodeUnit

public class RawComputeCodeStore
extends ComputeCodeStore<RawTile>
implements SIRCodeUnit

Repository for the compute code (SIR code that is converted to C and mapped to the compute processor) for a tile. This class is used by Rawify as it visits the schedules to generate the code that will implement the schedules. This class includes methods to add code to the 3 different schedules (init, primepump, steady) that are executed at each tile. This class is then used by at.dms.kjc.spacetime.SliceIRtoC to convert the sir code for each tile to C code for each tile.

Author:
mgordon

Field Summary
static boolean GEN_PRESYNCH
          If true, generate presynched dram commands when needed
protected  HashMap<FilterContent,RawExecutionCode> rawCode
          this hash map holds RawExecutionCode that was generated so when we see the filter for the first time in the init and if we see the same filter again, we do not have to add the functions again
 
Fields inherited from class at.dms.kjc.backendSupport.ComputeCodeStore
cleanupBlock, CODE, fields, initBlock, mainMethod, mainName, methods, myMainName, parent, steadyLoop
 
Constructor Summary
RawComputeCodeStore(RawTile parent)
          Create a store for the compute code of tile.
 
Method Summary
 void addDRAMCommand(boolean read, SchedulingPhase whichPhase, int bytes, OffChipBuffer buffer, boolean staticNet)
          Add a dram command and possibly a rotation of the buffer at the current position of this code compute code for either the init stage (including primepump) or the steady state.
 void addDRAMGDNReadCommand(SchedulingPhase whichPhase, int bytes, OffChipBuffer buffer, boolean presynched, RawTile dest)
          Add a dram read command at the current position of this code compute code for either the init stage (including primepump) or the steady state over the gdn and send it to the
 void addFileCommand(boolean read, boolean init, int words, OffChipBuffer buffer, boolean staticNet)
          Generate a command to read or write from a file daisy-chained to a i/o port.
 void addFileGDNReadCommand(SchedulingPhase whichPhase, int words, OffChipBuffer buffer, RawTile dest)
          Generate a command to read from a file daisy-chained to a i/o port on the gdn and send the data to
 void addGDNFileStoreCommandWithSynch(boolean init, int words, OffChipBuffer buffer)
          If we are generating a file command for a store over the gdn and the tile that is writing the data is different from the home tile, and we cannot use any other synchronization, we must send a word over the static network to the tile writing the data for the store from this tile to tell it that we have sent the dram command and it can begin the store.
 void addGDNStoreCommandWithSynch(SchedulingPhase whichPhase, int bytes, OffChipBuffer buffer)
          If we are generating a DRAM command for a store over the gdn and the tile that is writing the data is different from the home tile, and we cannot use any other synchronization, we must send a word over the static network to the tile writing the data for the store from this tile to tell it that we have sent the dram command and it can begin the store.
 void addSliceInit(FilterInfo filterInfo, Layout layout)
          Add filterInfo's init stage block at the current position of the init stage for this code store.
 void addSlicePrimePump(FilterInfo filterInfo, Layout layout)
          Add filterInfo's prime pump block to the current position of the primepump code for this tile.
 void addSliceSteady(FilterInfo filterInfo, Layout layout)
          Add the code necessary to execution the filter of filterInfo at the current position in the steady-state code of this store, given the layout.
static void barrier(RawChip chip, boolean init, boolean primepump)
          Create a barrier in the init stage at this point in code generation.
 void disregardIncoming(IODevice dev, int words, boolean init)
          Generate code to receive
 void dummyOutgoing(IODevice dev, int words, boolean init)
          Generate code on the compute process to send over
static void presynchAllDramsInInit()
          This function will create a presynch read command for every dram that is used in the program and add it to the current position in the init block.
static void presynchEmptyTilesInSteady()
          This function will create a presynch read command for each dram that does not have a filter assigned to it but initiates DRAM commands.
 void sendConstToSwitch(int constant, boolean init)
          Create code on the compute processor to send constant to the switch.
 boolean shouldPresynch(boolean read, SchedulingPhase whichPhase, OffChipBuffer buffer)
          Decide if a dram command should be presynched at the given time based on the command and the buffer.
static JStatement sirDramCommand(boolean read, int cacheLines, JExpression sampleAddress, boolean staticNet, boolean shouldPreSynch, JExpression address)
          Return sir code that will call the macro for a dram command to transfer
 
Methods inherited from class at.dms.kjc.backendSupport.ComputeCodeStore
addCleanupStatement, addField, addFields, addInitFunctionCall, addInitStatement, addInitStatementFirst, addMethod, addMethods, addSteadyLoop, addSteadyLoop, addSteadyLoopStatement, getFields, getMainFunction, getMethods, getMyMainName, hasMethod, setFields, setMethods, setMyMainName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface at.dms.kjc.sir.SIRCodeUnit
addField, addFields, addMethod, addMethods, getFields, getMethods, setFields, setMethods
 

Field Detail

GEN_PRESYNCH

public static final boolean GEN_PRESYNCH
If true, generate presynched dram commands when needed

See Also:
Constant Field Values

rawCode

protected HashMap<FilterContent,RawExecutionCode> rawCode
this hash map holds RawExecutionCode that was generated so when we see the filter for the first time in the init and if we see the same filter again, we do not have to add the functions again

Constructor Detail

RawComputeCodeStore

public RawComputeCodeStore(RawTile parent)
Create a store for the compute code of tile.

Parameters:
parent -
Method Detail

addFileCommand

public void addFileCommand(boolean read,
                           boolean init,
                           int words,
                           OffChipBuffer buffer,
                           boolean staticNet)
Generate a command to read or write from a file daisy-chained to a i/o port.

Parameters:
read - True if load, false store
init - true if we want to append command to init stage, false steady
words - the number of words to x-fer
buffer - Used to get the port
staticNet - True if static net, false gdn

addFileGDNReadCommand

public void addFileGDNReadCommand(SchedulingPhase whichPhase,
                                  int words,
                                  OffChipBuffer buffer,
                                  RawTile dest)
Generate a command to read from a file daisy-chained to a i/o port on the gdn and send the data to
dest

Parameters:
init - true if we want to append command to init stage, false steady
words - the number of words to x-fer
buffer - Used to get the port
dest - The tile to which to send the data.

addGDNStoreCommandWithSynch

public void addGDNStoreCommandWithSynch(SchedulingPhase whichPhase,
                                        int bytes,
                                        OffChipBuffer buffer)
If we are generating a DRAM command for a store over the gdn and the tile that is writing the data is different from the home tile, and we cannot use any other synchronization, we must send a word over the static network to the tile writing the data for the store from this tile to tell it that we have sent the dram command and it can begin the store. This function will generate the gdn store command and also inject the synch word to the static network.

Parameters:
init -
buffer -

addGDNFileStoreCommandWithSynch

public void addGDNFileStoreCommandWithSynch(boolean init,
                                            int words,
                                            OffChipBuffer buffer)
If we are generating a file command for a store over the gdn and the tile that is writing the data is different from the home tile, and we cannot use any other synchronization, we must send a word over the static network to the tile writing the data for the store from this tile to tell it that we have sent the dram command and it can begin the store. This function will generate the gdn file store command and also inject the synch word to the static network.

Parameters:
init -
words -
buffer -

dummyOutgoing

public void dummyOutgoing(IODevice dev,
                          int words,
                          boolean init)
Generate code on the compute process to send over
words
words of data using a header that was already set previously.

Parameters:
dev -
words - The number of dummy words to send
init -

disregardIncoming

public void disregardIncoming(IODevice dev,
                              int words,
                              boolean init)
Generate code to receive
words
words into a dummy volatile variable on the compute processor from gdn.

Parameters:
dev -
words - The number of words to disregard
init - Which schedule should be append this code to?

shouldPresynch

public boolean shouldPresynch(boolean read,
                              SchedulingPhase whichPhase,
                              OffChipBuffer buffer)
Decide if a dram command should be presynched at the given time based on the command and the buffer.

Parameters:
read -
init -
primepump -
buffer -
Returns:
True if we should presynch, false if not.

addDRAMCommand

public void addDRAMCommand(boolean read,
                           SchedulingPhase whichPhase,
                           int bytes,
                           OffChipBuffer buffer,
                           boolean staticNet)
Add a dram command and possibly a rotation of the buffer at the current position of this code compute code for either the init stage (including primepump) or the steady state. If in the init stage, don't rotate buffers. If in init or primepump, add the code to the init stage.

Parameters:
read - True if we want to issue a read, false if write
init - true if init
primepump - true if primepump
bytes - The number of bytes
buffer - The address to load/store
staticNet - True if we want to use the static network, false if gdn

sirDramCommand

public static JStatement sirDramCommand(boolean read,
                                        int cacheLines,
                                        JExpression sampleAddress,
                                        boolean staticNet,
                                        boolean shouldPreSynch,
                                        JExpression address)
Return sir code that will call the macro for a dram command to transfer
cacheLines
cache-lines from a single address
address
using
sampleAddress
to send the command to the correct dram port.

Parameters:
read - True then load, false then store
cacheLines -
sampleAddress - An address that resides on the drams
staticNet - If true, use static net, otherwise gdn
shouldPreSynch - If true, generate a presynched command
address - The address for the xfer
Returns:
...

addDRAMGDNReadCommand

public void addDRAMGDNReadCommand(SchedulingPhase whichPhase,
                                  int bytes,
                                  OffChipBuffer buffer,
                                  boolean presynched,
                                  RawTile dest)
Add a dram read command at the current position of this code compute code for either the init stage (including primepump) or the steady state over the gdn and send it to the
dest
tile. Don't rotate the buffer we are in the init stage.

Parameters:
init - true if init
primepump - true if primepump stage
bytes - The number of bytes
buffer - The address to load/store
presynched - True if we want all other dram commands to finish before this one is issued
dest - The read's destination.

addSliceSteady

public void addSliceSteady(FilterInfo filterInfo,
                           Layout layout)
Add the code necessary to execution the filter of filterInfo at the current position in the steady-state code of this store, given the layout.

Parameters:
filterInfo - The filter to add to the steady-state schedule.
layout - The layout of the application.

addSlicePrimePump

public void addSlicePrimePump(FilterInfo filterInfo,
                              Layout layout)
Add filterInfo's prime pump block to the current position of the primepump code for this tile.

Parameters:
filterInfo - The filter.
layout - The layout of the application.

addSliceInit

public void addSliceInit(FilterInfo filterInfo,
                         Layout layout)
Add filterInfo's init stage block at the current position of the init stage for this code store.

Parameters:
filterInfo - The filter.
layout - The layout of the application.

presynchEmptyTilesInSteady

public static void presynchEmptyTilesInSteady()
This function will create a presynch read command for each dram that does not have a filter assigned to it but initiates DRAM commands. This will be placed at the current position of the steady state.


barrier

public static void barrier(RawChip chip,
                           boolean init,
                           boolean primepump)
Create a barrier in the init stage at this point in code generation.

Parameters:
chip - The raw chip.

presynchAllDramsInInit

public static void presynchAllDramsInInit()
This function will create a presynch read command for every dram that is used in the program and add it to the current position in the init block. It will make sure that all dram write commands are finished before anything else can be issued.


sendConstToSwitch

public void sendConstToSwitch(int constant,
                              boolean init)
Create code on the compute processor to send constant to the switch. If init then append the code to the init schedule, otherwise steady-schedule.

It does nothing on the switch, that is left for somewhere else.

Parameters:
constant - The number to send.
init - if true add to init stage, otherwise add to steady.