-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom_mpi.cpp
More file actions
19 lines (16 loc) · 787 Bytes
/
custom_mpi.cpp
File metadata and controls
19 lines (16 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include "custom_mpi.h"
void custom_all_gather(boost::mpi::communicator& comm,
std::vector<std::shared_ptr<Timetable>>& input_values,
std::vector<std::shared_ptr<Timetable>>& destination_values) {
int rank = comm.rank();
int size = comm.size();
std::vector<std::shared_ptr<Timetable>> transfer_buffer = std::vector<std::shared_ptr<Timetable>>();
for (int i = 0; i < size; i++) {
transfer_buffer.clear();
if (rank == i) {
transfer_buffer.insert(transfer_buffer.end(), input_values.begin(), input_values.end());
}
boost::mpi::broadcast(comm, transfer_buffer, i);
destination_values.insert(destination_values.end(), transfer_buffer.begin(), transfer_buffer.end());
}
}