Skip to content

Commit

Permalink
more mpe logging
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Jun 14, 2019
1 parent e8efdb4 commit ad4fd9a
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 33 deletions.
35 changes: 19 additions & 16 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,6 @@ if test "x$enable_logging" = xyes; then
AC_DEFINE([PIO_ENABLE_LOGGING], 1, [If true, turn on logging.])
fi

# Does the user want to use MPE library?
AC_MSG_CHECKING([whether use of MPE library is enabled])
AC_ARG_ENABLE([mpe],
[AS_HELP_STRING([--enable-mpe],
[enable use of MPE library for timing and diagnostic info (may negatively impact performance).])])
test "x$enable_mpe" = xyes || enable_mpe=no
AC_MSG_RESULT([$enable_mpe])
if test "x$enable_mpe" = xyes; then
AC_SEARCH_LIBS([MPE_Log_get_event_number], [mpe], [HAVE_LIBMPE=yes], [HAVE_LIBMPE=no], [-lpthread -lm])
AC_CHECK_HEADERS([mpe.h], [HAVE_MPE=yes], [HAVE_MPE=no])
if test "x$HAVE_LIBMPE" = xno -o "x$HAVE_MPE" = xno; then
AC_MSG_ERROR([MPE not found but --enable-mpe used.])
fi
AC_DEFINE([USE_MPE], 1, [If true, use MPE timing library.])
fi

