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 e0779a83b3..8cc5b24379 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 @@ -9,7 +9,6 @@ #ifndef CORE_GNP_DISTRIBUTED_DUALTREE_DFS_DEV_H #define CORE_GNP_DISTRIBUTED_DUALTREE_DFS_DEV_H -#include #include #include "core/gnp/distributed_dualtree_dfs.h" #include "core/gnp/dualtree_dfs_dev.h" @@ -126,8 +125,15 @@ void DistributedDualtreeDfs::ReduceScatter_( for(typename std::map::const_iterator it = sub_engine.unpruned_reference_nodes().begin(); it != sub_engine.unpruned_reference_nodes().end(); it++) { - receive_requests[i].push_back( - std::pair(it->first, it->second)); + + // This operation might be less than ideal, so change it + // later. + std::pair new_pair(it->first, it->second); + if(std::find( + receive_requests[i].begin(), receive_requests[i].end(), + new_pair) == receive_requests[i].end()) { + receive_requests[i].push_back(new_pair); + } } new_computation_frontier[i].insert( new_computation_frontier[i].end(), diff --git a/fastlib/trunk/contrib/dongryel/thesis_research/core/optimization/optimization.test.cc b/fastlib/trunk/contrib/dongryel/thesis_research/core/optimization/optimization.test.cc index d98af0ffbd..51de05a706 100644 --- a/fastlib/trunk/contrib/dongryel/thesis_research/core/optimization/optimization.test.cc +++ b/fastlib/trunk/contrib/dongryel/thesis_research/core/optimization/optimization.test.cc @@ -284,4 +284,5 @@ int main(int argc, char *argv[]) { core::optimization::TrustRegionSearchMethod::STEIHAUG); printf("All tests passed!"); + return 0; } 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 874db3f2a8..98ae8a9cf8 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 @@ -591,6 +591,14 @@ class DistributedTreeBuilder { printf( "Took %g seconds to read in the distributed tree.\n", distributed_table_index_timer.elapsed()); + printf( + "The following is the distribution of points among all MPI " + "processes.\n"); + for(int i = 0; i < world.size(); i++) { + printf( + "Process %d has %d points.\n", i, + distributed_table_->local_n_entries(i)); + } } } }; diff --git a/fastlib/trunk/contrib/dongryel/thesis_research/core/parallel/table_exchange.h b/fastlib/trunk/contrib/dongryel/thesis_research/core/parallel/table_exchange.h index 177ba87af5..cd97d4e555 100644 --- a/fastlib/trunk/contrib/dongryel/thesis_research/core/parallel/table_exchange.h +++ b/fastlib/trunk/contrib/dongryel/thesis_research/core/parallel/table_exchange.h @@ -16,8 +16,8 @@ namespace core { namespace table { extern core::table::MemoryMappedFile *global_m_file_; -}; -}; +} +} namespace core { namespace parallel { @@ -38,7 +38,7 @@ class TableExchange { std::vector new_from_old_cache_; - std::vector< SubTableListType > received_subtables; + std::vector< SubTableListType > received_subtables_; public: @@ -60,18 +60,18 @@ class TableExchange { SubTableType &FindSubTable(int process_id, int begin, int count) { // Naive search, but probably should use a STL map here... - for(unsigned int i = 0; i < received_subtables[process_id].size(); i++) { + for(unsigned int i = 0; i < received_subtables_[process_id].size(); i++) { if( - received_subtables[ + received_subtables_[ process_id][i].table()->get_tree()->begin() == begin && - received_subtables[ + received_subtables_[ process_id][i].table()->get_tree()->count() == count) { - return received_subtables[process_id][i]; + return received_subtables_[process_id][i]; } } // The code should not get to this point. - return received_subtables[process_id][0]; + return received_subtables_[process_id][0]; } void Init( @@ -150,16 +150,16 @@ class TableExchange { } // Clear the received subtables and resize. - received_subtables.resize(0); - received_subtables.resize(world.size()); + received_subtables_.resize(0); + received_subtables_.resize(world.size()); for(unsigned int j = 0; j < receive_requests.size(); j++) { for(unsigned int i = 0; i < receive_requests[j].size(); i++) { - received_subtables[j].push_back( + received_subtables_[j].push_back( j, point_cache_[j], old_from_new_cache_[j], new_from_old_cache_[j], max_num_levels_to_serialize); } } - boost::mpi::all_to_all(world, send_subtables, received_subtables); + boost::mpi::all_to_all(world, send_subtables, received_subtables_); // Clear the receive requests so that it can be used in the next // iteration. @@ -169,7 +169,7 @@ class TableExchange { return false; } }; -}; -}; +} +} #endif diff --git a/fastlib/trunk/contrib/dongryel/thesis_research/core/table/sub_table.h b/fastlib/trunk/contrib/dongryel/thesis_research/core/table/sub_table.h index d5aa04c61b..594ce090a0 100644 --- a/fastlib/trunk/contrib/dongryel/thesis_research/core/table/sub_table.h +++ b/fastlib/trunk/contrib/dongryel/thesis_research/core/table/sub_table.h @@ -360,7 +360,7 @@ class SubTable { tree_ = table_in->get_tree_offset_ptr(); } }; -}; -}; +} +} #endif diff --git a/fastlib/trunk/contrib/dongryel/thesis_research/core/table/sub_table_list.h b/fastlib/trunk/contrib/dongryel/thesis_research/core/table/sub_table_list.h index 8175fa9b85..fad6079503 100644 --- a/fastlib/trunk/contrib/dongryel/thesis_research/core/table/sub_table_list.h +++ b/fastlib/trunk/contrib/dongryel/thesis_research/core/table/sub_table_list.h @@ -1,4 +1,7 @@ /** @file sub_table_list.h + * + * An abstract class to maintain a list of subtables to aid in the + * all-to-all exchange. * * @author Dongryeol Lee (dongryel@cc.gatech.edu) */ @@ -11,6 +14,9 @@ namespace core { namespace table { + +/** @brief An abstract class for a list of subtables. + */ template class SubTableList { public: @@ -21,20 +27,36 @@ class SubTableList { typedef IncomingSubTableType SubTableType; private: + + // For boost serialization. friend class boost::serialization::access; + /** @brief The list of subtables. + */ std::vector list_; public: + /** @brief Resets the subtable list to be an empty list. + */ + void Reset() { + list_.resize(0); + } + + /** @brief Returns the subtable at a given position. + */ SubTableType &operator[](int pos) { return list_[pos]; } + /** @brief The size of the subtable list. + */ unsigned int size() const { return list_.size(); } + /** @brief Serializes each element of the subtable list. + */ template void serialize(Archive &ar, const unsigned int version) { for(unsigned int i = 0; i < list_.size(); i++) { @@ -42,6 +64,8 @@ class SubTableList { } } + /** @brief Pushes back a subtable for loading. + */ template void push_back( int rank_in, core::table::DenseMatrix &data_alias_in, @@ -54,6 +78,9 @@ class SubTableList { max_num_levels_to_serialize_in); } + /** @brief Pushes back a starting node and the number of levels to + * serialize under. + */ template void push_back( TableType *table_in, TreeType *start_node_in, @@ -63,7 +90,7 @@ class SubTableList { table_in, start_node_in, max_num_levels_to_serialize_in); } }; -}; -}; +} +} #endif