Commit 91e270c3 authored by uahhx's avatar uahhx

added latency cycle-number-depenency on time based latency

parent 1b8f85ce
package FunnelNetSim;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import FunnelNetSim.Nodes.*;
import FunnelNetSim.Strategies.Strategy;
import javax.xml.crypto.Data;
public class FunnelNet {
private Strategy strategy;
private int cycleCounter = 0;
public final int packetLatency = 1; //in cycles
public final int packetLatency = 70000; //in ns
public final int realTimeConstraint = 10000; //RTC in ns
public final int nodeClock = 125; //node Clockspeed in MHz
public final int packetCycleLatency = (int)Math.ceil((packetLatency*nodeClock)/1000f); //rounded up because packets won't arrive until a full cycle is complete
public final int rtcCycles = (realTimeConstraint*nodeClock)/1000; //rounded down because it has to arrive before the point-value deadline
// public final int rtcCycles = 510;
//public static final int dataWidth = 64/8; //dataWidth in number of segments per transmission. this should be a round number even if it wasn't forced by type.
private final int minBufferSize = packetLatency*2 + 1;
public static final int bufferSize = 16; //max # of packets per buffer
private final int minBufferSize = packetCycleLatency *3 + 1; //todo: check that it's not actually "packetLatency*2 + 1"
public static final int bufferSize = 22; //max # of packets per buffer
//public static final int bufferSize = 4 + minBufferSize; //max # of packets per buffer
//public static final int bufferSize = 2*minBufferSize; //max # of packets per buffer
public final int realTimeConstraint = 10000; //RTC in ns
public final int nodeClock = 125; //node Clockspeed in MHz
// public final int rtcCycles = (realTimeConstraint*nodeClock)/1000; //warning: put this back
public final int rtcCycles = 510;
private int numDownConnections;//7; //total number of connections is this+1
private int numSlaves; //7*7*7*7;
......
......@@ -6,7 +6,6 @@ import FunnelNetSim.SimHost;
import FunnelNetSim.Strategies.Strategy;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
public abstract class Node {
......@@ -63,9 +62,9 @@ public abstract class Node {
this.subIncomingLines = new ArrayList<LinkedList<DataPacket>>(subNeighbors.length);
this.superBuffers = new ArrayList<SlinkyBuffer>(subNeighbors.length);
for (int i = 0; i < subNeighbors.length; i++) {
subBuffers.add(new SlinkyBuffer(parentNet.packetLatency, FunnelNet.bufferSize));
subBuffers.add(new SlinkyBuffer(parentNet.packetCycleLatency, FunnelNet.bufferSize));
subIncomingLines.add(new LinkedList<DataPacket>());
superBuffers.add(new SlinkyBuffer(parentNet.packetLatency, FunnelNet.bufferSize*2));
superBuffers.add(new SlinkyBuffer(parentNet.packetCycleLatency, FunnelNet.bufferSize*2));
subSendEnableM[i] = true; //initially all slaves are able to send
}
......@@ -203,7 +202,7 @@ public abstract class Node {
//priority 1: send stop if required
if (subSendEnableM[i] && curSubBuf.limitReached()) {
subSendEnableM[i] = false;
selectedMessage = new DataPacket(-1, parentNet.packetLatency, parentNet.getCycleCounter(), DataPacket.messageType.STOPSTART);
selectedMessage = new DataPacket(-1, parentNet.packetCycleLatency, parentNet.getCycleCounter(), DataPacket.messageType.STOPSTART);
}
//priority 2: forward messages from super
else {
......@@ -218,7 +217,7 @@ public abstract class Node {
//priority 4: send start if free
if (selectedMessage == null && !subSendEnableM[i] && !curSubBuf.limitReached()) {
subSendEnableM[i] = true;
selectedMessage = new DataPacket(-1, parentNet.packetLatency, parentNet.getCycleCounter(), DataPacket.messageType.STOPSTART);
selectedMessage = new DataPacket(-1, parentNet.packetCycleLatency, parentNet.getCycleCounter(), DataPacket.messageType.STOPSTART);
}
//add unsent super message to buffer
......@@ -286,7 +285,7 @@ public abstract class Node {
}
LinkedList<DataPacket> incomingLine = subNumber < 0 ? superIncomingLine : subIncomingLines.get(subNumber);
message.resetLatencyCounter(parentNet.packetLatency);
message.resetLatencyCounter(parentNet.packetCycleLatency);
incomingLine.addFirst(message);
if (SimHost.verbose(8))
System.out.println(nodeID() + " receiving Message no. " + message.getPacketID() + " from " + (subNumber < -1 ? "unconnected" : (subNumber == -1 ? superNeighbor.nodeID() : (subNumber >= 0 ? subNeighbors[subNumber].nodeID() : subNumber))));
......
......@@ -82,7 +82,7 @@ public class SlaveNode extends Node {
}
public boolean createPacket() {
DataPacket newPacket = new DataPacket(this.getNodeNumber(), parentNet.packetLatency, parentNet.getCycleCounter(), DataPacket.messageType.REGULAR);
DataPacket newPacket = new DataPacket(this.getNodeNumber(), parentNet.packetCycleLatency, parentNet.getCycleCounter(), DataPacket.messageType.REGULAR);
if (superBuffers.isEmpty() && superSendEnableS) {
parentNet.livePackets.add(newPacket);
send(newPacket, superNeighbor);
......
......@@ -88,23 +88,23 @@ public class SimHost {
// FunnelNet net = new FunnelNet(new GlobalTimeStamp(), 65, 2, 0);
// FunnelNet net = new FunnelNet(new GlobalTimeStampRR(), 27*3*3*3, 3, 0);
// FunnelNet net = new FunnelNet(new RoundRobin(), 27*3*3*3, 3, 0);
// FunnelNet net = new FunnelNet(new GlobalTimeStampLARRR(), 27*3*3*3, 3, 0);
FunnelNet net = new FunnelNet(new LocalTimeStampRR(), 27*3*3*3, 3, 0);
FunnelNet net = new FunnelNet(new GlobalTimeStampLARRR(), 27*3*3*3, 3, 0);
// FunnelNet net = new FunnelNet(new LocalTimeStampRR(), 27*3*3*3, 3, 0);
int prevUnbuf = 0;
for (int i = 0; i < 1000000; i++) {
for (int i = 0; i < 100000000; i++) {
int cycleNo = net.tickNet();
if (cycleNo % 1000 == 0) {
System.out.println(cycleNo +": Average RT: " + net.cumulativeRT / (float)net.successfulPacketCounter + ", # LivePackets: " + net.livePackets.size());
}
// if (cycleNo == 10)
// net.slavesNodes.iterator().next().createPacket();
HashSet<DataPacket> packetCopy = (HashSet<DataPacket>)net.livePackets.clone();
packetCopy.removeAll(net.bufferedContents());
if (packetCopy.size() > prevUnbuf) {
System.out.println("do masteroutput here");
prevUnbuf = packetCopy.size();
System.out.println("no of unbuffered live packets: " + packetCopy.size());
if (cycleNo % 10000 == 0) {
System.out.println(cycleNo +": Average RT: " + net.cumulativeRT / (float)net.successfulPacketCounter + ", # LivePackets: " + net.livePackets.size() + ", # RejectedPackets: " + net.rejectedPackets.size() + ", Max RT: " + net.maxRT);
}
//// if (cycleNo == 10)
//// net.slavesNodes.iterator().next().createPacket();
// HashSet<DataPacket> packetCopy = (HashSet<DataPacket>)net.livePackets.clone();
// packetCopy.removeAll(net.bufferedContents());
// if (packetCopy.size() > prevUnbuf) {
// System.out.println("do masteroutput here");
// prevUnbuf = packetCopy.size();
// System.out.println("no of unbuffered live packets: " + packetCopy.size());
// }
}
System.out.println("no of live packets: " + net.livePackets.size());
System.out.println("no of successful packets: " + net.successfulPacketCounter);
......
......@@ -46,7 +46,7 @@ public class GlobalTimeStampLARRR extends Strategy {
FunnelNet net = parentNode.parentNet;
int age = net.getCycleCounter() - packet.getTimeStamp();
int bestCaseUpward = parentNode.getLayerNumber();
int worstCaseDownward = ((net.getNumLayers()-1)*2); //todo: make sure that this actually is the worst case;
int worstCaseDownward = ((net.getNumLayers()-1)*(2+FunnelNet.bufferSize)); //todo: make sure that this actually is the worst case;
if (age + bestCaseUpward + worstCaseDownward > parentNode.parentNet.rtcCycles) {
packet.setMState(dropPackets ? DataPacket.messageState.DROP : DataPacket.messageState.REJECTED);
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment