コード例 #1
0
 private static void putActionsForReferences(List<RefGroup> references, Groups actions) {
   for (final RefGroup refGroup : references) {
     if (refGroup instanceof SingletonRefGroup) {
       String name = refGroup.getName();
       if (!actions.singletonGroups.contains(name)) {
         actions.singletonGroups.add(name);
       }
     } else if (refGroup.isExpanded()) {
       addToGroup(refGroup, actions.expandedGroups);
     } else {
       addToGroup(refGroup, actions.collapsedGroups);
     }
   }
 }
コード例 #2
0
ファイル: LoopPermute.java プロジェクト: troore/scale
  private Cost computeRefCostSum(LoopHeaderChord loop, Vector<RefGroup> refGroups) {
    Cost lc = new Cost();
    int l = refGroups.size();
    for (int i = 0; i < l; i++) {
      RefGroup rg = refGroups.elementAt(i);
      SubscriptExpr se = rg.getRepresentative();
      Cost cost = computeRefCost(loop, se);

      if (cost == null) continue;

      lc.add(cost);
    }
    return lc;
  }
コード例 #3
0
  private static void addToGroup(
      final RefGroup refGroup, TreeMap<String, TreeSet<String>> groupToAdd) {
    TreeSet<String> existingGroup = groupToAdd.get(refGroup.getName());

    TreeSet<String> actions = new TreeSet<String>();
    for (VcsRef ref : refGroup.getRefs()) {
      actions.add(ref.getName());
    }

    if (existingGroup == null) {
      groupToAdd.put(refGroup.getName(), actions);
    } else {
      for (String action : actions) {
        existingGroup.add(action);
      }
    }
  }
コード例 #4
0
ファイル: LoopPermute.java プロジェクト: troore/scale
  private void computeEdgeRefs(DDEdge edge, RefGroup rg, int level, int dist) {
    if (!edge.isDistanceKnown(level)) return;

    int distance = edge.getDistance(level);
    if (distance < 0) distance = -distance;

    if (distance > dist) return;

    long[] ddinfo = edge.getDDInfo();
    for (int k = 0; k < ddinfo.length; k++)
      if ((k != level)
          && DDInfo.isDistanceKnown(ddinfo[k])
          && (DDInfo.getDistance(ddinfo[k]) != 0)) {
        rg.add(edge);
        break;
      }
  }
コード例 #5
0
ファイル: LoopPermute.java プロジェクト: troore/scale
  /**
   * Compute the reference groups for this loop. Two array references are in the same group with
   * respect to this loop if - there is a loop-independent dependence between them, or - the
   * dependence distance(dependence vector entry dl) for this loop is less than some constant
   * *dist*, and all other dependence vector entries are 0. - the two array refer to the same array
   * and differ by at most *dist2* in the first subscript dimension, where d is less than or equal
   * to the cache line size in terms of array elements. All other subscripts must be identical.
   * Notes: Here we assume dist1 = dist2 = 2
   */
  private void computeRefGroups(
      int level,
      int dist1,
      int dist2,
      Table<Declaration, SubscriptExpr> arrayRefs,
      Vector<RefGroup> refGroups) {
    if (arrayRefs == null) return;

    Enumeration<Declaration> ek = arrayRefs.keys();
    while (ek.hasMoreElements()) {
      VariableDecl vd = (VariableDecl) ek.nextElement();
      String s = vd.getName(); // array name
      Object[] v = arrayRefs.getRowArray(vd); // vector of SubscriptExpr's
      int vi = v.length;

      for (int j = vi - 1; j >= 0; j--) {
        SubscriptExpr sr = (SubscriptExpr) v[j];
        Vector<LoopHeaderChord> allRelatedLoops =
            sr.allRelatedLoops(); // ** Incorrect when something like a[(j+i][j]
        int arls = allRelatedLoops.size();
        int firstsub = arls - 1; // ** Making an invalid assumption here

        // Process the list of references r' with which r has a data
        // dependence, and  r is the source(data flows from r to r').

        RefGroup rg = new RefGroup(s, sr);
        Object[] edges = graph.getEdges(sr);
        int len = edges.length;

        for (int i = 0; i < len; i++) {
          DDEdge edge = (DDEdge) edges[i];

          if (edge.isSpatial()) continue;

          // Condition(1)-(a) in McKinley's paper

          if (edge.isLoopIndependentDependency()) { // add rP to the RefGroup of r:
            rg.add(edge);
            continue;
          }

          // Condition(1)-(b) in McKinley's paper

          computeEdgeRefs(edge, rg, level, dist1);

          if (arls <= 0) continue;

          // Condition(2) in McKinley's paper
          // rlevel is the level of the loop related to the first subscript.

          int rlevel = allRelatedLoops.elementAt(firstsub).getNestedLevel();

          computeEdgeRefs(edge, rg, rlevel, dist2);
        }

        boolean isInExistingRefGroups = false;
        int rgl = refGroups.size();
        for (int i = 0; i < rgl; i++) {
          RefGroup rg2 = refGroups.elementAt(i);
          if (!rg2.getName().equals(s)) continue;

          isInExistingRefGroups = rg2.contains(rg);

          if (isInExistingRefGroups) {
            rg2.add(rg);
            break;
          }
        }

        if (!isInExistingRefGroups) refGroups.addElement(rg);
      }
    }
  }