diff --git a/ompi/contrib/vt/vt/ChangeLog b/ompi/contrib/vt/vt/ChangeLog index 44c38c8d23..0cb3fc4e09 100644 --- a/ompi/contrib/vt/vt/ChangeLog +++ b/ompi/contrib/vt/vt/ChangeLog @@ -1,12 +1,15 @@ 5.8.1openmpi - updated version of internal OTF to 1.6.5openmpi (see extlib/otf/ChangeLog) + - added functions 'MPI_Group_range_' to Fortran MPI wrappers + - added environment variable VT_METRICS_SEP to specify a string which separate + the counter names in VT_METRICS - fixed build error: do not add objects from the static version of the BFD library to the shared VT libraries, because the BFD objects might be built without position independent code (PIC) 5.8openmpi - - updated version of internal OTF to 1.6.4openmpi + - updated version of internal OTF to 1.6.4stingray (see extlib/otf/ChangeLog) - added support for tracing calls to arbitrary third party libraries The new tool 'vtlibwrapgen' can be used to generate a wrapper library. @@ -14,6 +17,7 @@ filter directives - added support for automatic instrumentation with PGI 9 compiler using its new compiler flag '-Minstrument' + - added MPI-parallel trace unifier (vtunify-mpi) - disabled simultaneous support for multiple compiler instrumentation types in one VampirTrace installation (all known compiler instrumentation types for the compiler wrappers diff --git a/ompi/contrib/vt/vt/config/defaults/bgl b/ompi/contrib/vt/vt/config/defaults/bgl index 3ba39ffc8c..01f0a7e73f 100644 --- a/ompi/contrib/vt/vt/config/defaults/bgl +++ b/ompi/contrib/vt/vt/config/defaults/bgl @@ -3,6 +3,7 @@ CXX="blrts_xlC" F77="blrts_xlf90" FC="blrts_xlf90" MPICC="mpixlc" +MPICXX="mpixlcxx" CC_FOR_BUILD="xlc_r" CXX_FOR_BUILD="xlC_r" enable_shared="no" diff --git a/ompi/contrib/vt/vt/config/defaults/bgp b/ompi/contrib/vt/vt/config/defaults/bgp index 877a5c8e55..3cf2adfe42 100644 --- a/ompi/contrib/vt/vt/config/defaults/bgp +++ b/ompi/contrib/vt/vt/config/defaults/bgp @@ -3,6 +3,7 @@ CXX="bgxlC_r" F77="bgxlf_r" FC="bgxlf95_r" MPICC="mpixlc_r" +MPICXX="mpixlcxx_r" CC_FOR_BUILD="xlc_r" CXX_FOR_BUILD="xlC_r" enable_shared="no" diff --git a/ompi/contrib/vt/vt/config/defaults/necsx b/ompi/contrib/vt/vt/config/defaults/necsx index e57202063c..2a4b970a5f 100644 --- a/ompi/contrib/vt/vt/config/defaults/necsx +++ b/ompi/contrib/vt/vt/config/defaults/necsx @@ -5,6 +5,7 @@ F77="sxf90" FC="sxf90" CCAS="sxas" MPICC="sxmpicc" +MPICXX="sxmpic++" MPIF77="sxmpif90" CC_FOR_BUILD="cc" CXX_FOR_BUILD="c++" diff --git a/ompi/contrib/vt/vt/config/m4/acinclude.bfd.m4 b/ompi/contrib/vt/vt/config/m4/acinclude.bfd.m4 index f24d9d37a5..9cbe596480 100644 --- a/ompi/contrib/vt/vt/config/m4/acinclude.bfd.m4 +++ b/ompi/contrib/vt/vt/config/m4/acinclude.bfd.m4 @@ -11,7 +11,7 @@ AC_DEFUN([ACVT_BFD], BFDLIB= AC_ARG_WITH(bfd, - AC_HELP_STRING([--with-bfd], [use BFD to get symbol information of an executable instrumented with GNU, Intel, or Pathscale compiler, default: yes]), + AC_HELP_STRING([--with-bfd], [use BFD to get symbol information of an executable instrumented with GNU, Intel, PGI9, or Pathscale compiler, default: yes]), [AS_IF([test x"$withval" = "xyes"], [force_bfd="yes"], [check_bfd="no"])]) AC_ARG_WITH(bfd-dir, diff --git a/ompi/contrib/vt/vt/config/mpigen/fortran_dont_generate.txt b/ompi/contrib/vt/vt/config/mpigen/fortran_dont_generate.txt index 0020b45388..a7f06ca69f 100644 --- a/ompi/contrib/vt/vt/config/mpigen/fortran_dont_generate.txt +++ b/ompi/contrib/vt/vt/config/mpigen/fortran_dont_generate.txt @@ -1,8 +1,6 @@ # This file lists all calls, which should not be generated # automatically by mk_fortran_wrapper.sh -MPI_Group_range_excl -MPI_Group_range_incl MPI_Init MPI_Initialized MPI_Init_thread diff --git a/ompi/contrib/vt/vt/config/mpigen/mk_fortran_wrapper.sh.in b/ompi/contrib/vt/vt/config/mpigen/mk_fortran_wrapper.sh.in index c578a37a5a..fdde5f7779 100644 --- a/ompi/contrib/vt/vt/config/mpigen/mk_fortran_wrapper.sh.in +++ b/ompi/contrib/vt/vt/config/mpigen/mk_fortran_wrapper.sh.in @@ -110,7 +110,7 @@ cat <$tmp.awk if (type[i-2] == "char*") { strings[stringcnt++] = para[i-2] printf "%s %s", type[i-2], para[i-2] - } else if (index(type[i-2], "*") != 0) { + } else if (index(type[i-2], "*") != 0 || index(para[i-2], "[") != 0) { printf "%s %s", converttype(type[i-2]), para[i-2] } else { printf "%s* %s", converttype(type[i-2]), para[i-2] @@ -155,8 +155,6 @@ cat <$tmp.awk printf " *ierr = %s(", mpicall for (i=3; i<=NF; i++) { if (i > 3) printf ", " - #remove arrays declarations from parameter: - gsub("[[].*[]]","",para[i-2]) # If the original type already needed a pointer, pass as is, # otherwise dereference the parameter printf "%s", get_converted_name(para[i-2],type[i-2]) @@ -179,7 +177,7 @@ cat <$tmp.awk } else { for (i=3; i<=NF; i++) { if (i > 3) printf ", " - if (index(type[i-2], "*") != 0) + if (index(type[i-2], "*") != 0 || index(para[i-2], "[") != 0) printf "%s %s", converttype(type[i-2]), para[i-2] else printf "%s* %s", converttype(type[i-2]), para[i-2] @@ -763,10 +761,13 @@ function get_converted_name(para,type) { if (type == "char*") return para "C" pointer="" - if (index(type, "*") == 0) + if (index(type, "*") == 0 && index(para, "[") == 0) pointer="*" - #Find out wheter we have to pass address operator "&" + #remove arrays declarations from parameter: + gsub("[[].*[]]","",para) + + #find out wheter we have to pass address operator "&" address="" if ((index(para,"_CLASS_SINGLE_") != 0) && (index(type,"MPI_Status") == 0) ) address="&" diff --git a/ompi/contrib/vt/vt/configure.in b/ompi/contrib/vt/vt/configure.in index 050614ec30..5169d7c595 100644 --- a/ompi/contrib/vt/vt/configure.in +++ b/ompi/contrib/vt/vt/configure.in @@ -12,7 +12,9 @@ AM_CONFIG_HEADER(config.h) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) # Check whether we are inside Open MPI package -AC_ARG_WITH(openmpi-inside, [], [inside_openmpi="yes"]) +inside_openmpi="no" +AC_ARG_WITH(openmpi-inside, [], +[AS_IF([test x"$withval" != "xno"], [inside_openmpi="yes"])]) ACVT_CONF_INIT diff --git a/ompi/contrib/vt/vt/doc/UserManual.html b/ompi/contrib/vt/vt/doc/UserManual.html index 679e6d49d4..c1dbcee866 100644 --- a/ompi/contrib/vt/vt/doc/UserManual.html +++ b/ompi/contrib/vt/vt/doc/UserManual.html @@ -52,8 +52,7 @@ DIV.navigation { } SPAN.textbf { font-weight: bold } SPAN.arabic { } SPAN.textit { font-style: italic } - -BODY {font-family: sans-serif;} +body {font-family: sans-serif;} @@ -62,7 +61,7 @@ BODY {font-family: sans-serif;}

-VampirTrace 5.8 User Manual +VampirTrace 5.8.1 User Manual


@@ -289,18 +288,18 @@ OpenMP events, and performance counters.

After a successful tracing run, VampirTrace writes all collected data to a trace file in the Open Trace Format (OTF)[+]. + HREF="#foot1149">[+]. As a result, the information is available for post-mortem analysis and visualization by various tools. Most notably, VampirTrace provides the input data for the Vampir analysis and visualization tool[+]. + HREF="#foot1150">[+].

VampirTrace is included in OpenMPI 1.3 and later versions. If not disabled explicitly, VampirTrace is built automatically when installing OpenMPI[+]. + HREF="#foot1151">[+].

Trace files can quickly become very large, especially with automatic instrumentation. @@ -1048,7 +1047,7 @@ Binary Instrumentation Using Dyninst The option -vt:inst dyninst is used with the compiler wrapper to instrument the application during runtime (binary instrumentation), by using Dyninst[+]. + HREF="#foot1175">[+]. Recompiling is not necessary for this kind of instrumentation, but relinking: @@ -1310,7 +1309,7 @@ of a VampirTrace instrumented executable: 1 VT_MAX_THREADS -Maximum number of threads (Maximum number of threads ([IMAGE png]) per process that VampirTrace reserves resources for. 65536 @@ -1430,11 +1429,15 @@ of a VampirTrace instrumented executable: VT_METRICS Specify counter metrics to be recorded with trace events as a - colon-separated list of names. + colon/VT_METRICS_SEP-separated list of names.
⇒ Section [*] - +VT_METRICS_SEP +Separator string between counter specifications in VT_METRICS. +: + VT_RUSAGE Colon-separated list of resource usage counters which shall be recorded.
@@ -1684,7 +1687,7 @@ for the enhanced timer synchronization:

  • CLAPACK[+] + HREF="#foot1185">[+]
  • AMD ACML
  • @@ -2619,7 +2622,7 @@ default: automatically by configure enable support for Dyninst instrumentation, default: enable if found by configure Note: Requires Dyninst[+] version 5.1 or higher! + HREF="#foot1201">[+] version 5.1 or higher!

    @@ -4090,39 +4093,39 @@ into the official VampirTrace package.



    Footnotes

    -
    ... (OTF)... (OTF)[+]
    http://www.tu-dresden.de/zih/otf
    -
    ... tool ... tool [+]
    http://www.vampir.eu
    -
    ... +
    ... Open MPI [+]
    http://www.open-mpi.org/faq/?category=vampirtrace
    -
    ... +
    ... Dyninst [+]
    http://www.dyninst.org
    -
    ... CLAPACK... CLAPACK[+]
    www.netlib.org/clapack
    -
    ... Dyninst ... Dyninst [+]
    http://www.dyninst.org diff --git a/ompi/contrib/vt/vt/doc/UserManual.pdf b/ompi/contrib/vt/vt/doc/UserManual.pdf index 90ceddc576..602dd0ac35 100644 Binary files a/ompi/contrib/vt/vt/doc/UserManual.pdf and b/ompi/contrib/vt/vt/doc/UserManual.pdf differ diff --git a/ompi/contrib/vt/vt/extlib/otf/otflib/OTF_Parse.c b/ompi/contrib/vt/vt/extlib/otf/otflib/OTF_Parse.c index 710ea72eab..adc0550fa2 100644 --- a/ompi/contrib/vt/vt/extlib/otf/otflib/OTF_Parse.c +++ b/ompi/contrib/vt/vt/extlib/otf/otflib/OTF_Parse.c @@ -16,10 +16,11 @@ /* *** some macros *** ****************************************** */ -#define PARSE_ERROR( buffer ) \ - OTF_fprintf( stderr, "parse error in %s() %s:%u : %s", \ - __FUNCTION__, __FILE__, __LINE__, OTF_RBuffer_printRecord( buffer ) ); - +#define PARSE_ERROR( buffer ) { \ + char* record_str = OTF_RBuffer_printRecord( buffer ); \ + OTF_fprintf( stderr, "parse error in %s() %s:%u : %s", \ + __FUNCTION__, __FILE__, __LINE__, record_str ); \ + free( record_str ); } /* *** local headers *** **************************************************** */ @@ -1119,7 +1120,7 @@ int OTF_Reader_readDefProcessGroup( OTF_RBuffer* buffer, if ( name == NULL ) { - PARSE_ERROR( buffer ); + PARSE_ERROR( buffer ); return 0; } diff --git a/ompi/contrib/vt/vt/extlib/otf/otflib/OTF_Reader.c b/ompi/contrib/vt/vt/extlib/otf/otflib/OTF_Reader.c index 3544e43fd2..d5a42d7026 100644 --- a/ompi/contrib/vt/vt/extlib/otf/otflib/OTF_Reader.c +++ b/ompi/contrib/vt/vt/extlib/otf/otflib/OTF_Reader.c @@ -1070,8 +1070,10 @@ int OTF_Reader_finish( OTF_Reader* reader ) { reader->markerHeap= NULL; } - OTF_MasterControl_close( reader->mc ); - reader->mc = NULL; + if ( NULL != reader->mc ) { + OTF_MasterControl_close( reader->mc ); + reader->mc = NULL; + } return ret; } diff --git a/ompi/contrib/vt/vt/extlib/otf/tools/otfinfo/otfinfo.c b/ompi/contrib/vt/vt/extlib/otf/tools/otfinfo/otfinfo.c index 4830b14bca..15d251e19b 100644 --- a/ompi/contrib/vt/vt/extlib/otf/tools/otfinfo/otfinfo.c +++ b/ompi/contrib/vt/vt/extlib/otf/tools/otfinfo/otfinfo.c @@ -23,15 +23,15 @@ static void set_handles_level_3( OTF_HandlerArray *handles, static void set_handles_level_4( OTF_HandlerArray *handles, definitionInfoT *info ); -static void show_info_level_1( definitionInfoT info ); -static void show_info_level_2( definitionInfoT info ); -static void show_info_level_3( definitionInfoT info ); -static void show_info_level_4( definitionInfoT info ); +static void show_info_level_1( definitionInfoT *info ); +static void show_info_level_2( definitionInfoT *info ); +static void show_info_level_3( definitionInfoT *info ); +static void show_info_level_4( definitionInfoT *info ); -static void free_data_level_1( definitionInfoT info ); -static void free_data_level_2( definitionInfoT info ); -static void free_data_level_3( definitionInfoT info ); -static void free_data_level_4( definitionInfoT info ); +static void free_data_level_1( definitionInfoT *info ); +static void free_data_level_2( definitionInfoT *info ); +static void free_data_level_3( definitionInfoT *info ); +static void free_data_level_4( definitionInfoT *info ); int main(int argc, char **argv) { @@ -183,12 +183,12 @@ int main(int argc, char **argv) /*printing the results and cleanup*/ if( 0 < infoLevel ) { - show_info_level_1( info ); - free_data_level_1( info ); + show_info_level_1( &info ); + free_data_level_1( &info ); if( 1 < infoLevel ) { - show_info_level_2( info ); - free_data_level_2( info ); + show_info_level_2( &info ); + free_data_level_2( &info ); } } checkVal = OTF_HandlerArray_close( handles ); @@ -260,12 +260,12 @@ int main(int argc, char **argv) otfinfo_assert( checkVal != OTF_READ_ERROR ); } /*printing the results and cleanup*/ - show_info_level_3( info ); - free_data_level_3( info ); + show_info_level_3( &info ); + free_data_level_3( &info ); if( 3 < infoLevel ) { - show_info_level_4( info ); - free_data_level_4( info ); + show_info_level_4( &info ); + free_data_level_4( &info ); } checkVal = OTF_HandlerArray_close( handles ); otfinfo_assert( checkVal ); @@ -323,11 +323,11 @@ static void set_handles_level_1( OTF_HandlerArray *handles, OTF_HandlerArray_setFirstHandlerArg( handles, info, OTF_DEFINITIONCOMMENT_RECORD ); } -static void show_info_level_1( definitionInfoT info ) +static void show_info_level_1( definitionInfoT *info ) { uint32_t i = 0, index = 0; - double resolution = info.timerResolution; - double fileSize = info.traceFileSize; + double resolution = info->timerResolution; + double fileSize = info->traceFileSize; char* unitTimer; char* unitFileSize; @@ -366,38 +366,38 @@ static void show_info_level_1( definitionInfoT info ) printf( "+-------------------------------------------------------------------------------\n" ); printf( "| general information \n" ); printf( "+----------------------+--------------------------------------------------------\n" ); - printf( "| tracefile name | %s\n", info.filePrefix ); - printf( "| creator of the trace | %s\n", info.creatorName ); - printf( "| used OTF version | %i.%i.%i %s\n", info.otfVersionMajor, - info.otfVersionMinor, info.otfVersionSub, info.otfVersionString ); + printf( "| tracefile name | %s\n", info->filePrefix ); + printf( "| creator of the trace | %s\n", info->creatorName ); + printf( "| used OTF version | %i.%i.%i %s\n", info->otfVersionMajor, + info->otfVersionMinor, info->otfVersionSub, info->otfVersionString ); printf( "| event files size | %.2f %s\n", fileSize,unitFileSize ); printf( "| process definitions | %llu\n", - (unsigned long long)info.counterProcessDefinition ); + (unsigned long long)info->counterProcessDefinition ); printf( "| timer resolution | %.2f %s\n",resolution,unitTimer ); printf( "+----------------------+--------------------------------------------------------\n" ); - index = info.counterDefinitionComment; + index = info->counterDefinitionComment; printf( "| definition comments\n" ); printf( "+-------------------------------------------------------------------------------\n" ); for( i = 0; i < index; i++ ) { - printf( "| %s\n", info.definitionComments[i] ); + printf( "| %s\n", info->definitionComments[i] ); } printf( "+-------------------------------------------------------------------------------\n" ); printf( "\n" ); } -static void free_data_level_1( definitionInfoT info ) +static void free_data_level_1( definitionInfoT *info ) { uint32_t i, index; - free( info.creatorName ); + free( info->creatorName ); - index = info.counterDefinitionComment; + index = info->counterDefinitionComment; for( i = 0; i < index; i++ ) { - free( info.definitionComments[i] ); + free( info->definitionComments[i] ); } - free( info.definitionComments ); - free( info.otfVersionString ); + free( info->definitionComments ); + free( info->otfVersionString ); } static void set_handles_level_2( OTF_HandlerArray *handles, definitionInfoT *info ) @@ -453,7 +453,7 @@ static void set_handles_level_2( OTF_HandlerArray *handles, definitionInfoT *inf OTF_HandlerArray_setFirstHandlerArg( handles, info, OTF_DEFSCLFILE_RECORD ); } -static void show_info_level_2( definitionInfoT info ) +static void show_info_level_2( definitionInfoT *info ) { int index,i; @@ -464,41 +464,41 @@ static void show_info_level_2( definitionInfoT info ) printf( "| trace content\n" ); printf( "+----------------------------+--------------------------------------------------\n" ); printf( "| function definitions | %llu\n", - (unsigned long long)info.counterFunctionDefinition ); + (unsigned long long)info->counterFunctionDefinition ); printf( "| counter definitions | %llu\n", - (unsigned long long)info.counterCounterDefinition ); + (unsigned long long)info->counterCounterDefinition ); printf( "| marker definitions | %llu\n", - (unsigned long long)info.counterDefinitionMarker ); + (unsigned long long)info->counterDefinitionMarker ); printf( "| |\n" ); printf( "| process group definitions | %llu\n", - (unsigned long long)info.counterProcessGroupDefinition ); + (unsigned long long)info->counterProcessGroupDefinition ); printf( "| function group definitions | %llu\n", - (unsigned long long)info.counterFunctionGroupDefinition ); + (unsigned long long)info->counterFunctionGroupDefinition ); printf( "| counter group definitions | %llu\n", - (unsigned long long)info.counterCounterGroupDefinition ); + (unsigned long long)info->counterCounterGroupDefinition ); printf( "+----------------------------+--------------------------------------------------\n" ); - index = info.counterSourceFileName; + index = info->counterSourceFileName; printf( "| source file names\n" ); printf( "+-------------------------------------------------------------------------------\n" ); for( i = 0; i < index; i++) { - printf( "| %s\n", info.sourceFileNames[i] ); + printf( "| %s\n", info->sourceFileNames[i] ); } printf( "+-------------------------------------------------------------------------------\n" ); } -static void free_data_level_2( definitionInfoT info ) +static void free_data_level_2( definitionInfoT *info ) { int i, index; - index = info.counterSourceFileName; + index = info->counterSourceFileName; for( i = 0; i < index; i++ ) { - free( (info.sourceFileNames)[i] ); + free( (info->sourceFileNames)[i] ); } - free( info.sourceFileNames ); + free( info->sourceFileNames ); } static void set_handles_level_3( OTF_HandlerArray *handles, @@ -613,7 +613,7 @@ static void set_handles_level_3( OTF_HandlerArray *handles, } -static void show_info_level_3( definitionInfoT info ) +static void show_info_level_3( definitionInfoT *info ) { uint64_t i; @@ -622,47 +622,47 @@ static void show_info_level_3( definitionInfoT info ) printf( "\n##############\n" ); printf( "+-----------------------+-------------------------------------------------------\n" ); printf( "| enters | %llu\n", - (unsigned long long)info.counterEnter ); + (unsigned long long)info->counterEnter ); printf( "| leaves | %llu\n", - (unsigned long long)info.counterLeave ); + (unsigned long long)info->counterLeave ); printf( "| sends | %llu\n", - (unsigned long long)info.counterSend ); + (unsigned long long)info->counterSend ); printf( "| receives | %llu\n", - (unsigned long long)info.counterReceive ); + (unsigned long long)info->counterReceive ); printf( "| RMA Put | %llu\n", - (unsigned long long)info.counterRMAPut ); + (unsigned long long)info->counterRMAPut ); printf( "| RMA Put remote end | %llu\n", - (unsigned long long)info.counterRMAPutRemoteEnd ); + (unsigned long long)info->counterRMAPutRemoteEnd ); printf( "| RMA Get | %llu\n", - (unsigned long long)info.counterRMAGet ); + (unsigned long long)info->counterRMAGet ); printf( "| RMA End | %llu\n", - (unsigned long long)info.counterRMAEnd ); + (unsigned long long)info->counterRMAEnd ); printf( "| collective operations | %llu\n", - (unsigned long long)info.counterCollectiveOperation ); + (unsigned long long)info->counterCollectiveOperation ); printf( "| file operations | %llu\n", - (unsigned long long)info.counterFileOperation ); + (unsigned long long)info->counterFileOperation ); printf( "| snapshots | %llu\n", - (unsigned long long)info.counterSnapshot ); + (unsigned long long)info->counterSnapshot ); printf( "+-----------------------+-------------------------------------------------------\n" ); printf( "+-------------------------------------------------------------------------------\n" ); printf( "| counters[%llu]\n", - (unsigned long long)info.counterCounterDefinition ); + (unsigned long long)info->counterCounterDefinition ); printf( "+---------------+---------------------------------------------------------------\n" ); - for( i = 0; i < info.counterCounterDefinition; i++ ) + for( i = 0; i < info->counterCounterDefinition; i++ ) { - printf( "| name | %s\n", info.counters[i].name ); - if( ((info.counters[i].properties) & OTF_COUNTER_TYPE_BITS) == + printf( "| name | %s\n", info->counters[i].name ); + if( ((info->counters[i].properties) & OTF_COUNTER_TYPE_BITS) == OTF_COUNTER_TYPE_ACC ) { uint64_t lastValue = - process_get_sum_value( info.counters[i].processMap ); + process_get_sum_value( info->counters[i].processMap ); uint64_t lastTime = - process_get_sum_time( info.counters[i].processMap ); + process_get_sum_time( info->counters[i].processMap ); double average = - ((double)(lastValue)) * ((double)(info.timerResolution)) / + ((double)(lastValue)) * ((double)(info->timerResolution)) / ((double)(lastTime)); double highestRate = - process_get_highest_rate(info.counters[i].processMap); + process_get_highest_rate(info->counters[i].processMap); printf( "| last value | %llu\n", (unsigned long long)lastValue ); printf( "| average rate | %7.4E per sec\n", average ); @@ -674,17 +674,17 @@ static void show_info_level_3( definitionInfoT info ) printf( "\n" ); } -static void free_data_level_3( definitionInfoT info ) +static void free_data_level_3( definitionInfoT *info ) { uint64_t i; - for( i = 0; i < info.counterCounterDefinition; i++ ) + for( i = 0; i < info->counterCounterDefinition; i++ ) { - free( (info.counters)[i].name ); - if( NULL != (info.counters)[i].processMap ) - hash_delete( (info.counters)[i].processMap ); + free( (info->counters)[i].name ); + if( NULL != (info->counters)[i].processMap ) + hash_delete( (info->counters)[i].processMap ); } - free( info.counters ); + free( info->counters ); } static void set_handles_level_4( OTF_HandlerArray *handles, @@ -747,7 +747,7 @@ static void set_handles_level_4( OTF_HandlerArray *handles, OTF_HandlerArray_setFirstHandlerArg( handles, info, OTF_DEFCOUNTERGROUP_RECORD ); } -static void show_info_level_4( definitionInfoT info ) +static void show_info_level_4( definitionInfoT *info ) { uint64_t i; @@ -756,130 +756,130 @@ static void show_info_level_4( definitionInfoT info ) printf( "\n##############\n" ); printf( "+-------------------------------------------------------------------------------\n" ); printf( "| process definitions[%llu]\n", - (unsigned long long)info.counterProcessDefinition ); + (unsigned long long)info->counterProcessDefinition ); printf( "+-------------------------------------------------------------------------------\n" ); - for( i = 0; i < info.counterProcessDefinition; i++ ) + for( i = 0; i < info->counterProcessDefinition; i++ ) { - printf( "| %s\n", info.processNames[i] ); + printf( "| %s\n", info->processNames[i] ); } printf( "+-------------------------------------------------------------------------------\n" ); printf( "\n" ); printf( "+-------------------------------------------------------------------------------\n" ); printf( "| function definitions[%llu]\n", - (unsigned long long)info.counterFunctionDefinition ); + (unsigned long long)info->counterFunctionDefinition ); printf( "+-------------------------------------------------------------------------------\n" ); - for(i = 0; i < info.counterFunctionDefinition; i++ ) + for(i = 0; i < info->counterFunctionDefinition; i++ ) { - printf( "| %s\n",info.functionNames[i] ); + printf( "| %s\n",info->functionNames[i] ); } printf( "+-------------------------------------------------------------------------------\n" ); printf( "\n" ); printf( "+-------------------------------------------------------------------------------\n" ); printf( "| marker definitions[%llu]\n", - (unsigned long long)info.counterDefinitionMarker ); + (unsigned long long)info->counterDefinitionMarker ); printf( "+-------------------------------------------------------------------------------\n" ); - for( i = 0; i < info.counterDefinitionMarker; i++ ) + for( i = 0; i < info->counterDefinitionMarker; i++ ) { - printf( "| %s\n", info.markerNames[i] ); + printf( "| %s\n", info->markerNames[i] ); } printf( "+-------------------------------------------------------------------------------\n" ); printf( "\n" ); printf( "+-------------------------------------------------------------------------------\n" ); printf( "| collective operation definitions[%llu]\n", - (unsigned long long)info.counterCollectiveOperation ); + (unsigned long long)info->counterCollectiveOperation ); printf( "+-------------------------------------------------------------------------------\n" ); - for( i = 0; i < info.counterCollectiveOperation; i++ ) + for( i = 0; i < info->counterCollectiveOperation; i++ ) { - printf( "| %s\n", info.collectiveOperationNames[i] ); + printf( "| %s\n", info->collectiveOperationNames[i] ); } printf( "+-------------------------------------------------------------------------------\n" ); printf( "\n" ); printf( "+-------------------------------------------------------------------------------\n" ); printf( "| process group definitions[%llu]\n", - (unsigned long long)info.counterProcessGroupDefinition ); + (unsigned long long)info->counterProcessGroupDefinition ); printf( "+-------------------------------------------------------------------------------\n" ); - for( i = 0; i < info.counterProcessGroupDefinition; i++ ) + for( i = 0; i < info->counterProcessGroupDefinition; i++ ) { - printf( "| %s\n", info.processGroupNames[i] ); + printf( "| %s\n", info->processGroupNames[i] ); } printf( "+-------------------------------------------------------------------------------\n" ); printf( "\n" ); printf( "+-------------------------------------------------------------------------------\n" ); printf( "| function group definitions[%llu]\n", - (unsigned long long)info.counterFunctionGroupDefinition ); + (unsigned long long)info->counterFunctionGroupDefinition ); printf( "+-------------------------------------------------------------------------------\n" ); - for( i = 0; i < info.counterFunctionGroupDefinition; i++ ) + for( i = 0; i < info->counterFunctionGroupDefinition; i++ ) { - printf( "| %s\n", info.functionGroupNames[i] ); + printf( "| %s\n", info->functionGroupNames[i] ); } printf( "+-------------------------------------------------------------------------------\n" ); printf( "\n" ); printf( "+-------------------------------------------------------------------------------\n" ); printf( "| counter group definitions[%llu]\n", - (unsigned long long)info.counterCounterGroupDefinition ); + (unsigned long long)info->counterCounterGroupDefinition ); printf( "+-------------------------------------------------------------------------------\n" ); - for( i = 0; i < info.counterCounterGroupDefinition; i++ ) + for( i = 0; i < info->counterCounterGroupDefinition; i++ ) { - printf( "| %s\n", info.counterGroupNames[i] ); + printf( "| %s\n", info->counterGroupNames[i] ); } printf( "+-------------------------------------------------------------------------------\n" ); } -static void free_data_level_4( definitionInfoT info ) +static void free_data_level_4( definitionInfoT *info ) { uint64_t i; - if( info.processNames != NULL ) + if( info->processNames != NULL ) { - for( i = 0; i < info.counterProcessDefinition; i++ ) + for( i = 0; i < info->counterProcessDefinition; i++ ) { - free( (info.processNames)[i] ); + free( (info->processNames)[i] ); } - free( info.processNames ); + free( info->processNames ); } - if( info.processGroupNames != NULL ) + if( info->processGroupNames != NULL ) { - for( i = 0; i < info.counterProcessGroupDefinition; i++ ) + for( i = 0; i < info->counterProcessGroupDefinition; i++ ) { - free( (info.processGroupNames)[i] ); + free( (info->processGroupNames)[i] ); } - free( info.processGroupNames ); + free( info->processGroupNames ); } - if( info.functionNames != NULL ) + if( info->functionNames != NULL ) { - for( i = 0; i < info.counterFunctionDefinition; i++ ) + for( i = 0; i < info->counterFunctionDefinition; i++ ) { - free( (info.functionNames)[i] ); + free( (info->functionNames)[i] ); } - free( info.functionNames ); + free( info->functionNames ); } - if( info.functionGroupNames != NULL ) + if( info->functionGroupNames != NULL ) { - for( i = 0; i < info.counterFunctionGroupDefinition; i++ ) + for( i = 0; i < info->counterFunctionGroupDefinition; i++ ) { - free( (info.functionGroupNames)[i] ); + free( (info->functionGroupNames)[i] ); } - free( info.functionGroupNames ); + free( info->functionGroupNames ); } - for(i = 0; i < info.counterCollectiveOperation; i++ ) + for(i = 0; i < info->counterCollectiveOperation; i++ ) { - free( (info.collectiveOperationNames)[i] ); + free( (info->collectiveOperationNames)[i] ); } - free( info.collectiveOperationNames ); + free( info->collectiveOperationNames ); - for(i = 0; i < info.counterCounterGroupDefinition; i++ ) + for(i = 0; i < info->counterCounterGroupDefinition; i++ ) { - free( (info.counterGroupNames)[i] ); + free( (info->counterGroupNames)[i] ); } - free( info.counterGroupNames ); + free( info->counterGroupNames ); - for( i = 0; i < info.counterDefinitionMarker; i++ ) + for( i = 0; i < info->counterDefinitionMarker; i++ ) { - free( (info.markerNames)[i] ); + free( (info->markerNames)[i] ); } - free( info.markerNames ); + free( info->markerNames ); } diff --git a/ompi/contrib/vt/vt/extlib/otf/tools/otfprofile/DataStructure.cpp b/ompi/contrib/vt/vt/extlib/otf/tools/otfprofile/DataStructure.cpp index 65031cb823..743d24de3b 100644 --- a/ompi/contrib/vt/vt/extlib/otf/tools/otfprofile/DataStructure.cpp +++ b/ompi/contrib/vt/vt/extlib/otf/tools/otfprofile/DataStructure.cpp @@ -1643,7 +1643,7 @@ bool Summary_Container::find_CollOp(CollOp_Def_Key coll_def_key) return true; } -int Summary_Container::mergeContainer(Summary_Container container) { +int Summary_Container::mergeContainer(Summary_Container& container) { FunctionMap fmap = container.function_map; FunctionMap::iterator fit; diff --git a/ompi/contrib/vt/vt/extlib/otf/tools/otfprofile/DataStructure.h b/ompi/contrib/vt/vt/extlib/otf/tools/otfprofile/DataStructure.h index b4a785a09f..229fde51d2 100644 --- a/ompi/contrib/vt/vt/extlib/otf/tools/otfprofile/DataStructure.h +++ b/ompi/contrib/vt/vt/extlib/otf/tools/otfprofile/DataStructure.h @@ -827,7 +827,7 @@ class Summary_Container int csv_P2P(fstream& out, uint32_t trace); int csv_CollOp(fstream& out, uint32_t trace); int csv_Data(fstream& out, uint32_t trace); - int mergeContainer(Summary_Container container); + int mergeContainer(Summary_Container& container); private: FunctionMap function_map; diff --git a/ompi/contrib/vt/vt/extlib/otf/tools/otfprofile/otfprofile.cpp b/ompi/contrib/vt/vt/extlib/otf/tools/otfprofile/otfprofile.cpp index 26c9de5cfb..ac91b0fa26 100644 --- a/ompi/contrib/vt/vt/extlib/otf/tools/otfprofile/otfprofile.cpp +++ b/ompi/contrib/vt/vt/extlib/otf/tools/otfprofile/otfprofile.cpp @@ -344,7 +344,7 @@ int main( int argc, const char** argv ) } } - data_array = (global_data**) malloc(num_threads * sizeof(global_data)); + data_array = (global_data**) malloc(num_threads * sizeof(global_data*)); cpu2thread = (uint32_t*) malloc(num_cpus * sizeof(uint32_t)); /* Definitons */ @@ -472,9 +472,11 @@ int main( int argc, const char** argv ) uint32_t start = 0; uint32_t end = 0; +# ifdef _OPENMP for(int k=0; kprocMap.end() != first->procMap.find(procs[i]) ) { @@ -48,12 +49,17 @@ int handleDefProcessGroup (void *userData, uint32_t stream, uint32_t procGroup, } if(mod_numberOfProcs < 1) { + delete[] mod_procs; return OTF_RETURN_OK; } - return ( 0 == OTF_Writer_writeDefProcessGroup ( (OTF_Writer*) first->writer, stream, procGroup, name, + ret = ( 0 == OTF_Writer_writeDefProcessGroup ( (OTF_Writer*) first->writer, stream, procGroup, name, mod_numberOfProcs, mod_procs) ) ? OTF_RETURN_ABORT : OTF_RETURN_OK; + delete[] mod_procs; + + return ret; + } int handleDefFunction (void *userData, uint32_t stream, uint32_t func, const char *name, uint32_t funcGroup, uint32_t source) { @@ -106,8 +112,11 @@ int handleDefCreator (void *userData, uint32_t stream, const char *creator) { int handleDefVersion (void *userData, uint32_t stream, uint8_t major, uint8_t minor, uint8_t sub, const char *string) { - return ( 0 == OTF_Writer_writeOtfVersion ( (OTF_Writer*) userData, stream) ) - ? OTF_RETURN_ABORT : OTF_RETURN_OK; + /* this is deprecated and not necessary at all */ + /*return ( 0 == OTF_Writer_writeOtfVersion ( (OTF_Writer*) userData, stream) ) + ? OTF_RETURN_ABORT : OTF_RETURN_OK;*/ + + return OTF_RETURN_OK; } int handleDefFile (void *userData, uint32_t stream, uint32_t token, const char *name, uint32_t group) { diff --git a/ompi/contrib/vt/vt/extlib/otf/tools/otfshrink/otfshrink.cpp b/ompi/contrib/vt/vt/extlib/otf/tools/otfshrink/otfshrink.cpp index 140fd2ad81..692c3e97e1 100644 --- a/ompi/contrib/vt/vt/extlib/otf/tools/otfshrink/otfshrink.cpp +++ b/ompi/contrib/vt/vt/extlib/otf/tools/otfshrink/otfshrink.cpp @@ -25,6 +25,9 @@ #define RANGE_MODE 1 #define TABLE_MODE 2 +#define CLEAR_EVERYTHING free_all_pointers(ch_i, first, entries, writer, reader, \ + handlers, manager, master, new_master); + #define HELPTEXT "" \ " \n" \ " otfshrink - creates a new otf file that only includes \n" \ @@ -50,10 +53,13 @@ map cpuMap; int write_master(string input, string output, bool invers, bool show, int sim_mode); int display_processes(firstarg *first, int sim_mode); +void free_all_pointers(char *ch_i, firstarg *first, OTF_MapEntry *entries, OTF_Writer *writer, + OTF_Reader *reader, OTF_HandlerArray *handlers, OTF_FileManager *manager, + OTF_MasterControl *master, OTF_MasterControl *new_master); int main (int argc, char* argv[]) { - char *pwd = new char[OTF_PATH_MAX]; + char *pwd = NULL; bool enable = true; bool invers_mode = true; bool mode_set = false; @@ -69,12 +75,6 @@ int main (int argc, char* argv[]) { string output_folder; string output_path; - /* get current working directory */ - pwd = getcwd(pwd, OTF_PATH_MAX); - if ( pwd == NULL) { - cerr << "Error: Path length greater than the maximum." << endl; - } - if ( argc <= 1 ) { cout << HELPTEXT << endl; return 0; @@ -222,6 +222,16 @@ int main (int argc, char* argv[]) { cerr << "Error: No input file given." << endl; return 1; } + + /* get current working directory */ + pwd = new char[OTF_PATH_MAX]; + *pwd = '\0'; + pwd = getcwd(pwd, OTF_PATH_MAX); + if ( pwd == NULL) { + cerr << "Error: Path length greater than the maximum." << endl; + delete[] pwd; + return 1; + } /* make absolute path - necessary to create a symbolic link later on */ if (input_path[0] != '/') { @@ -288,17 +298,11 @@ int main (int argc, char* argv[]) { } /*** end string operations ***/ - + /* create symbolic links, definiton file and master file */ - if ( write_master(input_path ,output_path, invers_mode, simulation, sim_mode) ) { - return 2; - } - - - return 0; + return write_master(input_path ,output_path, invers_mode, simulation, sim_mode); } - int write_master(string input, string output, bool invers, bool show, int sim_mode) { /* create symbolic links, definiton file and master file */ @@ -320,8 +324,9 @@ int write_master(string input, string output, bool invers, bool show, int sim_mo OTF_HandlerArray *handlers = NULL; OTF_FileManager *manager = NULL; OTF_MasterControl *master = NULL; + OTF_MasterControl *new_master = NULL; - manager = OTF_FileManager_open(1); + manager = OTF_FileManager_open(2); master = OTF_MasterControl_new(manager); OTF_MasterControl_read(master, input.c_str()); @@ -333,6 +338,7 @@ int write_master(string input, string output, bool invers, bool show, int sim_mo } else { cerr << "Error while reading tracefile. No entries in file found." << endl; } + CLEAR_EVERYTHING return 2; } @@ -354,13 +360,13 @@ int write_master(string input, string output, bool invers, bool show, int sim_mo } } - /* create new master and symbolic links */ - master = OTF_MasterControl_new(manager); + /* create new empty master and symbolic links */ + new_master = OTF_MasterControl_new(manager); for(uint32_t i = 0; i < num_args; i++) { append = false; for(uint32_t j = 0; j < entries[i].n; j++) { if(entries[i].values[j] > 0) { - OTF_MasterControl_append(master, i+1, entries[i].values[j]); + OTF_MasterControl_append(new_master, i+1, entries[i].values[j]); first->procMap[ entries[i].values[j] ] = true; append = true; } @@ -372,7 +378,7 @@ int write_master(string input, string output, bool invers, bool show, int sim_mo } /* create symbolic links */ - sprintf(ch_i, "%x", i+1); + snprintf(ch_i, MAX_L, "%x", i+1); for(int k = 0; k < 4; k++) { @@ -383,11 +389,13 @@ int write_master(string input, string output, bool invers, bool show, int sim_mo if ( ! access(s_link.c_str(), F_OK) ) { if ( unlink(s_link.c_str()) ) { cerr << "Error while removing symbolic link " << s_link << endl; + CLEAR_EVERYTHING return 2; } } if ( symlink( file.c_str(), s_link.c_str() ) ) { cerr << "Error while creating symbolic link " << s_link << endl; + CLEAR_EVERYTHING return 2; } } else { @@ -398,16 +406,19 @@ int write_master(string input, string output, bool invers, bool show, int sim_mo if ( ! access(s_link.c_str(), F_OK) ) { if ( unlink(s_link.c_str()) ) { cerr << "Error while removing symbolic link " << s_link << endl; + CLEAR_EVERYTHING return 2; } } if ( symlink( file.c_str(), s_link.c_str() ) ) { cerr << "Error while creating symbolic link " << s_link << endl; + CLEAR_EVERYTHING return 2; } } else { if ( k == 0 ) { cerr << "Error: Could not find " << file << endl; + CLEAR_EVERYTHING return 2; } } @@ -415,14 +426,20 @@ int write_master(string input, string output, bool invers, bool show, int sim_mo } } + /* close original master, he is not needed anymore */ + OTF_MasterControl_close(master); + master = NULL; + if (show) { display_processes(first, sim_mode); + CLEAR_EVERYTHING return 0; } /* check if there is at least one process to show */ - if (OTF_MasterControl_getCount(master) < 1) { + if (OTF_MasterControl_getCount(new_master) < 1) { cerr << "You exclude all processes! Master not wrote." << endl; + CLEAR_EVERYTHING return 2; } @@ -513,24 +530,17 @@ int write_master(string input, string output, bool invers, bool show, int sim_mo read = OTF_Reader_readDefinitions (reader, handlers); if( read == OTF_READ_ERROR ) { - fprintf(stderr,"An error occurred while reading the tracefile. It seems to be damaged. Abort.\n"); + cerr << "An error occurred while reading the tracefile. It seems to be damaged. Abort." << endl; + CLEAR_EVERYTHING return 1; } - OTF_HandlerArray_close(handlers); - OTF_Reader_close(reader); - OTF_Writer_close(writer); - - /* writes new master file to harddisk */ - OTF_MasterControl_write(master, output.c_str()); - - OTF_MasterControl_close(master); - OTF_FileManager_close(manager); + /* set the writer's master to the modified master instance */ + /* closing the writer at the end writes the new master file to harddisk */ + OTF_Writer_setMasterControl(writer, new_master); /* clear everything */ - delete[] ch_i; - delete first; - delete[] entries; + CLEAR_EVERYTHING return 0; } @@ -595,3 +605,56 @@ int display_processes(firstarg *first, int sim_mode) { return 0; } +void free_all_pointers(char *ch_i, firstarg *first, OTF_MapEntry *entries, OTF_Writer *writer, + OTF_Reader *reader, OTF_HandlerArray *handlers, OTF_FileManager *manager, + OTF_MasterControl *master, OTF_MasterControl *new_master) { + + if(ch_i != NULL) { + delete[] ch_i; + ch_i = NULL; + } + + if(first != NULL) { + delete first; + first = NULL; + } + + if(entries != NULL) { + delete[] entries; + entries = NULL; + } + + /* new_master is free'd by writer instance */ + if(writer != NULL) { + OTF_Writer_close(writer); + writer = NULL; + new_master = NULL; + } + + if(reader != NULL) { + OTF_Reader_close(reader); + reader = NULL; + } + + + if(handlers != NULL) { + OTF_HandlerArray_close(handlers); + handlers = NULL; + } + + if(manager != NULL) { + OTF_FileManager_close(manager); + manager = NULL; + } + + if(master != NULL) { + OTF_MasterControl_close(master); + master = NULL; + } + + if(new_master != NULL) { + OTF_MasterControl_close(new_master); + new_master = NULL; + } +} + diff --git a/ompi/contrib/vt/vt/tools/opari/doc/lacsi01.pdf b/ompi/contrib/vt/vt/tools/opari/doc/lacsi01.pdf index d96bb43c2d..706faa7324 100644 Binary files a/ompi/contrib/vt/vt/tools/opari/doc/lacsi01.pdf and b/ompi/contrib/vt/vt/tools/opari/doc/lacsi01.pdf differ diff --git a/ompi/contrib/vt/vt/tools/vtunify/vt_unify.cc b/ompi/contrib/vt/vt/tools/vtunify/vt_unify.cc index b803898459..e2f2affaec 100644 --- a/ompi/contrib/vt/vt/tools/vtunify/vt_unify.cc +++ b/ompi/contrib/vt/vt/tools/vtunify/vt_unify.cc @@ -727,7 +727,7 @@ parseCommandLine( int argc, char ** argv ) { Params.bequiet = true; Params.showprogress = false; - Params.beverbose = false; + Params.verbose_level = 0; } else if( strcmp( argv[i], "-v" ) == 0 || strcmp( argv[i], "--verbose" ) == 0 ) @@ -880,10 +880,6 @@ getMinStartTime() // store minimum timestamp g_uMinStartTime = min_start_time; - -#ifdef VT_MPI - if( error ) return false; -#endif // VT_MPI } // MASTER #ifdef VT_MPI @@ -927,50 +923,53 @@ cleanUp() } if( i != Params.uctl_files_num ) - return false; + return false; // remove local def./events/stats/marker trace files // for( i = 0; i < g_vecUnifyCtls.size(); i++ ) { - for( uint32_t j = 0; j < 4; j++ ) - { - switch( j ) - { - case 0: - filetype = OTF_FILETYPE_DEF; - break; - case 1: - filetype = OTF_FILETYPE_EVENT; - break; - case 2: - filetype = OTF_FILETYPE_STATS; - case 3: - default: - filetype = OTF_FILETYPE_MARKER; - break; - } + for( uint32_t j = 0; j < 4; j++ ) + { + bool removed = false; - OTF_getFilename( Params.in_file_prefix.c_str(), - g_vecUnifyCtls[i]->streamid, - filetype, - STRBUFSIZE, filename1 ); - - if( access( filename1, F_OK ) != 0 ) - { - assert( strlen( filename1 ) + 2 + 1 < sizeof( filename1 ) - 1 ); + switch( j ) + { + case 0: + filetype = OTF_FILETYPE_DEF; + break; + case 1: + filetype = OTF_FILETYPE_EVENT; + break; + case 2: + filetype = OTF_FILETYPE_STATS; + case 3: + default: + filetype = OTF_FILETYPE_MARKER; + break; + } - // file not found, try '.z' suffix - strncat( filename1, ".z", 2 ); - } + OTF_getFilename( Params.in_file_prefix.c_str(), + g_vecUnifyCtls[i]->streamid, filetype, + STRBUFSIZE, filename1 ); - if( remove( filename1 ) == 0 ) - VPrint( 2, " Removed %s\n", filename1 ); - } + if( !( removed = ( remove( filename1 ) == 0 ) ) ) + { + OTF_getFilename( Params.in_file_prefix.c_str(), + g_vecUnifyCtls[i]->streamid, + filetype | OTF_FILECOMPRESSION_COMPRESSED, + STRBUFSIZE, filename1 ); + + removed = ( remove( filename1 ) == 0 ); + } + + if( removed ) + VPrint( 2, " Removed %s\n", filename1 ); + } } - if( i != g_vecUnifyCtls.size() ) - return false; + if( i < g_vecUnifyCtls.size() ) + return false; } std::string tmp_out_file_prefix = @@ -980,41 +979,41 @@ cleanUp() // for( i = 0; i < 2; i++ ) { + bool renamed = false; + if( i == 0 ) filetype = OTF_FILETYPE_DEF; else filetype = OTF_FILETYPE_MARKER; - OTF_getFilename( tmp_out_file_prefix.c_str(), 0, - filetype, - STRBUFSIZE, filename1 ); - OTF_getFilename( Params.out_file_prefix.c_str(), 0, - filetype, - STRBUFSIZE, filename2 ); - - if( access( filename1, F_OK ) != 0 ) - { - assert( strlen( filename1 ) + 2 + 1 < sizeof( filename1 ) - 1 ); - assert( strlen( filename2 ) + 2 + 1 < sizeof( filename2 ) - 1 ); + OTF_getFilename( tmp_out_file_prefix.c_str(), 0, filetype, + STRBUFSIZE, filename1 ); + OTF_getFilename( Params.out_file_prefix.c_str(), 0, filetype, + STRBUFSIZE, filename2 ); - // file not found, try '.z' suffix - strncat( filename1, ".z", 2 ); - strncat( filename2, ".z", 2 ); + if( !( renamed = ( rename( filename1, filename2 ) == 0 ) ) ) + { + OTF_getFilename( tmp_out_file_prefix.c_str(), 0, + filetype | OTF_FILECOMPRESSION_COMPRESSED, + STRBUFSIZE, filename1 ); + OTF_getFilename( Params.out_file_prefix.c_str(), 0, + filetype | OTF_FILECOMPRESSION_COMPRESSED, + STRBUFSIZE, filename2 ); + + renamed = ( rename( filename1, filename2 ) == 0 ); } - if( rename( filename1, filename2 ) != 0 ) - { - if( i == 0 ) - { - std::cerr << ExeName << ": Error: Could not rename " - << filename1 << " to " - << filename2 << std::endl; - return false; - } - } - else + if( renamed ) { VPrint( 2, " Renamed %s to %s\n", filename1, filename2 ); } + else if( i == 0 ) + { + std::cerr << ExeName << ": Error: Could not rename " + << filename1 << " to " + << filename2 << std::endl; + break; + } } + if( i < 2 ) return false; // rename temporary master control file // @@ -1098,7 +1097,7 @@ shareParams() // create MPI datatype for Params_struct // - char filenames[3][1024]; + char **filenames; char flags[5]; VT_MPI_INT blockcounts[5] = { 3*1024, 1, 1, 1, 5 }; VTUnify_MPI_Aint displ[5]; @@ -1107,7 +1106,12 @@ shareParams() VTUnify_MPI_INT, VTUnify_MPI_CHAR }; VTUnify_MPI_Datatype newtype; - VTUnify_MPI_Address( &filenames, &displ[0] ); + filenames = new char*[3]; + filenames[0] = new char[3*1024]; + filenames[1] = filenames[0] + ( 1024 * sizeof(char) ); + filenames[2] = filenames[1] + ( 1024 * sizeof(char) ); + + VTUnify_MPI_Address( filenames[0], &displ[0] ); VTUnify_MPI_Address( &(Params.uctl_files_num), &displ[1] ); VTUnify_MPI_Address( &(Params.verbose_level), &displ[2] ); VTUnify_MPI_Address( &(Params.stats_sort_flags), &displ[3] ); @@ -1146,6 +1150,9 @@ shareParams() Params.bequiet = (flags[4] == 1); } + delete [] filenames[0]; + delete [] filenames; + // free MPI datatype VTUnify_MPI_Type_free( &newtype ); diff --git a/ompi/contrib/vt/vt/tools/vtunify/vt_unify.h b/ompi/contrib/vt/vt/tools/vtunify/vt_unify.h index d4eb880652..65c917484e 100644 --- a/ompi/contrib/vt/vt/tools/vtunify/vt_unify.h +++ b/ompi/contrib/vt/vt/tools/vtunify/vt_unify.h @@ -72,7 +72,6 @@ struct Params_struct bool showusage; bool showprogress; bool bequiet; - bool beverbose; }; // diff --git a/ompi/contrib/vt/vt/tools/vtunify/vt_unify_defs.cc b/ompi/contrib/vt/vt/tools/vtunify/vt_unify_defs.cc index 191268592f..1e66415401 100644 --- a/ompi/contrib/vt/vt/tools/vtunify/vt_unify_defs.cc +++ b/ompi/contrib/vt/vt/tools/vtunify/vt_unify_defs.cc @@ -496,9 +496,9 @@ Definitions::createGlobal( const std::vector * // start-time // tt = (time_t)(g_uMinStartTimeEpoch / 1e6); - sprintf( comment, " Start: %s (%"U64STR")", - asctime(localtime(&tt)), - g_uMinStartTimeEpoch ); + snprintf( comment, sizeof( comment ) - 1, " Start: %s (%"U64STR")", + asctime(localtime(&tt)), + g_uMinStartTimeEpoch ); p_vecGlobDefs->push_back( new DefRec_DefinitionComment_struct( 1, comment ) ); @@ -506,9 +506,9 @@ Definitions::createGlobal( const std::vector * // stop-time // tt = (time_t)(g_uMaxStopTimeEpoch / 1e6); - sprintf( comment, " Stop: %s (%"U64STR")", - asctime(localtime(&tt)), - g_uMaxStopTimeEpoch ); + snprintf( comment, sizeof( comment ) - 1, " Stop: %s (%"U64STR")", + asctime(localtime(&tt)), + g_uMaxStopTimeEpoch ); p_vecGlobDefs->push_back( new DefRec_DefinitionComment_struct( 2, comment ) ); @@ -517,11 +517,12 @@ Definitions::createGlobal( const std::vector * // tt = (time_t)((g_uMaxStopTimeEpoch - g_uMinStartTimeEpoch) / 1e6); gmtime_r(&tt, &elapsed_tm); - sprintf( comment, " Elapsed: %s%d:%s%d:%s%d (%"U64STR")", - elapsed_tm.tm_hour < 10 ? "0" : "", elapsed_tm.tm_hour, - elapsed_tm.tm_min < 10 ? "0" : "", elapsed_tm.tm_min, - elapsed_tm.tm_sec < 10 ? "0" : "", elapsed_tm.tm_sec, - (g_uMaxStopTimeEpoch - g_uMinStartTimeEpoch) ); + snprintf( comment, sizeof( comment ) - 1, + " Elapsed: %s%d:%s%d:%s%d (%"U64STR")", + elapsed_tm.tm_hour < 10 ? "0" : "", elapsed_tm.tm_hour, + elapsed_tm.tm_min < 10 ? "0" : "", elapsed_tm.tm_min, + elapsed_tm.tm_sec < 10 ? "0" : "", elapsed_tm.tm_sec, + (g_uMaxStopTimeEpoch - g_uMinStartTimeEpoch) ); p_vecGlobDefs->push_back( new DefRec_DefinitionComment_struct( 3, comment ) ); diff --git a/ompi/contrib/vt/vt/tools/vtwrapper/vt_wrapper.cc b/ompi/contrib/vt/vt/tools/vtwrapper/vt_wrapper.cc index 0b8af1ac98..d448bc14c3 100644 --- a/ompi/contrib/vt/vt/tools/vtwrapper/vt_wrapper.cc +++ b/ompi/contrib/vt/vt/tools/vtwrapper/vt_wrapper.cc @@ -264,8 +264,9 @@ Wrapper::readDataFile() case 21: // inst_avail { char cvalue[128]; - strcpy( cvalue, value.c_str() ); - + strncpy( cvalue, value.c_str(), sizeof( cvalue ) - 1 ); + cvalue[sizeof(cvalue) - 1] = '\0'; + char * token = strtok( cvalue, " " ); if( !token ) { @@ -465,10 +466,12 @@ Wrapper::parseCommandLine( int argc, char ** argv ) return false; } - char * args = new char[strlen(argv[i+1])+1]; - strcpy( args, argv[++i] ); - char * token = strtok( args, " " ); + size_t args_len = strlen(argv[i+1])+1; + char * args = new char[args_len]; + strncpy( args, argv[++i], args_len - 1 ); + args[args_len - 1] = '\0'; + char * token = strtok( args, " " ); do { if( strcmp( token, "-rcfile" ) == 0 ) @@ -478,7 +481,7 @@ Wrapper::parseCommandLine( int argc, char ** argv ) { std::cerr << ExeName << ": expected -- -rcfile" << std::endl; - delete args; + delete [] args; return false; } m_pConfig->opari_setRcFile( token ); @@ -490,7 +493,7 @@ Wrapper::parseCommandLine( int argc, char ** argv ) { std::cerr << ExeName << ": expected -- -table" << std::endl; - delete args; + delete [] args; return false; } @@ -502,7 +505,7 @@ Wrapper::parseCommandLine( int argc, char ** argv ) } } while( ( token = strtok( 0, " " ) ) ); - delete args; + delete [] args; } // // -vt:seq @@ -937,31 +940,34 @@ Wrapper::run() // for( i = 0; i < m_pConfig->m_vecOpari_ModObjFiles.size(); i++ ) { - if( access( m_pConfig->m_vecOpari_ModObjFiles[i].c_str(), F_OK ) == 0 ) - { - int modi = m_pConfig->m_vecOpari_ModObjFiles[i].find( ".mod" ); + int modi = m_pConfig->m_vecOpari_ModObjFiles[i].find( ".mod" ); - if( modi != -1 ) - { - std::string target = m_pConfig->m_vecOpari_ModObjFiles[i]; - target.erase( modi, 4 ); - - if( beverbose ) - std::cout << "+++ rename " << m_pConfig->m_vecOpari_ModObjFiles[i] - << " to " << target << std::endl; - - rename( m_pConfig->m_vecOpari_ModObjFiles[i].c_str(), - target.c_str() ); - } - } + if( modi != -1 ) + { + std::string target = m_pConfig->m_vecOpari_ModObjFiles[i]; + target.erase( modi, 4 ); + + if( beverbose ) + std::cout << "+++ rename " << m_pConfig->m_vecOpari_ModObjFiles[i] + << " to " << target << std::endl; + + if( rename( m_pConfig->m_vecOpari_ModObjFiles[i].c_str(), + target.c_str() ) == -1 ) + { + std::cerr << ExeName << ": could not rename " + << m_pConfig->m_vecOpari_ModObjFiles[i] << " to " + << target << std::endl; + return 1; + } + } } // delete intermediate opari output (in non-verbose mode) // if( !beverbose ) { - for( i = 0; i < m_pConfig->m_vecOpari_ModSrcFiles.size(); i++ ) - remove( m_pConfig->m_vecOpari_ModSrcFiles[i].c_str() ); + for( i = 0; i < m_pConfig->m_vecOpari_ModSrcFiles.size(); i++ ) + remove( m_pConfig->m_vecOpari_ModSrcFiles[i].c_str() ); } } @@ -1208,7 +1214,7 @@ Wrapper::getIncFilesFromTabFile() // Config::Config() : - m_eInstType(INST_TYPE_MANUAL), m_iInstAvail(0), + m_eLangType(LANG_CC), m_eInstType(INST_TYPE_MANUAL), m_iInstAvail(0), m_bBeVerbose(false), m_bCompOnly(false), m_bUsesMpi(false), m_bUsesThreads(false), @@ -1228,22 +1234,23 @@ Config::~Config() bool Config::setLanguage( const LangTypeT lang ) { +#if !(defined(HAVE_F77) && HAVE_F77) || !(defined(HAVE_F90) && HAVE_F90) bool error = false; std::string str_lang; if( lang == LANG_F77 ) { -#if !(defined(HAVE_F77) && HAVE_F77) +# if !(defined(HAVE_F77) && HAVE_F77) str_lang = "Fortran 77"; error = true; -#endif // HAVE_F77 +# endif // HAVE_F77 } else if( lang == LANG_F90 ) { -#if !(defined(HAVE_F90) && HAVE_F90) +# if !(defined(HAVE_F90) && HAVE_F90) str_lang = "Fortran 90"; error = true; -#endif // HAVE_F90 +# endif // HAVE_F90 } if( !error ) @@ -1253,12 +1260,16 @@ Config::setLanguage( const LangTypeT lang ) else { std::cerr << "Unfortunately, this installation of VampirTrace " - << "was not compiled with" << std::endl - << str_lang << " support. As such, the " << ExeName - << " compiler is non-functional." << std::endl; + << "was not compiled with" << std::endl + << str_lang << " support. As such, the " << ExeName + << " compiler is non-functional." << std::endl; } return !error; +#else // HAVE_F77 || HAVE_F90 + m_eLangType = lang; + return true; +#endif // HAVE_F77 || HAVE_F90 } void diff --git a/ompi/contrib/vt/vt/vtlib/vt_env.c b/ompi/contrib/vt/vt/vtlib/vt_env.c index 94847c5ab3..bf1aa10ba9 100644 --- a/ompi/contrib/vt/vt/vtlib/vt_env.c +++ b/ompi/contrib/vt/vt/vtlib/vt_env.c @@ -507,7 +507,8 @@ int vt_env_mode() char* tk; int dc; - strncpy(tmpbuf, tmp, 128); + strncpy(tmpbuf, tmp, 127); + tmpbuf[127] = '\0'; while( *p ) { *p = tolower(*p); p++; } tk = strtok(tmpbuf, ":"); @@ -570,7 +571,8 @@ int vt_env_stat_props() char* tk; int dc; - strncpy(tmpbuf, tmp, 128); + strncpy(tmpbuf, tmp, 127); + tmpbuf[127] = '\0'; while( *p ) { *p = tolower(*p); p++; } if (strcmp( tmpbuf, "all" ) == 0) @@ -626,7 +628,8 @@ int vt_env_stat_msg_dtls() char* tk; int dc; - strncpy(tmpbuf, tmp, 128); + strncpy(tmpbuf, tmp, 127); + tmpbuf[127] = '\0'; while( *p ) { *p = tolower(*p); p++; } tk = strtok(tmpbuf, ":"); @@ -670,7 +673,8 @@ int vt_env_stat_collop_dtls() char* tk; int dc; - strncpy(tmpbuf, tmp, 128); + strncpy(tmpbuf, tmp, 127); + tmpbuf[127] = '\0'; while( *p ) { *p = tolower(*p); p++; } tk = strtok(tmpbuf, ":"); @@ -1008,6 +1012,22 @@ char* vt_env_metrics() return metrics; } +char* vt_env_metrics_sep() +{ + static char* metrics_sep = NULL; + + if (!metrics_sep) + { + metrics_sep = getenv("VT_METRICS_SEP"); + if (metrics_sep == NULL || strlen(metrics_sep) == 0) + { + metrics_sep = ":"; + } + } + + return metrics_sep; +} + /* The file with the metrics specifications can be defined with the VT_METRICS_SPEC environment variable, otherwise it is looked for in the current directory and the VampirTrace installation DATADIR. */ diff --git a/ompi/contrib/vt/vt/vtlib/vt_env.h b/ompi/contrib/vt/vt/vtlib/vt_env.h index a62f798dd4..1d8af5b747 100644 --- a/ompi/contrib/vt/vt/vtlib/vt_env.h +++ b/ompi/contrib/vt/vt/vtlib/vt_env.h @@ -57,6 +57,7 @@ EXTERN int vt_env_mpicheck_errexit(void); EXTERN char* vt_env_rusage(void); EXTERN int vt_env_rusage_intv(void); EXTERN char* vt_env_metrics(void); +EXTERN char* vt_env_metrics_sep(void); EXTERN char* vt_env_metrics_spec(void); EXTERN int vt_env_sync_flush(void); EXTERN int vt_env_sync_flush_level(void); diff --git a/ompi/contrib/vt/vt/vtlib/vt_fork.c b/ompi/contrib/vt/vt/vtlib/vt_fork.c index d25d043251..d2d59fa1c7 100644 --- a/ompi/contrib/vt/vt/vtlib/vt_fork.c +++ b/ompi/contrib/vt/vt/vtlib/vt_fork.c @@ -77,8 +77,9 @@ static int get_new_trcid() } /* read current trace id */ - if ( read(fd, tmp, 10) == -1 ) + if ( read(fd, tmp, 9) == -1 ) vt_error_msg("Cannot read file %s: %s", trcid_filename, strerror(errno)); + tmp[9] = '\0'; if ( tmp[0] == '\0' ) new_trcid = 1; /* set trace id to 1, if file is empty */ @@ -116,8 +117,8 @@ void vt_fork_init() /* create temp. id filename, if necessary */ if ( trcid_filename[0] == '\0' ) { - sprintf(trcid_filename, "%s/%s.%lx.%u.trcid.tmp", - vt_env_ldir(), vt_env_fprefix(), vt_pform_node_id(), getpid()); + snprintf(trcid_filename, sizeof(trcid_filename)-1, "%s/%s.%lx.%u.trcid.tmp", + vt_env_ldir(), vt_env_fprefix(), vt_pform_node_id(), getpid()); } } diff --git a/ompi/contrib/vt/vt/vtlib/vt_libwrap.c b/ompi/contrib/vt/vt/vtlib/vt_libwrap.c index 7f56de2c49..8c60c46f9b 100644 --- a/ompi/contrib/vt/vt/vtlib/vt_libwrap.c +++ b/ompi/contrib/vt/vt/vtlib/vt_libwrap.c @@ -284,8 +284,10 @@ void VTLibwrap_func_init(const VTLibwrap* lw, const char* func, for( i = 0; i < lw->handlen; i++ ) { - if( i > 0 ) strcat(dlsym_errors_merged, "\n"); - strcat(dlsym_errors_merged, dlsym_errors[i]); + if( i > 0 ) + strncat(dlsym_errors_merged, "\n", 255 - strlen(dlsym_errors_merged)); + strncat(dlsym_errors_merged, dlsym_errors[i], + 255 - strlen(dlsym_errors_merged)); } vt_error_msg("dlsym(\"%s\") failed:\n%s", func, dlsym_errors_merged); } diff --git a/ompi/contrib/vt/vt/vtlib/vt_metric_cpc.c b/ompi/contrib/vt/vt/vtlib/vt_metric_cpc.c index aed954ab78..d2c341f2da 100644 --- a/ompi/contrib/vt/vt/vtlib/vt_metric_cpc.c +++ b/ompi/contrib/vt/vt/vtlib/vt_metric_cpc.c @@ -66,6 +66,7 @@ static void metricv_add(char* name) int vt_metric_open() { char* env; + char* env_sep; char* var; char* token; @@ -73,6 +74,8 @@ int vt_metric_open() if ( ( env = vt_env_metrics() ) == NULL ) return 0; + env_sep = vt_env_metrics_sep(); + var = strdup(env); vt_cntl_msg(2, "VT_METRICS=%s", var); @@ -81,11 +84,11 @@ int vt_metric_open() vt_error_msg("cpc_open: %s", strerror(errno)); /* read metrics from specification string */ - token = strtok(var, ":"); + token = strtok(var, env_sep); while ( token && (nmetrics < VT_METRIC_MAXNUM) ) { metricv_add( token ); - token = strtok(NULL, ":"); + token = strtok(NULL, env_sep); } free(var); diff --git a/ompi/contrib/vt/vt/vtlib/vt_metric_necsx.c b/ompi/contrib/vt/vt/vtlib/vt_metric_necsx.c index 3fd5c1fec9..e484981544 100644 --- a/ompi/contrib/vt/vt/vtlib/vt_metric_necsx.c +++ b/ompi/contrib/vt/vt/vtlib/vt_metric_necsx.c @@ -355,6 +355,7 @@ int vt_metric_open() { int i; char* env; + char* env_sep; char* var; char* token; const int max_metrics = sizeof (vt_sx_metrics) / sizeof (vt_sx_metrics[0]); @@ -364,6 +365,8 @@ int vt_metric_open() if ( env == NULL ) return nmetrics; + env_sep = vt_env_metrics_sep(); + var = strdup(env); vt_cntl_msg(2, "VT_METRICS=%s", var); @@ -372,7 +375,7 @@ int vt_metric_open() while ( *token ) { *token = tolower(*token); token++; } /* read metrics from specification string */ - token = strtok(var, ":"); + token = strtok(var, env_sep); if (token && (0 == strcmp (token, "all"))) { vt_cntl_msg(2, "token:%s Adding all metrics", token); for (i = 0; i < max_metrics; i++) { @@ -393,7 +396,7 @@ int vt_metric_open() if (i == max_metrics) { vt_error_msg ("Metric <%s> not supported", token); } - token = strtok(NULL, ":"); + token = strtok(NULL, env_sep); } } diff --git a/ompi/contrib/vt/vt/vtlib/vt_metric_papi.c b/ompi/contrib/vt/vt/vtlib/vt_metric_papi.c index 84cc06e24c..d48cce76f6 100644 --- a/ompi/contrib/vt/vt/vtlib/vt_metric_papi.c +++ b/ompi/contrib/vt/vt/vtlib/vt_metric_papi.c @@ -106,31 +106,27 @@ static metricmap_t* metricmap_append(metricmap_t* map, static void metricmap_dump(metricmap_t* map) { - unsigned j=0; + unsigned i = 0; - if (map == NULL) { - printf("Can't dump empty metricmap!\n"); + if (map == NULL || vt_env_verbose() < 3) return; - } - printf("Metricmap dump (head=0x%p):\n", (void*)map); + vt_cntl_msg(3, "Metricmap dump (head=0x%p):", (void*)map); while (map != NULL) { - printf("m[%3u] 0x%X %s = %s\n", j, map->type, - map->event_name, map->alias_name); - j++; + vt_cntl_msg(3, "m[%3u] 0x%X %s = %s", i, map->type, + map->event_name, map->alias_name); + i++; map = map->next; } - printf("Metricmap dumped %u maps\n", j); + vt_cntl_msg(3, "Metricmap dumped %u maps", i); } static void metricmap_free(metricmap_t* map) { - if (map == NULL) { - /*printf("Can't free empty metricmap!\n");*/ + if (map == NULL) return; - } - /*printf("Metricmap free (head=0x%p):\n", map);*/ + vt_cntl_msg(3, "Metricmap free (head=0x%p):", map); while (map != NULL) { metricmap_t* next = map->next; if (map->event_name != NULL) free(map->event_name); @@ -353,6 +349,7 @@ int vt_metric_open() { int retval; char* env; + char* env_sep; char* var; char* token; PAPI_event_info_t info; @@ -368,9 +365,11 @@ int vt_metric_open() #endif } + env_sep = vt_env_metrics_sep(); + mapv = vt_metricmap_init( (metmap_t)(METMAP_MEASURE|METMAP_AGGROUP)); - /*metricmap_dump(mapv);*/ + metricmap_dump(mapv); /* initialize PAPI */ retval = PAPI_library_init(PAPI_VER_CURRENT); @@ -385,7 +384,7 @@ int vt_metric_open() vt_cntl_msg(2, "VT_METRICS=%s", var); /* read metrics from specification string */ - token = strtok(var, ":"); + token = strtok(var, env_sep); while ( token && (nmetrics < VT_METRIC_MAXNUM) ) { /* search metricmap for a suitable definition */ metricmap_t* map = mapv; @@ -447,7 +446,7 @@ int vt_metric_open() metricv_add(component, code); } - token = strtok(NULL, ":"); + token = strtok(NULL, env_sep); } /*printf("nmetrics=%d\n", nmetrics);*/ @@ -617,7 +616,9 @@ uint32_t vt_metric_props(int i) return OTF_COUNTER_TYPE_ACC; } -uint64_t vt_metric_clckrt() +#if TIMER == TIMER_PAPI_REAL_CYC + +uint64_t vt_metric_clckrt(void) { const PAPI_hw_info_t* hwinfo = NULL; double hertz; @@ -639,12 +640,16 @@ uint64_t vt_metric_clckrt() return (uint64_t)hertz; } -uint64_t vt_metric_real_cyc() +uint64_t vt_metric_real_cyc(void) { return (uint64_t)PAPI_get_real_cyc(); } -uint64_t vt_metric_real_usec() +#elif TIMER == TIMER_PAPI_REAL_USEC + +uint64_t vt_metric_real_usec(void) { return (uint64_t)PAPI_get_real_usec(); } + +#endif /* TIMER */ diff --git a/ompi/contrib/vt/vt/vtlib/vt_mpiwrap.c b/ompi/contrib/vt/vt/vtlib/vt_mpiwrap.c index f5ac43f49b..405cdb76d7 100644 --- a/ompi/contrib/vt/vt/vtlib/vt_mpiwrap.c +++ b/ompi/contrib/vt/vt/vtlib/vt_mpiwrap.c @@ -4094,12 +4094,12 @@ VT_MPI_INT MPI_Exscan( void* sendbuf, vt_mpifile_data *fdata = vt_mpifile_get_data(fh); \ if (result == MPI_SUCCESS) \ { \ - VT_MPI_INT sz, count; \ + VT_MPI_INT sz, cnt; \ PMPI_Type_size(fdata->datatype, &sz); \ - PMPI_Get_count(status, fdata->datatype, &count); \ - if (count == MPI_UNDEFINED) \ - count = 0; \ - vt_ioend(&time, fdata->fid, fdata->split_collective_id, IOOP, (uint64_t)count * (uint64_t)sz); \ + PMPI_Get_count(status, fdata->datatype, &cnt); \ + if (cnt == MPI_UNDEFINED) \ + cnt = 0; \ + vt_ioend(&time, fdata->fid, fdata->split_collective_id, IOOP, (uint64_t)cnt * (uint64_t)sz); \ } \ else \ { \ @@ -4120,12 +4120,12 @@ VT_MPI_INT MPI_Exscan( void* sendbuf, uint32_t fid = vt_mpifile_get_id(fh); \ if (result == MPI_SUCCESS) \ { \ - VT_MPI_INT sz, count; \ + VT_MPI_INT sz, cnt; \ PMPI_Type_size(datatype, &sz); \ - PMPI_Get_count(status, datatype, &count); \ - if (count == MPI_UNDEFINED) \ - count = 0; \ - vt_ioend(&time, fid, handleid, IOOP, (uint64_t)count * (uint64_t)sz); \ + PMPI_Get_count(status, datatype, &cnt); \ + if (cnt == MPI_UNDEFINED) \ + cnt = 0; \ + vt_ioend(&time, fid, handleid, IOOP, (uint64_t)cnt * (uint64_t)sz); \ } \ else \ { \ diff --git a/ompi/contrib/vt/vt/vtlib/vt_otf_gen.c b/ompi/contrib/vt/vt/vtlib/vt_otf_gen.c index 1a44fb7e08..d15e839dc2 100644 --- a/ompi/contrib/vt/vt/vtlib/vt_otf_gen.c +++ b/ompi/contrib/vt/vt/vtlib/vt_otf_gen.c @@ -1242,6 +1242,7 @@ void VTGen_delete(VTGen* gen) { char* tmp_namev[5]; char* global_name; + uint32_t global_name_len; char* suffix; char* gdir = vt_env_gdir(); @@ -1284,18 +1285,19 @@ void VTGen_delete(VTGen* gen) suffix = strchr(tmp_namev[i]+strlen(gen->fileprefix)+1, '.'); /* build global file name */ - global_name = (char*)calloc(strlen(gdir) + - strlen(fprefix) + 32, sizeof(char)); + global_name_len = strlen(gdir) + strlen(fprefix) + 32; + global_name = (char*)calloc(global_name_len+1, sizeof(char)); + if (vt_my_funique > 0) { - sprintf(global_name, "%s/%s_%u.%x%s", - gdir, fprefix, vt_my_funique, 65536*gen->tid+(vt_my_trace+1), - suffix); + snprintf(global_name, global_name_len, "%s/%s_%u.%x%s", + gdir, fprefix, vt_my_funique, 65536*gen->tid+(vt_my_trace+1), + suffix); } else { - sprintf(global_name, "%s/%s.%x%s", - gdir, fprefix, 65536*gen->tid+(vt_my_trace+1), suffix); + snprintf(global_name, global_name_len, "%s/%s.%x%s", + gdir, fprefix, 65536*gen->tid+(vt_my_trace+1), suffix); } /* rename file, if possible */ diff --git a/ompi/contrib/vt/vt/vtlib/vt_otf_trc.c b/ompi/contrib/vt/vt/vtlib/vt_otf_trc.c index e1cd9cbf50..472713c6b6 100644 --- a/ompi/contrib/vt/vt/vtlib/vt_otf_trc.c +++ b/ompi/contrib/vt/vt/vtlib/vt_otf_trc.c @@ -1283,7 +1283,7 @@ static uint32_t vt_get_unique_file_id() VT_SUSPEND_IO_TRACING(); /* create filename for unique id file */ - sprintf(lock_filename, "%s/%s.lock", vt_env_gdir(), vt_env_fprefix()); + snprintf(lock_filename, sizeof(lock_filename)-1, "%s/%s.lock", vt_env_gdir(), vt_env_fprefix()); /* open/create unique id file */ if( (fd = open(lock_filename, (O_RDWR | O_CREAT), @@ -1299,9 +1299,12 @@ static uint32_t vt_get_unique_file_id() } /* read current unique id */ - if( read(fd, tmp, 16) == -1 ) + if( read(fd, tmp, 15) == -1 ) vt_error_msg("Cannot read file %s: %s", lock_filename, strerror(errno)); + /* terminate buffer to avoid issues in upcoming functions */ + tmp[15] = '\0'; + if( tmp[0] == '\0' ) new_fuid = 0; /* set unique id to 0, if file is empty */ else @@ -1343,16 +1346,19 @@ static void vt_write_def_header() /* VT_MODE */ tmp_int32 = vt_env_mode(); - strcpy(tmp_char, ""); + tmp_char[0] = '\0'; if( (tmp_int32 & VT_MODE_TRACE) != 0 ) - strcpy(tmp_char, "TRACE"); + { + strncpy(tmp_char, "TRACE", sizeof(tmp_char)-1); + tmp_char[sizeof(tmp_char)-1] = '\0'; + } if( (tmp_int32 & VT_MODE_STAT) != 0 ) { if( strlen(tmp_char) > 0 ) - strcat(tmp_char, ":"); + strncat(tmp_char, ":", sizeof(tmp_char)-1-strlen(tmp_char)); - strcat(tmp_char, "STAT"); + strncat(tmp_char, "STAT", sizeof(tmp_char)-1-strlen(tmp_char)); } vt_def_comment("__VT_COMMENT__ VT_MODE: %s", tmp_char); @@ -1363,16 +1369,16 @@ static void vt_write_def_header() if( tmp_uint64 >= (1024*1024*1024) ) { tmp_uint64 /= (1024*1024*1024); - sprintf(tmp_char, "%"U64STR"G", tmp_uint64); + snprintf(tmp_char, sizeof(tmp_char)-1, "%"U64STR"G", tmp_uint64); } else if( tmp_uint64 >= (1024*1024) ) { tmp_uint64 /= (1024*1024); - sprintf(tmp_char, "%"U64STR"M", tmp_uint64); + snprintf(tmp_char, sizeof(tmp_char)-1, "%"U64STR"M", tmp_uint64); } else { - sprintf(tmp_char, "%"U64STR, tmp_uint64); + snprintf(tmp_char, sizeof(tmp_char)-1, "%"U64STR, tmp_uint64); } vt_def_comment("__VT_COMMENT__ VT_BUFFER_SIZE: %s", tmp_char);