|
From: <sv...@va...> - 2007-02-08 12:05:05
|
Author: sewardj
Date: 2007-02-08 12:05:03 +0000 (Thu, 08 Feb 2007)
New Revision: 6575
Log:
Handle type MPI_PACKED and associated functions PMPI_Packed and
PMPI_Unpacked.
Modified:
trunk/auxprogs/libmpiwrap.c
Modified: trunk/auxprogs/libmpiwrap.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/auxprogs/libmpiwrap.c 2007-02-08 11:31:03 UTC (rev 6574)
+++ trunk/auxprogs/libmpiwrap.c 2007-02-08 12:05:03 UTC (rev 6575)
@@ -424,8 +424,8 @@
if (ty =3D=3D MPI_DOUBLE) return sizeof(double);
if (ty =3D=3D MPI_BYTE) return 1;
if (ty =3D=3D MPI_LONG_DOUBLE) return sizeof_long_double_image();
+ if (ty =3D=3D MPI_PACKED) return 1;
=20
- /* MPI_PACKED */
/* new in MPI2: */
# if defined(MPI_WCHAR)
if (ty =3D=3D MPI_WCHAR) return sizeof(wchar_t);
@@ -1513,6 +1513,107 @@
=20
/*------------------------------------------------------------*/
/*--- ---*/
+/*--- Sec 3.13, Pack and unpack ---*/
+/*--- ---*/
+/*------------------------------------------------------------*/
+
+/* --- Pack --- */
+/* pre: must be readable: position
+ must be readable: (inbuf,incount,datatype)
+ must be writable: outbuf[0 .. outsize-1]
+ must be writable: outbuf[*position ..=20
+ *position - 1=20
+ + however much space PMPI_Pack_size=20
+ says we will need]
+ post: make readable: outbuf[old *position .. new *position]
+*/
+int WRAPPER_FOR(PMPI_Pack)( void* inbuf, int incount, MPI_Datatype datat=
ype,=20
+ void* outbuf, int outsize,=20
+ int* position, MPI_Comm comm )=20
+{
+ OrigFn fn;
+ int err, szB =3D 0;
+ int position_ORIG =3D *position;
+ VALGRIND_GET_ORIG_FN(fn);
+ before("Pack");
+ /* stay sane */
+ check_mem_is_defined_untyped(position, sizeof(*position));
+ /* check input */
+ check_mem_is_defined(inbuf, incount, datatype);
+ /* check output area's stated bounds make sense */
+ check_mem_is_addressable_untyped(outbuf, outsize);
+ /* check output area's actual used size properly */
+ err =3D PMPI_Pack_size( incount, datatype, comm, &szB );
+ if (err =3D=3D MPI_SUCCESS && szB > 0) {
+ check_mem_is_addressable_untyped(=20
+ ((char*)outbuf) + position_ORIG, szB
+ );
+ }
+
+ CALL_FN_W_7W(err, fn, inbuf,incount,datatype, outbuf,outsize,position=
, comm);
+
+ if (err =3D=3D MPI_SUCCESS && (*position) > position_ORIG) {
+ /* paint output */
+ make_mem_defined_if_addressable_untyped(=20
+ ((char*)outbuf) + position_ORIG, *position - position_ORIG
+ );
+ }
+ after("Pack", err);
+ return err;
+}
+
+/* --- Unpack --- */
+/* pre: must be readable: position
+ must be writable: (outbuf,outcount,datatype)
+ must be writable: outbuf[0 .. outsize-1]
+ must be writable: outbuf[*position ..=20
+ *position - 1=20
+ + however much space PMPI_Pack_size=20
+ says we will need]
+ post: make readable: (outbuf,outcount,datatype)
+ and also do a readability check of
+ inbuf[old *position .. new *position]
+*/
+int WRAPPER_FOR(PMPI_Unpack)( void* inbuf, int insize, int* position,
+ void* outbuf, int outcount, MPI_Datatype d=
atatype,=20
+ MPI_Comm comm )
+{
+ OrigFn fn;
+ int err, szB =3D 0;
+ int position_ORIG =3D *position;
+ VALGRIND_GET_ORIG_FN(fn);
+ before("Unpack");
+ /* stay sane */
+ check_mem_is_defined_untyped(position, sizeof(*position));
+ /* check output area is accessible */
+ check_mem_is_addressable(outbuf, outcount, datatype);
+ /* check input area's stated bounds make sense */
+ check_mem_is_addressable_untyped(inbuf, insize);
+ /* check input area's actual used size properly */
+ err =3D PMPI_Pack_size( outcount, datatype, comm, &szB );
+ if (err =3D=3D MPI_SUCCESS && szB > 0) {
+ check_mem_is_addressable_untyped(=20
+ ((char*)inbuf) + position_ORIG, szB
+ );
+ }
+
+ CALL_FN_W_7W(err, fn, inbuf,insize,position, outbuf,outcount,datatype=
, comm);
+
+ if (err =3D=3D MPI_SUCCESS && (*position) > position_ORIG) {
+ /* recheck input more carefully */
+ check_mem_is_defined_untyped(=20
+ ((char*)inbuf) + position_ORIG, *position - position_ORIG
+ );
+ /* paint output */
+ make_mem_defined_if_addressable( outbuf, outcount, datatype );
+ }
+ after("Unpack", err);
+ return err;
+}
+
+
+/*------------------------------------------------------------*/
+/*--- ---*/
/*--- Sec 4.4, Broadcast ---*/
/*--- ---*/
/*------------------------------------------------------------*/
@@ -2232,7 +2333,7 @@
DEFAULT_WRAPPER_W_1W(Op_free)
DEFAULT_WRAPPER_W_7W(Pack_external)
DEFAULT_WRAPPER_W_4W(Pack_external_size)
-DEFAULT_WRAPPER_W_7W(Pack)
+/* DEFAULT_WRAPPER_W_7W(Pack) */
DEFAULT_WRAPPER_W_4W(Pack_size)
/* int MPI_Pcontrol(const int level, ...) */
/* DEFAULT_WRAPPER_W_4W(Probe) */
@@ -2308,7 +2409,7 @@
DEFAULT_WRAPPER_W_5W(Type_struct)
DEFAULT_WRAPPER_W_2W(Type_ub)
DEFAULT_WRAPPER_W_5W(Type_vector)
-DEFAULT_WRAPPER_W_7W(Unpack)
+/* DEFAULT_WRAPPER_W_7W(Unpack) */
DEFAULT_WRAPPER_W_3W(Unpublish_name)
DEFAULT_WRAPPER_W_7W(Unpack_external)
/* DEFAULT_WRAPPER_W_3W(Waitall) */
|