at.dms.kjc.cluster
Class FixedBufferTape

java.lang.Object
  extended by at.dms.kjc.cluster.FixedBufferTape

public class FixedBufferTape
extends Object

Calculate buffer sizes for an edge (a tape) that uses a fixed-length buffer.
Calculates buffer size. Separately, calculates extra size needed for peeks (as int, boolean). Separately calculates whether to use modular buffers.
TODO: determine if ever need size for init and size for steady separately.
This code is specific to the cluster backend. To generalize would have to make all backends inherit from a common ancestor defining initExecutionCounts and steadyExecutionCounts: doable, but not today.

Author:
allyn from code by mike for rstream

Constructor Summary
FixedBufferTape()
           
 
Method Summary
static int bufferSize(int src, int dst, CodegenPrintWriter p, boolean printComments)
          Static method to calculate a buffer size for standalone mode.
static int getRemaining(int src, int dst)
          Determine the size of largest number of items that may be on a tape before an execution of a work function.
static boolean isFixedBuffer(int src, int dst)
          Determine whether a tape is is "fused".
static boolean needsModularBuffer(int src, int dst)
          Return whether a tape buffer should be modular based on destination.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixedBufferTape

public FixedBufferTape()
Method Detail

isFixedBuffer

public static boolean isFixedBuffer(int src,
                                    int dst)
Determine whether a tape is is "fused".
This version relies totally on the KjcOptions.standalone flag for its determination.

Parameters:
src - the NetStream number of a SIROperator at source of tape
dst - the NetStream number of a SIROperator at destination of tape
Returns:
whether tape uses a "fused" buffer: a linear or modular buffer

getRemaining

public static int getRemaining(int src,
                               int dst)
Determine the size of largest number of items that may be on a tape before an execution of a work function.

Parameters:
src - the NetStream number of a SIROperator for the source of the tape
dst - the NetStream number of a SIROperator for the destination of the tape
Returns:
max(peeks-pops, 0) for a filter, 0 otherwise, for a joiner: number of enqueues not processed in first execution.

needsModularBuffer

public static boolean needsModularBuffer(int src,
                                         int dst)
Return whether a tape buffer should be modular based on destination.
I am not sure that I understand Janis' reasoning here. A buffer needs to be modular if both (1) KjcOptions.modfusion is set and (2) if the number of peeks in the dst work function is != the number of pops in the dst work function.

Parameters:
src - the NetStream number of a SIROperator for the source of the tape
dst - the NetStream number of a SIROperator for the destination of the tape
Returns:
trus of buffer should be modular, false otherwise.

bufferSize

public static int bufferSize(int src,
                             int dst,
                             CodegenPrintWriter p,
                             boolean printComments)
Static method to calculate a buffer size for standalone mode.
Retrieve the calculated info using getters. Implicit parameters are ClusterBackend.initExecutionCounts and ClusterBackend.steadyExecutionCounts

Parameters:
src - from getSource on a NetStream
dst - from getDest on the same NetStream
p - a CodeGenPrintWriter for generating comments or null.
printComments - whether to generate comments: should be false if p is null.
Returns:
max number of items that will be bufferred on this edge.