[Openmp-commits] [PATCH] D108046: tsan: Add new annotation functions to promote all accesses to atomic

Joachim Protze via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Aug 13 11:33:26 PDT 2021


protze.joachim created this revision.
protze.joachim added reviewers: vitalybuka, dvyukov, melver.
protze.joachim added a project: Sanitizers.
Herald added a subscriber: jfb.
protze.joachim requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, Sanitizers, sstefan1.
Herald added a project: OpenMP.

The idea of the new annotation functions is to work very similar to AnnotateIgnoreWriteBegin/End. 
The difference is, that the memory accesses should not be ignored but they should be treated like atomic accesses.

I want to use the new annotation to improve the modeling of OpenMP reduction semantics. With this patch, I can detect the data race between the increment of var by the master thread and the other threads performing the reduction. 
Without this patch I miss the data race, because the current strategy for OpenMP reduction is to ignore the accesses performed by the OpenMP runtime library (see the changes in ompt-tsan.cpp).
The presence of the reduction does not introduce any synchronization other than ensuring that the consistently reduced result is available at the next synchronization point.

Does this patch make sense to you, or do you think it goes into a completely wrong direction?
I must admit that this patch as it is causes ~10% runtime increase for one of my benchmarks that doesn't even use this annotation. If the patch is in general ok, we can optimize the performance.

I can separate out the OpenMP specific changes into a separate patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108046

Files:
  compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp
  compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
  compiler-rt/lib/tsan/rtl/tsan_rtl.h
  openmp/tools/archer/ompt-tsan.cpp
  openmp/tools/archer/tests/races/reduction-race.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108046.366314.patch
Type: text/x-patch
Size: 8850 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210813/948e3430/attachment.bin>


More information about the Openmp-commits mailing list