<commit_before>#ifndef __TAPAS_HOT_LET__
#define __TAPAS_HOT_LET__

#include<vector>

#include <tapas/iterator.h>
#include <tapas/debug_util.h>

using tapas::debug::BarrierExec;

namespace tapas {
namespace hot {

template<class TSP> class Cell;
template<class TSP> class Partitioner;

/**
 * Enum values of predicate function
 */
enum class SplitType {
  Approx,       // Compute using right cell's attribute
  Body,         // Compute using right cell's bodies
  SplitLeft,    // Split Left (local) cell
  SplitRight,   // Split Right (remote) cell
  None,         // Nothing. Use when a target cell isn't local in Traverse
};


#define USING_TAPAS_TYPES(TSP)                          \
  using FP = typename TSP::FP;                          \
  using BodyType = TSP::BT::type BodyType;              \
  using BodyAttrType = TSP::BT_ATTR;                    \
  using SFC = typename TSP::SFC;                        \
  using KeyType = typename CellType::KeyType;           \
  using CellType = Cell<TSP>;                           \
  using Data = typename CellType::Data


template<class TSP, class SetType>
void TraverseLET_old(typename Cell<TSP>::BodyType &p,
    typename Cell<TSP>::KeyType src_key,
    typename Cell<TSP>::Data &data,
    SetType &list_attr, SetType &list_body) {
  using CellType = Cell<TSP>;
  using FP = typename TSP::FP;
  using SFC = typename Cell<TSP>::SFC;
  using KeyType = typename Cell<TSP>::KeyType;

  const constexpr double theta = 0.5;

  auto &r = data.region_;
  auto &ht = data.ht_;

  // Maximum depth of the tree.
  const int max_depth = data.max_depth_;

  bool is_src_local = ht.count(src_key) != 0;
  bool is_src_local_leaf = is_src_local && ht[src_key]->IsLeaf();
  bool is_src_remote_leaf = !is_src_local && SFC::GetDepth(src_key) >= max_depth;

  if (is_src_local_leaf) {
    // if the source cell is a remote leaf, we need it (the cell is not longer splittable anyway).
    return;
  }
    else if (is_src_remote_leaf) {
      // If the source cell is a remote leaf, we need it (with it's bodies).
      list_attr.insert(src_key);
      list_body.insert(src_key);
      return;
    }

    // the cell attributes is necessary (because traversal has come here.)
    list_attr.insert(src_key);
    TAPAS_ASSERT(SFC::GetDepth(src_key) <= SFC::MAX_DEPTH);

    auto src_child_keys = SFC::GetChildren(src_key);

    // distance function closure, which returns distance from p
    auto distR2 = [&p](const Vec<TSP::Dim, FP> &v) -> FP {
      FP dx = p.x - v[0];
      FP dy = p.y - v[1];
      FP dz = p.z - v[2];
      return dx * dx + dy * dy + dz * dz;
    };

    // compare function to sort cells by their distance from p
    auto comp = [&p, &r, &distR2](KeyType k1, KeyType k2) {
      auto ctr1 = CellType::CalcCenter(k1, r);
      auto ctr2 = CellType::CalcCenter(k2, r);

      FP d1 = distR2(ctr1);
      FP d2 = distR2(ctr2);

      return d1 < d2;
    };

    // Sort children according to their distance from p
    // If a certain child is "approximated", the farer children are all "approximated."
    //std::sort(std::begin(src_child_keys), std::end(src_child_keys), comp);

    for (size_t i = 0; i < src_child_keys.size(); i++) {
      KeyType ckey = src_child_keys[i];
      auto ctr = CellType::CalcCenter(ckey, r);

      FP s = CellType::CalcRegion(ckey, r).width(0); // width
      FP d = std::sqrt(distR2(ctr));

      if (s/d > theta) { // if the cell(ckey) is close
        TraverseLET_old<TSP, SetType>(p, ckey, data, list_attr, list_body);
      } else {
        // If i-th children is far enough from `cell`, the rest of children
        // are also `far`. Thus we don't need to traverse them recursively
        // and just need their attributes(multipole)
        if (ht.count(ckey) == 0) {
          list_attr.insert(ckey);
        }
      }
    }
    // ------ block ends here -------
    return;
}<commit_msg>minor fix: removed unused code<commit_after>#ifndef __TAPAS_HOT_LET__
#define __TAPAS_HOT_LET__

#include<vector>

#include <tapas/iterator.h>
#include <tapas/debug_util.h>

using tapas::debug::BarrierExec;

namespace tapas {
namespace hot {

template<class TSP> class Cell;
template<class TSP> class Partitioner;

/**
 * Enum values of predicate function
 */
enum class SplitType {
  Approx,       // Compute using right cell's attribute
  Body,         // Compute using right cell's bodies
  SplitLeft,    // Split Left (local) cell
  SplitRight,   // Split Right (remote) cell
  None,         // Nothing. Use when a target cell isn't local in Traverse
};

#define USING_TAPAS_TYPES(TSP)                          \
  using FP = typename TSP::FP;                          \
  using BodyType = TSP::BT::type BodyType;              \
  using BodyAttrType = TSP::BT_ATTR;                    \
  using SFC = typename TSP::SFC;                        \
  using KeyType = typename CellType::KeyType;           \
  using CellType = Cell<TSP>;                           \
  using Data = typename CellType::Data


template<class TSP, class SetType>
void TraverseLET_old(typename Cell<TSP>::BodyType &p,
    typename Cell<TSP>::KeyType src_key,
    typename Cell<TSP>::Data &data,
    SetType &list_attr, SetType &list_body) {
  using CellType = Cell<TSP>;
  using FP = typename TSP::FP;
  using SFC = typename Cell<TSP>::SFC;
  using KeyType = typename Cell<TSP>::KeyType;

  const constexpr double theta = 0.5;

  auto &r = data.region_;
  auto &ht = data.ht_;

  // Maximum depth of the tree.
  const int max_depth = data.max_depth_;

  bool is_src_local = ht.count(src_key) != 0;
  bool is_src_local_leaf = is_src_local && ht[src_key]->IsLeaf();
  bool is_src_remote_leaf = !is_src_local && SFC::GetDepth(src_key) >= max_depth;

  if (is_src_local_leaf) {
    // if the source cell is a remote leaf, we need it (the cell is not longer splittable anyway).
    return;
  }
    else if (is_src_remote_leaf) {
      // If the source cell is a remote leaf, we need it (with it's bodies).
      list_attr.insert(src_key);
      list_body.insert(src_key);
      return;
    }

    // the cell attributes is necessary (because traversal has come here.)
    list_attr.insert(src_key);
    TAPAS_ASSERT(SFC::GetDepth(src_key) <= SFC::MAX_DEPTH);

    auto src_child_keys = SFC::GetChildren(src_key);

    // distance function closure, which returns distance from p
    auto distR2 = [&p](const Vec<TSP::Dim, FP> &v) -> FP {
      FP dx = p.x - v[0];
      FP dy = p.y - v[1];
      FP dz = p.z - v[2];
      return dx * dx + dy * dy + dz * dz;
    };

    for (size_t i = 0; i < src_child_keys.size(); i++) {
      KeyType ckey = src_child_keys[i];
      auto ctr = CellType::CalcCenter(ckey, r);

      FP s = CellType::CalcRegion(ckey, r).width(0); // width
      FP d = std::sqrt(distR2(ctr));

      if (s/d > theta) { // if the cell(ckey) is close
        TraverseLET_old<TSP, SetType>(p, ckey, data, list_attr, list_body);
      } else {
        // If i-th children is far enough from `cell`, the rest of children
        // are also `far`. Thus we don't need to traverse them recursively
        // and just need their attributes(multipole)
        if (ht.count(ckey) == 0) {
          list_attr.insert(ckey);
        }
      }
    }
    // ------ block ends here -------
    return;
}
{'fraction_non_alphanumeric': 0.12112869924294563, 'fraction_numerical': 0.005092911218169305, 'mean_word_length': 2.5169409486931267, 'pattern_counts': {'":': 0, '<': 38, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7528232', 'n_tokens_mistral': 2539, 'n_tokens_neox': 2419, 'n_words': 706}