src/core/compile.cpp
/*
 an index function maps a point in memory given a location in the loop tree
*/
an index function maps a point in memory given a location in the loop tree
an index function maps a point in memory given a location in the loop tree
std::function<size_t(int[MAX_DEPTH])> gen_idx_func(const LoopTree &lt,
                                                   const Allocation &alloc,
                                                   LoopTree::TreeRef use) {
  auto ref = alloc.producer;
  ASSERT(lt.node(ref).kind == LoopTree::NODE);
  ASSERT(lt.node(use).kind == LoopTree::NODE);
  auto idx_vec = gen_idx_vector(lt, alloc, use);
  return [=](int indices[MAX_DEPTH]) {
    size_t idx = 0;
    for (const auto &p : idx_vec) {
      idx += indices[p.first] * p.second;
    }
    return idx;
  };
}
std :: function < size_t ( int [ MAX_DEPTH ] ) > gen_idx_func ( const LoopTree & lt , const Allocation & alloc , LoopTree :: TreeRef use ) { auto ref = alloc . producer ; ASSERT ( lt . node ( ref ) . kind == LoopTree :: NODE ) ; ASSERT ( lt . node ( use ) . kind == LoopTree :: NODE ) ; auto idx_vec = gen_idx_vector ( lt , alloc , use ) ; return [ = ] ( int indices [ MAX_DEPTH ] ) { size_t idx = 0 ; for ( const auto & p : idx_vec ) { idx += indices [ p . first ] * p . second ; } return idx ; } ; }
an index function maps a point in memory given a location in the loop tree
an index function maps a point in memory given a location in the loop tree
// if (lt.ir.node(lt.node(ref).node).vars().size() > 2) { //  std::cerr << "vec for alloc "<<lt.ir.dump(lt.node(ref).node)<<" "; //  for (auto i : idx_vec) { //    std::cerr << i.first << "->" << i.second << ", "; //  } //  std::cerr << "\n"; //}