Need to write a non-sampling based binary tree builder.

This commit is contained in:
Dongryeol Lee
2011-01-21 04:45:05 +00:00
parent 408959f6dc
commit fac397eda7
3 changed files with 42 additions and 5 deletions
@@ -9,6 +9,7 @@
#define CORE_GNP_DISTRIBUTED_DUALTREE_DFS_H
#include <boost/mpi/communicator.hpp>
#include <boost/thread.hpp>
#include <boost/tuple/tuple.hpp>
#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<TreeType *, TreeType *> work_queue_;
private:
template<typename MetricType>
@@ -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 > {
@@ -13,6 +13,7 @@
#include <boost/mpi.hpp>
#include <boost/tuple/tuple.hpp>
#include <list>
#include <map>
#include <queue>
#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<typename DistributedProblemType>
void DistributedDualtreeDfs<DistributedProblemType>::DoIt_() {
// Dequeue a work.
}
template<typename DistributedProblemType>
template<typename MetricType>
void DistributedDualtreeDfs<DistributedProblemType>::AllToAllReduce_(
@@ -214,6 +222,13 @@ void DistributedDualtreeDfs<DistributedProblemType>::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<typename DistributedProblemType>
@@ -236,11 +251,11 @@ void DistributedDualtreeDfs<DistributedProblemType>::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.
@@ -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<TreeType *> top_leaf_nodes;