示例#1
0
  public void addBlock(InstructionBlock block) {
    int repetitions = block.getRepetitions();
    // Get current instructions
    Long instructions = instPerRepetitions.get(repetitions);
    if (instructions == null) {
      instructions = 0l;
    }
    instructions += block.getTotalInstructions();
    totalInstructions += block.getTotalInstructions();

    instPerRepetitions.put(repetitions, instructions);
  }
 public void accept(InstructionBlock instructionBlock) {
   // Forward instruction block if the number of repetitions is equal or above
   // a certain threshold
   if (instructionBlock.getRepetitions() >= repetitionThreshold) {
     producer.sendBlock(instructionBlock);
   }
 }
  // Done this way because of floating-point arithmetic. Never sum doubles
  // if you can sum integers and then calculate the double.
  public static double getIlpBlock(InstructionBlock block, Mapper ilpScene) {
    List<Operation> operations = MbParser.parseMbInstructions(block.getInstructions());
    // Create ILP Data
    ilpScene.processOperations(operations);

    return calcIlp(ilpScene.getNumberOfOps(), ilpScene.getNumberOfLines());

    // List<InstructionBlock> blocks = new ArrayList<InstructionBlock>();
    // blocks.add(block);
    // return getIlp(blocks, ilpScene);
  }
  public static double getIlpBlock(List<InstructionBlock> blocks, Mapper ilpScene) {
    int totalOperations = 0;
    int totalLines = 0;

    for (InstructionBlock block : blocks) {
      getIlpBlock(block, ilpScene);
      // Transform block into IR
      // List<Operation> operations = MbParser.parseMbInstructions(block.getInstructions());

      // Collect ILP
      // MbIlpScene1 ilp = new MbIlpScene1(new MbImmutableTest(), new MbMemoryTest());
      // Mapper ilp = new MbIlpScene2(new MbImmutableTest(), new MbMemoryTest());
      // ilpScene.processOperations(operations);

      // Collect data
      totalOperations += (ilpScene.getNumberOfOps() * block.getRepetitions());
      totalLines += (ilpScene.getNumberOfLines() * block.getRepetitions());
    }

    return ((double) totalOperations / (double) totalLines);
  }