Commit 784ceacd authored by uahhx's avatar uahhx

sync

TODO: buffer behaviour check.
small leak at master node: reliably happens at cycle 1253 with all 3 lines when slave fire chance = 1f
parent 0fcbcf33
......@@ -2,6 +2,7 @@ package FunnelNetSim;
import FunnelNetSim.Nodes.Node;
import java.util.HashMap;
import java.util.LinkedList;
public class DataPacket {
......@@ -14,7 +15,7 @@ public class DataPacket {
private int lastCounter = 1;
private int timeStamp; //for beeva, but also used by global timestamp strategy
private int finalAge = -1;
private LinkedList<Node> netPath = new LinkedList<Node>();
private HashMap<Integer, Node> netPath = new HashMap<Integer, Node>();
//private boolean isControlPacket; //might want to implement just unsing a bool later on, for info it might be better to use the enum though
......@@ -97,12 +98,12 @@ public class DataPacket {
this.finalAge = currentCycle-timeStamp;
}
public DataPacket visit(Node visitedNode) {
netPath.add(visitedNode);
public DataPacket visit(int timeStamp, Node visitedNode) {
netPath.put(timeStamp, visitedNode);
return this;
}
public LinkedList<Node> getNetPath() {
public HashMap<Integer, Node> getNetPath() {
return netPath;
}
}
......@@ -131,7 +131,7 @@ public class FunnelNet {
//for (int i = 0; i < newSlaveNodes.length - homogeneousReduction - (inhomogeneousReduction > 0 ? 1 : 0); i++) {
SlaveNode[] newSlaveNodes = new SlaveNode[numNewNodes - homogeneousReduction - (inhomogeneousReduction > 0 ? 1 : 0)];
for (int j = 0; j < newSlaveNodes.length; j++) {
SlaveNode curNewNode = new SlaveNode(layerNumber, curNode.getNodeNumber()*numNewNodes+j, this, 1f/(numSlaves));
SlaveNode curNewNode = new SlaveNode(layerNumber, curNode.getNodeNumber()*numNewNodes+j, this, 1f);///(numSlaves));
curNewNode.setSuperNeighbor(curNode);
curNewNode.setSubNeighbors(new Node[0]);
newSlaveNodes[j] = curNewNode;
......
......@@ -244,7 +244,7 @@ public abstract class Node {
public void send(DataPacket message, Node target) {
if (message != null && target != null)
target.receive(message.visit(target), this);
target.receive(message.visit(parentNet.getCycleCounter(), target), this);
}
/**
......
......@@ -8,7 +8,6 @@ import java.util.LinkedList;
public class SlinkyBuffer<T> {
private LinkedList<T> buffer;
private final int latency;
private boolean hitLimit = false;
public SlinkyBuffer(int latency) {
this.buffer = new LinkedList<T>();
......
......@@ -83,12 +83,17 @@ 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);
int prevUnbuf = 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());
}
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());
}
}
......@@ -111,7 +116,11 @@ public class SimHost {
for (DataPacket dataPacket : packetCopy) {
if (dataPacket.getMState() == DataPacket.messageState.UNPROCESSED)
processedCounter++;
Node lastNode = dataPacket.getNetPath().getLast();
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)
......
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