Commit 0fcbcf33 authored by uahhx's avatar uahhx

sync

TODO: buffer behaviour check.
fixed major leak in downwardCom
small leak at master node, all of the lost packets are unprocessed. no idea what's happening
parent b49f9e91
......@@ -19,7 +19,7 @@ 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 = 24; //max # of packets per buffer
public static final int bufferSize = 8; //max # of packets per buffer
//public static final int bufferSize = 4 + packetLatency*2; //max # of packets per buffer
public final int realTimeConstraint = 10000; //RTC in ns
......
......@@ -117,6 +117,8 @@ public abstract class Node {
lockNodeToggle();
//superSendEnableS ^= true;
superIncoming = null; //remove packet so it doesn't get handled by the code for regular data packets. in vhdl this will need to be multiplexed
if (this instanceof MasterNode)
superIncoming.getMState(); //warning: this is meant to crash the thing and should not happen. remove when cleaning up
}
}
......@@ -143,14 +145,21 @@ public abstract class Node {
int subSelect = strategy.selectForwardingSub(subFrontRow);
if(subSelect >= 0 && subSelect < subFrontRow.length) {
if(subBuffers.get(subSelect).isEmpty())
subIncoming[subSelect] = null;
else
subBuffers.get(subSelect).takeFromBuffer();
DataPacket result = subFrontRow[subSelect];
subFrontRow[subSelect] = null;
return result;
//if(subSelect >= 0 && subSelect < subFrontRow.length) {
if(subSelect >= 0) {
if (subSelect < subFrontRow.length) {
if(subBuffers.get(subSelect).isEmpty())
subIncoming[subSelect] = null;
else
subBuffers.get(subSelect).takeFromBuffer();
DataPacket result = subFrontRow[subSelect];
subFrontRow[subSelect] = null;
return result;
}
else {
return null;
}
}
return null;
//return (subSelect >= 0 && subSelect < subFrontRow.length) ? subFrontRow[subSelect] : null;
......@@ -172,6 +181,7 @@ public abstract class Node {
curSubBuf = subBuffers.get(i);
curSuperBuf = superBuffers.get(i);
//check frontRow for packet to be dropped or rejected
if (subFrontRow[i] != null && subFrontRow[i].getMState() != DataPacket.messageState.UNPROCESSED) {
DataPacket message = subFrontRow[i];
if (subIncoming[i] == message)
......@@ -182,6 +192,7 @@ public abstract class Node {
selectedMessage = message;
subFrontRow[i] = null; //just to make sure.
}
//add unnulled (aka unsent) incoming to buffer, update buffer limit state if necessary
if (selectedMessage == null) {
curSubBuf.add(subIncoming[i]);
if (curSubBuf.limitReached() == subSendEnableM[i]) { //if the limit is reached and the sub is currently allowed to send (or vice versa), send control packet
......@@ -194,18 +205,26 @@ public abstract class Node {
parentNet.printMe("!!!!! This blocked message " + (curSuperBuf.isEmpty() ? superIncoming.getPacketID() : curSuperBuf.lookAtBuffer().getPacketID()));
}
}
//forward super messages downward
else if (!curSuperBuf.isEmpty() || superIncDest == i) {
selectedMessage = curSuperBuf.isEmpty() ? superIncoming : curSuperBuf.takeFromBuffer();
if (superIncDest == i)
// boolean skipBuffer = curSuperBuf.isEmpty();
// selectedMessage = skipBuffer ? superIncoming : curSuperBuf.takeFromBuffer();
if (!curSuperBuf.isEmpty())
selectedMessage = curSuperBuf.takeFromBuffer();
else if (superIncDest == i) {
selectedMessage = superIncoming;
superIncoming = null;
}
}
}
//add unsent super message to buffer
if (superIncDest == i && superIncoming != null) {
curSuperBuf.add(superIncoming);
superIncoming = null;
if (curSuperBuf.limitReached())
parentNet.printMe("a superbuffer hit limit! this should not be happening!"); //NOTE: use this <PLACE> to check super buffer fill state later (implement buffer.size())
}
//send message to neighbor
if (selectedMessage != null)
send(selectedMessage, subNeighbors[i]);
......
package FunnelNetSim;
import FunnelNetSim.Nodes.MasterNode;
import FunnelNetSim.Nodes.Node;
import FunnelNetSim.Nodes.SlaveNode;
import FunnelNetSim.Strategies.GlobalTimeStamp;
import FunnelNetSim.Strategies.GlobalTimeStampPlus;
import FunnelNetSim.Strategies.RoundRobin;
import FunnelNetSim.Visualizers.PseudoGraphics;
import java.util.HashMap;
import java.util.HashSet;
public class SimHost {
......@@ -78,12 +81,15 @@ public class SimHost {
}
private static void test2() {
//FunnelNet net = new FunnelNet(new GlobalTimeStamp(), 27*3*3*3, 3, 0);
FunnelNet net = new FunnelNet(new RoundRobin(), 27*3*3*3, 3, 0);
for (int i = 0; i < 100000; i++) {
FunnelNet net = new FunnelNet(new GlobalTimeStamp(), 27*3*3*3, 3, 0);
// FunnelNet net = new FunnelNet(new RoundRobin(), 27*3*3*3, 3, 0);
for (int i = 0; i < 5000000; i++) {
int cycleNo = net.tickNet();
if (cycleNo % 1000 == 0) {
System.out.println(cycleNo +": Average RT: " + net.cumulativeRT / (float) net.successfulPackets.size() + ", # LivePackets: " + net.livePackets.size());
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("no of live packets: " + net.livePackets.size());
......@@ -100,6 +106,21 @@ public class SimHost {
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++;
Node lastNode = dataPacket.getNetPath().getLast();
// 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