tc/core/polyhedral/cuda/memory_promotion_heuristic.cc
/*
 * Transform schedule bands into a union_map.
 * Takes all partial schedules at leaves as MUPAs (without accounting for
 * intermediate non-band nodes), intersects
 * their domain with the filters between the root and the
 * current leaves and transforms them into union maps.
 * Mapping filters are ignored.
 */
Transform schedule bands into a union_map.
Takes all partial schedules at leaves as MUPAs (without accounting for
intermediate non-band nodes), intersects
their domain with the filters between the root and the
current leaves and transforms them into union maps.
Mapping filters are ignored.
Transform schedule bands into a union_map . Takes all partial schedules at leaves as MUPAs ( without accounting for intermediate non - band nodes ) intersects their domain with the filters between the root and the current leaves and transforms them into union maps . Mapping filters are ignored .
isl::union_map fullSchedule(const detail::ScheduleTree* root) {
  using namespace tc::polyhedral::detail;
  if (!root->elemAs<ScheduleTreeElemDomain>()) {
    throw promotion::PromotionLogicError("expected root to be a domain node");
  }
  std::function<bool(const ScheduleTree* tree)> isLeaf =
      [](const ScheduleTree* tree) { return tree->numChildren() == 0; };
  auto leaves = functional::Filter(isLeaf, ScheduleTree::collect(root));
  auto schedule = isl::union_map::empty(
      root->elemAs<ScheduleTreeElemDomain>()->domain_.get_space());
  for (auto node : leaves) {
    auto domain = root->elemAs<ScheduleTreeElemDomain>()->domain_;
    auto prefixMupa = prefixScheduleMupa(root, node);
    if (auto band = node->elemAs<ScheduleTreeElemBand>()) {
      prefixMupa = prefixMupa.flat_range_product(band->mupa_);
    }
    auto pathToRoot = node->ancestors(root);
    pathToRoot.push_back(node);
    for (auto n : pathToRoot) {
      if (auto filterNode = n->elemAs<ScheduleTreeElemFilter>()) {
        domain = domain.intersect(filterNode->filter_);
      }
    }
    prefixMupa = prefixMupa.intersect_domain(domain);
    schedule = schedule.unite(isl::union_map::from(prefixMupa));
    if (!schedule.is_single_valued()) {
      std::stringstream ss;
      ss << "schedules must be single-valued " << schedule << std::endl
         << *root;
      throw promotion::PromotionLogicError(ss.str());
    }
  }
  return schedule;
}
isl :: union_map fullSchedule ( const detail :: ScheduleTree * root ) { using namespace tc :: polyhedral :: detail ; if ( ! root -> elemAs < ScheduleTreeElemDomain > ( ) ) { throw promotion :: PromotionLogicError ( " " ) ; } std :: function < bool ( const ScheduleTree * tree ) > isLeaf = [ ] ( const ScheduleTree * tree ) { return tree -> numChildren ( ) == 0 ; } ; auto leaves = functional :: Filter ( isLeaf , ScheduleTree :: collect ( root ) ) ; auto schedule = isl :: union_map :: empty ( root -> elemAs < ScheduleTreeElemDomain > ( ) -> domain_ . get_space ( ) ) ; for ( auto node : leaves ) { auto domain = root -> elemAs < ScheduleTreeElemDomain > ( ) -> domain_ ; auto prefixMupa = prefixScheduleMupa ( root , node ) ; if ( auto band = node -> elemAs < ScheduleTreeElemBand > ( ) ) { prefixMupa = prefixMupa . flat_range_product ( band -> mupa_ ) ; } auto pathToRoot = node -> ancestors ( root ) ; pathToRoot . push_back ( node ) ; for ( auto n : pathToRoot ) { if ( auto filterNode = n -> elemAs < ScheduleTreeElemFilter > ( ) ) { domain = domain . intersect ( filterNode -> filter_ ) ; } } prefixMupa = prefixMupa . intersect_domain ( domain ) ; schedule = schedule . unite ( isl :: union_map :: from ( prefixMupa ) ) ; if ( ! schedule . is_single_valued ( ) ) { std :: stringstream ss ; ss << " " << schedule << std :: endl << * root ; throw promotion :: PromotionLogicError ( ss . str ( ) ) ; } } return schedule ; }
Transform schedule bands into a union_map.
Transform schedule bands into a union_map .
// Find all innermost nodes. // Take a union of partial schedules of the innermost nodes.  Because they // are innermost, the partial schedule can no longer be affected by deeper // nodes and hence is full.