⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 genschedulerstats.java

📁 一种将c高级语言转化给VHDL的编译器
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * LA-CC 05-135 Trident 0.7.1Copyright NoticeCopyright 2006 (c) the Regents of the University of California.This Software was produced under a U.S. Government contract(W-7405-ENG-36) by Los Alamos National Laboratory, which is operatedby the University of California for the U.S. Department of Energy. TheU.S. Government is licensed to use, reproduce, and distribute thisSoftware. Permission is granted to the public to copy and use thisSoftware without charge, provided that this Notice and any statementof authorship are reproduced on all copies. Neither the Government northe University makes any warranty, express or implied, or assumes anyliability or responsibility for the user of this Software. */package fp.passes;import java.util.*;import fp.flowgraph.*;import fp.util.*;import fp.hardware.*;import fp.*;import fp.hwdesc.Memory;/** This pass is used, to calculate the following statistics about the generated *  schedules (per block and per design): *   *  1) Ops/Cycle --including high, low, and average *  2) Total Operations *  3) Operation Types *  4) Ops/Block *  * @author Kris Peterson */public class GenSchedulerStats extends Pass implements GraphPass {private static final String[] operatorTypes = new String[] {     "nop",     "ret",     "goto",     "br",     "switch",     "add",     "sub",     "mul",     "div",     "seteq",     "setne",     "setlt",     "setgt",     "setle",     "setge",     "and",     "or",     "xor",     "shl",     "shr",     "inv",     "not",     "malloc",     "load",     "aload",     "store",     "astore",     "getelementptr",     "phi",     "call",     "cast",     "select",     "libop"};  public GenSchedulerStats(PassManager pm) {    super(pm);  }     /** calculate stats.   *    * @param graph_BlockGraph    * @return true   */  public boolean optimize(BlockGraph graph) {    float designAveOpsPCycle = 0;    float designMaxOpsPCycle = -99999999;    float designMinOpsPCycle =  99999999;    //memory access stats:    //number of reads or writes per cycle    float designAveReadsPCycle = 0;    float designMaxReadsPCycle = -99999999;    float designMinReadsPCycle =  99999999;    float designAveWritesPCycle = 0;    float designMaxWritesPCycle = -99999999;    float designMinWritesPCycle =  99999999;    //number of bits read or written per cycle    float designAveReadDataPCycle = 0;    float designMaxReadDataPCycle = -99999999;    float designMinReadDataPCycle =  99999999;    float designAveWriteDataPCycle = 0;    float designMaxWriteDataPCycle = -99999999;    float designMinWriteDataPCycle =  99999999;    //number of bits read or written as a percentage of the maximum possible per    //cycle    float designAveRDPercentPCycle = 0;    float designMaxRDPercentPCycle = -99999999;    float designMinRDPercentPCycle =  99999999;    float designAveWDPercentPCycle = 0;    float designMaxWDPercentPCycle = -99999999;    float designMinWDPercentPCycle =  99999999;    float cyclesPerBlock =  0;    float opsPerBlock =  0;    int designTotOps = 0;    int designCycleCount = 0;    HashMap designOperatorCounts = new HashMap();    graph.setOperatorCounts(new HashMap());         float totPossReadData = 0;        float totPossWriteData = 0;        ArrayList memBlockList = GlobalOptions.chipDef.getMemoryBlockList();    for (Iterator itsMem = memBlockList.iterator(); itsMem.hasNext(); ) {      Memory memBlock = (Memory)itsMem.next();      totPossReadData += ((float)memBlock.getWidth() * memBlock.getNumOfReadBus());      totPossWriteData += ((float)memBlock.getWidth() * memBlock.getNumOfWriteBus());    }       for (Iterator vIt = graph.getAllNodes().iterator();              vIt.hasNext();) {      BlockNode node = (BlockNode) vIt.next();      float blockAveOpsPCycle = 0;      float blockMaxOpsPCycle = -99999999;      float blockMinOpsPCycle =  99999999;      //memory access stats:      //number of reads or writes per cycle      float blockAveReadsPCycle = 0;      float blockMaxReadsPCycle = -99999999;      float blockMinReadsPCycle =  99999999;      float blockAveWritesPCycle = 0;      float blockMaxWritesPCycle = -99999999;      float blockMinWritesPCycle =  99999999;      //number of bits read or written per cycle      float blockAveReadDataPCycle = 0;      float blockMaxReadDataPCycle = -99999999;      float blockMinReadDataPCycle =  99999999;      float blockAveWriteDataPCycle = 0;      float blockMaxWriteDataPCycle = -99999999;      float blockMinWriteDataPCycle =  99999999;      //number of bits read or written as a percentage of the maximum possible per      //cycle      float blockAveRDPercentPCycle = 0;      float blockMaxRDPercentPCycle = -99999999;      float blockMinRDPercentPCycle =  99999999;      float blockAveWDPercentPCycle = 0;      float blockMaxWDPercentPCycle = -99999999;      float blockMinWDPercentPCycle =  99999999;      int blockTotOps = 0;      int blockCycleCount = 0;      HashMap rSchedule = new HashMap();      HashMap rDSchedule = new HashMap();      HashMap wSchedule = new HashMap();      HashMap wDSchedule = new HashMap();      HashMap schedule = new HashMap();      HashMap blockOperatorCounts = new HashMap();      ArrayList instList = node.getInstructions();      blockTotOps = instList.size();      node.setOperatorCounts(new HashMap());            if(blockTotOps == 0) continue;            for (Iterator iIt = instList.iterator();              iIt.hasNext();) {        Instruction inst = (Instruction) iIt.next();        	  if(inst.type() == null) continue;	System.out.println("inst " + inst + " inst type " + inst.type() + " inst width " +	                      inst.type().getWidth());	int total = inst.getNumberOfOperands();	for(int i = 0; i < total; i++) {          Operand op = inst.getOperand(i);	  if(op == null) continue;	  if(op.getType() == null) continue;	  System.out.println("inst " + inst + " op " + op + " op type " + op.getType() + " op width " +	                      op.getType().getWidth());	}	int a = 6;	int b = 7;	int c = a * b;	int d = (int)5.4;		int cycle = inst.getExecClkCnt();		for(int i = 0; i<operatorTypes.length-1;i++)	{	  if(inst.operator.toString().indexOf(operatorTypes[i]) >= 0)	  {	    String type = "";	    if(inst.type() != null)	    {	      if(inst.operator.getInputClass() == Operator.FP)		type = "fp_";	      if(inst.operator.getInputClass() == Operator.INT)		type = "int_";	    }	    	    if(!blockOperatorCounts.containsKey(type + operatorTypes[i]))	       blockOperatorCounts.put(type + operatorTypes[i], 	                               new Integer(0));	    int operCntTmp = 		  ((Integer)blockOperatorCounts.get(type + operatorTypes[i]))		                                     .intValue();	    blockOperatorCounts.put(type + operatorTypes[i], 	                            new Integer(++operCntTmp));	    if(!designOperatorCounts.containsKey(type + operatorTypes[i]))	       designOperatorCounts.put(type + operatorTypes[i], 	                               new Integer(0));	    operCntTmp = 		  ((Integer)designOperatorCounts.get(type + operatorTypes[i]))		                                      .intValue();	    designOperatorCounts.put(type + operatorTypes[i], 	                            new Integer(++operCntTmp));	  }	}		if(ALoad.conforms(inst)) {	  blockAveReadsPCycle++;	  blockAveReadDataPCycle += (ALoad.getPrimalSource(inst)).getType().getWidth();	  if(!rSchedule.containsKey(new Integer(cycle)))	     rSchedule.put(new Integer(cycle), new Integer(0));	  int readCntTmp = ((Integer)rSchedule.get(new Integer(cycle))).intValue();	  rSchedule.put(new Integer(cycle), new Integer(++readCntTmp));	  if(!rDSchedule.containsKey(new Integer(cycle)))	     rDSchedule.put(new Integer(cycle), new Integer(0));	  int rDCntTmp = ((Integer)rDSchedule.get(new Integer(cycle))).intValue();	  rDCntTmp += (ALoad.getPrimalSource(inst)).getType().getWidth();	  rDSchedule.put(new Integer(cycle), new Integer(rDCntTmp));	}	if(AStore.conforms(inst)) {	  blockAveWritesPCycle++;	  blockAveWriteDataPCycle += (AStore.getPrimalDestination(inst)).getType().getWidth();	  if(!wSchedule.containsKey(new Integer(cycle)))	     wSchedule.put(new Integer(cycle), new Integer(0));	  int readCntTmp = ((Integer)wSchedule.get(new Integer(cycle))).intValue();	  wSchedule.put(new Integer(cycle), new Integer(++readCntTmp));	  if(!wDSchedule.containsKey(new Integer(cycle)))	     wDSchedule.put(new Integer(cycle), new Integer(0));	  int wDCntTmp = ((Integer)wDSchedule.get(new Integer(cycle))).intValue();	  wDCntTmp += (AStore.getPrimalDestination(inst)).getType().getWidth();	  wDSchedule.put(new Integer(cycle), new Integer(wDCntTmp));	}		blockCycleCount = Math.max(blockCycleCount, cycle);	if(!schedule.containsKey(new Integer(cycle)))	   schedule.put(new Integer(cycle), new Integer(0));	int opCntTmp = ((Integer)schedule.get(new Integer(cycle))).intValue();	schedule.put(new Integer(cycle), new Integer(++opCntTmp));            }      blockCycleCount++; //since the 1st cycle is 0      blockAveOpsPCycle = ((float)blockTotOps) / ((float)blockCycleCount);            designAveReadsPCycle += blockAveReadsPCycle;      designAveReadDataPCycle += blockAveReadDataPCycle;      designAveWritesPCycle += blockAveWritesPCycle;      designAveWriteDataPCycle += blockAveWriteDataPCycle;            designTotOps += blockTotOps;      designCycleCount += blockCycleCount;            blockAveReadsPCycle /= blockCycleCount;      blockAveReadDataPCycle /= blockCycleCount;      blockAveWritesPCycle /= blockCycleCount;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -