Index: openmp/tools/archer/ompt-tsan.cpp =================================================================== --- openmp/tools/archer/ompt-tsan.cpp +++ openmp/tools/archer/ompt-tsan.cpp @@ -82,6 +82,31 @@ } }; +class TsanFlags { +public: + int ignore_noninstrumented_modules; + + TsanFlags(const char *env) : ignore_noninstrumented_modules(0) { + if (env) { + std::vector tokens; + std::string token; + std::string str(env); + std::istringstream iss(str); + while (std::getline(iss, token, ' ')) + tokens.push_back(token); + + for (std::vector::iterator it = tokens.begin(); + it != tokens.end(); ++it) { + // we are interested in ignore_noninstrumented_modules to print a + // warning + if (sscanf(it->c_str(), "ignore_noninstrumented_modules=%d", + &ignore_noninstrumented_modules)) + continue; + } + } + } +}; + #if (LLVM_VERSION) >= 40 extern "C" { int __attribute__((weak)) __archer_get_omp_status(); @@ -89,6 +114,7 @@ } #endif ArcherFlags *archer_flags; +TsanFlags *tsan_flags; // The following definitions are pasted from "llvm/Support/Compiler.h" to allow // the code @@ -822,6 +848,8 @@ ompt_data_t *tool_data) { const char *options = getenv("ARCHER_OPTIONS"); archer_flags = new ArcherFlags(options); + options = getenv("TSAN_OPTIONS"); + tsan_flags = new TsanFlags(options); ompt_set_callback_t ompt_set_callback = (ompt_set_callback_t)lookup("ompt_set_callback"); @@ -853,6 +881,12 @@ SET_CALLBACK_T(mutex_acquired, mutex); SET_CALLBACK_T(mutex_released, mutex); SET_OPTIONAL_CALLBACK_T(reduction, sync_region, hasReductionCallback, ompt_set_never); + + if (!tsan_flags->ignore_noninstrumented_modules) + fprintf( + stderr, + "Warning: please export TSAN_OPTION='ignore_noninstrumented_modules=1' " + "to avoid false positive reports from the OpenMP runtime.!\n"); return 1; // success }