8 #ifndef PROGS_SRC_MPI_MPI_MPI__INLINE_HPP_ 9 #define PROGS_SRC_MPI_MPI_MPI__INLINE_HPP_ 41 #pragma GCC diagnostic push 42 #pragma GCC diagnostic ignored "-Wold-style-cast" 43 MPI_Iprobe(from_rank, 0, MPI_COMM_WORLD, &is_finished, MPI_STATUS_IGNORE);
44 #pragma GCC diagnostic pop 53 unsigned int nb_process;
55 #pragma GCC diagnostic push 56 #pragma GCC diagnostic ignored "-Wold-style-cast" 57 MPI_Comm_size(MPI_COMM_WORLD, reinterpret_cast<int*>(&nb_process));
58 #pragma GCC diagnostic pop 67 char processor_name[MPI_MAX_PROCESSOR_NAME];
70 MPI_Get_processor_name(processor_name, reinterpret_cast<int*>(&len));
72 return std::string(processor_name);
81 #pragma GCC diagnostic push 82 #pragma GCC diagnostic ignored "-Wold-style-cast" 83 MPI_Comm_rank(MPI_COMM_WORLD, reinterpret_cast<int*>(&rank));
84 #pragma GCC diagnostic pop 95 #pragma GCC diagnostic push 96 #pragma GCC diagnostic ignored "-Wold-style-cast" 97 MPI_Send(&n, 1, MPI_UINT32_T, 0, 0, MPI_COMM_WORLD);
98 #pragma GCC diagnostic pop 105 #pragma GCC diagnostic push 106 #pragma GCC diagnostic ignored "-Wold-style-cast" 107 MPI_Send(
nullptr, 0, MPI_UINT32_T, 0, 0, MPI_COMM_WORLD);
108 #pragma GCC diagnostic pop 119 const uint64_t data[4] = {first_n, last_n, bad_first_n, bad_last_n};
121 #pragma GCC diagnostic push 122 #pragma GCC diagnostic ignored "-Wold-style-cast" 123 MPI_Send(data, 4, MPI_UINT64_T, to_rank, 0, MPI_COMM_WORLD);
124 #pragma GCC diagnostic pop 134 const uint64_t data[3] = {n, first_n, last_n};
136 #pragma GCC diagnostic push 137 #pragma GCC diagnostic ignored "-Wold-style-cast" 138 MPI_Send(data, 3, MPI_UINT64_T, to_rank, 0, MPI_COMM_WORLD);
139 #pragma GCC diagnostic pop 148 #pragma GCC diagnostic push 149 #pragma GCC diagnostic ignored "-Wold-style-cast" 150 MPI_Send(&n, 1, MPI_UINT64_T, to_rank, 0, MPI_COMM_WORLD);
151 #pragma GCC diagnostic pop 160 const nat_type data[2] = {first_n, last_n};
162 #pragma GCC diagnostic push 163 #pragma GCC diagnostic ignored "-Wold-style-cast" 164 MPI_Send(data, 2, MPI_UINT64_T, to_rank, 0, MPI_COMM_WORLD);
165 #pragma GCC diagnostic pop 174 #pragma GCC diagnostic push 175 #pragma GCC diagnostic ignored "-Wold-style-cast" 176 MPI_Send(&n, 1, MPI_UINT32_T, to_rank, 0, MPI_COMM_WORLD);
177 #pragma GCC diagnostic pop 186 #pragma GCC diagnostic push 187 #pragma GCC diagnostic ignored "-Wold-style-cast" 188 MPI_Recv(&n, 1, MPI_UINT32_T, from_rank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
189 #pragma GCC diagnostic pop 198 #pragma GCC diagnostic push 199 #pragma GCC diagnostic ignored "-Wold-style-cast" 200 MPI_Recv(
nullptr, 0, MPI_UINT32_T, from_rank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
201 #pragma GCC diagnostic pop 212 #pragma GCC diagnostic push 213 #pragma GCC diagnostic ignored "-Wold-style-cast" 214 MPI_Recv(data, 4, MPI_UINT64_T, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
215 #pragma GCC diagnostic pop 217 return {data[0], data[1], data[2], data[3]};
228 #pragma GCC diagnostic push 229 #pragma GCC diagnostic ignored "-Wold-style-cast" 230 MPI_Recv(data, 3, MPI_UINT64_T, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
231 #pragma GCC diagnostic pop 233 return {data[0], data[1], data[2]};
244 #pragma GCC diagnostic push 245 #pragma GCC diagnostic ignored "-Wold-style-cast" 246 MPI_Recv(&n, 1, MPI_UINT64_T, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
247 #pragma GCC diagnostic pop 254 std::pair<nat_type, nat_type>
260 #pragma GCC diagnostic push 261 #pragma GCC diagnostic ignored "-Wold-style-cast" 262 MPI_Recv(data, 2, MPI_UINT64_T, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
263 #pragma GCC diagnostic pop 265 return std::make_pair(data[0], data[1]);
274 #pragma GCC diagnostic push 275 #pragma GCC diagnostic ignored "-Wold-style-cast" 276 MPI_Recv(&n, 1, MPI_UINT32_T, from_rank, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
277 #pragma GCC diagnostic pop 283 #endif // PROGS_SRC_MPI_MPI_MPI__INLINE_HPP_ unsigned int mpi_rank()
Return the rank of this process.
void send_size_to(unsigned int size, rank_type to_rank)
Send a size to a process.
unsigned int wait_size_from(rank_type from_rank)
Wait and receive a size from a process.
Structure for n, first_n and last_n values.
void send_bool_to_master(bool b)
Send a boolean value to the master.
first_last_bad_bad_type wait_first_last_bad_bad_from_master()
Wait and receive values first_n, last_n and bad_last_n from the master.
void send_finished_to_master()
Send a finished empty message to the master.
nat_type wait_n_from_master()
Wait and receive a value from the master.
sigmaodd::nat_type nat_type
bool wait_bool_from(rank_type from_rank)
Wait and receive a boolean value from a process.
unsigned int mpi_nb_process()
Return the number of process.
void send_n_to(nat_type n, rank_type to_rank)
Send a value to a process.
unsigned int rank_type
Type of MPI rank.
bool is_finished_from(rank_type from_rank)
Return true iff the process send an empty finished message.
std::string mpi_processor_name()
Return the processor name.
std::pair< nat_type, nat_type > wait_range_from_master()
Wait and receive a range (first_n, last_n) from the master.
Structure for first_n, last_n, bad_first_n and bad_last_n values.
void send_first_last_bad_bad_to(nat_type first_n, nat_type last_n, nat_type bad_first_n, nat_type bad_last_n, rank_type to_rank)
Send first_n, last_n, bad_first and bad_last_n to a process.
n_bad_bad_type wait_n_bad_bad_from_master()
Wait and receive values n, first_n and last_n from the master.
void send_range_to(nat_type first_n, nat_type last_n, rank_type to_rank)
Send a range (first_n, last_n) to a process.
void wait_finished_from(rank_type from_rank)
Wait and received a finished empty message from a process.
void send_n_bad_bad_to(nat_type n, nat_type first_n, nat_type last_n, rank_type to_rank)
Send n, first_n and last_n to a process.
constexpr bool is_master(rank_type rank)
Return true iff rank correspond to the master instance.