ComputeNode sourceNode = null; int mult;  if (init)
System.err.println("Creating switchcode linear: "+node);   int mult, sentItems = 0;   boolean cacheAlignSource = true; if (node.getPrevious() instanceof InputTraceNode) { OffChipBuffer buf = IntraTraceBuffer.getBuffer((InputTraceNode)node.getPrevious(), node).getNonRedundant(); if (buf != null && buf.getDest() instanceof OutputTraceNode && ((OutputTraceNode)buf.getDest()).isFileReader()) cacheAlignSource = false; }   boolean cacheAlignDest = true; if (node.getNext() instanceof OutputTraceNode) { OutputTraceNode output = (OutputTraceNode)node.getNext(); if (output.oneOutput() && OffChipBuffer.unnecessary(output) && output.getSingleEdge().getDest().isFileWriter() && OffChipBuffer.unnecessary(output.getSingleEdge().getDest())) cacheAlignDest = false; }    if (primePump) mult = filterInfo.primePump - (filterInfo.push == 0 ? 0 : (filterInfo.primePumpItemsNotConsumed() / filterInfo.push)); else if (init)
    private static void createSwitchCodeLinear(FilterTraceNode node, Trace parent, 					       FilterInfo filterInfo, boolean init, boolean primePump, 					       RawTile tile, RawChip rawChip) {	//createReceiveCode(0,  node,  parent,  filterInfo,  init,  primePump,  tile,  rawChip);	ComputeNode sourceNode = null;	int mult;		if (init)	    mult = filterInfo.initMult;	else 	    mult = filterInfo.steadyMult;		if (node.getPrevious().isFilterTrace())	    sourceNode = rawChip.getTile(((FilterTraceNode)node.getPrevious()).getX(),  					 ((FilterTraceNode)node.getPrevious()).getY());	else {	    if (KjcOptions.magicdram && node.getPrevious() !=  null &&		node.getPrevious().isInputTrace() &&		tile.hasIODevice()) 		sourceNode = tile.getIODevice();	    else 		return;	}	SwitchIPort src = rawChip.getIPort(sourceNode, tile);	SwitchIPort src2 = rawChip.getIPort2(sourceNode, tile);	sourceNode = null;	ComputeNode destNode = null;	if (node.getNext().isFilterTrace())	    destNode = rawChip.getTile(((FilterTraceNode)node.getNext()).getX(),  				       ((FilterTraceNode)node.getNext()).getY());	else {	    if (KjcOptions.magicdram && node.getNext() !=  null &&		node.getNext().isOutputTrace() && tile.hasIODevice())		destNode = tile.getIODevice();	    else		return;	}	SwitchOPort dest = rawChip.getOPort(tile, destNode);	SwitchOPort dest2 = rawChip.getOPort2(tile, destNode);	destNode = null;	FilterContent content = node.getFilter();	final int peek = content.getArray().length;	final int pop = content.getPopCount();	final int numPop = peek/pop;	final boolean begin=content.getBegin();	final boolean end=content.getEnd();	System.out.println("SRC: "+src);	System.out.println("DEST: "+dest);	SwitchCodeStore code = tile.getSwitchCode();	boolean first=true;	for(int i = 0; i<numPop-1; i++)	    for(int j = 0; j<pop; j++) {		FullIns ins = new FullIns(tile, new MoveIns(SwitchReg.R1, src));		if (KjcOptions.magicdram && node.getPrevious() != null &&		    node.getPrevious().isInputTrace())		    createMagicDramLoad((InputTraceNode)node.getPrevious(), 					node, (init || primePump), rawChip);		ins.addRoute(src, SwitchOPort.CSTI);		//if(!first) {		if(!end) {		    if (KjcOptions.magicdram && node.getPrevious() != null &&			node.getPrevious().isInputTrace())			createMagicDramLoad((InputTraceNode)node.getPrevious(), 					    node, (init || primePump), rawChip);		    if (KjcOptions.magicdram && node.getNext() != null &&			node.getNext().isOutputTrace())			createMagicDramStore((OutputTraceNode)node.getNext(), 					     node, (init || primePump), rawChip);		    ins.addRoute(src,dest);		    //}		}		code.appendIns(ins, init||primePump);		for(int k = i-1; k>= 0; k--) {		    FullIns newIns = new FullIns(tile);		    newIns.addRoute(SwitchReg.R1, SwitchOPort.CSTI);		    code.appendIns(newIns, init||primePump);		}		FullIns newIns=null;		if(!begin) {		    newIns=new FullIns(tile);		    if (KjcOptions.magicdram && node.getPrevious() != null &&			node.getPrevious().isInputTrace())			createMagicDramLoad((InputTraceNode)node.getPrevious(), 					    node, (init || primePump), rawChip);		    newIns.addRoute(src2, SwitchOPort.CSTI2);		    code.appendIns(newIns, init||primePump);		}		/*if(!first) {		    newIns = new FullIns(tile);		    newIns.addRoute(SwitchIPort.CSTO,dest);		    code.appendIns(newIns, init||primePump);		}		first=false;*/	    }	final int turns=content.getPos();	for(int turn=0;turn<turns;turn++)	    for(int j = 0; j<pop; j++) {		FullIns ins = new FullIns(tile, new MoveIns(SwitchReg.R1, src));		if (KjcOptions.magicdram && node.getPrevious() != null &&		    node.getPrevious().isInputTrace())		    createMagicDramLoad((InputTraceNode)node.getPrevious(), 					node, (init || primePump), rawChip);		ins.addRoute(src, SwitchOPort.CSTI);		if(!first) {		    if(!end) {			if (KjcOptions.magicdram && node.getPrevious() != null &&			    node.getPrevious().isInputTrace())			    createMagicDramLoad((InputTraceNode)node.getPrevious(), 						node, (init || primePump), rawChip);			if (KjcOptions.magicdram && node.getNext() != null &&			    node.getNext().isOutputTrace())			    createMagicDramStore((OutputTraceNode)node.getNext(), 						 node, (init || primePump), rawChip);			ins.addRoute(src,dest);		    }		}		code.appendIns(ins, init||primePump);		for(int k = numPop-2; k>= 0; k--) {		    FullIns newIns = new FullIns(tile);		    newIns.addRoute(SwitchReg.R1, SwitchOPort.CSTI);		    code.appendIns(newIns, init||primePump);		}		FullIns newIns=null;		if(!begin) {		    newIns=new FullIns(tile);		    if (KjcOptions.magicdram && node.getPrevious() != null &&			node.getPrevious().isInputTrace())			createMagicDramLoad((InputTraceNode)node.getPrevious(), 					    node, (init || primePump), rawChip);		    newIns.addRoute(src2, SwitchOPort.CSTI2);		    code.appendIns(newIns, init||primePump);		}		if(!first) {		    newIns = new FullIns(tile);		    if (KjcOptions.magicdram && node.getNext() != null &&			node.getNext().isOutputTrace())			createMagicDramStore((OutputTraceNode)node.getNext(), 					     node, (init || primePump), rawChip);		    newIns.addRoute(SwitchIPort.CSTO,dest2);		    code.appendIns(newIns, init||primePump);		}		first=false;	    }	Label label = code.getFreshLabel();	//code.appendIns(label, init||primePump);	final int numTimes = Linear.getMult(peek);	int pendingSends=0;	int times=0;	FullIns ins=null;	//final int turns2=content.getTotal()-content.getPos()+1;	final int turns2=content.getPos();	//final int turns2=1;	for(int turn=0;turn<turns2+4;turn++) {	    if(turn==turns2)		code.appendIns(label, init||primePump);	for(int i = 0;i<numTimes;i++) {	    for(int j=0;j<pop;j++) {		if(numPop==1&&j==0)		    pendingSends++;		times++;		ins = new FullIns(tile, new MoveIns(SwitchReg.R1, src));		if (KjcOptions.magicdram && node.getPrevious() != null &&		    node.getPrevious().isInputTrace())		    createMagicDramLoad((InputTraceNode)node.getPrevious(), 					node, (init || primePump), rawChip);		ins.addRoute(src, SwitchOPort.CSTI);		if(!end) {		    if (KjcOptions.magicdram && node.getPrevious() != null &&			node.getPrevious().isInputTrace())			createMagicDramLoad((InputTraceNode)node.getPrevious(), 					    node, (init || primePump), rawChip);		    if (KjcOptions.magicdram && node.getNext() != null &&			node.getNext().isOutputTrace())			createMagicDramStore((OutputTraceNode)node.getNext(), 					     node, (init || primePump), rawChip);		    ins.addRoute(src,dest);		}		if(turn>0&&times>1) {		    if(!end)			ins.addRoute(SwitchIPort.CSTO,dest2);		    else			ins.addRoute(SwitchIPort.CSTO,dest);		}				/*if(times>2) {		  if(!begin) {		  if (KjcOptions.magicdram && node.getPrevious() != null &&		  node.getPrevious().isInputTrace())		  createMagicDramLoad((InputTraceNode)node.getPrevious(), 		  node, (init || primePump), rawChip);		  ins.addRoute(src2,SwitchOPort.CSTI2);		  }		  pendingSends--;		  }*/		/*if(turn>1) {		  if(!begin) {		  if (KjcOptions.magicdram && node.getPrevious() != null &&		  node.getPrevious().isInputTrace())		  createMagicDramLoad((InputTraceNode)node.getPrevious(), 		  node, (init || primePump), rawChip);		  ins.addRoute(src2,SwitchOPort.CSTI2);		  }		  }*/		code.appendIns(ins, init||primePump);		if(times==4) {		    times=0;		    if(true||!begin) {		    //if(turn==0)		    //pendingSends++;		    if(pendingSends>0) {			for(int l=0;l<pendingSends;l++) {			    ins=new FullIns(tile);			    if(/*turn>0&&*/!begin) {				if (KjcOptions.magicdram && node.getPrevious() != null &&				    node.getPrevious().isInputTrace())				    createMagicDramLoad((InputTraceNode)node.getPrevious(), 							node, (init || primePump), rawChip);				ins.addRoute(src2,SwitchOPort.CSTI2);			    }			    if (KjcOptions.magicdram && node.getNext() != null &&				node.getNext().isOutputTrace())				createMagicDramStore((OutputTraceNode)node.getNext(), 						     node, (init || primePump), rawChip);			    			    if(turn>0&&l<1) {				if(!end)				    ins.addRoute(SwitchIPort.CSTO,dest2);				else				    ins.addRoute(SwitchIPort.CSTO,dest);			      }			    			    //if(!begin)			    code.appendIns(ins,init||primePump);			}			pendingSends=0;		    }		    }		}		for(int k = 1;k<numPop;k++) {		    if(j==0&&k==numPop-1)			pendingSends++;		    times++;		    ins=new FullIns(tile);		    ins.addRoute(SwitchReg.R1, SwitchOPort.CSTI);		    code.appendIns(ins, init||primePump);		    if(times==4) {			times=0;			if(true||!begin) {			//if(turn==0)			//pendingSends++;			if(pendingSends>0) {			    for(int l=0;l<pendingSends;l++) {				ins=new FullIns(tile);				if(/*turn>0&&*/!begin) {				    if (KjcOptions.magicdram && node.getPrevious() != null &&					node.getPrevious().isInputTrace())					createMagicDramLoad((InputTraceNode)node.getPrevious(), 							    node, (init || primePump), rawChip);				    ins.addRoute(src2,SwitchOPort.CSTI2);				}				if (KjcOptions.magicdram && node.getNext() != null &&				    node.getNext().isOutputTrace())				    createMagicDramStore((OutputTraceNode)node.getNext(), 							 node, (init || primePump), rawChip);								if(turn>0&&l<1) {				    if(!end)					ins.addRoute(SwitchIPort.CSTO,dest2);				    else					ins.addRoute(SwitchIPort.CSTO,dest);				}				//if(!begin)				code.appendIns(ins,init||primePump);			    }			    pendingSends=0;			}			}		    }		    }	    }	    	}	}	/*for(int i=0;i<numTimes-1;i++) {	  FullIns newIns=new FullIns(tile);	  newIns.addRoute(SwitchIPort.CSTO,dest);	  code.appendIns(newIns,init||primePump);	  }	  FullIns newIns=new FullIns(tile,new JumpIns(label.getLabel()));	  newIns.addRoute(SwitchIPort.CSTO,dest);	  code.appendIns(newIns,init||primePump);*/	//code.appendIns(new JumpIns(label.getLabel()),init||primePump);	ins.setProcessorIns(new JumpIns(label.getLabel()));    }