Commit b49f9e91 authored by uahhx's avatar uahhx

sync

TODO: buffer behaviour check.
WHAT. WHY. WHAT IS HAPPENING. HALP.
check why globaltimestamp w/o wait is getting these ridiculous buffer usages/number of live packets

update: we got leaking packets, apparently at the master node
parent 4ec63703
package FunnelNetSim;
import FunnelNetSim.Nodes.Node;
import java.util.LinkedList;
public class DataPacket {
private messageType mType;
private messageState mState;
......@@ -10,6 +14,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 boolean isControlPacket; //might want to implement just unsing a bool later on, for info it might be better to use the enum though
......@@ -91,4 +96,13 @@ public class DataPacket {
public void setFinalAge(int currentCycle) {
this.finalAge = currentCycle-timeStamp;
}
public DataPacket visit(Node visitedNode) {
netPath.add(visitedNode);
return this;
}
public LinkedList<Node> getNetPath() {
return netPath;
}
}
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;
......@@ -129,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;
......@@ -172,4 +174,27 @@ public class FunnelNet {
public void printMe(String printMe) {
System.out.println(cycleCounter + ": " + printMe);
}
public HashSet<DataPacket> bufferedContents() {
HashSet<DataPacket> packets = new HashSet<DataPacket>();
for (Node node : allNodes) {
for (SlinkyBuffer<DataPacket> buffer : node.getSubBuffers()) {
packets.addAll(buffer.getBuffer());
}
for (LinkedList<DataPacket> incLine : node.getSubIncomingLines()) {
packets.addAll(incLine);
}
for (DataPacket inc : node.getSubIncoming()) {
if (inc != null)
packets.add(inc);
}
for (SlinkyBuffer<DataPacket> buffer : node.getSuperBuffers()) {
packets.addAll(buffer.getBuffer());
}
if (node.getSuperIncoming() != null)
packets.add(node.getSuperIncoming());
packets.addAll(node.getSuperIncomingLine());
}
return packets;
}
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ public class MasterNode extends Node {
private int topAge = 0;
public int noOOOEx = 0;
public int idleTicks = -1;
public MasterNode(int layerNumber, int nodeNumber, FunnelNet parentNet) {
super(layerNumber, nodeNumber, parentNet);
......@@ -26,11 +27,14 @@ public class MasterNode extends Node {
if (superIncoming != null)
System.out.println("WHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAT");
superIncoming = selectFromFrontRow(); //uses the superIncoming variable because downwardCom refers to it. /should/ run smoothly. TODO: make sure this actually does run smoothly
if (superIncoming == null) {
//parentNet.printMe("MASTER IDLE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
if (idleTicks < 0 && superIncoming != null)
idleTicks = 0;
if (idleTicks >= 0 && superIncoming == null) {
parentNet.printMe("MASTER IDLE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
idleTicks++;
}
if (superIncoming != null) {
if (SimHost.verbose)
if (SimHost.verbose(16))
System.out.println("Master processing " + superIncoming.toString());
superIncoming.setMState(DataPacket.messageState.PROCESSED);
if (superIncoming.getTimeStamp() < topAge) {
......
......@@ -101,7 +101,7 @@ public abstract class Node {
if (line.get(i).decrementLatencyCounter()) {
if(i != line.size()-1)
System.out.println("Warning: Line holds Packets beyond the currently forwarded one!");
if (SimHost.verbose)
if (SimHost.verbose(5))
System.out.println("Packet reached " + this.toString());
return line.remove(i);
}
......@@ -187,9 +187,10 @@ public abstract class Node {
if (curSubBuf.limitReached() == subSendEnableM[i]) { //if the limit is reached and the sub is currently allowed to send (or vice versa), send control packet
subSendEnableM[i] = !curSubBuf.limitReached();
selectedMessage = new DataPacket(-1, parentNet.packetLatency, parentNet.getCycleCounter(), DataPacket.messageType.STOPSTART); //send StartStop K-Flagged segment.
if(SimHost.verbose) {
System.out.println(nodeID() + " SubBuffer no." + i + (subSendEnableM[i] ? " free again" : " reached limit"));
if (superIncDest == i)
if(SimHost.verbose(2)) {
if(SimHost.verbose(1))
System.out.println(nodeID() + " SubBuffer no." + i + (subSendEnableM[i] ? " free again" : " reached limit"));
else if (superIncDest == i)
parentNet.printMe("!!!!! This blocked message " + (curSuperBuf.isEmpty() ? superIncoming.getPacketID() : curSuperBuf.lookAtBuffer().getPacketID()));
}
}
......@@ -224,7 +225,7 @@ public abstract class Node {
public void send(DataPacket message, Node target) {
if (message != null && target != null)
target.receive(message, this);
target.receive(message.visit(target), this);
}
/**
......@@ -264,7 +265,7 @@ public abstract class Node {
LinkedList<DataPacket> incomingLine = subNumber < 0 ? superIncomingLine : subIncomingLines.get(subNumber);
message.resetLatencyCounter(parentNet.packetLatency);
incomingLine.addFirst(message);
if (SimHost.verbose)
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))));
}
......
......@@ -51,7 +51,7 @@ public class SlaveNode extends Node {
if (superIncoming != null) {
superIncoming.setFinalAge(parentNet.getCycleCounter());
int age = superIncoming.getFinalAge();
if (SimHost.verbose)
if (SimHost.verbose(33))
System.out.println("--------- Message no. " + superIncoming.getPacketID() + " from " + superIncoming.getOrigin() +
" returned to " + getNodeNumber() + " after " + (age) + " cycles");
parentNet.livePackets.remove(superIncoming);
......@@ -85,11 +85,11 @@ public class SlaveNode extends Node {
if (superBuffers.isEmpty() && superSendEnableS) {
parentNet.livePackets.add(newPacket);
send(newPacket, superNeighbor);
if (SimHost.verbose)
if (SimHost.verbose(33))
System.out.println("created new Packet");
return true;
}
//if (SimHost.verbose)
if (SimHost.verbose(32))
System.out.println("!!!!!!!!! could not create new Packet!");
newPacket.setFinalAge(0);
rejected = true;
......
......@@ -24,7 +24,7 @@ public class SlinkyBuffer<T> {
buffer.addFirst(newPkt);
//warning remove me:
if (SimHost.verbose) {
if (SimHost.verbose(2)) {
if (buffer.size() == FunnelNet.bufferSize)
System.out.println("Warning - buffer full : " + this.toString());
else if (buffer.size() > FunnelNet.bufferSize)
......@@ -39,7 +39,7 @@ public class SlinkyBuffer<T> {
public T takeFromBuffer() {
if (buffer.size() <= 0)
return null;
if (SimHost.verbose && buffer.size() == FunnelNet.bufferSize)
if (SimHost.verbose(2) && buffer.size() == FunnelNet.bufferSize)
System.out.println("Buffer free again : " + this.toString());
return buffer.removeLast();
}
......@@ -74,4 +74,8 @@ public class SlinkyBuffer<T> {
public boolean isEmpty() {
return buffer.isEmpty();
}
public LinkedList<T> getBuffer() {
return buffer;
}
}
......@@ -6,9 +6,23 @@ import FunnelNetSim.Strategies.GlobalTimeStampPlus;
import FunnelNetSim.Strategies.RoundRobin;
import FunnelNetSim.Visualizers.PseudoGraphics;
import java.util.HashSet;
public class SimHost {
public static final boolean verbose = false;//true;
/*
0: super verbose
1: buffer info
2: line info
3: send/recv info
4: master info
5: slave info
*/
public static final byte verboseByte = (0b0000 << 4) + 0b0000;//true;
public static boolean verbose(int requiredFlags) {
return (verboseByte & (byte)requiredFlags) >= requiredFlags;
}
public static void main(String[] args) {
// for (int i = 0; i < 10; i++) {
......@@ -64,8 +78,9 @@ public class SimHost {
}
private static void test2() {
FunnelNet net = new FunnelNet(new GlobalTimeStamp(), 27*3*3*3, 3, 0);
for (int i = 0; i < 1000000; 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 < 100000; 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());
......@@ -79,7 +94,12 @@ public class SimHost {
System.out.println("Max RT: " + net.maxRT);
System.out.println("Average RT: " + net.cumulativeRT/(float)net.successfulPackets.size());
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());
}
......
......@@ -7,24 +7,26 @@ public class GlobalTimeStamp extends Strategy {
@Override
public int selectForwardingSub(DataPacket[] frontRow) {
boolean visited = false;
boolean rejected = false;
int oldest = -1;
int oldestStamp = Integer.MAX_VALUE;
for (int i = 0; i < frontRow.length; i++) {
DataPacket curPacket = frontRow[i];
if (curPacket != null)
if (curPacket != null) {
visited = true;
rejected |= shouldReject(curPacket);
if (curPacket != null && !shouldReject(curPacket)) {
if (curPacket.getTimeStamp() < oldestStamp) {
oldest = i;
oldestStamp = curPacket.getTimeStamp();
if (curPacket != null && !shouldReject(curPacket)) {
if (curPacket.getTimeStamp() < oldestStamp) {
oldest = i;
oldestStamp = curPacket.getTimeStamp();
}
}
}
//return i;
}
if (visited && oldest <= -1) //TODO: removeme
System.out.println("NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO");
System.out.println("NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO " + (rejected ? " it's okay" : " IT'S NOT OKAY"));
return oldest;
}
......
......@@ -15,7 +15,7 @@ public class PseudoGraphics {
if (currentNode != null) {
currentNode.getSubIncoming();
}
else if (SimHost.verbose)
else if (SimHost.verbose(1))
System.out.println("Layer " + i + ", Node " + j + " is 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