diff options
| author | Jonas Hahnfeld <Hahnfeld@itc.rwth-aachen.de> | 2016-11-07 15:58:36 +0000 |
|---|---|---|
| committer | Jonas Hahnfeld <Hahnfeld@itc.rwth-aachen.de> | 2016-11-07 15:58:36 +0000 |
| commit | 50fed0475f13e0a5868e25cc29746ac3fa32efbd (patch) | |
| tree | 6df2518e60b4060c7e67ebc529d9df3270f8e25d /openmp/runtime/src/z_Linux_util.c | |
| parent | 1d50fe9befc215d37af3b0459035e1022de6abde (diff) | |
| download | bcm5719-llvm-50fed0475f13e0a5868e25cc29746ac3fa32efbd.tar.gz bcm5719-llvm-50fed0475f13e0a5868e25cc29746ac3fa32efbd.zip | |
[OpenMP] Enable ThreadSanitizer to check OpenMP programs
This patch allows ThreadSanitizer (Tsan) to verify OpenMP programs.
It means that no false positive will be reported by Tsan when
verifying an OpenMP programs.
This patch introduces annotations within the OpenMP runtime module to
provide information about thread synchronization to the Tsan runtime.
In order to enable the Tsan support when building the runtime, you must
enable the TSAN_SUPPORT option with the following environment variable:
-DLIBOMP_TSAN_SUPPORT=TRUE
The annotations will be enabled in the main shared library
(same mechanism of OMPT).
Patch by Simone Atzeni and Joachim Protze!
Differential Revision: https://reviews.llvm.org/D13072
llvm-svn: 286115
Diffstat (limited to 'openmp/runtime/src/z_Linux_util.c')
| -rw-r--r-- | openmp/runtime/src/z_Linux_util.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/openmp/runtime/src/z_Linux_util.c b/openmp/runtime/src/z_Linux_util.c index 6c51301d1bf..b3c3e80083b 100644 --- a/openmp/runtime/src/z_Linux_util.c +++ b/openmp/runtime/src/z_Linux_util.c @@ -59,6 +59,8 @@ #include <ctype.h> #include <fcntl.h> +#include "tsan_annotations.h" + /* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */ @@ -1609,6 +1611,7 @@ __kmp_suspend_initialize( void ) static void __kmp_suspend_initialize_thread( kmp_info_t *th ) { + ANNOTATE_HAPPENS_AFTER(&th->th.th_suspend_init_count); if ( th->th.th_suspend_init_count <= __kmp_fork_count ) { /* this means we haven't initialized the suspension pthread objects for this thread in this instance of the process */ @@ -1618,6 +1621,7 @@ __kmp_suspend_initialize_thread( kmp_info_t *th ) status = pthread_mutex_init( &th->th.th_suspend_mx.m_mutex, & __kmp_suspend_mutex_attr ); KMP_CHECK_SYSFAIL( "pthread_mutex_init", status ); *(volatile int*)&th->th.th_suspend_init_count = __kmp_fork_count + 1; + ANNOTATE_HAPPENS_BEFORE(&th->th.th_suspend_init_count); }; } |

