I have some vectors that I want to transmit between processes using MPI in C++. I have been using broadcast
to exchange the data one vector at a time, but it doesn't seem to scale up well with the number of processes. I was told that this is because I am using too many broadcast calls and it causes too much lag as the number of processes increases. Therefore, it was recommended to me to pack all the data in one structure, and send them all in one go.
My problem is that my vectors are of type int
and double
(2 vectors of each type), and their length is not known at compile time (it's equal to the number of processes). Therefore, I cannot create a struct
to hold all the data and then broadcast that using a custom MPI structure (MPI_Type_create_struct) as described here because it requires to hardcode the sizes of the c-arrays at compile time. I know how to create the MPI custom structure, but I can't figure out how to pack the data into a struct in order to send it.
So, to sum up, is there a way to broadcast 4 vectors of different types (2 int and 2 double) between processes using only one broadcast?
struct
s. – Hristo IlievMPI_BOTTOM
as the data buffer address in the call toMPI_Send
. Just use your favourite search engine to search for"MPI_Type_create_struct" "MPI_BOTTOM"
. – Hristo Iliev