Commit 05c6df55 authored by William Gropp's avatar William Gropp
Browse files

[svn-r4674] Added support for exporting the debug versions of the nesting...

[svn-r4674] Added support for exporting the debug versions of the nesting macros to help find nesting errors in ROMIO
parent bb8f8ab7
......@@ -2286,6 +2286,11 @@ void MPIR_Nest_incr_export(void);
void MPIR_Nest_decr_export(void);
#ifdef MPICH_DEBUG_NESTING
/* These two routines export the versions of the nest macros that
provide the file/line where the nest value changes, also for use in ROMIO */
void MPIR_Nest_incr_export_dbg(const char *, int);
void MPIR_Nest_decr_export_dbg(const char *, int);
/* FIXME: We should move the initialization and error reporting into
routines that can be called when necessary */
#define MPIR_Nest_init() {\
......@@ -2302,10 +2307,15 @@ void MPIR_Nest_decr_export(void);
MPICH_MAX_NESTFILENAME);\
MPIU_THREADPRIV_FIELD(nestinfo)[MPIU_THREADPRIV_FIELD(nest_count)].line=__LINE__;}\
MPIU_THREADPRIV_FIELD(nest_count)++; }
#define MPIR_Nest_decr() {MPIU_THREADPRIV_FIELD(nest_count)--; \
/* Set the line for the current entry to - the old line - this can help
identify increments that did not set the fields */
#define MPIR_Nest_decr() {\
if (MPIU_THREADPRIV_FIELD(nest_count) >= 0) {\
MPIU_THREADPRIV_FIELD(nestinfo)[MPIU_THREADPRIV_FIELD(nest_count)].line=-__LINE__;} \
MPIU_THREADPRIV_FIELD(nest_count)--; \
if (MPIU_THREADPRIV_FIELD(nest_count) < MPICH_MAX_NESTINFO && \
strcmp(MPIU_THREADPRIV_FIELD(nestinfo)[MPIU_THREADPRIV_FIELD(nest_count)].file,__FILE__) != 0) {\
MPIU_Msg_printf( "Decremented nest count int file %s:%d but incremented in different file (%s:%d)\n",\
MPIU_Msg_printf( "Decremented nest count in file %s:%d but incremented in different file (%s:%d)\n",\
__FILE__,__LINE__,\
MPIU_THREADPRIV_FIELD(nestinfo)[MPIU_THREADPRIV_FIELD(nest_count)].file,\
MPIU_THREADPRIV_FIELD(nestinfo)[MPIU_THREADPRIV_FIELD(nest_count)].line);\
......
......@@ -166,7 +166,44 @@ void MPIR_Nest_decr_export( void )
MPIU_THREADPRIV_GET;
MPIU_THREADPRIV_FIELD(nest_count) = MPIU_THREADPRIV_FIELD(nest_count) - 1;
}
#ifdef MPICH_DEBUG_NESTING
void MPIR_Nest_incr_export_dbg( const char *srcfile, int srcline )
{
MPIU_THREADPRIV_DECL;
MPIU_THREADPRIV_GET;
printf( "incr from %d at %s:%d\n", MPIU_THREADPRIV_FIELD(nest_count), srcfile, srcline );
if (MPIU_THREADPRIV_FIELD(nest_count) >= MPICH_MAX_NESTINFO) {
MPIU_Internal_error_printf("nest stack exceeded at %s:%d\n",
srcfile, srcline );
}
else {
MPIU_Strncpy(MPIU_THREADPRIV_FIELD(nestinfo)[MPIU_THREADPRIV_FIELD(nest_count)].file,srcfile, MPICH_MAX_NESTFILENAME);
MPIU_THREADPRIV_FIELD(nestinfo)[MPIU_THREADPRIV_FIELD(nest_count)].line=srcline;
}
MPIU_THREADPRIV_FIELD(nest_count)++;
}
void MPIR_Nest_decr_export_dbg( const char *srcfile, int srcline )
{
MPIU_THREADPRIV_DECL;
MPIU_THREADPRIV_GET;
printf( "decr from %d at %s:%d\n", MPIU_THREADPRIV_FIELD(nest_count), srcfile, srcline );
if (MPIU_THREADPRIV_FIELD(nest_count) >= 0) {
MPIU_THREADPRIV_FIELD(nestinfo)[MPIU_THREADPRIV_FIELD(nest_count)].line=-srcline;}
MPIU_THREADPRIV_FIELD(nest_count)--;
if (MPIU_THREADPRIV_FIELD(nest_count) < MPICH_MAX_NESTINFO &&
strcmp(MPIU_THREADPRIV_FIELD(nestinfo)[MPIU_THREADPRIV_FIELD(nest_count)].file,srcfile) != 0) {
MPIU_Msg_printf( "Decremented nest count in file %s:%d but incremented in different file (%s:%d)\n",
srcfile, srcline,
MPIU_THREADPRIV_FIELD(nestinfo)[MPIU_THREADPRIV_FIELD(nest_count)].file, \
MPIU_THREADPRIV_FIELD(nestinfo)[MPIU_THREADPRIV_FIELD(nest_count)].line);\
}
else if (MPIU_THREADPRIV_FIELD(nest_count) < 0) {
MPIU_Msg_printf("Decremented nest count in file %s:%d is negative\n",
srcfile,srcline);
}
}
#endif
/* ------------------------------------------------------------------------- */
/* These routines are called on error exit from most top-level MPI routines
to invoke the appropriate error handler. Also included is the routine
......
......@@ -28,10 +28,24 @@
#undef MPIR_Nest_decr
#endif
#ifndef MPICH_DEBUG_NESTING
/* These implement the nesting support expected by MPICH2; the primary
purpose of these is to cause MPI routines to return error codes
instead of invoking an error handler (which would be incorrect,
since the relevant MPI_File error handler should be invoked). */
void MPIR_Nest_incr_export(void);
void MPIR_Nest_decr_export(void);
#define MPIR_Nest_incr MPIR_Nest_incr_export
#define MPIR_Nest_decr MPIR_Nest_decr_export
#define MPIR_Nest_incr() MPIR_Nest_incr_export()
#define MPIR_Nest_decr() MPIR_Nest_decr_export()
#else
/* These implement the nesting support with additional code to
provide traces of nest increments and decrements, which are very
helpful in finding errors in properly updating the nesting values */
void MPIR_Nest_incr_export_dbg(const char *, int);
void MPIR_Nest_decr_export_dbg(const char *, int);
#define MPIR_Nest_incr() MPIR_Nest_incr_export_dbg(__FILE__,__LINE__)
#define MPIR_Nest_decr() MPIR_Nest_decr_export_dbg(__FILE__,__LINE__)
#endif
#else /* not ROMIO_INSIDE_MPICH2 */
/* Any MPI implementation that wishes to follow the thread-safety and
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment