Exemple #1
0
void AliasCheckGenerator::printConditions(const isl::Set &ParamContext,
                                          const isl::Set &Acc,
                                          const BoundsMapT &map) const {
  void *np = NULL;
  Set AccA = Acc;

  // Eliminate all but one single dimension and take the min/max.
  unsigned int ndims = AccA.dim(DimType::DTSet);
  AccA = AccA.eliminate(DimType::DTSet, 1, ndims - 1);
  PwAff minA = AccA.dimMin(0);
  PwAff maxA = AccA.dimMax(0);

  AstBuild Builder = AstBuild::fromContext(ParamContext);
  Space A = AccA.getSpace();
  std::string nA = A.getTupleName(DimType::DTSet);
  Id idA = Id::alloc(nA, np);

  AstExpr ExpMinA = Builder.exprFromPwAff(minA);
  AstExpr ExpMaxA = Builder.exprFromPwAff(maxA);
  AstExpr ExpIdA = AstExpr::fromId(idA);

  ExpMinA = ExpIdA.add(ExpMinA);
  ExpMaxA = ExpIdA.add(ExpMaxA);

  for (const isl::Set &s : map) {
    Set AccB = s;
    Space B = AccB.getSpace();

    std::string nB = B.getTupleName(DimType::DTSet);
    Id idB = Id::alloc(nB, np);

    PwAff minB = AccB.dimMin(0);
    PwAff maxB = AccB.dimMax(0);

    AstExpr ExpMinB = Builder.exprFromPwAff(minB);
    AstExpr ExpMaxB = Builder.exprFromPwAff(maxB);
    AstExpr ExpIdB = AstExpr::fromId(idB);

    ExpMinB = ExpIdB.add(ExpMinB);
    ExpMaxB = ExpIdB.add(ExpMaxB);

    dbgs().indent(6) << "[ (" << ExpMinA.toStr(Format::FC) << ")";
    dbgs() << " <=  (" << ExpMaxB.toStr(Format::FC) << ")";
    dbgs() << " && (" << ExpMinB.toStr(Format::FC) << ")";
    dbgs() << " <=  (" << ExpMaxA.toStr(Format::FC) << ") ]\n";
  }
}
Exemple #2
0
void AliasCheckGenerator::printIslExpressions(const Scop &S) {
  BoundsMapT BoundsMap;
  unsigned int numAccs = 0;
  for (ScopStmt *Stmt : S) {
    for (MemoryAccess *Acc : *Stmt) {
      Map Access = isl::Map(Acc->getAccessRelation());
      Set Domain = isl::Set(Stmt->getDomain());
      const Set MemAccs = Domain.apply(Access);
      if (!BoundsMap.count(MemAccs)) {
        BoundsMap.insert(MemAccs);
        ++numAccs;
      }
    }
  }

  log(Debug, 2) << "Num Accesses: " << numAccs << " -> "
                << binomial_coefficient(numAccs, 2) << "\n";

  BoundsMapT mapcp = BoundsMap;
  const Set ParamCtx = Set(S.getAssumedContext());
  Set Cond = Set::universe(ParamCtx.getSpace());

  for (const Set &s : BoundsMap) {
    BoundsMapT::iterator it = mapcp.find(s);
    if (it != mapcp.end()) {
      mapcp.erase(it);
      if (mapcp.size() > 0) {
        Cond = checkPairs(Cond, s, mapcp);
      }
    }
  }

  AstBuild Builder = AstBuild::fromContext(ParamCtx);
  PwAff Check = Cond.indicatorFunction();
  AstExpr ExprCheck = Builder.exprFromPwAff(Check);

  log(Debug, 4) << "if (" << ExprCheck.toStr(Format::FC) << ")\n\n";
}