Another checkpoint, getting closer.
This commit is contained in:
@@ -9,14 +9,41 @@
|
||||
#define CORE_PARALLEL_TABLE_EXCHANGE_H
|
||||
|
||||
#include <boost/mpi.hpp>
|
||||
#include "core/table/memory_mapped_file.h"
|
||||
#include "core/table/dense_matrix.h"
|
||||
|
||||
namespace core {
|
||||
namespace table {
|
||||
extern core::table::MemoryMappedFile *global_m_file_;
|
||||
};
|
||||
};
|
||||
|
||||
namespace core {
|
||||
namespace parallel {
|
||||
class TableExchange {
|
||||
private:
|
||||
std::vector< core::table::DenseMatrix > point_cache_;
|
||||
|
||||
public:
|
||||
|
||||
template<typename DistributedTableType>
|
||||
void Init(
|
||||
boost::mpi::communicator &world,
|
||||
const DistributedTableType &distributed_table) {
|
||||
|
||||
// Preallocate the point cache.
|
||||
point_cache_.resize(world.size());
|
||||
for(int i = 0; i < world.size(); i++) {
|
||||
if(i != world.rank()) {
|
||||
point_cache_[i].Init(
|
||||
distributed_table.n_attributes(),
|
||||
distributed_table.local_n_entries(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename TableType, typename SubTableListType>
|
||||
static void AllToAll(
|
||||
void AllToAll(
|
||||
boost::mpi::communicator &world,
|
||||
int max_num_levels_to_serialize,
|
||||
TableType &local_table,
|
||||
@@ -47,7 +74,8 @@ class TableExchange {
|
||||
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(j, max_num_levels_to_serialize);
|
||||
(*received_subtables)[j].push_back(
|
||||
j, point_cache_[j], max_num_levels_to_serialize);
|
||||
}
|
||||
}
|
||||
boost::mpi::all_to_all(world, send_subtables, *received_subtables);
|
||||
|
||||
@@ -244,10 +244,14 @@ class SubTable {
|
||||
return tree_;
|
||||
}
|
||||
|
||||
void Init(int rank_in, int max_num_levels_to_serialize_in) {
|
||||
void Init(
|
||||
int rank_in, core::table::DenseMatrix &data_alias_in,
|
||||
int max_num_levels_to_serialize_in) {
|
||||
table_ = (core::table::global_m_file_) ?
|
||||
core::table::global_m_file_->Construct<TableType>() :
|
||||
new TableType();
|
||||
table_->data().Alias(
|
||||
data_alias_in.ptr(), data_alias_in.n_rows(), data_alias_in.n_cols());
|
||||
is_alias_ = false;
|
||||
table_->set_rank(rank_in);
|
||||
this->Init(table_, (TreeType *) NULL, max_num_levels_to_serialize_in);
|
||||
|
||||
@@ -35,9 +35,12 @@ class SubTableList {
|
||||
}
|
||||
}
|
||||
|
||||
void push_back(int rank_in, int max_num_levels_to_serialize_in) {
|
||||
void push_back(
|
||||
int rank_in, core::table::DenseMatrix &data_alias_in,
|
||||
int max_num_levels_to_serialize_in) {
|
||||
list_.resize(list_.size() + 1);
|
||||
list_[list_.size() - 1].Init(rank_in, max_num_levels_to_serialize_in);
|
||||
list_[list_.size() - 1].Init(
|
||||
rank_in, data_alias_in, max_num_levels_to_serialize_in);
|
||||
}
|
||||
|
||||
template<typename TableType, typename TreeType>
|
||||
|
||||
@@ -43,10 +43,8 @@ class TestTree {
|
||||
while(node_it.HasNext());
|
||||
|
||||
if(node->is_leaf() == false) {
|
||||
return TestTreeIterator_(
|
||||
table.get_node_left_child(node), table) &&
|
||||
TestTreeIterator_(
|
||||
table.get_node_right_child(node), table);
|
||||
return TestTreeIterator_(node->left(), table) &&
|
||||
TestTreeIterator_(node->right(), table);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
+7
-1
@@ -26,12 +26,18 @@ class MixedLogitDCM {
|
||||
|
||||
private:
|
||||
|
||||
/** @brief Computes the sample data error (Section 3.1)
|
||||
/** @brief Computes the sample data error (Section 3.1).
|
||||
*/
|
||||
double SampleDataError_(
|
||||
const SamplingType &first_sample,
|
||||
const SamplingType &second_sample) const;
|
||||
|
||||
/** @brief Computes the simulation error (Section 3.2).
|
||||
*/
|
||||
double SimulationError_(
|
||||
const SamplingType &first_sample,
|
||||
const SamplingType &second_sample) const;
|
||||
|
||||
public:
|
||||
|
||||
TableType *attribute_table();
|
||||
|
||||
+7
@@ -12,6 +12,13 @@
|
||||
namespace mlpack {
|
||||
namespace mixed_logit_dcm {
|
||||
|
||||
template<typename TableType>
|
||||
double MixedLogitDCM<TableType>::SimulationError_(
|
||||
const SamplingType &first_sample,
|
||||
const SamplingType &second_sample) const {
|
||||
|
||||
}
|
||||
|
||||
template<typename TableType>
|
||||
double MixedLogitDCM<TableType>::SampleDataError_(
|
||||
const SamplingType &first_sample,
|
||||
|
||||
Reference in New Issue
Block a user