Class FatTreeSwitch

java.lang.Object
  extended by FatTreeSwitch
All Implemented Interfaces:
Switch

public class FatTreeSwitch
extends java.lang.Object
implements Switch

This switch is used for building the Butterfly Fat Tree topology network. This type of switch is interconnected with different number of switches/nodes according to its position in the network. The switches are arranged according to a butter fly fat tree hierarchy. Here every switch has two parent switches except the top level switches. Every switch has four child switches except the lowest level switches. Lowest level switches have four child IP Nodes (Node class, resource of the network). All the resources (IP Nodes) are at level 0.

Version:
1.0

Field Summary
private  int address
          This is an int type variable used to hold the address of the switch in the network.
private  FatTreeSwitch[] downSwitchList
          This is an array of FatTreeSwitch used to store the list of reference of adjacent child switches if any.
private  int indexInLevel
          This is an int type variable used to store the index value of this switch it its level in the fat tree network.
private  InputLinkController[] inputLC
          These are array of InputLinkController used to store the list of input link controller objects instantiated for input communication management with the adjacent nodes and switches.
private  int[] lastVCServedList
          In order to facilitate round-robin service for the virtual channels, this array keeps track of the index of last served virtual channel on different links.
private  int level
          This is an int type variable used to store the level value of this switch in the fat tree network.
private  boolean[] LinkUseStatus
          This array keeps track of the status of the output links if there are any transmission of flits in a particular simulation cycle.
private  Node[] nodeList
          This is array of Node used to store the list of references of adjacent nodes.
private  int noOfPhysicalLink
          This is an int type variable used to hold the number of physical links attached with the switch to perform communication between adjacent switches and nodes.
private  int noOfVirtualLink
          This is an int type variable used to hold the number of virtual channel used for every physical link.
private  OutputLinkController[] outputLC
          These are array of OutputLinkController used to store the list of output link controller objects instantiated for output communication management with the adjacent nodes and switches.
private  Router router
          This is an object of type Router.
private  int switchIndex
          Index of the switch in the global array of switches in the
private  int[] switchingInfoVector
          This is an array of int variable having the size of noOfPhysicalLink * noOfVirtualLink.
private  FatTreeSwitch[] upSwitchList
          This is an array of FatTreeSwitch used to store the list of reference of adjacent parent switches if any.
 
Constructor Summary
FatTreeSwitch(int address, int switchIndex)
          This is the constructor of the FatTreeSwitch used for butterfly fat tree topology.
 
Method Summary
 boolean addInputBufferData(int linkNo, Flit flit, int curCycle)
          Adds a flit to the input buffer on a particular physical link.
 boolean addOutputBufferData(int linkNo, Flit flit, int vcId, int curCycle)
          Adds a flit to the output buffer on a particular physical link.
private  void createLinkController(int linkCount, int vcCount)
          Instantiates the input and output link controllers.
 void createRouter()
          Assigns a Router implementation of the Butterfly Fat Tree network.
private  void createSwitchingInfoVector()
          Instantiates and initializes the switchingInfoVector data structure to hold the path mapping information.
 int determineRoute(int src, int dest)
          Determines the outgoing link to switch a packet orgininated from a source node (src) and destined to the destination node (dest).
private  void forwardFlitToNode(Node adjNode, int linkNo, int curCycle)
           Transfers a flit to an adjacent node.
