[Openmp-commits] [PATCH] D13072: [OpenMP] Enable ThreadSanitizer to check OpenMP programs

Simone via Openmp-commits openmp-commits at lists.llvm.org
Fri Oct 21 16:27:21 PDT 2016


simoatze added inline comments.


================
Comment at: runtime/CMakeLists.txt:323-326
+if(${LIBOMP_TSAN_SUPPORT})
+  add_definitions(-D TSAN_SUPPORT=1)
+endif()
+
----------------
jlpeyton wrote:
> It seems TSAN is only supported on Linux X86-64 so inside cmake/config-ix.cmake this should be appended:
> ```
> if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" AND ${INTEL64})
>   set(LIBOMP_HAVE_TSAN_SUPPORT TRUE)
> else()
>   set(LIBOMP_HAVE_TSAN_SUPPORT FALSE)
> endif()
> ```
> 
> and in the main CMakeLists.txt file (You'll see this pattern a lot in this file):
> ```
> set(LIBOMP_TSAN_SUPPORT FALSE CACHE BOOL
>   "TSAN-support?")
> if(LIBOMP_TSAN_SUPPORT AND (NOT LIBOMP_HAVE_TSAN_SUPPORT))
>   libomp_error_say("TSAN functionality requested but not available")
> endif()
> ```
> 
> Also, as Jonas pointed out, we usually use the kmp_config.h.cmake file instead of sending in definitions.  So in kmp_config.h.cmake there should be:
> ```
> #cmakedefine01 LIBOMP_TSAN_SUPPORT
> #if LIBOMP_TSAN_SUPPORT
> #define TSAN_SUPPORT
> #endif
> ```
Tsan is also supported for other architectures (I personally ported it on PPC64), however I wasn't able to compile the OpenMP runtime on PPC64, I'll leave only x86_64 for now.


================
Comment at: runtime/src/kmp_barrier.cpp:310
            any more - it could be deallocated by the master thread at any time.  */
+        ANNOTATE_BARRIER_BEFORE(this_thr);
         kmp_flag_64 flag(&thr_bar->b_arrived, other_threads[parent_tid]);
----------------
jlpeyton wrote:
> I'm not familiar with the thread sanitizer or what these functions do.  Can you explain a little bit about BARRIER_BEFORE and AFTER and what they do with their argument?
Those annotations basically update the vector clock for a certain thread that Tsan keeps to compute the happens-before relation.


https://reviews.llvm.org/D13072





More information about the Openmp-commits mailing list