Skip to content

Commit

Permalink
starting to bring MPE logging into PIO library
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Jun 14, 2019
1 parent 6f0afaa commit 3c32fbb
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/clib/pio_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#include <gptl.h>
#endif
#include <assert.h>
#ifdef USE_MPE
#include <mpe.h>
#endif /* USE_MPE */

/* These are the sizes of types in netCDF files. Do not replace these
* constants with sizeof() calls for C types. They are not the
Expand Down Expand Up @@ -85,6 +88,23 @@ void pio_log(int severity, const char *fmt, ...);
* internally. */
#define PIO_LONG_INTERNAL 13

#ifdef USE_MPE
/* These are for the event numbers array used to log various events in
* the program with the MPE library, which produces output for the
* Jumpshot program. */
#define NUM_EVENTS 7
#define START 0
#define END 1
#define INIT 0
#define DECOMP 1
#define CREATE 2
#define DARRAY_WRITE 3
#define CLOSE 4
#define CALCULATE 5
#define INGEST 6
#define ERR_LOGGING 99
#endif /* USE_MPE */

#if defined(__cplusplus)
extern "C" {
#endif
Expand Down
50 changes: 50 additions & 0 deletions src/clib/pioc_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,56 @@ PIOc_set_log_level(int level)
return PIO_NOERR;
}

#ifdef USE_MPE

/* This array holds even numbers for MPE. */
int event_num[2][NUM_EVENTS];

/** This will set up the MPE logging event numbers. The calling program
* must call MPE_Init_log() before this function is called.
*
* @param my_rank rank of processor in MPI_COMM_WORLD.
* @author Ed Hartnett
*/
int
init_mpe(int my_rank)
{
int ret;

/* Get a bunch of event numbers. */
event_num[START][INIT] = MPE_Log_get_event_number();
event_num[END][INIT] = MPE_Log_get_event_number();
event_num[START][DECOMP] = MPE_Log_get_event_number();
event_num[END][DECOMP] = MPE_Log_get_event_number();
event_num[START][INGEST] = MPE_Log_get_event_number();
event_num[END][INGEST] = MPE_Log_get_event_number();
event_num[START][CLOSE] = MPE_Log_get_event_number();
event_num[END][CLOSE] = MPE_Log_get_event_number();
event_num[START][CALCULATE] = MPE_Log_get_event_number();
event_num[END][CALCULATE] = MPE_Log_get_event_number();
event_num[START][CREATE] = MPE_Log_get_event_number();
event_num[END][CREATE] = MPE_Log_get_event_number();
event_num[START][DARRAY_WRITE] = MPE_Log_get_event_number();
event_num[END][DARRAY_WRITE] = MPE_Log_get_event_number();

/* You should track at least initialization and partitioning, data
* ingest, update computation, all communications, any memory
* copies (if you do that), any output rendering, and any global
* communications. */
if (!my_rank)
{
MPE_Describe_state(event_num[START][INIT], event_num[END][INIT], "init", "red");
MPE_Describe_state(event_num[START][INGEST], event_num[END][INGEST], "ingest", "yellow");
MPE_Describe_state(event_num[START][DECOMP], event_num[END][DECOMP], "decomposition", "green");
MPE_Describe_state(event_num[START][CALCULATE], event_num[END][CALCULATE], "calculate", "orange");
MPE_Describe_state(event_num[START][CREATE], event_num[END][CREATE], "create", "purple");
MPE_Describe_state(event_num[START][CLOSE], event_num[END][CLOSE], "close file", "blue");
MPE_Describe_state(event_num[START][DARRAY_WRITE], event_num[END][DARRAY_WRITE], "darray write", "pink");
}
return 0;
}
#endif /* USE_MPE */

/**
* Initialize logging. Open log file, if not opened yet, or increment
* ref count if already open.
Expand Down
26 changes: 26 additions & 0 deletions tests/cunit/test_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,39 @@ int pio_test_init2(int argc, char **argv, int *my_rank, int *ntasks,
if ((ret = PIOc_set_log_level(log_level)))
return ret;

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

/* Change error handling so we can test inval parameters. */
if ((ret = PIOc_set_iosystem_error_handling(PIO_DEFAULT, PIO_RETURN_ERROR, NULL)))
return ret;

return PIO_NOERR;
}

/* Finalize a PIO C test. This version of the finalize function takes
* a test name, which is used if MPE logging is in use.
*
* @param test_comm pointer to the test communicator.
* @param test_name name of the test
* @returns 0 for success, error code otherwise.
* @author Ed Hartnett
*/
int pio_test_finalize2(MPI_Comm *test_comm, const char *test_name)
{
int ret;

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

return pio_test_finalize(test_comm);
}

/* Finalize a PIO C test.
*
* @param test_comm pointer to the test communicator.
Expand Down

0 comments on commit 3c32fbb

Please sign in to comment.