# Does the user want to enable timing?
AC_MSG_CHECKING([whether GPTL timing library is used])
AC_ARG_ENABLE([timing],
Expand Down Expand Up @@ -104,6 +88,25 @@ test "x$enable_fortran" = xyes || enable_fortran=no
AC_MSG_RESULT([$enable_fortran])
AM_CONDITIONAL(BUILD_FORTRAN, [test "x$enable_fortran" = xyes])

# Does the user want to use MPE library?
AC_MSG_CHECKING([whether use of MPE library is enabled])
AC_ARG_ENABLE([mpe],
[AS_HELP_STRING([--enable-mpe],
[enable use of MPE library for timing and diagnostic info (may negatively impact performance).])])
test "x$enable_mpe" = xyes || enable_mpe=no
AC_MSG_RESULT([$enable_mpe])
if test "x$enable_mpe" = xyes; then
AC_SEARCH_LIBS([MPE_Log_get_event_number], [mpe], [HAVE_LIBMPE=yes], [HAVE_LIBMPE=no], [-lpthread -lm])
AC_CHECK_HEADERS([mpe.h], [HAVE_MPE=yes], [HAVE_MPE=no])
if test "x$HAVE_LIBMPE" = xno -o "x$HAVE_MPE" = xno; then
AC_MSG_ERROR([MPE not found but --enable-mpe used.])
fi
if test $enable_fortran = yes; then
AC_MSG_ERROR([MPE not implemented in Fortran tests and examples.])
fi
AC_DEFINE([USE_MPE], 1, [If true, use MPE timing library.])
fi

# Does the user want to disable pnetcdf?
AC_MSG_CHECKING([whether pnetcdf is to be used])
AC_ARG_ENABLE([pnetcdf],
Expand Down
27 changes: 14 additions & 13 deletions examples/c/darray_no_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ int check_file(int iosysid, int ntasks, char *filename, int iotype,
/* Open the file. */
if ((ret = PIOc_openfile_retry(iosysid, &ncid, &iotype, filename, 0, 0)))
return ret;
printf("opened file %s ncid = %d\n", filename, ncid);
/* printf("opened file %s ncid = %d\n", filename, ncid); */

/* Check the metadata. */
if ((ret = PIOc_inq(ncid, &ndims, &nvars, &ngatts, &unlimdimid)))
Expand Down Expand Up @@ -262,8 +262,8 @@ int main(int argc, char* argv[])
/* Check that a valid number of processors was specified. */
if (ntasks != TARGET_NTASKS)
fprintf(stderr, "Number of processors must be 16!\n");
printf("%d: ParallelIO Library darray_no_async example running on %d processors.\n",
my_rank, ntasks);
/* printf("%d: ParallelIO Library darray_no_async example running on %d processors.\n", */
/* my_rank, ntasks); */

/* Turn on logging. */
if ((ret = PIOc_set_log_level(LOG_LEVEL)))
Expand All @@ -290,8 +290,8 @@ int main(int argc, char* argv[])
/* Create the PIO decomposition for this example. Since this
* is a variable with an unlimited dimension, we want to
* create a 2-D composition which represents one record. */
printf("rank: %d Creating decomposition, elements_per_pe %lld...\n", my_rank,
elements_per_pe);
/* printf("rank: %d Creating decomposition, elements_per_pe %lld...\n", my_rank, */
/* elements_per_pe); */
if ((ret = PIOc_init_decomp(iosysid, PIO_INT, NDIM3 - 1, &dim_len[1], elements_per_pe,
compdof, &ioid, PIO_REARR_SUBSET, NULL, NULL)))
ERR(ret);
Expand Down Expand Up @@ -319,13 +319,13 @@ int main(int argc, char* argv[])
sprintf(filename, "darray_no_async_iotype_%d.nc", format[fmt]);

/* Create the netCDF output file. */
printf("rank: %d Creating sample file %s with format %d...\n",
my_rank, filename, format[fmt]);
/* printf("rank: %d Creating sample file %s with format %d...\n", */
/* my_rank, filename, format[fmt]); */
if ((ret = PIOc_createfile(iosysid, &ncid, &(format[fmt]), filename, PIO_CLOBBER)))
ERR(ret);

/* Define netCDF dimension and variable. */
printf("rank: %d Defining netCDF metadata...\n", my_rank);
/* printf("rank: %d Defining netCDF metadata...\n", my_rank); */
for (int d = 0; d < NDIM3; d++)
if ((ret = PIOc_def_dim(ncid, dim_name[d], dim_len[d], &dimid[d])))
ERR(ret);
Expand All @@ -345,7 +345,7 @@ int main(int argc, char* argv[])
buffer[i] = 100 * t + START_DATA_VAL + my_rank;

/* Write data to the file. */
printf("rank: %d Writing sample data...\n", my_rank);
/* printf("rank: %d Writing sample data...\n", my_rank); */
if ((ret = PIOc_setframe(ncid, varid, t)))
ERR(ret);
if ((ret = PIOc_write_darray(ncid, varid, ioid, elements_per_pe, buffer, NULL)))
Expand All @@ -357,7 +357,7 @@ int main(int argc, char* argv[])
ERR(ret);

/* Close the netCDF file. */
printf("rank: %d Closing the sample data file...\n", my_rank);
/* printf("rank: %d Closing the sample data file...\n", my_rank); */
if ((ret = PIOc_closefile(ncid)))
ERR(ret);

Expand All @@ -368,12 +368,12 @@ int main(int argc, char* argv[])
}

/* Free the PIO decomposition. */
printf("rank: %d Freeing PIO decomposition...\n", my_rank);
/* printf("rank: %d Freeing PIO decomposition...\n", my_rank); */
if ((ret = PIOc_freedecomp(iosysid, ioid)))
ERR(ret);

/* Finalize the IO system. */
printf("rank: %d Freeing PIO resources...\n", my_rank);
/* printf("rank: %d Freeing PIO resources...\n", my_rank); */
if ((ret = PIOc_free_iosystem(iosysid)))
ERR(ret);

Expand All @@ -391,6 +391,7 @@ int main(int argc, char* argv[])
return ret;
#endif

printf("rank: %d SUCCESS!\n", my_rank);
if (!my_rank)
printf("rank: %d SUCCESS!\n", my_rank);
return 0;
}
21 changes: 19 additions & 2 deletions examples/c/example1.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
#ifdef TIMING
#include <gptl.h>
#endif
#ifdef USE_MPE
#include <mpe.h>
#endif /* USE_MPE */

/* The name of this program. */
#define TEST_NAME "example1"

/** The number of possible output netCDF output flavors available to
* the ParallelIO library. */
Expand Down Expand Up @@ -303,7 +309,13 @@ int check_file(int ntasks, char *filename) {
printf("%d: ParallelIO Library example1 running on %d processors.\n",
my_rank, ntasks);

/* keep things simple - 1 iotask per MPI process */
#ifdef USE_MPE
/* If MPE logging is being used, then initialize it. */
if ((ret = MPE_Init_log()))
return ret;
#endif /* USE_MPE */

/* keep things simple - 1 iotask per MPI process */
niotasks = ntasks;

/* Turn on logging if available. */
Expand Down Expand Up @@ -415,6 +427,11 @@ int check_file(int ntasks, char *filename) {
ERR(ret);
}

#ifdef USE_MPE
if ((ret = MPE_Finish_log(TEST_NAME)))
MPIERR(ret);
#endif /* USE_MPE */

/* Finalize the MPI library. */
MPI_Finalize();

Expand All @@ -424,7 +441,7 @@ int check_file(int ntasks, char *filename) {
return ret;
#endif

if (verbose)
if (verbose)
printf("rank: %d SUCCESS!\n", my_rank);
return 0;
}
27 changes: 25 additions & 2 deletions examples/c/examplePio.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
#ifdef TIMING
#include <gptl.h>
#endif
#ifdef USE_MPE
#include <mpe.h>
#endif /* USE_MPE */

/* The name of this program. */
#define TEST_NAME "examplePio"

/** The length of our 1-d data array. */
static const int LEN = 16;
Expand Down Expand Up @@ -179,7 +185,16 @@ struct examplePioClass* epc_init( struct examplePioClass* this )
this->ntasks == 8 || this->ntasks == 16))
this->errorHandler(this, "Number of processors must be 1, 2, 4, 8, or 16!",
ERR_CODE);


