[Openmp-commits] [openmp] r338277 - [OpenMP] Fix build errors when building with KMP_DEBUG_ADAPTIVE_LOCKS=1
Jonathan Peyton via Openmp-commits
openmp-commits at lists.llvm.org
Mon Jul 30 10:45:23 PDT 2018
Author: jlpeyton
Date: Mon Jul 30 10:45:23 2018
New Revision: 338277
URL: http://llvm.org/viewvc/llvm-project?rev=338277&view=rev
Log:
[OpenMP] Fix build errors when building with KMP_DEBUG_ADAPTIVE_LOCKS=1
This change fixes build errors when building a runtime with adaptive lock stats
enabled. Most of the errors were due to the recent changes in the runtime, but
it seems that we have not tried to build this debug runtime on Windows for a
long time.
Patch by Hansang Bae
Differential Revision: https://reviews.llvm.org/D49823
Modified:
openmp/trunk/runtime/src/kmp.h
openmp/trunk/runtime/src/kmp_global.cpp
openmp/trunk/runtime/src/kmp_lock.cpp
openmp/trunk/runtime/src/kmp_settings.cpp
Modified: openmp/trunk/runtime/src/kmp.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp.h?rev=338277&r1=338276&r2=338277&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp.h (original)
+++ openmp/trunk/runtime/src/kmp.h Mon Jul 30 10:45:23 2018
@@ -3017,7 +3017,7 @@ struct kmp_adaptive_backoff_params_t {
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
Modified: openmp/trunk/runtime/src/kmp_global.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_global.cpp?rev=338277&r1=338276&r2=338277&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_global.cpp (original)
+++ openmp/trunk/runtime/src/kmp_global.cpp Mon Jul 30 10:45:23 2018
@@ -204,7 +204,7 @@ kmp_adaptive_backoff_params_t __kmp_adap
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
Modified: openmp/trunk/runtime/src/kmp_lock.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_lock.cpp?rev=338277&r1=338276&r2=338277&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_lock.cpp (original)
+++ openmp/trunk/runtime/src/kmp_lock.cpp Mon Jul 30 10:45:23 2018
@@ -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_statistics_t de
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_forget_lock(kmp_adapti
}
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_add_stats(kmp_adaptive
}
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 @@ static FILE *__kmp_open_stats_file() {
}
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 @@ void __kmp_print_speculative_stats() {
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"
Modified: openmp/trunk/runtime/src/kmp_settings.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/kmp_settings.cpp?rev=338277&r1=338276&r2=338277&view=diff
==============================================================================
--- openmp/trunk/runtime/src/kmp_settings.cpp (original)
+++ openmp/trunk/runtime/src/kmp_settings.cpp Mon Jul 30 10:45:23 2018
@@ -385,7 +385,7 @@ static void __kmp_stg_parse_int(
#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_print_adaptive_loc
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,
More information about the Openmp-commits
mailing list