private  void forwardFlitToSwitch(FatTreeSwitch adjSwitch, int linkNo, int curCycle)
           Performs the transmission of flit from the virtual channel (output buffer) to physical channel and ultimately the flit is stored in the corresponding virtual channel of the switch.
 int getAddress()
          Returns the address of the switch.
 int getAdjacentLinkNo(FatTreeSwitch fatSwitch)
          Returns the number of the output physical link that connects a neighboring switch, either situated above or beneath this switch.
 InputLinkController getInputLinkController(int linkNo)
          Returns the input link controller of the switch on a particular physical link.
 int getNoOfPhysicalLink()
          Returns the maximum number of physical links information.
 int getNoOfVirtualLink()
          Returns the number of virtual channel per physical link information.
 int getNumAdjacentNode()
          Returns the number of adjacent nodes to which the switch is connected.
 int getNumLinkActive()
          Returns the number of physical links for the switch
 OutputLinkController getOutputLinkController(int linkNo)
          Returns the output link controller of the switch on a particular physical link.
 int getSwitchIndex()
          Returns the index of the switch in the level of the Butterfly Fat Tree network where it is placed.
 int getSwitchingInfoVector(int dest)
           Returns the input virtual channel information for a packet flowing through the output virtual channel.
 int getSwitchLevel()
          Returns the level of the Butterfly Fat Tree network where the switch is placed.
 boolean hasFreeSlotInVCBuffer(int linkNo, int vcId)
          Checks whether there is one or more slots in the input virtual channel of an input buffer or not.
 boolean isVCFreeInSwitch(int linkNo, int vcId)
          Checks if the virtual channels in the input buffer of a particular physical link is available to be assigned to a new incoming packet.
 void moveInputBufferToOutputBuffer(int curCycle)
          This method is called by network in every cycle to transfer flit from input buffer to output buffer.
 void moveSwitchOutputBufferToInputBufferOfNodeSwitch(int curCycle)
          This method is called by Network in every cycle to transfer flit from output buffer of the switch to input buffer of adjacent nodes and switches.
 Flit removeInputBufferData(int linkNo, int vcId, int curCycle)
          Removes a flit data from an input virtual channel of the input buffer on a particular physical link.
 Flit removeOutputBufferData(int linkNo, int vcId, int curCycle)
          Removes a flit data from an output virtual channel of the output buffer on a particular physical link.
 void resetSwitchingInfoVector()
          Resets the switching info vector of the Switch instance which keeps track of the assignment of a output virtual channel to a packet on a input virtual channel.
 void setAddress(int addr)
          Sets the address of the switch.
 void setAdjacentNode(Node node, int linkNo)
          Assigns a node reference to which this Switch is connected.
 void setAdjacentSwitch(Switch sw, int linkNo)
          This method is not required for other purpose, so left as a blank implementation of the corresponding specified in the Switch interface.
 void setChildSwitch(FatTreeSwitch fatSwitch, int linkNo)
          Sets a child switch.
 void setInputLinkController(int linkNo, InputLinkController iLC)
          Assigns an input link controller to the switch on a particular physical link.
 void setNoOfPhysicalLink(int no)
          Sets the maximum number of physical links information.
 void setNoOfVirtualLink(int no)
          Sets the number of virtual channel per physical link information.
 void setOutputLinkController(int linkNo, OutputLinkController oLC)
          Assigns an output link controller to the switch on a particular physical link.
 void setParentSwitch(FatTreeSwitch fatSwitch, int linkNo)
          Sets a parent switch.
 boolean setSwitchingInfoVector(int dest, int src)
          Sets the path information for a pair of input virtual channel and output virtual channel.
 void updateStatusAfterCycle(int curCycle)
          Updates the statistical counters for a particular simulation cycle and re-initializes the temporary status variables.
 void updateSwitchOutPathRequest(int curCycle)
          This method is called by network in every cycle to set the request of transferring flit from the input buffer to output buffer of the respective switch.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

address

private int address
This is an int type variable used to hold the address of the switch in the network.


switchIndex

private int switchIndex
Index of the switch in the global array of switches in the

See Also:
Network

noOfPhysicalLink

private int noOfPhysicalLink
This is an int type variable used to hold the number of physical links attached with the switch to perform communication between adjacent switches and nodes.


noOfVirtualLink

private int noOfVirtualLink
This is an int type variable used to hold the number of virtual channel used for every physical link.


level

private int level
This is an int type variable used to store the level value of this switch in the fat tree network.


indexInLevel

