Skip to content

Commit ccd1bfd

Browse files
committed
feat(delete): add macro to avoid enable size opt in batch deleet
1 parent 978d705 commit ccd1bfd

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ option(CGAL "" OFF)
2525
option(MEMCHECK "" OFF)
2626
option(JEMA "" OFF)
2727
option(CCP "" OFF)
28+
option(DISABLE_BATCH_DELETE_SIZE_OPT "" OFF)
2829

2930

3031
if(CILKPLUS)
@@ -33,6 +34,8 @@ elseif(OPENCILK)
3334
add_compile_options(-DPARLAY_OPENCILK -DCILK -fopencilk)
3435
elseif(SERIAL)
3536
add_compile_options(-DPARLAY_SEQUENTIAL)
37+
elseif(DISABLE_BATCH_DELETE_SIZE_OPT)
38+
add_compile_options(-DDISABLE_BATCH_DELETE_SIZE_OPT)
3639
else()
3740
add_compile_options(-pthread)
3841
endif()

include/psi/base_tree_impl/tree_op/flatten.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ template <typename Point, typename DerivedTree, uint_fast8_t kSkHeight,
1919
template <SupportsForceParallel Interior, bool granularity>
2020
inline bool BaseTree<Point, DerivedTree, kSkHeight,
2121
kImbaRatio>::ForceParallelRecursion(Interior const* TI) {
22+
#ifndef DISABLE_BATCH_DELETE_SIZE_OPT
2223
return (granularity && TI->size > kSerialBuildCutoff) ||
2324
(!granularity && TI->ForceParallel());
25+
#else
26+
return (granularity) || (!granularity && TI->ForceParallel());
27+
#endif // !DISABLE_BATCH_DELETE_SIZE_OPT
2428
}
2529

2630
template <typename Point, typename DerivedTree, uint_fast8_t kSkHeight,

include/psi/kd_tree_impl/kd_batch_delete.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ KdTree<Point, SplitRule, LeafAugType, InteriorAugType, kSkHeight, kImbaRatio>::
6565
}
6666
}
6767

68+
#ifndef DISABLE_BATCH_DELETE_SIZE_OPT
6869
// INFO: it can be used to accelerate the whole deletion process
6970
if (n == T->size) {
7071
if (has_tomb) { // rebuild this subtree
@@ -84,6 +85,7 @@ KdTree<Point, SplitRule, LeafAugType, InteriorAugType, kSkHeight, kImbaRatio>::
8485
T->size = 0;
8586
return NodeBox(T, BT::GetEmptyBox());
8687
}
88+
#endif
8789

8890
if (T->is_leaf) {
8991
return BT::template DeletePoints4Leaf<Leaf, NodeBox>(T, In);
@@ -216,8 +218,13 @@ KdTree<Point, SplitRule, LeafAugType, InteriorAugType, kSkHeight, kImbaRatio>::
216218
assert(IT.tags[IT.rev_tag[i]].second == BT::kBucketNum + 3);
217219

218220
if (IT.tags[IT.rev_tag[i]].first->size == 0) { // NOTE: empty
221+
#ifndef DISABLE_BATCH_DELETE_SIZE_OPT
219222
BT::template DeleteTreeRecursive<Leaf, Interior, false>(
220223
IT.tags[IT.rev_tag[i]].first);
224+
#else
225+
BT::template DeleteTreeRecursive<Leaf, Interior, true>(
226+
IT.tags[IT.rev_tag[i]].first);
227+
#endif
221228
IT.tags[IT.rev_tag[i]].first = AllocEmptyLeafNode<Slice, Leaf>();
222229
} else { // NOTE: rebuild
223230
assert(BT::WithinBox(

include/psi/orth_tree_impl/orth_batch_delete.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Node* OrthTree<Point, SplitRule, LeafAugType, InteriorAugType, kMD, kSkHeight,
5252

5353
// INFO: delete the whole tree directly if its size equals to the input size,
5454
// can be used to accelerate the whole deletion process
55+
#ifndef DISABLE_BATCH_DELETE_SIZE_OPT
5556
if (n == T->size) {
5657
if (has_tomb) {
5758
BT::template DeleteTreeRecursive<Leaf, Interior>(T);
@@ -64,6 +65,7 @@ Node* OrthTree<Point, SplitRule, LeafAugType, InteriorAugType, kMD, kSkHeight,
6465
T->size = 0;
6566
return T;
6667
}
68+
#endif
6769

6870
if (T->is_leaf) {
6971
return BT::template DeletePoints4Leaf<Leaf, Node*>(T, In);
@@ -159,8 +161,15 @@ Node* OrthTree<Point, SplitRule, LeafAugType, InteriorAugType, kMD, kSkHeight,
159161
assert(IT.tags[IT.rev_tag[i]].second == BT::kBucketNum + 3);
160162

161163
if (IT.tags[IT.rev_tag[i]].first->size == 0) { // NOTE: empty
164+
165+
#ifndef DISABLE_BATCH_DELETE_SIZE_OPT
162166
BT::template DeleteTreeRecursive<Leaf, Interior, false>(
163167
IT.tags[IT.rev_tag[i]].first);
168+
#else
169+
BT::template DeleteTreeRecursive<Leaf, Interior, true>(
170+
IT.tags[IT.rev_tag[i]].first);
171+
#endif
172+
164173
IT.tags[IT.rev_tag[i]].first = AllocEmptyLeafNode<Slice, Leaf>();
165174
} else { // NOTE: rebuild
166175
assert(BT::WithinBox(

0 commit comments

Comments
 (0)