MPI send and recv for std::vector

hello,

Would you please help me send a std::vector<MyClass> vec; from the master node to the slave nodes?

Is it possible to send and receive the whole vector at once, I have to send it element by element?

Thanks,
M

You can (and should) send a normal array in one go.
http://www.mpich.org/static/docs/v3.1/www3/MPI_Sendrecv.html

I'm not sure whether MPI_Datatype will allow a vector, or whether it has to be a primitive type. You could always copy your vector elements into a dynamically-allocated array and send and receive that. Remember to delete the temporary buffer afterwards.
Topic archived. No new replies allowed.