From fac397eda7e3352d99b85d09050f496d8b9e06eb Mon Sep 17 00:00:00 2001 From: Dongryeol Lee Date: Fri, 21 Jan 2011 04:45:05 +0000 Subject: [PATCH] Need to write a non-sampling based binary tree builder. --- .../core/gnp/distributed_dualtree_dfs.h | 22 ++++++++++++++++++ .../core/gnp/distributed_dualtree_dfs_dev.h | 23 +++++++++++++++---- .../core/parallel/distributed_tree_builder.h | 2 +- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/fastlib/trunk/contrib/dongryel/thesis_research/core/gnp/distributed_dualtree_dfs.h b/fastlib/trunk/contrib/dongryel/thesis_research/core/gnp/distributed_dualtree_dfs.h index b652129539..92adf0ca00 100644 --- a/fastlib/trunk/contrib/dongryel/thesis_research/core/gnp/distributed_dualtree_dfs.h +++ b/fastlib/trunk/contrib/dongryel/thesis_research/core/gnp/distributed_dualtree_dfs.h @@ -9,6 +9,7 @@ #define CORE_GNP_DISTRIBUTED_DUALTREE_DFS_H #include +#include #include #include "core/math/range.h" @@ -34,14 +35,30 @@ class DistributedDualtreeDfs { private: + /** @brief The pointer to the boost communicator. + */ boost::mpi::communicator *world_; + /** @brief The problem definition for the distributed computation. + */ DistributedProblemType *problem_; + /** @brief The distributed query table. + */ DistributedTableType *query_table_; + /** @brief The distributed reference table. + */ DistributedTableType *reference_table_; + /** @brief The worker pool. + */ + boost::thread_group worker_pool_; + + /** @brief The work queue from which the workers work. + */ + std::multimap work_queue_; + private: template @@ -63,6 +80,11 @@ class DistributedDualtreeDfs { const MetricType &metric, TreeType *qnode, ResultType *query_results); + static void DoIt_(); + + /** @brief The class used for prioritizing a computation object + * (query, reference pair). + */ class PrioritizeTasks_: public std::binary_function < FrontierObjectType &, FrontierObjectType &, bool > { diff --git a/fastlib/trunk/contrib/dongryel/thesis_research/core/gnp/distributed_dualtree_dfs_dev.h b/fastlib/trunk/contrib/dongryel/thesis_research/core/gnp/distributed_dualtree_dfs_dev.h index 556466ba91..ed3482b7b1 100644 --- a/fastlib/trunk/contrib/dongryel/thesis_research/core/gnp/distributed_dualtree_dfs_dev.h +++ b/fastlib/trunk/contrib/dongryel/thesis_research/core/gnp/distributed_dualtree_dfs_dev.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "core/gnp/distributed_dualtree_dfs.h" #include "core/gnp/dualtree_dfs_dev.h" @@ -30,6 +31,13 @@ extern core::table::MemoryMappedFile *global_m_file_; namespace core { namespace gnp { +template +void DistributedDualtreeDfs::DoIt_() { + + // Dequeue a work. + +} + template template void DistributedDualtreeDfs::AllToAllReduce_( @@ -214,6 +222,13 @@ void DistributedDualtreeDfs::Init( if(query_table_ != reference_table_) { ResetStatisticRecursion_(reference_table_->get_tree(), reference_table_); } + + // Start the thread worker pool. + //const int num_worker_threads = 8; + //for(int i = 0; i < num_worker_threads; i++) { + //worker_pool_.create_thread( + // DistributedDualtreeDfs < DistributedProblemType >::DoIt_); + //} } template @@ -236,11 +251,11 @@ void DistributedDualtreeDfs::Compute( PreProcessReferenceTree_(reference_table_->get_tree()); PreProcessReferenceTree_(reference_table_->local_table()->get_tree()); - // Figure out each process's work using the global tree. This is - // done using a naive approach where the global goal is to complete - // a 2D matrix workspace. This is currently doing an all-reduce type - // of exchange. + // Figure out each process's work using the global tree. a 2D matrix + // workspace. This is currently doing an all-reduce type of + // exchange. AllToAllReduce_(metric, query_results); + worker_pool_.join_all(); world_->barrier(); // Postprocess. diff --git a/fastlib/trunk/contrib/dongryel/thesis_research/core/parallel/distributed_tree_builder.h b/fastlib/trunk/contrib/dongryel/thesis_research/core/parallel/distributed_tree_builder.h index e8c10f47cb..51cfd7f1a0 100644 --- a/fastlib/trunk/contrib/dongryel/thesis_research/core/parallel/distributed_tree_builder.h +++ b/fastlib/trunk/contrib/dongryel/thesis_research/core/parallel/distributed_tree_builder.h @@ -541,7 +541,7 @@ class DistributedTreeBuilder { global_root_bound.get(i) = global_root_bound_vector[i]; } - for(int num_outer_it = 0; num_outer_it < 3; num_outer_it++) { + for(int num_outer_it = 0; num_outer_it < 30; num_outer_it++) { // Build the initial sample tree. std::vector top_leaf_nodes;