From bd7b5d66bd375cba96141d02664da5a36c64eb4f Mon Sep 17 00:00:00 2001 From: vasiloglou Date: Tue, 29 May 2007 14:27:12 +0000 Subject: [PATCH] Trying to make the balanced case work --- fastlib/u/nvasil/dataset/binary_dataset.h | 2 +- .../mmanager_with_tpie/memory_manager_impl.h | 12 +++---- .../u/nvasil/mmengines_comparisons/build.py | 15 ++++++--- fastlib/u/nvasil/tree/binary_tree_impl.h | 9 +++--- fastlib/u/nvasil/tree/binary_tree_unit.cc | 7 ++-- fastlib/u/nvasil/tree/kd_pivoter2.h | 32 +++++++------------ fastlib/u/nvasil/tree/tree_definitions.h | 4 +-- 7 files changed, 41 insertions(+), 40 deletions(-) diff --git a/fastlib/u/nvasil/dataset/binary_dataset.h b/fastlib/u/nvasil/dataset/binary_dataset.h index 86f2caaab6..db4bd7795a 100644 --- a/fastlib/u/nvasil/dataset/binary_dataset.h +++ b/fastlib/u/nvasil/dataset/binary_dataset.h @@ -63,7 +63,7 @@ class BinaryDataset { it.current_pos_+=i; DEBUG_ASSERT_MSG(it.current_pos_="LI"\n", - it.current_pos_, set_.get_num_of_points()); + it.current_pos_, set_->get_num_of_points()); return it; } Iterator operator--() { diff --git a/fastlib/u/nvasil/mmanager_with_tpie/memory_manager_impl.h b/fastlib/u/nvasil/mmanager_with_tpie/memory_manager_impl.h index a0b9d540ab..41767dfc14 100644 --- a/fastlib/u/nvasil/mmanager_with_tpie/memory_manager_impl.h +++ b/fastlib/u/nvasil/mmanager_with_tpie/memory_manager_impl.h @@ -30,13 +30,13 @@ void MEMORY_MANAGER__::Init() { fd = open ("/dev/zero", O_RDONLY); cache_ = (char *)mmap (NULL, alloc_size_, PROT_WRITE, MAP_PRIVATE, fd, 0); - if (mlock(cache_, alloc_size_) == -1) { + /* if (mlock(cache_, alloc_size_) == -1) { NONFATAL("Could not lock memory manger's cache, error %s\n", strerror(errno)); const char *temp="Memory manager proceeds with unlocked memory," "this may slow down performance\n" ; NONFATAL(temp); - } + }*/ close(fd); page_modified_ = new bool[num_of_pages_]; memset(page_modified_, false, num_of_pages_); @@ -152,12 +152,12 @@ void MEMORY_MANAGER__::Load() { // as write-only, initially. fd = open ("/dev/zero", O_RDONLY); cache_ = (char *)mmap (NULL, alloc_size_, PROT_WRITE, MAP_PRIVATE, fd, 0); - if (mlock(cache_, alloc_size_)==-1) { + /*if (mlock(cache_, alloc_size_)==-1) { NONFATAL("Could not lock memory manager's cache, error %s\n", strerror(errno)); NONFATAL("Memory manager proceeds with unlocked memory," "this may slow down performance\n"); - } + }*/ close (fd); page_modified_ = new bool[num_of_pages_]; memset(page_modified_, false, num_of_pages_); @@ -210,11 +210,11 @@ void MEMORY_MANAGER__::Destruct() { delete []cache_to_page_; delete []page_locks_; // delete cache - if (unlikely(munlock(cache_, alloc_size_)==-1)) { + /*if (unlikely(munlock(cache_, alloc_size_)==-1)) { NONFATAL("Could not unlock memory manger's cache, error %s\n", strerror(errno)); NONFATAL("Continue execution\n"); - } + }*/ munmap(cache_, alloc_size_); delete []page_modified_; // Before closing the file we update the number of total ram pages diff --git a/fastlib/u/nvasil/mmengines_comparisons/build.py b/fastlib/u/nvasil/mmengines_comparisons/build.py index 58a0c6522d..2f04f04541 100644 --- a/fastlib/u/nvasil/mmengines_comparisons/build.py +++ b/fastlib/u/nvasil/mmengines_comparisons/build.py @@ -1,7 +1,14 @@ binrule( - name="memcomp", + name="memcomp1", sources=["main.cc"], - linkables = ["fastlib:fastlib", "u/nvasil/mmanager:mmapmm", - "u/nvasil/mmanager_with_tpie:tpiemm", - "u/nvasil/tree:binarytree"] + deplibs = ["fastlib:fastlib", "u/nvasil/mmanager:mmapmm", + "u/nvasil/mmanager_with_tpie:tpiemm", + "u/nvasil/tree:binarytree"] + ) +binrule( + name="memcomp2", + sources=["main.cc"], + deplibss = ["fastlib:fastlib", "u/nvasil/mmanager:mmapmm", + "u/nvasil/mmanager_with_tpie:tpiemm", + "u/nvasil/tree:binarytree"] ) diff --git a/fastlib/u/nvasil/tree/binary_tree_impl.h b/fastlib/u/nvasil/tree/binary_tree_impl.h index ea001bb155..d1efa1bbd0 100644 --- a/fastlib/u/nvasil/tree/binary_tree_impl.h +++ b/fastlib/u/nvasil/tree/binary_tree_impl.h @@ -209,11 +209,12 @@ void TREE__::NearestNeighbor(POINTTYPE test_point, vector > *nearest_point, NEIGHBORTYPE range) { - LOKI_STATIC_CHECK((NodeInitializerTrait::IsItGoodForRangeNN && - Loki::TypeTraits::isStdFloat==true) || - Loki::TypeTraits::isStdFloat==false, - You_are_using_the_wrong_node_probably_KnnNode_instead_of_Node); + LOKI_STATIC_CHECK((NodeInitializerTrait::IsItGoodForRangeNN && + Loki::TypeTraits::isStdFloat==true) || + Loki::TypeTraits::isStdFloat==false, + You_are_using_the_wrong_node_probably_KnnNode_instead_of_Node); + bool found = false; NearestNeighbor(parent_, test_point, diff --git a/fastlib/u/nvasil/tree/binary_tree_unit.cc b/fastlib/u/nvasil/tree/binary_tree_unit.cc index c2787533b8..759aa08b43 100644 --- a/fastlib/u/nvasil/tree/binary_tree_unit.cc +++ b/fastlib/u/nvasil/tree/binary_tree_unit.cc @@ -314,7 +314,10 @@ struct NodeParameters2 { typedef NullStatistics NodeCachedStatistics_t; typedef SimpleDiscriminator PointIdDiscriminator_t; }; - +struct TreeParameters2 { + typedef Node Node_t; + typedef KdPivoter1 Pivot_t; +}; struct TreeParameters3 { typedef Node Node_t; typedef KdPivoter2 Pivot_t; @@ -328,7 +331,7 @@ struct TreeParameters4 { typedef BinaryTreeTest BinaryTreeTest1_t; typedef BinaryTreeTest BinaryTreeTest2_t; typedef BinaryTreeTest BinaryTreeTest3_t; -typedef BinaryTreeTest BinaryTreeTest4_t; +//typedef BinaryTreeTest BinaryTreeTest4_t; int main(int argc, char *argv[]) { BinaryTreeTest1_t test1; diff --git a/fastlib/u/nvasil/tree/kd_pivoter2.h b/fastlib/u/nvasil/tree/kd_pivoter2.h index c894fc775c..20518f062c 100644 --- a/fastlib/u/nvasil/tree/kd_pivoter2.h +++ b/fastlib/u/nvasil/tree/kd_pivoter2.h @@ -21,7 +21,7 @@ #include "fastlib/fastlib.h" #include "u/nvasil/dataset/binary_dataset.h" -#include "hyper_rectangle.h" +#include "u/nvasil/tree/hyper_rectangle.h" using namespace std; template class KdPivoter2 { @@ -50,7 +50,7 @@ class KdPivoter2 { } bool operator()(const CompletePoint &p1, const CompletePoint &p2) const { - return p1[pivot_dimension_] operator()(PivotInfo *pivot) { int32 dimension = data_->get_dimension(); - int32 max_range_dimension = pivot->box_.get_pivot_dimension(); index_t left_points = pivot->num_of_points_/2; index_t right_points = pivot->num_of_points_ - left_points; - BinaryDataset::Iterator it=data_.Begin()+left_points; + typename BinaryDataset::Iterator it= + data_->Begin()+pivot_->start_+left_points; Comparator comp; - comp.Init(pivot->box.get_pivot_dimension()); - std::nth_element(data_->Begin(), it, data_->End(), comp); - hr_left.Init(dimension); - hr_right.Init(dimension); + comp.Init(pivot->box_.get_pivot_dimension()); + std::nth_element(data_->Begin()+pivot->start_, it, + data_->Begin()+pivot->start_+pivot->num_of_points_, comp); - index_t left_start = pivot->start_; - index_t right_start = pivot->start_ + pivot->num_of_points_-1; - int32 dimension = data_->get_dimension(); - int32 max_range_dimension = pivot->box_.get_pivot_dimension(); - Precision_t pivot_value = pivot->box_.get_pivot_value(); - Precision_t *point_left = data_->At(left_start); - Precision_t *point_right = data_->At(right_start); - index_t left_points=0; - index_t right_points=0; - HyperRectangle_t hr_left; + HyperRectangle_t hr_left; HyperRectangle_t hr_right; hr_left.Init(dimension); hr_right.Init(dimension); - for(index_t i=0; istart_; + for(index_t i=left_start; iAt(i), hr_left); } - for(index_t i=left_points; inum_of_points_; i++) { UpdateHyperRectangle(data_->At(i), hr_right); } FindPivotDimensionValue(hr_left); FindPivotDimensionValue(hr_right); - PivotInfo* pv_left = new PivotInfo(); pv_left->Init(left_start, left_points, hr_left); PivotInfo* pv_right = new PivotInfo(); diff --git a/fastlib/u/nvasil/tree/tree_definitions.h b/fastlib/u/nvasil/tree/tree_definitions.h index 0550a01e30..b0433f7a6f 100644 --- a/fastlib/u/nvasil/tree/tree_definitions.h +++ b/fastlib/u/nvasil/tree/tree_definitions.h @@ -50,12 +50,12 @@ TREE_PARAMETERS(MMAPMM, false); struct BasicTypes1 { typedef float32 Precision_t; - typedef tpiemm::MemoryManager Allocator_t; + typedef tpiemm::MemoryManager Allocator_t; typedef EuclideanMetric Metric_t; }; struct NodeParameters1 { typedef float32 Precision_t; - typedef tpiemm::MemoryManager Allocator_t; + typedef tpiemm::MemoryManager Allocator_t; typedef EuclideanMetric Metric_t; typedef HyperRectangle BoundingBox_t; typedef NullStatistics NodeCachedStatistics_t;