-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate header-only mpi c++ wrapper #4833
Comments
acdemiralp/MPIDoes not compile with OpenMPI 5.0 due to the following error:
I have not investigated whether it compiles with earlier versions of OMPI. Dependencies
Other Promising OptionskaMPIngDependencies
Simple example to serialize and send non-trivial type: #include <cereal/types/vector.hpp>
#include "kamping/communicator.hpp"
#include "kamping/p2p/recv.hpp"
#include "kamping/p2p/send.hpp"
#include "kamping/serialization.hpp"
using namespace kamping;
struct Foo {
double x;
std::vector<int> v;
template <class Archive> void serialize(Archive &ar) { ar(x, v); }
};
int main() {
kamping::Environment env;
auto const &comm = kamping::comm_world();
Foo data = {3.14, {1, 2, 3}};
if (comm.is_root()) {
for (size_t dst = 0; dst < comm.size(); dst++) {
if (comm.is_root(dst)) {
continue;
}
comm.send(send_buf(as_serialized(data)), destination(dst));
}
} else {
auto const recv_data =
comm.recv(recv_buf(as_deserializable<Foo>()));
std::cout << "Node " << comm.rank() << " received " << recv_data.x << " "
<< recv_data.v.size() << std::endl;
}
} Cereal supports the boost serialization syntax and therefore there should be no changes needed in the serialization functions. Therefore this attempt to send espresso particles around should just work when exclusions are disabled, however, it does not. Attempt to send espresso Particle: #include "kamping/collectives/allgather.hpp"
#include "kamping/communicator.hpp"
#include "kamping/environment.hpp"
#include "kamping/named_parameters.hpp"
#include "kamping/p2p/send.hpp"
#include <kamping/p2p/recv.hpp>
#include <mpi.h>
#include <array>
#include <iostream>
#include "Particle.hpp"
std::string particle_to_string(Particle const &p) {
auto s = "Particle(pos=()" + std::to_string(p.pos()[0]) + "," +
std::to_string(p.pos()[1]) + "," + std::to_string(p.pos()[2]) +
"), force=(" + std::to_string(p.force()[0]) + "," +
std::to_string(p.force()[1]) + "," + std::to_string(p.force()[2]) +
"), exclusions=(";
#ifdef EXCLUSIONS
for (int i = 0; i < p.exclusions().size(); i++) {
s += std::to_string(p.exclusions().at(i)) + ",";
}
#endif
s += ")";
return s;
}
int main() {
using namespace kamping;
kamping::Environment env;
auto const &comm = kamping::comm_world();
auto p_send = Particle();
auto p_recv = Particle();
p_send.pos()[0] = comm.rank() * 10 - 0;
p_send.pos()[1] = comm.rank() * 10 - 1;
p_send.pos()[2] = comm.rank() * 10 - 2;
p_send.force()[0] = comm.rank() * 100 - 0;
p_send.force()[1] = comm.rank() * 100 - 1;
p_send.force()[2] = comm.rank() * 100 - 2;
#ifdef EXCLUSIONS
p_send.exclusions().push_back(comm.ranke() * 100 + 9);
p_send.exclusions().push_back(comm.ranke() * 100 + 8);
p_send.exclusions().push_back(comm.ranke() * 100 + 7);
p_send.exclusions().push_back(comm.ranke() * 100 + 6);
#endif
auto const own_id = comm.rank();
auto const send_id = (own_id + 1) % 4;
auto const recv_id = (own_id - 1) % 4;
comm.send(destination(send_id), send_buf(kamping::as_serialized(p_send)));
comm.recv(recv_buf(kamping::as_deserializable<Particle>(p_recv)),
source(recv_id));
std::cout << "Rank " << own_id << " sends " << particle_to_string(p_send)
<< " to " << send_id << " and receives "
<< particle_to_string(p_recv) << " from " << recv_id << "\n";
} This is the error message:
TODOs
|
Don't know if this is going to help, but I experienced the exact same error message in OpenMPI 4.1.2 recently. This was due to OpenMPI re-defining all Lines 62 to 70 in 8c90c3d
Regarding the particle struct, honestly I don't see how an error message like |
Regarding the acdemiralp/MPI library:
template <MPI_Datatype data_type>
struct data_type_traits {};
template <> struct data_type_traits<MPI_CHAR > { using type = char ; };
As far as I can tell from the documentation, Cereal does this by default as well. However, bitwise serialization might still be better than calling the
The documentation says boost syntax is also supported, which I confirmed with a simple struct.
Yes, this is what I thought too. My only idea right now is to simplify the |
Thank you for the work you did and for the detailed explanations!
I can confirm it's exactly the same error I encountered. I don't remember if I ever explored
Perfect.
I guess that's the right move. Deciphering cryptic compiler diagnostics is never fun. |
https://github.com/acdemiralp/mpi
This would allow us to get rid of the boost::mpi dependency, which is responsible for a lot of the build hesdaches on hpc systems, conda, pip and friends.
We would still need boost::serialization to send around stuff that is not store contiguously in memory etc.
The text was updated successfully, but these errors were encountered: