This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Remove TSan annotations from libomp
ClosedPublic

Authored by protze.joachim on Jun 6 2021, 9:24 AM.

Details

Summary

The annotations in libomp were never built by default. The annotations are also superseded by the OMPT tool libarcher.so, which is automatically loaded if an OpenMP application is built with TSan.
This patch removes all TSan annotations from the runtime code.

Diff Detail

Event Timeline

protze.joachim created this revision.Jun 6 2021, 9:24 AM
protze.joachim requested review of this revision.Jun 6 2021, 9:24 AM
ye-luo added a subscriber: ye-luo.Jun 6 2021, 10:16 AM

"libarcher.so, which is automatically loaded if an OpenMP application is built with TSan." Is this valid with gcc + libomp combination?

"libarcher.so, which is automatically loaded if an OpenMP application is built with TSan." Is this valid with gcc + libomp combination?

Yes. The OMPT startup code in libomp assumes libarcher.so to be the last element of the OMP_TOOL_LIBARARIES var. So, as long as you don't load a different OMPT tool while executing an application built with TSan, you will have Archer loaded. To verify, you can export ARCHER_OPTIONS=verbose=1. If you have doubts or if loading Archer fails for you, you can export OMP_TOOL_VERBOSE_INIT=stdout to get detailed information about OMPT initialization including dlerror output.

@AndreyChurbanov we talked about the patch during today's OpenMP in LLVM call and agreed that the patch should be applied. Can you please review and accept?

I just removed one unrelated change and rebased to current main.

Is archer a functionally equivalent replacement for TSAN?

I'm surprised that it can detect races without annotation where tsan does require annotations. There isn't anything about openmp that makes that obviously possible, so is it a case of features that could be added to tsan, such that we could run tsan against this without the annotations?

Probably, my statement was misleading. Archer is effectively an adapter between the OpenMP tools interface (OMPT) and the Annotation interface in TSan.
Archer does not perform its own data race analysis, but translates OpenMP synchronization semantics (derived from OMPT event callbacks) into TSan annotations.

Since libarcher gets loaded by default, enabling LIBOMP_TSAN_SUPPORT will result in redundant annotations for TSan, which slightly differ in details and coverage.

This revision is now accepted and ready to land.Jul 9 2021, 5:12 AM
This revision was automatically updated to reflect the committed changes.
openmp/runtime/src/kmp_tasking.cpp