31 #ifndef __MASTER_NODE__
32 #define __MASTER_NODE__
43 #include <boost/archive/text_oarchive.hpp>
44 #include <boost/archive/text_iarchive.hpp>
45 #include <boost/serialization/vector.hpp>
46 #include <boost/serialization/utility.hpp>
53 ,
class NeighborStrategy_t
60 MasterNode(MPI_Comm master_comm,
size_t buf_size_upper_bound,
size_t dim,
66 MPI_Comm_rank(master_comm, &tmp);
67 myID_ =
static_cast<size_t>(tmp);
69 MPI_Comm_size(master_comm, &tmp);
74 MPI_Alloc_mem(
sizeof(
char) * buf_size_upper_bound,
79 sizeof(
char), MPI_INFO_NULL, master_comm, &
win_);
81 MPI_Win_create(&
revision_, 1,
sizeof(
size_t), MPI_INFO_NULL,
98 void store(
char *local_state,
size_t buffer_size) {
101 MPI_Win_fence(MPI_MODE_NOPUT,
win_rev_);
103 size_t buf_size = buffer_size;
105 std::cout <<
"windows too small: " << buffer_size <<
" / "
109 MPI_Win_fence(MPI_MODE_NOPUT,
win_);
119 SolutionState_t tmp_states;
124 if(i ==
myID_)
continue;
129 MPI_Get(&revision, 1, MPI_UNSIGNED_LONG, i, 0, 1, MPI_UNSIGNED_LONG,
win_rev_);
137 MPI_Win_fence(0,
win_);
139 std::istringstream is(buffer);
140 boost::archive::text_iarchive ia(is);
143 SolutionState_t state;
145 tmp_states.insert(tmp_states.end(), state.begin(), state.end());
148 boost::archive::text_oarchive oa(states);
151 MPI_Free_mem(buffer);
Inform & endl(Inform &inf)
void collect(std::ostringstream &states)
collect all best values from all other masters
char * serialized_best_values_
pointer to MPI window holding current best solution state
std::vector< size_t > revision_state_
revision numbers of my neighbors
void store(char *local_state, size_t buffer_size)
store my best values
MasterNode(MPI_Comm master_comm, size_t buf_size_upper_bound, size_t dim, int island_id)
size_t revision_
my solution state revision number
size_t buf_size_upper_bound_
and upper bound on the allocated memory in the MPI window
std::set< size_t > collectFrom_
neighbors we collect solution states from