#ifdef USE_MPE
/* If MPE logging is being used, then initialize it. */
{
int ret;
if ((ret = MPE_Init_log()))
return NULL;
}
#endif /* USE_MPE */

/*
** set up PIO for rest of example
*/
Expand Down Expand Up @@ -458,6 +473,14 @@ struct examplePioClass* epc_cleanUp( struct examplePioClass* this )

PIOc_freedecomp(this->pioIoSystem, this->iodescNCells);
PIOc_free_iosystem(this->pioIoSystem);
#ifdef USE_MPE
{
int ret;
if ((ret = MPE_Finish_log(TEST_NAME)))
return NULL;
}
#endif /* USE_MPE */

MPI_Finalize();

return this;
Expand Down Expand Up @@ -587,7 +610,7 @@ int main(int argc, char* argv[])
if ((ret = GPTLinitialize ()))
return ret;
#endif

pioExInst->init(pioExInst);
pioExInst->createDecomp(pioExInst);
pioExInst->createFile(pioExInst);
Expand Down
17 changes: 17 additions & 0 deletions src/clib/pio_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
netCDF-4/HDF5 (starts at 65xxx). */
int pio_next_ncid = 16;

#ifdef USE_MPE
/* The event numbers for MPE logging. */
extern int event_num[2][NUM_EVENTS];
#endif /* USE_MPE */

/**
* Open an existing file using PIO library.
*
Expand Down Expand Up @@ -221,6 +226,12 @@ int PIOc_closefile(int ncid)
int ierr = PIO_NOERR; /* Return code from function calls. */
int mpierr = MPI_SUCCESS, mpierr2; /* Return code from MPI function codes. */

#ifdef USE_MPE
if ((ierr = MPE_Log_event(event_num[START][CLOSE], 0,
"PIOc_closefile")))
return pio_err(NULL, NULL, PIO_EIO, __FILE__, __LINE__);
#endif /* USE_MPE */

LOG((1, "PIOc_closefile ncid = %d", ncid));
/* Find the info about this file. */
if ((ierr = pio_get_file(ncid, &file)))
Expand Down Expand Up @@ -294,6 +305,12 @@ int PIOc_closefile(int ncid)
if ((ierr = pio_delete_file_from_list(ncid)))
return pio_err(ios, file, ierr, __FILE__, __LINE__);

#ifdef USE_MPE
if ((ierr = MPE_Log_event(event_num[END][CLOSE], 0,
"PIOc_closefile")))
return pio_err(ios, NULL, PIO_EIO, __FILE__, __LINE__);
#endif /* USE_MPE */

return ierr;
}

Expand Down

0 comments on commit ad4fd9a

Please sign in to comment.