private int indexInLevel
This is an int type variable used to store the index value of this switch it its level in the fat tree network. Both level and indexInLevel constitute the address of the switch.


lastVCServedList

private int[] lastVCServedList
In order to facilitate round-robin service for the virtual channels, this array keeps track of the index of last served virtual channel on different links.


upSwitchList

private FatTreeSwitch[] upSwitchList
This is an array of FatTreeSwitch used to store the list of reference of adjacent parent switches if any. This list is used to get the parent switches to whom this switch will communicate for transfer of flits.


downSwitchList

private FatTreeSwitch[] downSwitchList
This is an array of FatTreeSwitch used to store the list of reference of adjacent child switches if any. This list is used to get the child switches to whom this switch will communicate for transfer of flits to a node that is reachable by going through the child switches.


nodeList

private Node[] nodeList
This is array of Node used to store the list of references of adjacent nodes. One switch may be connected with multiple Nodes and when any flit is to send or any status of signal is required then the corresponding node’s reference is retrieved from the nodeList.


inputLC

private InputLinkController[] inputLC
These are array of InputLinkController used to store the list of input link controller objects instantiated for input communication management with the adjacent nodes and switches. There exists exactly one input link controller for every physical link.


outputLC

private OutputLinkController[] outputLC
These are array of OutputLinkController used to store the list of output link controller objects instantiated for output communication management with the adjacent nodes and switches. There exists exactly one output link controller for every physical link.


LinkUseStatus

private boolean[] LinkUseStatus
This array keeps track of the status of the output links if there are any transmission of flits in a particular simulation cycle.


router

private Router router
This is an object of type Router. Implements Router's determineRoute() method.


switchingInfoVector

private int[] switchingInfoVector
This is an array of int variable having the size of noOfPhysicalLink * noOfVirtualLink. This array is used for switching in crossbar switch i.e. it determines the path from input buffer to output buffer. At index i of this array a value x (>=0) is stored for path selection. Here x is the input virtual channel identifier and i is the output virtual channel identifier. That means the data from input port x is switched (transferred) to the output port i. Here input and output physical and virtual channels are identified as below.

Constructor Detail

FatTreeSwitch

public FatTreeSwitch(int address,
                     int switchIndex)
This is the constructor of the FatTreeSwitch used for butterfly fat tree topology. Here address is the address of this switch from which values of level and indexInLevel member variables can be calculated and switchIndex is an integer indicated its position in the list of all switches of the network used for statistical data storing.

Parameters:
address - Address of the switch
switchIndex - index of this switch in the global array of switches in the
See Also:
Network.createFatTreeNetwork()
Method Detail

createRouter

public void createRouter()
Assigns a Router implementation of the Butterfly Fat Tree network.

Specified by:
createRouter in interface Switch

createLinkController

private void createLinkController(int linkCount,
                                  int vcCount)
Instantiates the input and output link controllers.

Parameters:
linkCount - number of physical links
vcCount - number of virtual channels per link

setAdjacentNode

public void setAdjacentNode(Node node,
                            int linkNo)
Description copied from interface: Switch
Assigns a node reference to which this Switch is connected.

Specified by:
setAdjacentNode in interface Switch
Parameters:
node - Node
linkNo - the physical link number that connects the node
See Also:
Node

getNumAdjacentNode

public int getNumAdjacentNode()
Description copied from interface: Switch
Returns the number of adjacent nodes to which the switch is connected.

Specified by:
getNumAdjacentNode in interface Switch
Returns:
number of adjacent nodes

setParentSwitch

public void setParentSwitch(FatTreeSwitch fatSwitch,
                            int linkNo)
Sets a parent switch.

Parameters:
fatSwitch - parent switch
linkNo - index of the physical link

setChildSwitch

public void setChildSwitch(FatTreeSwitch fatSwitch,
                           int linkNo)
Sets a child switch.

Parameters:
fatSwitch - child switch
linkNo - index of the physical link

getInputLinkController

