<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div>Hi,<br></div>I have a question regarding the use of a communicator in MPI_Pack and MPI_Unpack.<br></div><div>I have googled and search the MPI mailing lists but haven't found an answer.<br></div><div><br></div>The OpenMPI man page for MPI_Pack states:<br>       The comm argument is the  communicator  that  will  be<br>       subsequently used for sending the packed message.<br><br></div><div>And something similar for MPI_Unpack.<br><br></div>Which seems to reflect what is defined in the MPI standards.<br><br></div>Basically, what I would like to do is to have an MPI rank as a coupler.<br></div>That is, receiving a packed message from one application and<br></div>passing it to another application.<br><br></div>Comm_A would be the ranks of application A plus the coupler and<br></div>Comm_B would be the ranks of application B plus the coupler.<br><br></div><div>In this case, MPI_COMM_WORLD = Comm_A U Comm_B.<br></div><div><br></div>I would like to have a solution that does not have the coupler unpacking<br></div>the buffer received from application A and then packing it to send it to application B<br><br></div><div>I just found a very nice explanation of the need for a
        communicator in Pack / Unpack on page 135 of Using MPI Portable Parallel Programming with the
        Message-Passing Interface
      </div><div>second edition by Gropp, Lusk, and Skjellum.<br><br></div><div>If I understand this correctly, it would be legal to use MPI_COMM_WORLD as the communicator<br></div><div>for MPI_Pack and MPI_Unpack. The only downside is that one might not get the optimal performance.<br><br></div><div>The alternative we are using is to use MPI_Pack_external and MPI_Unpack_external<br></div><div>which requires no communicator. But the downside is that on homogeneous little-endian HPCs,<br></div><div>this will always entail byte swapping on packing and unpacking.<br><br></div><div>So my question is: What is the correct and optimal way to implement passing packed messages<br></div><div>in the coupling example described above?<br><br></div><div>kindest regards<br></div><div>Mike<br></div></div>