/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ /* * (C) 2014 by Argonne National Laboratory. * See COPYRIGHT in top-level directory. */ /* style:allow:snprintf:9 sig:0 */ /* style:allow:strncpy:3 sig:0 */ /* style:allow:fprintf:26 sig:0 */ /* style:allow:free:3 sig:0 */ /* style:allow:malloc:3 sig:0 */ #include #include #include #include "mpi.h" /* At least one early implementation of MPIT failed to set the enumtype and thus dirty data was returned. This should not be needed, but is provided in case an implementation returns too many bogus results. In that case, define NEEDS_MPIT_ENUM_LIMIT */ #ifdef NEEDS_MPIT_ENUM_LIMIT #define MAX_ENUM_NUMBER 10 #endif /* Lengths for statically allocated character arrays */ #define MAX_NAME_LEN 128 #define MAX_DESC_LEN 1024 /* Function Prototypes */ /* Top level routines for printing MPI_T variables */ int PrintControlVars( FILE *fp ); int PrintPerfVars( FILE *fp ); int PrintCategories( FILE *fp ); /* Functions to print MPI_T objects */ int PrintEnum( FILE *fp, MPI_T_enum enumtype ); /* Functions to convert enums or handles to strings for printing */ const char *mpit_scopeToStr( int scope ); const char *mpit_bindingToStr( int binding ); const char *mpit_validDtypeStr( MPI_Datatype datatype ); const char *mpit_varclassToStr( int varClass ); const char *mpit_verbosityToStr( int verbosity ); const char *mpit_errclasscheck( int err ); /* Function to convert MPI_T variables to strings for printing */ int getCvarValueAsStr( int idx, MPI_Datatype dataytpe, char varValue[], int varValueLen ); int getPvarValueAsStr( int idx, MPI_Datatype datatype, int isContinuous, char varValue[], int varValueLen ); /* Functions for checking on correctness */ int perfCheckVarType( int varClass, MPI_Datatype datatype ); int checkStringLen( const char *str, int expectedLen, const char *strName ); /* Variable descriptions are sometimes long - this variable controls whether they are printed */ static int showDesc = 1; int main( int argc, char *argv[] ) { int required, provided, i, wrank; required = MPI_THREAD_SINGLE; /* The MPI standard permits MPI_T_init_thread to be called before or after MPI_Init_thread. In some cases, a user may need to call MPI_T_init_thread and set some MPI_T variables before calling MPI_Init_thread to change the behavior of the initialization. */ MPI_Init_thread( &argc, &argv, required, &provided ); MPI_T_init_thread( required, &provided ); MPI_Comm_rank( MPI_COMM_WORLD, &wrank ); /* Check for a few command-line controls */ /* Assumes that all processes see this */ for (i=1; i 0) fprintf( fp, "%d MPI_T categories\n", numCat ); else fprintf( fp, "No categories defined\n" ); for (i=0; i 0 || numPvars > 0 || numSubcat > 0) { fprintf( fp, "Category %s has %d control variables, %d performance variables, and %d subcategories\n", name, numCvars, numPvars, numSubcat ); } else { fprintf( fp, "Category %s defined but has no content\n", name ); } /* Output information about the categories */ if (numCvars > 0) { int *cvarIndex = (int *)malloc( numCvars * sizeof(int) ); MPI_T_category_get_cvars( i, numCvars, cvarIndex ); fprintf( fp, "\tControl Variables:\n" ); for (j=0; j 0) { int *pvarIndex = (int *)malloc( numPvars * sizeof(int) ); MPI_T_category_get_pvars( i, numPvars, pvarIndex ); fprintf( fp, "\tPerformance Variables:\n" ); for (j=0; j 0) { int *subcatIndex = (int *) malloc(numSubcat * sizeof(int)); MPI_T_category_get_categories(i, numSubcat, subcatIndex); fprintf( fp, "\tSubcategories:\n" ); for (j=0; j MAX_ENUM_NUMBER) { fprintf( stderr, "Max number of enum values = %d, > max permitted of %d\n", enumber, MAX_ENUM_NUMBER ); enumber = MAX_ENUM_NUMBER; } #endif for (i=0; i