Ejemplo n.º 1
0
  /** resets the costs of a set of edges */
  protected final void resetCost(Set<DAGEdge> edges) {
    Iterator<DAGEdge> iterator = edges.iterator();

    while (iterator.hasNext()) {

      MapperDAGEdge edge = (MapperDAGEdge) iterator.next();
      if (!(edge instanceof PrecedenceEdge)) edge.getTiming().resetCost();
    }
  }
Ejemplo n.º 2
0
  /** resets the costs of a set of edges */
  private final MapperDAGEdge translateInImplementationEdge(MapperDAGEdge edge) {

    MapperDAGVertex sourceVertex =
        translateInImplementationVertex((MapperDAGVertex) edge.getSource());
    MapperDAGVertex destVertex =
        translateInImplementationVertex((MapperDAGVertex) edge.getTarget());

    if (destVertex == null || sourceVertex == null) {
      WorkflowLogger.getLogger()
          .log(
              Level.SEVERE,
              "Implementation vertex with id "
                  + edge.getSource()
                  + " or "
                  + edge.getTarget()
                  + " not found");
    } else {
      MapperDAGEdge internalEdge = (MapperDAGEdge) implementation.getEdge(sourceVertex, destVertex);
      return internalEdge;
    }

    return null;
  }
  @Override
  public void execute(List<Object> resultList) {

    super.execute(resultList);

    MapperDAGVertex currentSource = (MapperDAGVertex) edge.getSource();
    MapperDAGVertex currentTarget = (MapperDAGVertex) edge.getTarget();

    if (edge instanceof PrecedenceEdge) {
      WorkflowLogger.getLogger()
          .log(Level.INFO, "no involvement vertex corresponding to a schedule edge");
      return;
    }

    String ivertexID =
        "__involvement (" + currentSource.getName() + "," + currentTarget.getName() + ")";

    if (involvementTime > 0) {
      iVertex = new InvolvementVertex(ivertexID, implementation);
      implementation.getTimings().dedicate(iVertex);
      implementation.getMappings().dedicate(iVertex);

      implementation.addVertex(iVertex);
      iVertex.getTiming().setCost(involvementTime);

      if (isSender) {
        iVertex.setEffectiveOperator(step.getSender());
        ((TransferVertex) currentTarget).setInvolvementVertex(iVertex);
      } else {
        iVertex.setEffectiveOperator(step.getReceiver());
        ((TransferVertex) currentSource).setInvolvementVertex(iVertex);
      }

      if (isSender) {
        MapperDAGEdge newInEdge = (MapperDAGEdge) implementation.addEdge(currentSource, iVertex);
        newInEdge.setInit(edge.getInit().clone());
        newInEdge.getTiming().setCost(0);

        MapperDAGVertex receiverVertex = currentTarget;
        do {
          Set<MapperDAGVertex> succs = receiverVertex.getSuccessors(false).keySet();
          if (succs.isEmpty() && receiverVertex instanceof TransferVertex) {
            WorkflowLogger.getLogger()
                .log(Level.SEVERE, "Transfer has no successor: " + receiverVertex.getName());
          }

          for (MapperDAGVertex next : receiverVertex.getSuccessors(false).keySet()) {
            if (next != null) {
              receiverVertex = next;
            }
          }
        } while (receiverVertex instanceof TransferVertex);

        MapperDAGEdge newoutEdge = (MapperDAGEdge) implementation.addEdge(iVertex, receiverVertex);
        newoutEdge.setInit(edge.getInit().clone());
        newoutEdge.getTiming().setCost(0);

        // TODO: Look at switching possibilities
        /*
         * if (false) { TaskSwitcher taskSwitcher = new TaskSwitcher();
         * taskSwitcher.setOrderManager(orderManager);
         * taskSwitcher.insertVertexBefore(currentTarget, iVertex); }
         * else
         */
        orderManager.insertBefore(currentTarget, iVertex);

      } else {
        MapperDAGEdge newOutEdge = (MapperDAGEdge) implementation.addEdge(iVertex, currentTarget);
        newOutEdge.setInit(edge.getInit().clone());
        newOutEdge.getTiming().setCost(0);

        orderManager.insertAfter(currentSource, iVertex);
      }

      // Scheduling involvement vertex
      new PrecedenceEdgeAdder(orderManager, implementation).scheduleVertex(iVertex);

      if (resultList != null) {
        resultList.add(iVertex);
      }
    }
  }
Ejemplo n.º 4
0
 /** Gets the cost of the given edge in the implementation */
 @Override
 public final long getCost(MapperDAGEdge edge) {
   edge = translateInImplementationEdge(edge);
   return edge.getTiming().getCost();
 }