public InputLinkController getInputLinkController(int linkNo)
Description copied from interface: Switch
Returns the input link controller of the switch on a particular physical link.

Specified by:
getInputLinkController in interface Switch
Parameters:
linkNo - link number
Returns:
input link controller reference of the switch on the link 'linkNo'
See Also:
InputLinkController

setInputLinkController

public void setInputLinkController(int linkNo,
                                   InputLinkController iLC)
Description copied from interface: Switch
Assigns an input link controller to the switch on a particular physical link.

Specified by:
setInputLinkController in interface Switch
Parameters:
linkNo - link number
iLC - input link controller
See Also:
InputLinkController

getOutputLinkController

public OutputLinkController getOutputLinkController(int linkNo)
Description copied from interface: Switch
Returns the output link controller of the switch on a particular physical link.

Specified by:
getOutputLinkController in interface Switch
Parameters:
linkNo - link number
Returns:
output link controller reference of the switch on the link 'linkNo'

setOutputLinkController

public void setOutputLinkController(int linkNo,
                                    OutputLinkController oLC)
Description copied from interface: Switch
Assigns an output link controller to the switch on a particular physical link.

Specified by:
setOutputLinkController in interface Switch
Parameters:
linkNo - link number
oLC - output link controller

createSwitchingInfoVector

private void createSwitchingInfoVector()
Instantiates and initializes the switchingInfoVector data structure to hold the path mapping information.


resetSwitchingInfoVector

public void resetSwitchingInfoVector()
Resets the switching info vector of the Switch instance which keeps track of the assignment of a output virtual channel to a packet on a input virtual channel.

Specified by:
resetSwitchingInfoVector in interface Switch

addInputBufferData

public boolean addInputBufferData(int linkNo,
                                  Flit flit,
                                  int curCycle)
Description copied from interface: Switch
Adds a flit to the input buffer on a particular physical link.

Specified by:
addInputBufferData in interface Switch
Parameters:
linkNo - link number
flit - Flit data
curCycle - simulation cycle
Returns:
true-if flit can be added, false-otherwise.
See Also:
InputVCBuffer.addBufferData(Flit, int, int)

addOutputBufferData

public boolean addOutputBufferData(int linkNo,
                                   Flit flit,
                                   int vcId,
                                   int curCycle)
Description copied from interface: Switch
Adds a flit to the output buffer on a particular physical link.

Specified by:
addOutputBufferData in interface Switch
Parameters:
linkNo - link number
flit - Flit data
vcId - virtual channel number
curCycle - simulation cycle
Returns:
true-if flit can be added, false-otherwise.
See Also:
OutputLinkController.addOutputBufferData(Flit, int, int)

setSwitchingInfoVector

public boolean setSwitchingInfoVector(int dest,
                                      int src)
Description copied from interface: Switch
Sets the path information for a pair of input virtual channel and output virtual channel.

Specified by:
setSwitchingInfoVector in interface Switch
Parameters:
dest - ((output link number * number of VC per link) + output virtual channel number)
src - ((input link number * number of VC per link) + input virtual channel number)
Returns:
true-if the path can be set, false-otherwise
See Also:
InputLinkController.setOutPathRequest(int)

getSwitchingInfoVector

public int getSwitchingInfoVector(int dest)
Description copied from interface: Switch

Returns the input virtual channel information for a packet flowing through the output virtual channel.

This pair of values identify the switching path in the switch for a packet.

Here the input virtual channel information is encoded as ((input link number * number of VC per link) + input virtual channel number) and the output virtual channel information is encoded as ((output link number * number of VC per link) + output virtual channel number).

Specified by:
getSwitchingInfoVector in interface Switch
Parameters:
dest - encoded output virtual channel information
Returns:
encoded input virtual channel information
See Also:
InputLinkController.setOutPathRequest(int)

removeInputBufferData

public Flit removeInputBufferData(int linkNo,
                                  int vcId,
                                  int curCycle)
Description copied from interface: Switch
Removes a flit data from an input virtual channel of the input buffer on a particular physical link.

