@@ -146,15 +146,18 @@ class LowererImplImperative : public LowererImpl {
146146 * \param statement
147147 * A concrete index notation statement to compute at the points in the
148148 * sparse iteration space described by the merge lattice.
149+ * \param mergeStrategy
150+ * A strategy for merging iterators. One of TwoFinger or Gallop.
149151 *
150152 * \return
151153 * IR code to compute the forall loop.
152154 */
153155 virtual ir::Stmt lowerMergeLattice (MergeLattice lattice, IndexVar coordinateVar,
154156 IndexStmt statement,
155- const std::set<Access>& reducedAccesses);
157+ const std::set<Access>& reducedAccesses,
158+ MergeStrategy mergeStrategy);
156159
157- virtual ir::Stmt resolveCoordinate (std::vector<Iterator> mergers, ir::Expr coordinate, bool emitVarDecl);
160+ virtual ir::Stmt resolveCoordinate (std::vector<Iterator> mergers, ir::Expr coordinate, bool emitVarDecl, bool mergeWithMax );
158161
159162 /* *
160163 * Lower the merge point at the top of the given lattice to code that iterates
@@ -169,23 +172,29 @@ class LowererImplImperative : public LowererImpl {
169172 * coordinate the merge point is at.
170173 * A concrete index notation statement to compute at the points in the
171174 * sparse iteration space region described by the merge point.
175+ * \param mergeWithMax
176+ * A boolean indicating whether coordinates should be combined with MAX instead of MIN.
177+ * MAX is needed when the iterators are merged with the Gallop strategy.
172178 */
173179 virtual ir::Stmt lowerMergePoint (MergeLattice pointLattice,
174180 ir::Expr coordinate, IndexVar coordinateVar, IndexStmt statement,
175- const std::set<Access>& reducedAccesses, bool resolvedCoordDeclared);
181+ const std::set<Access>& reducedAccesses, bool resolvedCoordDeclared,
182+ MergeStrategy mergestrategy);
176183
177184 // / Lower a merge lattice to cases.
178185 virtual ir::Stmt lowerMergeCases (ir::Expr coordinate, IndexVar coordinateVar, IndexStmt stmt,
179186 MergeLattice lattice,
180- const std::set<Access>& reducedAccesses);
187+ const std::set<Access>& reducedAccesses,
188+ MergeStrategy mergeStrategy);
181189
182190 // / Lower a forall loop body.
183191 virtual ir::Stmt lowerForallBody (ir::Expr coordinate, IndexStmt stmt,
184192 std::vector<Iterator> locaters,
185193 std::vector<Iterator> inserters,
186194 std::vector<Iterator> appenders,
187195 MergeLattice caseLattice,
188- const std::set<Access>& reducedAccesses);
196+ const std::set<Access>& reducedAccesses,
197+ MergeStrategy mergeStrategy);
189198
190199
191200 // / Lower a where statement.
@@ -375,7 +384,7 @@ class LowererImplImperative : public LowererImpl {
375384
376385 // / Conditionally increment iterator position variables.
377386 ir::Stmt codeToIncIteratorVars (ir::Expr coordinate, IndexVar coordinateVar,
378- std::vector<Iterator> iterators, std::vector<Iterator> mergers);
387+ std::vector<Iterator> iterators, std::vector<Iterator> mergers, MergeStrategy strategy );
379388
380389 ir::Stmt codeToLoadCoordinatesFromPosIterators (std::vector<Iterator> iterators, bool declVars);
381390
@@ -410,7 +419,8 @@ class LowererImplImperative : public LowererImpl {
410419 // / Lowers a merge lattice to cases assuming there are no more loops to be emitted in stmt.
411420 // / Will emit checks for explicit zeros for each mode iterator and each locator in the lattice.
412421 ir::Stmt lowerMergeCasesWithExplicitZeroChecks (ir::Expr coordinate, IndexVar coordinateVar, IndexStmt stmt,
413- MergeLattice lattice, const std::set<Access>& reducedAccesses);
422+ MergeLattice lattice, const std::set<Access>& reducedAccesses,
423+ MergeStrategy mergeStrategy);
414424
415425 // / Constructs cases comparing the coordVar for each iterator to the resolved coordinate.
416426 // / Returns a vector where coordComparisons[i] corresponds to a case for iters[i]
@@ -444,7 +454,7 @@ class LowererImplImperative : public LowererImpl {
444454 // / The map must be of iterators to exprs of boolean types
445455 std::vector<ir::Stmt> lowerCasesFromMap (std::map<Iterator, ir::Expr> iteratorToCondition,
446456 ir::Expr coordinate, IndexStmt stmt, const MergeLattice& lattice,
447- const std::set<Access>& reducedAccesses);
457+ const std::set<Access>& reducedAccesses, MergeStrategy mergeStrategy );
448458
449459 // / Constructs an expression which checks if this access is "zero"
450460 ir::Expr constructCheckForAccessZero (Access);
0 commit comments