// private Fu addMoveOperations(int destinationLine, Operand[] fuInputs, Operand[] opInputs) { private Fu addMoveOperations(int destinationLine, Operand fuInput) { // For each input // for(int i=0; i<fuInputs.length; i++) { if (fuInput == null) { return null; } if (fuInput.getOpType() != Operand.OpType.fu) { return null; } // System.out.println("fuInput:"+fuInput); Coordinate coor = fuInput.getValueAsCoordinate(); // Calculate distance between the input and the destinationLine int distance = destinationLine - coor.getLine(); // Check if destination is before input or in the same line as the input if (distance <= 0) { Logger.getLogger(IfmMapper.class.getName()) .warning("Input line:" + coor.getLine() + "; Consumer line:" + destinationLine); return null; } // Check if destination line is within the feed distance if (distance <= feedDistance) { // No move operation is needed return null; } // Calculate number of moves int numberOfMoves = distance - feedDistance; int startingLine = coor.getLine() + 1; Operand input = fuInput; Fu newMove = null; for (int j = 0; j < numberOfMoves; j++) { // Line int line = startingLine + j; // Check if line is avaliable. If not, mapping is not possible boolean isAvaliable = matrix.isLineAvaliable(line); if (!isAvaliable) { Logger.getLogger(IfmMapper.class.getName()) .warning( "Mapping is not possible for a matrix with " + "maximum line size of " + peLineSize); mappingFailed = true; return null; } line = matrix.getFirstAvaliableLine(line); // Get column int col = matrix.getFirstAvaliableColumn(line); newMove = matrix.mapMoveOperation(line, col, input); input = newMove.getOutput(); } // } return newMove; }
/** * Accepts operation to map on the matrix * * @param operation * @return */ private void mapOperation(Operation operation) { Operand[] opInputs = operation.getInputs(); Operand[] opOutputs = operation.getOutputs(); // Fu data Operand[] fuInputs = new Operand[opInputs.length]; // Operand[] fuOutputs = new Operand[opOutputs.length]; // Check inputs for (int i = 0; i < opInputs.length; i++) { if (opInputs[i] == null) { continue; } if (opInputs[i].getOpType() == Operand.OpType.literal) { fuInputs[i] = opInputs[i]; continue; } if (opInputs[i].getOpType() == Operand.OpType.register) { // This can be combine in one class String register = opInputs[i].getValue(); Operand op = null; // Check if literals table has this register op = literalsTable.get(register); // Check if current producers have this register if (op == null) { op = currentProducers.get(register); } if (op == null) { liveIns.add(register); } else { fuInputs[i] = op; } continue; } System.out.println("mapOperation Error: shouldn't be here"); } boolean isMemoryOperation = Memory.isMemoryOperation.contains(operation.getOperation()); int fromLine = 0; // 1 Memory operation per line if (isMemoryOperation) { // Check last line used by memory operation fromLine = lastLineUseByMemoryOperation + 1; } int destinationLine = calculateDestinationLine(fuInputs, fromLine); int destinationCol = matrix.getFirstAvaliableColumn(destinationLine); Fu mappedOp = matrix.mapNewOperation(destinationLine, destinationCol, operation, fuInputs); processOutput(opOutputs, mappedOp.getOutput()); // Add, in the end if (feedDistance > 0) { for (int i = 0; i < fuInputs.length; i++) { Fu newMove = addMoveOperations(destinationLine, fuInputs[i]); if (mappingFailed) { return; } } } // Update memory line /* if(isMemoryOperation) { // Check last line used by memory operation lastLineUseByMemoryOperation = destinationLine; } */ // Scenario 2: parallel loads, serial stores if (Memory.isStore.contains(operation.getOperation())) { lastLineUseByMemoryOperation = destinationLine; } }