Skip to content

Commit 8839ea8

Browse files
kumasentoivanradanov
authored andcommitted
[PlutoTransform] can handle index at top-level
1 parent d3584c7 commit 8839ea8

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

tools/polymer/lib/Support/OslScop.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,12 @@ void OslScop::createAccessRelationConstraints(
585585
cst.reset();
586586
cst.mergeAndAlignIdsWithOther(0, &domain);
587587

588+
LLVM_DEBUG({
589+
dbgs() << "Building access relation.\n"
590+
<< " + Domain:\n";
591+
domain.dump();
592+
});
593+
588594
SmallVector<mlir::Value, 8> idValues;
589595
domain.getAllValues(&idValues);
590596
llvm::SetVector<mlir::Value> idValueSet;

tools/polymer/lib/Support/ScopStmt.cc

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,20 @@ void ScopStmtImpl::initializeDomainAndEnclosingOps() {
115115
getEnclosingAffineForAndIfOps(*caller, &enclosingOps);
116116

117117
// The domain constraints can then be collected from the enclosing ops.
118-
getIndexSet(enclosingOps, &domain);
118+
assert(succeeded(getIndexSet(enclosingOps, &domain)));
119+
120+
// Add additional indices that are in the top level block arguments.
121+
for (Value arg : caller->getOperands()) {
122+
if (!arg.getType().isIndex())
123+
continue;
124+
unsigned pos;
125+
if (domain.findId(arg, &pos))
126+
continue;
127+
128+
domain.appendSymbolId(1);
129+
domain.dump();
130+
domain.setValue(domain.getNumDimAndSymbolIds() - 1, arg);
131+
}
119132

120133
// Symbol values, which could be a BlockArgument, or the result of DimOp or
121134
// IndexCastOp, or even an affine.apply. Here we limit the cases to be either
@@ -181,6 +194,8 @@ static mlir::Value findBlockArg(mlir::Value v) {
181194
void ScopStmt::getAccessMapAndMemRef(mlir::Operation *op,
182195
mlir::AffineValueMap *vMap,
183196
mlir::Value *memref) const {
197+
// Map from callee arguments to caller's. impl holds the callee and caller
198+
// instances.
184199
BlockAndValueMapping argMap;
185200
impl->getArgsValueMapping(argMap);
186201

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: polymer-opt %s -pluto-opt | FileCheck %s
2+
3+
4+
func @S0(%A: memref<10x60xf32>, %i: index, %j: index) attributes {scop.stmt} {
5+
%cst = arith.constant 3.14 : f32
6+
affine.store %cst, %A[%i, %j] : memref<10x60xf32>
7+
return
8+
}
9+
10+
func @foo(%A: memref<10x60xf32>, %i: index) {
11+
affine.for %j = 0 to 60 {
12+
call @S0(%A, %i, %j): (memref<10x60xf32>, index, index) -> ()
13+
}
14+
return
15+
}
16+
17+
// CHECK: func @foo(%[[A:.*]]: memref<{{.*}}>, %[[i:.*]]: index)
18+
// CHECK-NEXT: affine.for
19+
// CHECK-NEXT: affine.for %[[j:.*]] =
20+
// CHECK-NEXT: call @S0(%[[A]], %[[i]], %[[j]])

0 commit comments

Comments
 (0)