Specified by:
removeInputBufferData in interface Switch
Parameters:
linkNo - input physical link number
vcId - input virtual channel number
curCycle - simulation cycle
Returns:
Flit
See Also:
InputLinkController.removeInputBufferData(int, int)

removeOutputBufferData

public Flit removeOutputBufferData(int linkNo,
                                   int vcId,
                                   int curCycle)
Description copied from interface: Switch
Removes a flit data from an output virtual channel of the output buffer on a particular physical link.

Specified by:
removeOutputBufferData in interface Switch
Parameters:
linkNo - output physical link number
vcId - output virtual channel number
curCycle - simulation cycle
Returns:
Flit
See Also:
OutputLinkController.removeOutputBufferData(int, int)

determineRoute

public int determineRoute(int src,
                          int dest)
Description copied from interface: Switch
Determines the outgoing link to switch a packet orgininated from a source node (src) and destined to the destination node (dest).

Specified by:
determineRoute in interface Switch
Parameters:
src - address of the source node
dest - address of the destination node
Returns:
outgoing physical link of the switch
See Also:
Router.determineRoute(int, int, int)

hasFreeSlotInVCBuffer

public boolean hasFreeSlotInVCBuffer(int linkNo,
                                     int vcId)
Description copied from interface: Switch
Checks whether there is one or more slots in the input virtual channel of an input buffer or not.

Specified by:
hasFreeSlotInVCBuffer in interface Switch
Parameters:
linkNo - input physical link number
vcId - virtual channel number on the input link
Returns:
true-if more slots are available, false-otherwise
See Also:
InputLinkController.hasFreeSlotInVCBuffer(int)

updateSwitchOutPathRequest

public void updateSwitchOutPathRequest(int curCycle)
This method is called by network in every cycle to set the request of transferring flit from the input buffer to output buffer of the respective switch. For every input physical link attached with the switch input link controller’s setOutPathRequest(curCycle) method is called.

Specified by:
updateSwitchOutPathRequest in interface Switch
Parameters:
curCycle - current simulation cycle
See Also:
InputLinkController.setOutPathRequest(int)

moveInputBufferToOutputBuffer

public void moveInputBufferToOutputBuffer(int curCycle)
This method is called by network in every cycle to transfer flit from input buffer to output buffer. The working process of moving flit from input buffer to output buffer is described below.

Specified by:
moveInputBufferToOutputBuffer in interface Switch
Parameters:
curCycle - current simulation cycle
See Also:
InputLinkController, Network.moveSwitchTrafficFromInputBufferToOutputBuffer(int)

forwardFlitToSwitch

private void forwardFlitToSwitch(FatTreeSwitch adjSwitch,
                                 int linkNo,
                                 int curCycle)

Performs the transmission of flit from the virtual channel (output buffer) to physical channel and ultimately the flit is stored in the corresponding virtual channel of the switch.

This method is called by moveSwitchOutputBufferToInputBufferOfNodeSwitch(int curCycle) method of this switch to complete transmission between this switch and actual parameter adjSwitch (an adjacent switch) for this current cycle.

The method performs its activities in the order given below.

Parameters:
adjSwitch - adjacent Butterfly Fat Tree switch
linkNo - physical link number which connects the switch 'adjSwitch'
curCycle - simulation cycle

forwardFlitToNode

private void forwardFlitToNode(Node adjNode,
                               int linkNo,
                               int curCycle)

Transfers a flit to an adjacent node.

This method is called by moveSwitchOutputBufferToInputBufferOfNodeSwitch(int curCycle) method of this switch to complete transmission between this switch and parameter adjNode for this current cycle.

The method performs its activities in the order given below.

Parameters:
adjNode - node reference
linkNo - physical link number that connects the node to the switch
curCycle - simulation cycle

moveSwitchOutputBufferToInputBufferOfNodeSwitch

