Loading src/qcmesh/mpi/src/include/qcmesh/mpi/all_scatter.hpp +15 −1 Original line number Diff line number Diff line Loading @@ -20,10 +20,19 @@ #include <boost/mpi/nonblocking.hpp> #include <boost/mpi/request.hpp> #include <boost/mpi/status.hpp> #include <stdexcept> #include <vector> namespace qcmesh::mpi { /** * @brief Exception class thrown when an input vector has less than `mpi_size` * items. */ struct MpiSizeException : std::runtime_error { using std::runtime_error::runtime_error; }; /** * @brief Similar to boost::mpi::scatter, but scatters from / to all processes. * Loading @@ -42,8 +51,13 @@ void all_scatter(const std::vector<T> &in_values, std::vector<T> &out_values) { auto mpi_requests = std::vector<boost::mpi::request>{}; mpi_requests.reserve(n_requests); if (in_values.size() < mpi_size) throw MpiSizeException{ "in_values does not have size equal to the number of procs"}; if (out_values.size() < mpi_size) out_values.resize(mpi_size); throw MpiSizeException{ "out_values does not have size equal to the number of procs"}; constexpr int TAG = 0; for (std::size_t i_proc = 0; i_proc < mpi_size; i_proc++) Loading Loading
src/qcmesh/mpi/src/include/qcmesh/mpi/all_scatter.hpp +15 −1 Original line number Diff line number Diff line Loading @@ -20,10 +20,19 @@ #include <boost/mpi/nonblocking.hpp> #include <boost/mpi/request.hpp> #include <boost/mpi/status.hpp> #include <stdexcept> #include <vector> namespace qcmesh::mpi { /** * @brief Exception class thrown when an input vector has less than `mpi_size` * items. */ struct MpiSizeException : std::runtime_error { using std::runtime_error::runtime_error; }; /** * @brief Similar to boost::mpi::scatter, but scatters from / to all processes. * Loading @@ -42,8 +51,13 @@ void all_scatter(const std::vector<T> &in_values, std::vector<T> &out_values) { auto mpi_requests = std::vector<boost::mpi::request>{}; mpi_requests.reserve(n_requests); if (in_values.size() < mpi_size) throw MpiSizeException{ "in_values does not have size equal to the number of procs"}; if (out_values.size() < mpi_size) out_values.resize(mpi_size); throw MpiSizeException{ "out_values does not have size equal to the number of procs"}; constexpr int TAG = 0; for (std::size_t i_proc = 0; i_proc < mpi_size; i_proc++) Loading