@@ -115,38 +115,6 @@ std::string genCall(
115115 return ss.str ();
116116}
117117
118- // ! A utility class to check if an expression of a particular type exists
119- class ExprFinder : kir::ConstIrVisitor {
120- public:
121- // ! True if expr or any of its nested expressions is included in
122- // ! expr_types
123- static bool exists (
124- const Expr* expr,
125- const std::unordered_set<std::type_index>& expr_types) {
126- ExprFinder finder (expr_types);
127- finder.handle (std::vector<const Expr*>{expr});
128- return finder.is_found_ ;
129- }
130-
131- private:
132- ExprFinder (const std::unordered_set<std::type_index>& expr_types)
133- : expr_types_(expr_types) {}
134-
135- using kir::ConstIrVisitor::handle;
136-
137- void handle (const Expr* expr) final {
138- if (expr_types_.find (typeid (*expr)) != expr_types_.end ()) {
139- is_found_ = true ;
140- return ;
141- }
142- kir::ConstIrVisitor::handle (expr);
143- }
144-
145- private:
146- const std::unordered_set<std::type_index>& expr_types_;
147- bool is_found_ = false ;
148- };
149-
150118class CudaKernelGenerator : private OptOutConstDispatch {
151119 static constexpr const char * kTab = " " ;
152120
@@ -2482,19 +2450,6 @@ class CudaKernelGenerator : private OptOutConstDispatch {
24822450 " which is handled by its own handler" );
24832451 }
24842452
2485- // ! True if loop is grouped. The IterDomain of the loop must have
2486- // ! ParallelType::Group, but it isn't sufficient as the loop may be
2487- // ! for an initialization expression, for which the loop shold not
2488- // ! be grouped. Make sure a GroupedGridReduction is found.
2489- bool isGroupedLoop (const kir::ForLoop* loop) {
2490- if (loop->iter_domain ()->getParallelType () != ParallelType::Group) {
2491- return false ;
2492- }
2493- return ExprFinder::exists (
2494- loop,
2495- {typeid (kir::GroupedGridReduction), typeid (kir::GroupedGridWelford)});
2496- }
2497-
24982453 void handle (const kir::ForLoop* loop) final {
24992454 if (loop->isTrivial ()) {
25002455 handleTrivialLoop (loop);
@@ -2503,7 +2458,7 @@ class CudaKernelGenerator : private OptOutConstDispatch {
25032458
25042459 // If a loop is grouped, no loop is created, but it isn't
25052460 // considered trivial as the loop trip count is not one.
2506- if (isGroupedLoop ( loop)) {
2461+ if (loop-> isGrouped ( )) {
25072462 grouped_loops_.push_back (loop);
25082463 handleScope (loop->body ());
25092464 grouped_loops_.pop_back ();
0 commit comments