<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
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.
<div class=""><br class="">
</div>
<div class="">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).</div>
<div class=""><br class="">
</div>
<div class="">Bill</div>
<div class=""><br class="">
<div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">
William Gropp<br class="">
Director and Chief Scientist, NCSA<br class="">
Thomas M. Siebel Chair in Computer Science<br class="">
University of Illinois Urbana-Champaign</div>
<br class="Apple-interchange-newline">
</div>
</div>
<br class="Apple-interchange-newline">
</div>
<br class="Apple-interchange-newline">
</div>
<br class="Apple-interchange-newline">
<br class="Apple-interchange-newline">
</div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Jan 24, 2020, at 4:16 AM, Joachim Protze via mpiwg-p2p <<a href="mailto:mpiwg-p2p@lists.mpi-forum.org" class="">mpiwg-p2p@lists.mpi-forum.org</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">Hi all,<br class="">
<br class="">
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.<br class="">
<br class="">
I.e., is the following code valid MPI code?<br class="">
<br class="">
<br class="">
#include <mpi.h><br class="">
#include <stdio.h><br class="">
#include <stdlib.h><br class="">
<br class="">
int main() {<br class="">
 int A[100], B[10], psize;<br class="">
<br class="">
 for (int i = 0; i < 100; i++)<br class="">
   A[i] = i;<br class="">
<br class="">
 MPI_Init(NULL, NULL);<br class="">
 MPI_Pack_size(1, MPI_INT, MPI_COMM_SELF, &psize);<br class="">
 void *parr = malloc(psize * 10);<br class="">
 int pos = 0;<br class="">
 for (int i = 0; i < 10; i++)<br class="">
   MPI_Pack(&(A[i * 10]), 1, MPI_INT, parr, psize * 10, &pos,<br class="">
            MPI_COMM_SELF);<br class="">
 // Send the packed data and receive a contiguous buffer<br class="">
 MPI_Sendrecv(parr, pos, MPI_PACKED, 0, 42, B, 10, MPI_INT, 0, <span class="Apple-tab-span" style="white-space:pre">
</span><br class="">
              42, MPI_COMM_SELF, MPI_STATUS_IGNORE);<br class="">
<br class="">
 for (int i = 0; i < 10; i++)<br class="">
   printf("%i\n", B[i]);<br class="">
 MPI_Finalize();<br class="">
}<br class="">
<br class="">
<br class="">
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?<br class="">
<br class="">
Thanks<br class="">
Joachim<br class="">
<br class="">
-- <br class="">
Dipl.-Inf. Joachim Protze<br class="">
<br class="">
IT Center<br class="">
Group: High Performance Computing<br class="">
Division: Computational Science and Engineering<br class="">
RWTH Aachen University<br class="">
Seffenter Weg 23<br class="">
D 52074  Aachen (Germany)<br class="">
Tel: +49 241 80- 24765<br class="">
Fax: +49 241 80-624765<br class="">
<a href="mailto:protze@itc.rwth-aachen.de" class="">protze@itc.rwth-aachen.de</a><br class="">
www.itc.rwth-aachen.de<br class="">
<br class="">
_______________________________________________<br class="">
mpiwg-p2p mailing list<br class="">
mpiwg-p2p@lists.mpi-forum.org<br class="">
https://lists.mpi-forum.org/mailman/listinfo/mpiwg-p2p<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>