diff --git a/ompi/contrib/vt/vt/ChangeLog b/ompi/contrib/vt/vt/ChangeLog index 4d90b789f4..b5a727d297 100644 --- a/ompi/contrib/vt/vt/ChangeLog +++ b/ompi/contrib/vt/vt/ChangeLog @@ -7,6 +7,8 @@ - fixed a potential minor bug in CUPTI activity stream handling - workaround for CUDA 5.0 bug: do not call cuDeviceSynchronize(), if stream reuse is enabled and a CUDA stream is about to be destroyed + - fixed segmentation fault when writing intermediate statistics + (VT_STAT_INTV != 0) - vtdyn: do not instrument regions where using a trap is required - plugin counters: Merge a set of post-mortem counters and write them under a single async key. This speeds up the unification. diff --git a/ompi/contrib/vt/vt/configure.ac b/ompi/contrib/vt/vt/configure.ac index 11fd81b8c5..79c4945aa1 100644 --- a/ompi/contrib/vt/vt/configure.ac +++ b/ompi/contrib/vt/vt/configure.ac @@ -63,12 +63,7 @@ AS_IF([test "$?" = "0"], [AC_MSG_ERROR([VampirTrace does not allow whitespace in the source directory path!])]) AC_SUBST(top_vt_srcdir) AS_IF([test "$top_vt_builddir" != "$top_vt_srcdir"], -[ - AC_MSG_NOTICE([detected VPATH build]) - # If VPATH build, including of the source directory needed - # to find '/config_bottom.h' and '/util/util.h' - CPPFLAGS='-I$(top_srcdir)'" $CPPFLAGS" -]) +[AC_MSG_NOTICE([detected VPATH build])]) # Check for file system case sensitivity ACVT_CSFS @@ -464,6 +459,14 @@ AS_IF([test x"$enable_config_titles" = "xyes" -a x"$check_vtrun" = "xno"], [AC_MSG_NOTICE([disabled via command line switch])]) AM_CONDITIONAL(AMBUILDVTRUN, test x"$build_vtrun" = "xyes") +# If it's a VPATH build, add the top-level source directory as an include path +# to find '/config_bottom.h' and '/util/util.h' +AS_IF([test "$top_vt_builddir" != "$top_vt_srcdir"], +[ + CPPFLAGS='-I$(top_srcdir)'" $CPPFLAGS" + CPPFLAGS_FOR_BUILD='-I$(top_srcdir)'" $CPPFLAGS_FOR_BUILD" +]) + # Output files AC_CONFIG_FILES([Makefile extlib/Makefile diff --git a/ompi/contrib/vt/vt/rfg/rfg_filter.c b/ompi/contrib/vt/vt/rfg/rfg_filter.c index df25b37a57..0da3ac5a9f 100644 --- a/ompi/contrib/vt/vt/rfg/rfg_filter.c +++ b/ompi/contrib/vt/vt/rfg/rfg_filter.c @@ -8,10 +8,13 @@ #include #include +#include #include #include #include #include +#include +#include #define MAX_LINE_LEN 0x20000 /* max. file line length */ @@ -96,50 +99,49 @@ struct RFG_Filter_struct static int get_file_content( RFG_Filter* filter ) { - FILE* f; - size_t i; - uint8_t err = 0; - const size_t bsize = 1024; + int ret = 1; + + int fd; if( !filter || !filter->file_name || *(filter->file_name) == '\0' ) return 0; - /* open filter definition file */ - - f = fopen( filter->file_name, "r" ); - if( !f ) + /* open the filter file */ + if( ( fd = open( filter->file_name, O_RDONLY ) ) == -1 ) return 0; - filter->file_content = (char*)malloc( bsize * sizeof( char ) ); - if( !filter->file_content ) err = 1; - else filter->file_content_size = bsize; - - i = 0; - while( !err && ( ( filter->file_content[i++] = fgetc( f ) ) != (char)EOF ) ) + do { - /* enlarge buffer, if necessary */ + struct stat file_stat; - if( i == filter->file_content_size ) + /* get the file size */ + if( fstat(fd, &file_stat) == -1 || file_stat.st_size == 0 ) { - filter->file_content = - (char*)realloc( filter->file_content, - ( filter->file_content_size + bsize ) * sizeof( char ) ); - if( !filter->file_content ) - { - err = 1; - break; - } - filter->file_content_size += bsize; + ret = 0; + break; } - } - /* append '\0' to buffer */ - if( !err) filter->file_content[i-1] = '\0'; + /* allocate the buffer for storing the filter file content */ + filter->file_content = (char*)malloc( file_stat.st_size * sizeof( char ) ); + if( !filter->file_content ) + { + ret = 0; + break; + } - /* close filter definition file */ - fclose( f ); + /* read the filter file */ + if( read(fd, filter->file_content, file_stat.st_size ) == -1 ) + { + ret = 0; + break; + } - return (int)!err; + } while( 0 ); + + /* close the filter file */ + close( fd ); + + return ret; } static int get_file_content_line( RFG_Filter* filter, char* buf, @@ -993,7 +995,7 @@ int RFG_Filter_getCallPathRules( RFG_Filter* filter, uint32_t hash, { RFG_FilterCallPathRulesHN* cpath_rules_hn; - if( !filter && !r_callLimit ) + if( !filter || !r_callLimit ) return 0; if( size == 0 || size > RFG_FILTER_MAX_CPATH_SIZE ) diff --git a/ompi/contrib/vt/vt/tools/opari/tool/ompragma_f.cc b/ompi/contrib/vt/vt/tools/opari/tool/ompragma_f.cc index 29374c2cb0..4d09f0eb47 100644 --- a/ompi/contrib/vt/vt/tools/opari/tool/ompragma_f.cc +++ b/ompi/contrib/vt/vt/tools/opari/tool/ompragma_f.cc @@ -89,7 +89,7 @@ namespace { if ( line >= outer->lines.size() ) return; pos = outer->lines[line].find(sentinel) + slen; pos = outer->lines[line].find_first_not_of(" \t", pos); - if ( outer->lines[line][pos] == '&' ) ++pos; + if ( pos != string::npos && outer->lines[line][pos] == '&' ) ++pos; optr = &(outer->lines[line][pos]); iptr = &(inner->lines[line][pos]); } diff --git a/ompi/contrib/vt/vt/tools/vtunify/hooks/vt_unify_hooks_margins.cc b/ompi/contrib/vt/vt/tools/vtunify/hooks/vt_unify_hooks_margins.cc index ccb43d8557..771a75789b 100644 --- a/ompi/contrib/vt/vt/tools/vtunify/hooks/vt_unify_hooks_margins.cc +++ b/ompi/contrib/vt/vt/tools/vtunify/hooks/vt_unify_hooks_margins.cc @@ -18,7 +18,7 @@ // HooksProcessMarginsC::HooksProcessMarginsC() : HooksBaseC(), - m_maxThreads( 1 ) + m_maxThreads( 1 ), m_threadContexts( 0 ) { // Empty } diff --git a/ompi/contrib/vt/vt/tools/vtunify/vt_unify.h b/ompi/contrib/vt/vt/tools/vtunify/vt_unify.h index 4789d51ec0..e3113acae2 100644 --- a/ompi/contrib/vt/vt/tools/vtunify/vt_unify.h +++ b/ompi/contrib/vt/vt/tools/vtunify/vt_unify.h @@ -13,7 +13,7 @@ #ifndef _VT_UNIFY_H_ #define _VT_UNIFY_H_ -#include "config.h" +#include "vt_unify_config.h" #ifdef VT_MPI # include "vt_unify_mpi.h" diff --git a/ompi/contrib/vt/vt/tools/vtwrapper/vt_wrapper.cc b/ompi/contrib/vt/vt/tools/vtwrapper/vt_wrapper.cc index 1cb1104850..f4b039b48a 100644 --- a/ompi/contrib/vt/vt/tools/vtwrapper/vt_wrapper.cc +++ b/ompi/contrib/vt/vt/tools/vtwrapper/vt_wrapper.cc @@ -628,6 +628,7 @@ readDataFile() break; } case 31: // partype_default + default: { if( value.compare( "seq" ) == 0 ) { @@ -655,14 +656,6 @@ readDataFile() } break; } - default: - { - std::cerr << ExeName << ": " - << data_file << ":" << line_no << ": " - << "could not be parsed" << std::endl; - error = true; - break; - } } } diff --git a/ompi/contrib/vt/vt/vtlib/vt_otf_gen.c b/ompi/contrib/vt/vt/vtlib/vt_otf_gen.c index 7919313003..23017bd1c2 100644 --- a/ompi/contrib/vt/vt/vtlib/vt_otf_gen.c +++ b/ompi/contrib/vt/vt/vtlib/vt_otf_gen.c @@ -242,7 +242,7 @@ VTGen* VTGen_open(const char* tname, const char* tnamesuffix, void VTGen_guarantee(VTGen* gen, uint64_t* time, size_t size) { - if (time) + if (!time) { VTGEN_ALLOC(gen, VTGEN_ALIGN_LENGTH(size)); } diff --git a/ompi/contrib/vt/vt/vtlib/vt_plugin_cntr.c b/ompi/contrib/vt/vt/vtlib/vt_plugin_cntr.c index 2958bfc1e1..c6f089efb5 100644 --- a/ompi/contrib/vt/vt/vtlib/vt_plugin_cntr.c +++ b/ompi/contrib/vt/vt/vtlib/vt_plugin_cntr.c @@ -98,7 +98,7 @@ struct vt_plugin_cntr_defines { /* called when activating events */ static void maybe_register_new_thread(VTThrd * thrd, uint32_t tid); /* called when activating events */ -static void add_events(struct vt_plugin current_plugin, VTThrd * thrd); +static void add_events(const struct vt_plugin * current_plugin, VTThrd * thrd); static uint32_t post_mortem_asynch_key(void); @@ -571,7 +571,7 @@ void vt_plugin_cntr_thread_init(VTThrd * thrd, uint32_t tid) { maybe_register_new_thread(thrd, tid); /* now, that the thread is registered, register the counters */ - add_events(vt_plugin_handles[i][j], thrd); + add_events(&(vt_plugin_handles[i][j]), thrd); } } @@ -742,64 +742,64 @@ static void maybe_register_new_thread(VTThrd * thrd, uint32_t tid) { } } -static void add_events(struct vt_plugin current_plugin, VTThrd * thrd) { +static void add_events(const struct vt_plugin * current_plugin, VTThrd * thrd) { int j; struct vt_plugin_single_counter * current; uint32_t * current_size; struct vt_plugin_cntr_defines * plugin_cntr_defines = (struct vt_plugin_cntr_defines *) thrd->plugin_cntr_defines; /* get the current counters for this thread and synch type*/ - current = plugin_cntr_defines->counters[current_plugin.info.synch]; + current = plugin_cntr_defines->counters[current_plugin->info.synch]; if (current == NULL) { - plugin_cntr_defines->counters[current_plugin.info.synch] = + plugin_cntr_defines->counters[current_plugin->info.synch] = calloc(VT_PLUGIN_COUNTERS_PER_THREAD, sizeof(struct vt_plugin_single_counter)); - current = plugin_cntr_defines->counters[current_plugin.info.synch]; + current = plugin_cntr_defines->counters[current_plugin->info.synch]; } /* get the number of counters for this thread and synch type*/ current_size - = &(plugin_cntr_defines->size_of_counters[current_plugin.info.synch]); + = &(plugin_cntr_defines->size_of_counters[current_plugin->info.synch]); vt_cntl_msg(3, "Process %i Thread %s-%s adds own plugin metrics", vt_my_ptrace, thrd->name, thrd->name_suffix); - for (j = 0; j < current_plugin.num_selected_events; j++) { + for (j = 0; j < current_plugin->num_selected_events; j++) { if (*current_size >= VT_PLUGIN_COUNTERS_PER_THREAD) { vt_error_msg("You're about to add more then %i plugin counters," "which is impossible\n", VT_PLUGIN_COUNTERS_PER_THREAD); continue; } - if (current_plugin.info.synch == VT_PLUGIN_CNTR_ASYNCH_CALLBACK) { + if (current_plugin->info.synch == VT_PLUGIN_CNTR_ASYNCH_CALLBACK) { if (*current_size == 0) { } } /* add counter */ - current[*current_size].from_plugin_id = current_plugin.info.add_counter( - current_plugin.selected_events[j]); + current[*current_size].from_plugin_id = current_plugin->info.add_counter( + current_plugin->selected_events[j]); /* add successfully? */ if (current[*current_size].from_plugin_id < 0) { vt_error_msg( "Error while adding plugin counter \"%s\" to thread \"%s%s\"\n", - current_plugin.selected_events[j], thrd->name, thrd->name_suffix); + current_plugin->selected_events[j], thrd->name, thrd->name_suffix); continue; } /* get the vampir trace id for the counter */ - current[*current_size].vt_counter_id = current_plugin.vt_counter_ids[j]; - current[*current_size].vt_asynch_key = current_plugin.vt_asynch_keys[j]; - current[*current_size].enable_counter = current_plugin.info.enable_counter; + current[*current_size].vt_counter_id = current_plugin->vt_counter_ids[j]; + current[*current_size].vt_asynch_key = current_plugin->vt_asynch_keys[j]; + current[*current_size].enable_counter = current_plugin->info.enable_counter; current[*current_size].disable_counter - = current_plugin.info.disable_counter; + = current_plugin->info.disable_counter; /* per type stuff */ - if (current_plugin.info.synch == VT_PLUGIN_CNTR_SYNCH) + if (current_plugin->info.synch == VT_PLUGIN_CNTR_SYNCH) /* synch counters have to implement getValue */ - current[*current_size].getValue = current_plugin.info.get_current_value; - if ((current_plugin.info.synch == VT_PLUGIN_CNTR_ASYNCH_EVENT) - || (current_plugin.info.synch == VT_PLUGIN_CNTR_ASYNCH_POST_MORTEM)) { + current[*current_size].getValue = current_plugin->info.get_current_value; + if ((current_plugin->info.synch == VT_PLUGIN_CNTR_ASYNCH_EVENT) + || (current_plugin->info.synch == VT_PLUGIN_CNTR_ASYNCH_POST_MORTEM)) { /* these have to implement getAllValues */ - current[*current_size].getAllValues = current_plugin.info.get_all_values; + current[*current_size].getAllValues = current_plugin->info.get_all_values; } - if (current_plugin.info.synch == VT_PLUGIN_CNTR_ASYNCH_CALLBACK) { + if (current_plugin->info.synch == VT_PLUGIN_CNTR_ASYNCH_CALLBACK) { /* callback should set the callback function */ /* allocate resources */ #if (defined(VT_MT) || defined (VT_HYB) || defined(VT_JAVA)) @@ -807,11 +807,11 @@ static void add_events(struct vt_plugin current_plugin, VTThrd * thrd) { (VTThrdMutex **) &(current[*current_size].callback_mutex) ); /* try to set callback function */ - if (current_plugin.info.set_callback_function(¤t[*current_size], + if (current_plugin->info.set_callback_function(¤t[*current_size], current[*current_size].from_plugin_id, callback_function)) { vt_error_msg("Asynchronous callback plugin %s failed " - "to set callback function for counter %s.\n", current_plugin.name, - current_plugin.selected_events[j]); + "to set callback function for counter %s.\n", current_plugin->name, + current_plugin->selected_events[j]); } current[*current_size].callback_values = malloc( @@ -828,18 +828,18 @@ static void add_events(struct vt_plugin current_plugin, VTThrd * thrd) { } current[*current_size].tid = VT_MY_THREAD;/* - switch (current_plugin.info.run_per) { + switch (current_plugin->info.run_per) { case VT_PLUGIN_CNTR_PER_PROCESS: if (thread_group != INVALID_GROUP_NUMBER) current[*current_size].tid = thread_group; break; case VT_PLUGIN_CNTR_PER_HOST: - if (current_plugin.info.run_per == VT_PLUGIN_CNTR_PER_HOST) + if (current_plugin->info.run_per == VT_PLUGIN_CNTR_PER_HOST) if (host_group != INVALID_GROUP_NUMBER) current[*current_size].tid = host_group; break; case VT_PLUGIN_CNTR_ONCE: - if (current_plugin.info.run_per == VT_PLUGIN_CNTR_ONCE) + if (current_plugin->info.run_per == VT_PLUGIN_CNTR_ONCE) if (all_group != INVALID_GROUP_NUMBER) current[*current_size].tid = all_group; break; @@ -1012,9 +1012,10 @@ void vt_plugin_cntr_write_callback_data(uint64_t *time, uint32_t tid) { (struct vt_plugin_cntr_defines *) VTThrdv[tid]->plugin_cntr_defines; if (plugin_cntr_defines == NULL) - if (plugin_cntr_defines->size_of_counters[VT_PLUGIN_CNTR_ASYNCH_CALLBACK] - == 0) - return; + return; + if (plugin_cntr_defines->size_of_counters[VT_PLUGIN_CNTR_ASYNCH_CALLBACK] + == 0) + return; for (i = 0; i < plugin_cntr_defines->size_of_counters[VT_PLUGIN_CNTR_ASYNCH_CALLBACK]; i++) { @@ -1124,8 +1125,11 @@ void vt_plugin_cntr_write_post_mortem(VTThrd * thrd) { /* get data */ number_of_values_by_counter[counter_index] = current_counter.getAllValues( current_counter.from_plugin_id, &(time_values_by_counter[counter_index])); - if (time_values_by_counter[counter_index] == NULL) + if (time_values_by_counter[counter_index] == NULL) { + free(time_values_by_counter); + free(number_of_values_by_counter); return; + } } /* initialized with 0! */ counter_current_indices = calloc(number_of_counters, sizeof(*counter_current_indices)); diff --git a/ompi/contrib/vt/vt/vtlib/vt_trc.c b/ompi/contrib/vt/vt/vtlib/vt_trc.c index fb2363c3fe..3c1593918f 100644 --- a/ompi/contrib/vt/vt/vtlib/vt_trc.c +++ b/ompi/contrib/vt/vt/vtlib/vt_trc.c @@ -3490,10 +3490,7 @@ void vt_enter_stat(uint32_t tid, uint64_t* time) if (VTTHRD_TRACE_STATUS(VTThrdv[tid]) != VT_TRACE_ON) return; - VTGen_write_ENTER(VTTHRD_GEN(VTThrdv[tid]), time, - vt_trc_regid[VT__TRC_STAT], 0); - - update_counter(tid, time); + VTGen_write_ENTER_STAT(VTTHRD_GEN(VTThrdv[tid]), time); } void vt_exit_stat(uint32_t tid, uint64_t* time) @@ -3502,10 +3499,7 @@ void vt_exit_stat(uint32_t tid, uint64_t* time) if (VTTHRD_TRACE_STATUS(VTThrdv[tid]) != VT_TRACE_ON) return; - update_counter(tid, time); - if (VTTHRD_TRACE_STATUS(VTThrdv[tid]) != VT_TRACE_ON) return; - - VTGen_write_LEAVE(VTTHRD_GEN(VTThrdv[tid]), time, 0, 0); + VTGen_write_LEAVE_STAT(VTTHRD_GEN(VTThrdv[tid]), time); } void vt_enter_flush(uint32_t tid, uint64_t* time)