title: How to transmit vectors of different types in MPI using one broadcast
body: <p>I have some vectors that I want to transmit between processes using MPI in C++. I have been using <code>broadcast</code> 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.</p>
  
  <p>My problem is that my vectors are of type <code>int</code> and <code>double</code> (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 <code>struct</code> to hold all the data and then broadcast that using a custom MPI structure (MPI_Type_create_struct) as described <a href="https://stackoverflow.com/questions/9864510/struct-serialization-in-c-and-transfer-over-mpi">here</a> 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.</p>
  
  <p>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?</p>