src/core/compile.cpp
// check if there are reductions in the body of this tree
// over the variable
check if there are reductions in the body of this tree
over the variable
check if there are reductions in the body of this tree over the variable
bool trivially_parallel(const LoopTree &lt, LoopTree::TreeRef ref) {
  bool threadable = true;
  auto tree_v = lt.node(ref).loop.var;
  lt.walk(
      [&](LoopTree::TreeRef ref, int) {
        if (lt.node(ref).kind == LoopTree::LOOP) {
          return;
        }
        auto node_ref = lt.node(ref).node;
        bool iters_over = false;
        for (auto v : lt.ir.all_vars(node_ref)) {
          if (v == tree_v) {
            iters_over = true;
            break;
          }
        }
        if (iters_over) {
          bool pointwise = false;
          for (auto v : lt.ir.pointwise_vars(node_ref)) {
            if (v == tree_v) {
              pointwise = true;
            }
          }
          if (!pointwise) {
            threadable = false;
          }
        }
      },
      ref);
  return threadable;
}
bool trivially_parallel ( const LoopTree & lt , LoopTree :: TreeRef ref ) { bool threadable = true ; auto tree_v = lt . node ( ref ) . loop . var ; lt . walk ( [ & ] ( LoopTree :: TreeRef ref , int ) { if ( lt . node ( ref ) . kind == LoopTree :: LOOP ) { return ; } auto node_ref = lt . node ( ref ) . node ; bool iters_over = false ; for ( auto v : lt . ir . all_vars ( node_ref ) ) { if ( v == tree_v ) { iters_over = true ; break ; } } if ( iters_over ) { bool pointwise = false ; for ( auto v : lt . ir . pointwise_vars ( node_ref ) ) { if ( v == tree_v ) { pointwise = true ; } } if ( ! pointwise ) { threadable = false ; } } } , ref ) ; return threadable ; }
check if there are reductions in the body of this tree
over the variable
check if there are reductions in the body of this tree over the variable