Index: openmp/trunk/runtime/src/kmp.h =================================================================== --- openmp/trunk/runtime/src/kmp.h +++ openmp/trunk/runtime/src/kmp.h @@ -3017,7 +3017,7 @@ extern kmp_adaptive_backoff_params_t __kmp_adaptive_backoff_params; #if KMP_DEBUG_ADAPTIVE_LOCKS -extern char *__kmp_speculative_statsfile; +extern const char *__kmp_speculative_statsfile; #endif #endif // KMP_USE_ADAPTIVE_LOCKS Index: openmp/trunk/runtime/src/kmp_global.cpp =================================================================== --- openmp/trunk/runtime/src/kmp_global.cpp +++ openmp/trunk/runtime/src/kmp_global.cpp @@ -204,7 +204,7 @@ 1, 1024}; // TODO: tune it! #if KMP_DEBUG_ADAPTIVE_LOCKS -char *__kmp_speculative_statsfile = "-"; +const char *__kmp_speculative_statsfile = "-"; #endif #endif // KMP_USE_ADAPTIVE_LOCKS Index: openmp/trunk/runtime/src/kmp_lock.cpp =================================================================== --- openmp/trunk/runtime/src/kmp_lock.cpp +++ openmp/trunk/runtime/src/kmp_lock.cpp @@ -20,6 +20,7 @@ #include "kmp_itt.h" #include "kmp_lock.h" #include "kmp_wait_release.h" +#include "kmp_wrapper_getpid.h" #include "tsan_annotations.h" @@ -1870,13 +1871,15 @@ static kmp_adaptive_lock_info_t liveLocks; // A lock so we can safely update the list of locks. -static kmp_bootstrap_lock_t chain_lock; +static kmp_bootstrap_lock_t chain_lock = + KMP_BOOTSTRAP_LOCK_INITIALIZER(chain_lock); // Initialize the list of stats. void __kmp_init_speculative_stats() { kmp_adaptive_lock_info_t *lck = &liveLocks; - memset((void *)&(lck->stats), 0, sizeof(lck->stats)); + memset(CCAST(kmp_adaptive_lock_statistics_t *, &(lck->stats)), 0, + sizeof(lck->stats)); lck->stats.next = lck; lck->stats.prev = lck; @@ -1914,7 +1917,8 @@ } static void __kmp_zero_speculative_stats(kmp_adaptive_lock_info_t *lck) { - memset((void *)&lck->stats, 0, sizeof(lck->stats)); + memset(CCAST(kmp_adaptive_lock_statistics_t *, &lck->stats), 0, + sizeof(lck->stats)); __kmp_remember_lock(lck); } @@ -1931,8 +1935,6 @@ } static void __kmp_accumulate_speculative_stats(kmp_adaptive_lock_info_t *lck) { - kmp_adaptive_lock_statistics_t *t = &destroyedStats; - __kmp_acquire_bootstrap_lock(&chain_lock); __kmp_add_stats(&destroyedStats, lck); @@ -1960,11 +1962,6 @@ } void __kmp_print_speculative_stats() { - if (__kmp_user_lock_kind != lk_adaptive) - return; - - FILE *statsFile = __kmp_open_stats_file(); - kmp_adaptive_lock_statistics_t total = destroyedStats; kmp_adaptive_lock_info_t *lck; @@ -1977,6 +1974,10 @@ kmp_uint32 totalSpeculations = t->successfulSpeculations + t->hardFailedSpeculations + t->softFailedSpeculations; + if (totalSections <= 0) + return; + + FILE *statsFile = __kmp_open_stats_file(); fprintf(statsFile, "Speculative lock statistics (all approximate!)\n"); fprintf(statsFile, " Lock parameters: \n" Index: openmp/trunk/runtime/src/kmp_settings.cpp =================================================================== --- openmp/trunk/runtime/src/kmp_settings.cpp +++ openmp/trunk/runtime/src/kmp_settings.cpp @@ -385,7 +385,7 @@ #if KMP_DEBUG_ADAPTIVE_LOCKS static void __kmp_stg_parse_file(char const *name, char const *value, - char *suffix, char **out) { + const char *suffix, char **out) { char buffer[256]; char *t; int hasSuffix; @@ -4236,7 +4236,7 @@ static void __kmp_stg_parse_speculative_statsfile(char const *name, char const *value, void *data) { - __kmp_stg_parse_file(name, value, "", &__kmp_speculative_statsfile); + __kmp_stg_parse_file(name, value, "", CCAST(char**, &__kmp_speculative_statsfile)); } // __kmp_stg_parse_speculative_statsfile static void __kmp_stg_print_speculative_statsfile(kmp_str_buf_t *buffer,