public void moveSwitchOutputBufferToInputBufferOfNodeSwitch(int curCycle)
This method is called by Network in every cycle to transfer flit from output buffer of the switch to input buffer of adjacent nodes and switches. For every adjacent nodes forwardFlitToNode(adjNode, linkNo, curCycle) is called and for every adjacent switch forwardFlitToSwitch(adjSwitch, linkNo, curCycle) is called.

Specified by:
moveSwitchOutputBufferToInputBufferOfNodeSwitch in interface Switch
Parameters:
curCycle - simulation cycle
See Also:
Network.moveSwitchTrafficFromOutputBufferToInputBufferOfNodeSwitch(int), forwardFlitToNode(Node, int, int), forwardFlitToSwitch(FatTreeSwitch, int, int)

isVCFreeInSwitch

public boolean isVCFreeInSwitch(int linkNo,
                                int vcId)
Description copied from interface: Switch
Checks if the virtual channels in the input buffer of a particular physical link is available to be assigned to a new incoming packet.

Specified by:
isVCFreeInSwitch in interface Switch
Parameters:
linkNo - input physical link number
vcId - virtual channel number
Returns:
true-if the virtual channel is free, false-otherwise.
See Also:
InputLinkController.isVCFree(int)

getNumLinkActive

public int getNumLinkActive()
Description copied from interface: Switch
Returns the number of physical links for the switch

Specified by:
getNumLinkActive in interface Switch
Returns:
number of valid physical links

updateStatusAfterCycle

public void updateStatusAfterCycle(int curCycle)
Description copied from interface: Switch
Updates the statistical counters for a particular simulation cycle and re-initializes the temporary status variables.

Specified by:
updateStatusAfterCycle in interface Switch
Parameters:
curCycle - simulation cycle

getSwitchLevel

public int getSwitchLevel()
Returns the level of the Butterfly Fat Tree network where the switch is placed.

Returns:
the level

getSwitchIndex

public int getSwitchIndex()
Returns the index of the switch in the level of the Butterfly Fat Tree network where it is placed.

Returns:
the index

setAddress

public void setAddress(int addr)
Description copied from interface: Switch
Sets the address of the switch.

Specified by:
setAddress in interface Switch
Parameters:
addr - address of the switch

getAddress

public int getAddress()
Description copied from interface: Switch
Returns the address of the switch.

Specified by:
getAddress in interface Switch
Returns:
address of the switch

getAdjacentLinkNo

public int getAdjacentLinkNo(FatTreeSwitch fatSwitch)
Returns the number of the output physical link that connects a neighboring switch, either situated above or beneath this switch.

Parameters:
fatSwitch - neighboring Fat Tree Switch
Returns:
output link number

setAdjacentSwitch

public void setAdjacentSwitch(Switch sw,
                              int linkNo)
This method is not required for other purpose, so left as a blank implementation of the corresponding specified in the Switch interface.

Specified by:
setAdjacentSwitch in interface Switch
Parameters:
sw - adjacent switch reference
linkNo - the physical link number that connects these two switches

setNoOfVirtualLink

public void setNoOfVirtualLink(int no)
Description copied from interface: Switch
Sets the number of virtual channel per physical link information.

Specified by:
setNoOfVirtualLink in interface Switch
Parameters:
no - number of virtual channel per physical link

setNoOfPhysicalLink

public void setNoOfPhysicalLink(int no)
Description copied from interface: Switch
Sets the maximum number of physical links information.

Specified by:
setNoOfPhysicalLink in interface Switch
Parameters:
no - maximum number of physical links

getNoOfPhysicalLink

public int getNoOfPhysicalLink()
Description copied from interface: Switch
Returns the maximum number of physical links information.

Specified by:
getNoOfPhysicalLink in interface Switch
Returns:
maximum number of physical links

getNoOfVirtualLink

public int getNoOfVirtualLink()
Description copied from interface: Switch
Returns the number of virtual channel per physical link information.

Specified by:
getNoOfVirtualLink in interface Switch
Returns:
number of virtual channel per physical link