Commit 331d95d4 authored by uahhx's avatar uahhx

sync

TODO: enhance packet rejection so it can send elegible packets at the same time. might require dual-channel-ram-like buffers or something idk.
checked buffers - they are behaving as intended. accidentally made it work correctly based on incorrect work on paper :3
parent f3ec13cb
......@@ -19,12 +19,14 @@ public class FunnelNet {
//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.
public static final int bufferSize = 8; //max # of packets per buffer
//public static final int bufferSize = 4 + packetLatency*2; //max # of packets per buffer
private final int minBufferSize = packetLatency*2 + 1;
public static final int bufferSize = 16; //max # of packets per buffer
//public static final int bufferSize = 4 + 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 = (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;
......
......@@ -30,7 +30,8 @@ public class MasterNode extends Node {
if (idleTicks < 0 && superIncoming != null)
idleTicks = 0;
if (idleTicks >= 0 && superIncoming == null) {
parentNet.printMe("MASTER IDLE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
if(SimHost.verbose(0b10001))
parentNet.printMe("MASTER IDLE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
idleTicks++;
}
if (superIncoming != null) {
......
......@@ -62,9 +62,9 @@ public abstract class Node {
this.subIncomingLines = new ArrayList<LinkedList<DataPacket>>(subNeighbors.length);
this.superBuffers = new ArrayList<SlinkyBuffer<DataPacket>>(subNeighbors.length);
for (int i = 0; i < subNeighbors.length; i++) {
subBuffers.add(new SlinkyBuffer<DataPacket>(parentNet.packetLatency));
subBuffers.add(new SlinkyBuffer<DataPacket>(parentNet.packetLatency, FunnelNet.bufferSize));
subIncomingLines.add(new LinkedList<DataPacket>());
superBuffers.add(new SlinkyBuffer<DataPacket>(parentNet.packetLatency));
superBuffers.add(new SlinkyBuffer<DataPacket>(parentNet.packetLatency, FunnelNet.bufferSize*2));
subSendEnableM[i] = true; //initially all slaves are able to send
}
......@@ -187,12 +187,14 @@ public abstract class Node {
if (subIncoming[i] == message)
subIncoming[i] = null;
else
subBuffers.get(i).takeFromBuffer();
// subBuffers.get(i).takeFromBuffer(); //todo: remove obsolete
curSubBuf.takeFromBuffer();
if (message.getMState() == DataPacket.messageState.REJECTED)
selectedMessage = message;
subFrontRow[i] = null; //just to make sure.
}
curSubBuf.add(subIncoming[i]); //if a packet got rejected, the limit reached check in the following if statement is not necessary. but also, this always needs to be added if it wasn't null or nulled!
subIncoming[i] = null;
//add unnulled (aka unsent) incoming to buffer, update buffer limit state if necessary
if (selectedMessage == null) {
if (curSubBuf.limitReached() == subSendEnableM[i]) { //if the limit is reached and the sub is currently allowed to send (or vice versa), send control packet
......
......@@ -8,10 +8,15 @@ import java.util.LinkedList;
public class SlinkyBuffer<T> {
private LinkedList<T> buffer;
private final int latency;
private final int limit;
private final int maxSize;
public static int overfillCount = 0;
public SlinkyBuffer(int latency) {
public SlinkyBuffer(int latency, int maxSize) {
this.buffer = new LinkedList<T>();
this.latency = latency;
this.maxSize = maxSize;
this.limit = maxSize - (2*latency -1);
}
/**
......@@ -26,8 +31,10 @@ public class SlinkyBuffer<T> {
if (SimHost.verbose(2)) {
if (buffer.size() == FunnelNet.bufferSize)
System.out.println("Warning - buffer full : " + this.toString());
else if (buffer.size() > FunnelNet.bufferSize)
System.out.println("This should not be happening, buffer got overfilled by: " + (buffer.size() - FunnelNet.bufferSize) + " : " + this.toString());
else if (buffer.size() > maxSize) {
System.out.println("This should not be happening, buffer got overfilled by: " + (buffer.size() - maxSize) + " : " + this.toString());
overfillCount++;
}
}
}
......@@ -38,7 +45,7 @@ public class SlinkyBuffer<T> {
public T takeFromBuffer() {
if (buffer.size() <= 0)
return null;
if (SimHost.verbose(2) && buffer.size() == FunnelNet.bufferSize)
if (SimHost.verbose(2) && buffer.size() == maxSize)
System.out.println("Buffer free again : " + this.toString());
return buffer.removeLast();
}
......@@ -58,7 +65,8 @@ public class SlinkyBuffer<T> {
*/
public boolean limitReached() {
//return buffer.size() + 2*FunnelNet.packetLatency -1 >= FunnelNet.bufferSize; //this actually makes it hit the buffer limit, better be careful around that
boolean result = buffer.size() + 2*latency >= FunnelNet.bufferSize;
boolean result = buffer.size() >= limit; //this actually makes it hit the buffer limit, better be careful around that
// boolean result = buffer.size() + 2*latency >= FunnelNet.bufferSize;
// if (SimHost.verbose) {
// if (result && !hitLimit)
......
package FunnelNetSim;
import FunnelNetSim.Nodes.NetNode;
import FunnelNetSim.Nodes.Node;
import FunnelNetSim.Nodes.SlaveNode;
import FunnelNetSim.Nodes.SlinkyBuffer;
import FunnelNetSim.Strategies.GlobalTimeStamp;
import FunnelNetSim.Strategies.GlobalTimeStampLARRR;
import FunnelNetSim.Strategies.GlobalTimeStampRR;
......@@ -20,7 +22,7 @@ public class SimHost {
4: master info
5: slave info
*/
public static final byte verboseByte = (0b0000 << 4) + 0b0000;//true;
public static final byte verboseByte = (0b0001 << 4) + 0b0011;//true;
public static boolean verbose(int requiredFlags) {
return (verboseByte & (byte)requiredFlags) >= requiredFlags;
......@@ -37,6 +39,8 @@ public class SimHost {
// }
// test1();
test2();
// test3();
// for (int i = 0; i < 15; i++) {
// System.out.println("-");
// }
......@@ -131,7 +135,91 @@ public class SimHost {
}
System.out.println(processedCounter);
System.out.println(terminodes);
System.out.println(SlinkyBuffer.overfillCount);
}
private static void test3() {
FunnelNet net = new FunnelNet(new GlobalTimeStampRR(), 1, 1, 7);
Node testNode = net.master.getSubNeighbors()[0].getSubNeighbors()[0];
int a = 20;
int b = a + 3;
int c = b +32;
for (int i = 0; i < a; i++) {
System.out.println(net.getCycleCounter());
net.tickNet();
System.out.println();
}
testNode.lockNodeToggle();
for (int i = a; i < b; i++) {
System.out.println(net.getCycleCounter());
net.tickNet();
for (int j = 1; j < net.layerNodes.size()-1; j++) {
Node curNode = net.layerNodes.get(j).get(0);
int bufSize = curNode.getSubBuffers().get(0).getBuffer().size();
System.out.print("L" + j + "@" + bufSize + ", " + curNode.isSuperSendEnableS() + ": " + curNode.getSubIncoming()[0] + " |");
for (DataPacket packet : curNode.getSubBuffers().get(0).getBuffer()) {
System.out.print("| "+ packet);
}
System.out.println();
}
System.out.println();
}
testNode.lockNodeToggle();
for (int i = b; i < c; i++) {
System.out.println(net.getCycleCounter());
net.tickNet();
for (int j = 1; j < net.layerNodes.size()-1; j++) {
Node curNode = net.layerNodes.get(j).get(0);
int bufSize = curNode.getSubBuffers().get(0).getBuffer().size();
System.out.print("L" + j + "@" + bufSize + ", " + curNode.isSuperSendEnableS() + ": " + curNode.getSubIncoming()[0] + " |");
for (DataPacket packet : curNode.getSubBuffers().get(0).getBuffer()) {
System.out.print("| "+ packet);
}
System.out.println();
}
System.out.println();
}
printResults(net);
}
private static void printResults(FunnelNet net) {
System.out.println("no of live packets: " + net.livePackets.size());
System.out.println("no of successful packets: " + net.successfulPacketCounter);
System.out.println("no of rejected packets: " + net.rejectedPackets.size());
System.out.println("no of dropped packets: " + net.droppedPackets.size());
System.out.println("Min RT: " + net.minRT);
System.out.println("Max RT: " + net.maxRT);
System.out.println("Average RT: " + net.cumulativeRT/(float)net.successfulPacketCounter);
System.out.println("Number of OOOEx: " + net.master.noOOOEx);
System.out.println("Number of Master Idle Ticks: " + net.master.idleTicks);
HashSet<DataPacket> packetCopy = (HashSet<DataPacket>)net.livePackets.clone();
packetCopy.removeAll(net.bufferedContents());
System.out.println("no of unbuffered live packets: " + packetCopy.size());
System.out.println(net.livePackets.size());
HashMap<Node, Integer> terminodes = new HashMap<Node, Integer>();
int processedCounter = 0;
for (DataPacket dataPacket : packetCopy) {
if (dataPacket.getMState() == DataPacket.messageState.UNPROCESSED)
processedCounter++;
int lastNodeStamp = 0;
for (Integer timeStamp : dataPacket.getNetPath().keySet())
if (timeStamp > lastNodeStamp)
lastNodeStamp = timeStamp;
Node lastNode = dataPacket.getNetPath().get(lastNodeStamp);
// if (!(lastNode instanceof MasterNode))
// System.out.println(dataPacket.getTimeStamp());
if (terminodes.get(lastNode) == null)
terminodes.put(lastNode, 1);
else
terminodes.put(lastNode, terminodes.get(lastNode)+1);
}
System.out.println(processedCounter);
System.out.println(terminodes);
}
}
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