|
From: <sv...@va...> - 2006-10-02 00:38:08
|
Author: sewardj
Date: 2006-10-02 01:38:05 +0100 (Mon, 02 Oct 2006)
New Revision: 6139
Log:
- Minor changes for mpxlc
- kludge; add option "initkludge" to cause PMPI_Init to return
&mpiwrap_walk_type_EXTERNALLY_VISIBLE
and adjust mpiwrap_type_test.c accordingly
Modified:
branches/AIX5/auxprogs/libmpiwrap.c
branches/AIX5/auxprogs/mpiwrap_type_test.c
Modified: branches/AIX5/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
--- branches/AIX5/auxprogs/libmpiwrap.c 2006-10-02 00:29:33 UTC (rev 6138=
)
+++ branches/AIX5/auxprogs/libmpiwrap.c 2006-10-02 00:38:05 UTC (rev 6139=
)
@@ -84,11 +84,20 @@
=20
/* Where are API symbols?
Open MPI lib/libmpi.so, soname =3D libmpi.so.0
+ AIX: in /usr/lpp/ppe.poe/lib/libmpi_r.a(mpicore*_r.o)
ditto Quadrics MPI
*/
/* ifdef OpenMPI ... */
-#define I_WRAP_FNNAME_U(_name) I_WRAP_SONAME_FNNAME_ZU(libmpiZdsoZa,_nam=
e)
+#if defined(_AIX)
+# define I_WRAP_FNNAME_U(_name) \
+ I_WRAP_SONAME_FNNAME_ZU(libmpiZurZdaZLmpicoreZaZurZdoZR,_name)
+ /* Don't change this without also changing all the names in
+ libmpiwrap.exp. */
+#else
+# define I_WRAP_FNNAME_U(_name) \
+ I_WRAP_SONAME_FNNAME_ZU(libmpiZdsoZa,_name)
=20
+#endif
=20
/*------------------------------------------------------------*/
/*--- Decls ---*/
@@ -119,11 +128,12 @@
static const char* preamble =3D "valgrind MPI wrappers";
=20
/* established at startup */
-static pid_t my_pid =3D -1;
-static char* options_str =3D NULL;
-static int opt_verbosity =3D 1;
-static Bool opt_missing =3D 0; /* 0:silent; 1:warn; 2:abort */
-static Bool opt_help =3D False;
+static pid_t my_pid =3D -1;
+static char* options_str =3D NULL;
+static int opt_verbosity =3D 1;
+static Bool opt_missing =3D 0; /* 0:silent; 1:warn; 2:abort */
+static Bool opt_help =3D False;
+static Bool opt_initkludge =3D False;
=20
static void before ( char* fnname )
{
@@ -145,6 +155,8 @@
opt_verbosity--;
if (NULL !=3D strstr(options_str, "help"))
opt_help =3D True;
+ if (NULL !=3D strstr(options_str, "initkludge"))
+ opt_initkludge =3D True;
}
if (opt_verbosity > 0)
fprintf(stderr, "%s %5d: Active for pid %d\n",=20
@@ -160,13 +172,14 @@
fprintf(stderr, "Valid options for the MPIWRAP_DEBUG environmen=
t"
" variable are:\n");
fprintf(stderr, "\n");
- fprintf(stderr, " quiet be silent except for errors\n");
- fprintf(stderr, " verbose show wrapper entries/exits\n");
- fprintf(stderr, " strict abort the program if a function"
+ fprintf(stderr, " quiet be silent except for errors\n")=
;
+ fprintf(stderr, " verbose show wrapper entries/exits\n");
+ fprintf(stderr, " strict abort the program if a function=
"
" with no wrapper is used\n");
- fprintf(stderr, " warn give a warning if a function"
+ fprintf(stderr, " warn give a warning if a function"
" with no wrapper is used\n");
- fprintf(stderr, " help display this message, then exit\=
n");
+ fprintf(stderr, " help display this message, then exit=
\n");
+ fprintf(stderr, " initkludge debugging hack; do not use\n");
fprintf(stderr, "\n");
fprintf(stderr, "Multiple options are allowed, eg"
" MPIWRAP_DEBUG=3Dstrict,verbose\n");
@@ -186,7 +199,7 @@
fprintf(stderr, "%s %5d: enter PMPI_%s\n", preamble, my_pid, fnna=
me );
}
=20
-static inline void after ( char* fnname, int err )
+static __inline__ void after ( char* fnname, int err )
{
if (opt_verbosity > 1)
fprintf(stderr, "%s %5d: exit PMPI_%s (err =3D %d)\n",=20
@@ -291,21 +304,21 @@
/* Note, PMPI_Comm_rank/size are themselves wrapped. Should work
fine. */
=20
-static inline int comm_rank ( MPI_Comm comm )=20
+static __inline__ int comm_rank ( MPI_Comm comm )=20
{
int err, r;
err =3D PMPI_Comm_rank(comm, &r);
return err ? 0/*arbitrary*/ : r;
}
=20
-static inline int comm_size ( MPI_Comm comm )=20
+static __inline__ int comm_size ( MPI_Comm comm )=20
{
int err, r;
err =3D PMPI_Comm_size(comm, &r);
return err ? 0/*arbitrary*/ : r;
}
=20
-static inline Bool count_from_Status( /*OUT*/int* recv_count,=20
+static __inline__ Bool count_from_Status( /*OUT*/int* recv_count,=20
MPI_Datatype datatype,=20
MPI_Status* status)
{
@@ -326,7 +339,7 @@
types that support assignment and equality operations." Hence the
following function should compile for any compliant definition of
MPI_Request. */
-static inline=20
+static __inline__=20
Bool eq_MPI_Request ( MPI_Request r1, MPI_Request r2 )
{
return r1 =3D=3D r2;
@@ -674,7 +687,7 @@
void mpiwrap_walk_type_EXTERNALLY_VISIBLE
( void(*f)(void*,long), char* base, MPI_Datatype ty )
{
- return walk_type(f, base, ty);
+ walk_type(f, base, ty);
}
=20
=20
@@ -688,7 +701,7 @@
----------------
*/
=20
-static inline
+static __inline__
void check_mem_is_defined_untyped ( void* buffer, long nbytes )
{
if (nbytes > 0) {
@@ -696,7 +709,7 @@
}
}
=20
-static inline
+static __inline__
void check_mem_is_addressable_untyped ( void* buffer, long nbytes )
{
if (nbytes > 0) {
@@ -704,7 +717,7 @@
}
}
=20
-static inline
+static __inline__
void make_mem_defined_if_addressable_untyped ( void* buffer, long nbytes=
)
{
if (nbytes > 0) {
@@ -712,7 +725,7 @@
}
}
=20
-static inline
+static __inline__
void make_mem_defined_if_addressable_if_success_untyped ( int err,=20
void* buffer, long nbytes )
{
@@ -724,7 +737,7 @@
/* Set the specified area to 'addressible but undefined'
(safe-to-write) state. */
=20
-static inline
+static __inline__
void make_mem_undefined_untyped ( void* buffer, long nbytes )
{
if (nbytes > 0) {
@@ -874,7 +887,11 @@
int err;
VALGRIND_GET_ORIG_FN(fn);
before("Get_count");
+# if defined(_AIX)
+ check_mem_is_addressable_untyped(status, sizeof(*status));
+# else
check_mem_is_defined_untyped(status, sizeof(*status));
+# endif
CALL_FN_W_WWW(err, fn, status,ty,count);
after("Get_count", err);
return err;
@@ -1061,7 +1078,7 @@
if (count < 0)=20
count =3D 0; /* Hmm. Call Mulder and Scully. */
copy =3D malloc( count * sizeof(MPI_Request) );
- if (copy =3D=3D NULL) {
+ if (copy =3D=3D NULL && count > 0) {
UNLOCK_SREQS;
barf("clone_Request_array: malloc failed");
}
@@ -1776,7 +1793,7 @@
=20
/* --- Init --- */
/* rd: *argc, *argv[0 .. *argc-1] */
-int WRAPPER_FOR(PMPI_Init)(int *argc, char ***argv)
+long WRAPPER_FOR(PMPI_Init)(int *argc, char ***argv)
{
OrigFn fn;
int err;
@@ -1786,7 +1803,10 @@
check_mem_is_defined_untyped(*argv, *argc * sizeof(char**));
CALL_FN_W_WW(err, fn, argc,argv);
after("Init", err);
- return err;
+ if (opt_initkludge)
+ return (long)(void*)&mpiwrap_walk_type_EXTERNALLY_VISIBLE;
+ else
+ return (long)err;
}
=20
/* --- Initialized --- */
Modified: branches/AIX5/auxprogs/mpiwrap_type_test.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
--- branches/AIX5/auxprogs/mpiwrap_type_test.c 2006-10-02 00:29:33 UTC (r=
ev 6138)
+++ branches/AIX5/auxprogs/mpiwrap_type_test.c 2006-10-02 00:38:05 UTC (r=
ev 6139)
@@ -9,7 +9,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
-#include <dlfcn.h>
#include "mpi.h"
#include "../memcheck/memcheck.h"
=20
@@ -19,6 +18,8 @@
#define False ((Bool)0)
#define True ((Bool)1)
=20
+void* walk_type_fn =3D NULL;
+
static Ty tycon_Contiguous ( int count, Ty t )
{
Ty t2; =20
@@ -96,7 +97,7 @@
return tres;
}
=20
-//////////////////////////////////////
+/* ------------------------------ */
=20
char characterise ( unsigned char b )
{
@@ -125,23 +126,14 @@
char* rbuf_walk;
int r;
=20
- void* dl_handle =3D NULL;
-
/* C: what a fabulous functional programming language :-) */
- void(*dl_walk_type)(void(*)(void*,long),char*,MPI_Datatype) =3D NULL;
-
- /* NULL: gives a handle which is RTLD_GLOBAL syms in current
- process image */
- dl_handle =3D dlopen(NULL, RTLD_LAZY);
- if (!dl_handle) {
- printf("sendToMyself: can't dlopen current process image\n");
- return;
- }
- dl_walk_type =3D dlsym(dl_handle, "mpiwrap_walk_type_EXTERNALLY_VISIB=
LE");
+ void(*dl_walk_type)(void(*)(void*,long),char*,MPI_Datatype)=20
+ =3D (void(*)(void(*)(void*,long),char*,MPI_Datatype))
+ walk_type_fn;
+ =20
if (!dl_walk_type) {
printf("sendToMyself: can't find mpiwrap_walk_type_EXTERNALLY_VISI=
BLE"
" in current process image\n");
- dlclose(dl_handle);
return;
}
=20
@@ -192,7 +184,6 @@
=20
dl_walk_type( sendToMyself_callback, rbuf_walk, *tyP );
=20
- dlclose(dl_handle);
if (commit_free) {
r =3D MPI_Type_free( tyP );
assert(r =3D=3D MPI_SUCCESS);
@@ -225,13 +216,22 @@
int main ( int argc, char** argv )
{
int rank, size;
+ char* opts;
=20
if (!RUNNING_ON_VALGRIND) {
printf("error: this program must be run on valgrind\n");
return 1;
}
+ opts =3D getenv("MPIWRAP_DEBUG");
+ if ((!opts) || NULL=3D=3Dstrstr(opts, "initkludge")) {
+ printf("error: program requires MPIWRAP_DEBUG=3Dinitkludge\n");
+ return 1;
+ }
=20
- MPI_Init( &argc, &argv );
+ walk_type_fn =3D (void*)(long) MPI_Init( &argc, &argv );
+ printf("mpiwrap_type_test: walk_type_fn =3D %p\n", walk_type_fn);
+ assert(walk_type_fn);
+
MPI_Comm_size( MPI_COMM_WORLD, &size );
MPI_Comm_rank( MPI_COMM_WORLD, &rank );
=20
|