[mpiwg-p2p] Question on MPI_PACKED
Joachim Protze
protze at itc.rwth-aachen.de
Fri Jan 24 04:16:36 CST 2020
Hi all,
the exception on MPI_PACKED in the type matching rules (3.3.1) suggests,
that one side of the communication can pack/unpack the message, while
the other side reads/writes natively.
I.e., is the following code valid MPI code?
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
int main() {
int A[100], B[10], psize;
for (int i = 0; i < 100; i++)
A[i] = i;
MPI_Init(NULL, NULL);
MPI_Pack_size(1, MPI_INT, MPI_COMM_SELF, &psize);
void *parr = malloc(psize * 10);
int pos = 0;
for (int i = 0; i < 10; i++)
MPI_Pack(&(A[i * 10]), 1, MPI_INT, parr, psize * 10, &pos,
MPI_COMM_SELF);
// Send the packed data and receive a contiguous buffer
MPI_Sendrecv(parr, pos, MPI_PACKED, 0, 42, B, 10, MPI_INT, 0,
42, MPI_COMM_SELF, MPI_STATUS_IGNORE);
for (int i = 0; i < 10; i++)
printf("%i\n", B[i]);
MPI_Finalize();
}
Can the packed buffer include meta data? This would be reflected by a
larger value in /pos/, right? Can this lead to unexpected message
truncation?
Thanks
Joachim
--
Dipl.-Inf. Joachim Protze
IT Center
Group: High Performance Computing
Division: Computational Science and Engineering
RWTH Aachen University
Seffenter Weg 23
D 52074 Aachen (Germany)
Tel: +49 241 80- 24765
Fax: +49 241 80-624765
protze at itc.rwth-aachen.de
www.itc.rwth-aachen.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5327 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.mpi-forum.org/pipermail/mpiwg-p2p/attachments/20200124/b350da10/attachment.p7s>
More information about the mpiwg-p2p
mailing list