Re: [mpiwg-p2p] Question on MPI_PACKED
Yes, you can send packed data and then receive it with a datatype. Example 4.21 (all references to MPI 3.1) does exactly that. An implementation may include metadata in the packed buffer; that’s the reason for MPI_PACK_SIZE and the constraint that you can’t concatenate pack buffers. This does mean that an implementation that includes metadata must handle this case; it can do so by noting that the data was sent with MPI_PACK. There isn’t a truncation problem because the metadata is not delivered; it would only be used to handle and necessary data transformations (e.g., big to little endian). Bill William Gropp Director and Chief Scientist, NCSA Thomas M. Siebel Chair in Computer Science University of Illinois Urbana-Champaign On Jan 24, 2020, at 4:16 AM, Joachim Protze via mpiwg-p2p <[email protected]<mailto:[email protected]>> wrote: 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 [email protected]<mailto:[email protected]> www.itc.rwth-aachen.de _______________________________________________ mpiwg-p2p mailing list [email protected] https://lists.mpi-forum.org/mailman/listinfo/mpiwg-p2p
participants (1)
-
Gropp, William D