Dividing up files.

This commit is contained in:
Dongryeol Lee
2010-10-05 17:40:55 +00:00
parent fd0548f655
commit 04ba43850b
5 changed files with 169 additions and 122 deletions
@@ -6,6 +6,9 @@ set(SOURCES
dense_matrix.h
dense_point.h
distributed_table.h
distributed_table_message.h
mailbox.h
point_request_message.h
table.h
transform.h
)
@@ -12,131 +12,12 @@
#include "boost/thread.hpp"
#include "boost/serialization/string.hpp"
#include "core/table/table.h"
#include "core/table/distributed_table_message.h"
#include "core/table/point_request_message.h"
#include "core/table/mailbox.h"
namespace core {
namespace table {
class PointRequestMessage {
private:
bool is_valid_;
int source_rank_;
int point_id_;
friend class boost::serialization::access;
public:
template<class Archive>
void serialize(Archive &ar, const unsigned int version) {
ar & source_rank_;
ar & point_id_;
}
PointRequestMessage() {
Reset();
}
PointRequestMessage(int source_rank_in, int point_id_in) {
source_rank_ = source_rank_in;
point_id_ = point_id_in;
}
bool is_valid() const {
return is_valid_;
}
void Reset() {
is_valid_ = false;
source_rank_ = -1;
point_id_ = -1;
}
void set_valid() {
is_valid_ = true;
}
int source_rank() const {
return source_rank_;
}
int point_id() const {
return point_id_;
}
};
class DistributedTableMessage {
public:
enum DistributedTableRequest { REQUEST_POINT, RECEIVE_POINT, TERMINATE_SERVER };
};
class Mailbox {
public:
boost::mutex termination_mutex_;
boost::condition_variable termination_cond_;
boost::mutex mutex_;
boost::condition_variable point_ready_cond_;
boost::mpi::communicator *communicator_;
std::pair <
boost::mpi::request,
core::table::PointRequestMessage > incoming_request_;
boost::mpi::request outgoing_request_;
std::pair< boost::mpi::request, bool> incoming_receive_request_;
int incoming_receive_source_;
std::vector<double> incoming_point_;
std::vector<double> outgoing_point_;
public:
bool is_done() {
bool first = (communicator_->iprobe(
boost::mpi::any_source,
core::table::DistributedTableMessage::TERMINATE_SERVER));
bool second = first &&
(!communicator_->iprobe(
boost::mpi::any_source,
core::table::DistributedTableMessage::REQUEST_POINT));
bool third = second &&
(!communicator_->iprobe(
boost::mpi::any_source,
core::table::DistributedTableMessage::RECEIVE_POINT));
bool fourth = (
third && incoming_request_.second.is_valid() == false &&
incoming_receive_request_.second == false);
if(fourth) {
try {
bool outgoing_request_done = outgoing_request_.test();
fourth = fourth && outgoing_request_done;
}
catch(boost::mpi::exception &e) {
}
}
return fourth;
}
void set_communicator(boost::mpi::communicator *comm_in) {
communicator_ = comm_in;
}
Mailbox() {
communicator_ = NULL;
incoming_receive_request_.second = false;
}
};
class DistributedTable: public boost::noncopyable {
typedef core::tree::GeneralBinarySpaceTree < core::tree::BallBound <
@@ -0,0 +1,18 @@
/** @file distributed_table_message.h
*
* @author Dongryeol Lee (dongryel@cc.gatech.edu)
*/
#ifndef CORE_TABLE_DISTRIBUTED_TABLE_MESSAGE_H
#define CORE_TABLE_DISTRIBUTED_TABLE_MESSAGE_H
namespace core {
namespace table {
class DistributedTableMessage {
public:
enum DistributedTableRequest { REQUEST_POINT, RECEIVE_POINT, TERMINATE_SERVER };
};
};
};
#endif
@@ -0,0 +1,81 @@
/** @file point_request_message.h
*
* @author Dongryeol Lee (dongryel@cc.gatech.edu)
*/
#ifndef CORE_TABLE_MAILBOX_H
#define CORE_TABLE_MAILBOX_H
#include "core/table/distributed_table_message.h"
namespace core {
namespace table {
class Mailbox {
public:
boost::mutex termination_mutex_;
boost::condition_variable termination_cond_;
boost::mutex mutex_;
boost::condition_variable point_ready_cond_;
boost::mpi::communicator *communicator_;
std::pair <
boost::mpi::request,
core::table::PointRequestMessage > incoming_request_;
boost::mpi::request outgoing_request_;
std::pair< boost::mpi::request, bool> incoming_receive_request_;
int incoming_receive_source_;
std::vector<double> incoming_point_;
std::vector<double> outgoing_point_;
public:
bool is_done() {
bool first = (communicator_->iprobe(
boost::mpi::any_source,
core::table::DistributedTableMessage::TERMINATE_SERVER));
bool second = first &&
(!communicator_->iprobe(
boost::mpi::any_source,
core::table::DistributedTableMessage::REQUEST_POINT));
bool third = second &&
(!communicator_->iprobe(
boost::mpi::any_source,
core::table::DistributedTableMessage::RECEIVE_POINT));
bool fourth = (
third && incoming_request_.second.is_valid() == false &&
incoming_receive_request_.second == false);
if(fourth) {
try {
bool outgoing_request_done = outgoing_request_.test();
fourth = fourth && outgoing_request_done;
}
catch(boost::mpi::exception &e) {
}
}
return fourth;
}
void set_communicator(boost::mpi::communicator *comm_in) {
communicator_ = comm_in;
}
Mailbox() {
communicator_ = NULL;
incoming_receive_request_.second = false;
}
};
};
};
#endif
@@ -0,0 +1,64 @@
/** @file point_request_message.h
*
* @author Dongryeol Lee (dongryel@cc.gatech.edu)
*/
#ifndef CORE_TABLE_POINT_REQUEST_MESSAGE_H
#define CORE_TABLE_POINT_REQUEST_MESSAGE_H
namespace core {
namespace table {
class PointRequestMessage {
private:
bool is_valid_;
int source_rank_;
int point_id_;
friend class boost::serialization::access;
public:
template<class Archive>
void serialize(Archive &ar, const unsigned int version) {
ar & source_rank_;
ar & point_id_;
}
PointRequestMessage() {
Reset();
}
PointRequestMessage(int source_rank_in, int point_id_in) {
source_rank_ = source_rank_in;
point_id_ = point_id_in;
}
bool is_valid() const {
return is_valid_;
}
void Reset() {
is_valid_ = false;
source_rank_ = -1;
point_id_ = -1;
}
void set_valid() {
is_valid_ = true;
}
int source_rank() const {
return source_rank_;
}
int point_id() const {
return point_id_;
}
};
};
};
#endif