Skip to content

Commit ad9ccc5

Browse files
committed
__has_feature(thread_sanitizer) and __SANITIZE_THREAD__ catch clang and gcc
1 parent 488a3da commit ad9ccc5

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

BUILD.bazel

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,26 @@ cc_library(
7373
],
7474
)
7575

76+
cc_library(
77+
name = "highs-runtime-opts",
78+
hdrs = ["app/HighsRuntimeOptions.h",
79+
"app/CLI11.hpp"],
80+
visibility = ["//visibility:public"],
81+
deps = [
82+
"//:highs",
83+
],
84+
)
85+
86+
cc_binary(
87+
name = "highs-bin",
88+
srcs = ["app/RunHighs.cpp"],
89+
visibility = ["//visibility:public"],
90+
deps = [
91+
"//:highs",
92+
"//:highs-runtime-opts",
93+
],
94+
)
95+
7696
cc_binary(
7797
name = "call-highs-example",
7898
srcs = ["examples/call_highs_from_cpp.cpp"],

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ option(HIGHS_COVERAGE "Activate the code coverage compilation" OFF)
126126
# Only Debug is theted atm
127127
# See below for RelWithDeb info, todo test wip
128128
set(DEBUG_MEMORY "Off" CACHE STRING "Sanitizers")
129-
option(SANITIZE_THREAD "TSAN" OFF)
130129

131130
# emscripten
132131
option(EMSCRIPTEN_HTML "Emscripten HTML output" OFF)

highs/HConfig.h.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#cmakedefine HIGHS_HAVE_MM_PAUSE
1414
#cmakedefine HIGHS_HAVE_BUILTIN_CLZ
1515
#cmakedefine HIGHS_HAVE_BITSCAN_REVERSE
16-
#cmakedefine SANITIZE_THREAD
1716

1817
#define HIGHS_GITHASH "@GITHASH@"
1918
#define HIGHS_VERSION_MAJOR @HIGHS_VERSION_MAJOR@

highs/parallel/HighsTaskExecutor.h

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@
2828
#include "util/HighsInt.h"
2929
#include "util/HighsRandom.h"
3030

31-
#if defined(SANITIZE_THREAD)
32-
#define TSAN_ENABLED
33-
#elif defined(__has_feature)
31+
#ifdef __has_feature
3432
#if __has_feature(thread_sanitizer)
3533
#define TSAN_ENABLED
3634
#endif
3735
#endif
3836

37+
#ifdef __SANITIZE_THREAD__
38+
#define TSAN_ENABLED
39+
#endif
40+
3941
#ifdef TSAN_ENABLED
4042
#define TSAN_ANNOTATE_HAPPENS_BEFORE(addr) \
4143
AnnotateHappensBefore(__FILE__, __LINE__, (void*)(addr))
@@ -144,10 +146,21 @@ class HighsTaskExecutor {
144146

145147
workerDeques.resize(numThreads);
146148
workerBunk = cache_aligned::make_shared<HighsSplitDeque::WorkerBunk>();
149+
#ifdef __has_feature
150+
std::cout << "__has_feature is ON" << std::endl;
151+
#else
152+
std::cout << "__has_feature is OFF" << std::endl;
153+
#endif
154+
#ifdef TSAN_ENABLED
155+
std::cout << "TSAN is ON" << std::endl;
156+
#else
157+
std::cout << "TSAN is OFF" << std::endl;
158+
#endif
147159
for (int i = 0; i < numThreads; ++i) {
148160
workerDeques[i] = cache_aligned::make_unique<HighsSplitDeque>(
149161
workerBunk, workerDeques.data(), i, numThreads);
150162

163+
151164
// TSAN_ANNOTATE_HAPPENS_AFTER(&workerBunk);
152165
}
153166

0 commit comments

Comments
 (0)