@@ -48,12 +48,10 @@ bool isSupportedReduction(Halide::Internal::Stmt stmt) {
4848// the reduction. that is a kind of internal state dependence we want to avoid
4949// If id is the statement identifier of an update statement
5050// of a supported type of reduction,
51- // then return the corresponding init statement in init and
52- // the corresponding reduction dimensions in reductionDims.
51+ // then return the corresponding reduction dimensions in reductionDims.
5352bool isReductionUpdateId (
5453 isl::id id,
5554 const Scop& scop,
56- Halide::Internal::Stmt& init,
5755 std::vector<size_t >& reductionDims) {
5856 CHECK_EQ (scop.halide .statements .count (id), 1u )
5957 << " id is not a statement in scop" << id;
@@ -63,7 +61,6 @@ bool isReductionUpdateId(
6361 }
6462 for (auto const & iup : scop.halide .reductions ) {
6563 if (iup.update .same_as (provideNode)) {
66- init = iup.init ;
6764 reductionDims = iup.dims ;
6865 return true ;
6966 }
@@ -104,9 +101,8 @@ bool isAlmostIdentityReduction(isl::pw_aff pa, const Scop& scop) {
104101 return false ;
105102 }
106103 auto stmtId = space.get_tuple_id (isl::dim_type::in);
107- Halide::Internal::Stmt init;
108104 std::vector<size_t > reductionDims;
109- if (!isReductionUpdateId (stmtId, scop, init, reductionDims)) {
105+ if (!isReductionUpdateId (stmtId, scop, reductionDims)) {
110106 return false ;
111107 }
112108
@@ -118,52 +114,18 @@ bool isAlmostIdentityReduction(isl::pw_aff pa, const Scop& scop) {
118114 return false ;
119115}
120116
121- /*
122- * Return the identifier that maps to "stmt".
123- */
124- isl::id statementId (const Scop& scop, const Halide::Internal::Stmt& stmt) {
125- for (auto kvp : scop.halide .statements ) {
126- if (kvp.second .same_as (stmt)) {
127- return kvp.first ;
128- }
129- }
130- CHECK (false ) << " no id recorded for statement" << stmt;
131- return isl::id ();
132- }
133-
134117} // namespace
135118
136- std::pair<isl::union_set, isl::union_set> reductionInitsUpdates (
137- isl::union_set domain,
138- const Scop& scop) {
139- auto initUnion = isl::union_set::empty (domain.get_space ());
140- auto update = initUnion;
141- std::unordered_set<isl::id, isl::IslIdIslHash> init;
142- std::vector<isl::set> nonUpdate;
143- // First collect all the update statements,
144- // the corresponding init statement and all non-update statements.
145- domain.foreach_set ([&init, &update, &nonUpdate, &scop](isl::set set) {
119+ isl::union_set reductionUpdates (isl::union_set domain, const Scop& scop) {
120+ auto update = isl::union_set::empty (domain.get_space ());
121+ domain.foreach_set ([&update, &scop](isl::set set) {
146122 auto setId = set.get_tuple_id ();
147- Halide::Internal::Stmt initStmt;
148123 std::vector<size_t > reductionDims;
149- if (isReductionUpdateId (setId, scop, initStmt, reductionDims)) {
124+ if (isReductionUpdateId (setId, scop, reductionDims)) {
150125 update = update.unite (set);
151- init.emplace (statementId (scop, initStmt));
152- } else {
153- nonUpdate.emplace_back (set);
154126 }
155127 });
156- // Then check if all the non-update statements are init statements
157- // that correspond to the update statements found.
158- // If not, return an empty list of update statements.
159- for (auto set : nonUpdate) {
160- if (init.count (set.get_tuple_id ()) != 1 ) {
161- return std::pair<isl::union_set, isl::union_set>(
162- initUnion, isl::union_set::empty (domain.get_space ()));
163- }
164- initUnion = initUnion.unite (set);
165- }
166- return std::pair<isl::union_set, isl::union_set>(initUnion, update);
128+ return update;
167129}
168130
169131bool isReductionMember (
0 commit comments