This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP][OMPT] Implement verbose tool loading
ClosedPublic

Authored by protze.joachim on Nov 13 2020, 2:58 PM.

Details

Summary

OpenMP 5.1 introduces the new env variable OMP_TOOL_VERBOSE_INIT=(disabled|stdout|stderr|<filename>) to enable verbose loading and initialization of OMPT tools.
This env variable helps to understand the cause when loading of a tool fails (e.g., undefined symbols or dependency not in LD_LIBRARY_PATH)

Tests for this patch are integrated into the different existing tool loading tests, making these tests more verbose.

Patch prepared by: Isabel Thärigen

Diff Detail

Event Timeline

protze.joachim created this revision.Nov 13 2020, 2:58 PM
protze.joachim requested review of this revision.Nov 13 2020, 2:58 PM
hbae added a comment.Nov 16 2020, 9:45 AM

Can we also add print routine for OMP_TOOL_VERBOSE_INIT in kmp_settings.cpp (for OMP_DISPLAY_ENV) ?

openmp/runtime/src/ompt-general.cpp
248

Can we put the common pattern if (verbose_init) fprintf(verbose_file, into a macro? e.g., OMPT_VERBOSE(<message>). We may be able to add some common prefix to the macro if desired.

Use macros for the conditional verbose output.
We also added a test for the archer-specific output.

Also include OMP_TOOL_VERBOSE_INIT in the output for OMP_DISPLAY_ENV as requested.

hbae accepted this revision.Nov 24 2020, 2:31 PM

Looks good to me.

This revision is now accepted and ready to land.Nov 24 2020, 2:31 PM

The verbose information used in this patch is limited to Linux only. On macOS it prints completely different information, which causes regression on macOS (https://github.com/llvm/llvm-project/issues/56833). Can you please fix it?

Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2023, 10:36 AM

FYI, the following is the output on macOS. I'm not sure if the output makes sense or not.

➜ env OMP_TOOL_LIBRARIES=$PWD/non_existing_file.so:$PWD/first_tool.so:$PWD/second_tool.so:$PWD/third_tool.so OMP_TOOL_VERBOSE_INIT=stdout ./tool_available_search.c.tmp
----- START LOGGING OF TOOL REGISTRATION -----
Search for OMP tool in current address space... Failed.
Searching tool libraries...
OMP_TOOL_LIBRARIES = /Users/shiltian/Documents/code/build/openmp/release/runtime/test/ompt/loadtool/tool_available_search/Output/non_existing_file.so:/Users/shiltian/Documents/code/build/openmp/release/runtime/test/ompt/loadtool/tool_available_search/Output/first_tool.so:/Users/shiltian/Documents/code/build/openmp/release/runtime/test/ompt/loadtool/tool_available_search/Output/second_tool.so:/Users/shiltian/Documents/code/build/openmp/release/runtime/test/ompt/loadtool/tool_available_search/Output/third_tool.so
Opening /Users/shiltian/Documents/code/build/openmp/release/runtime/test/ompt/loadtool/tool_available_search/Output/non_existing_file.so... Failed: dlopen(/Users/shiltian/Documents/code/build/openmp/release/runtime/test/ompt/loadtool/tool_available_search/Output/non_existing_file.so, 0x0001): tried: '/Users/shiltian/Documents/code/build/openmp/release/runtime/test/ompt/loadtool/tool_available_search/Output/non_existing_file.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/shiltian/Documents/code/build/openmp/release/runtime/test/ompt/loadtool/tool_available_search/Output/non_existing_file.so' (no such file), '/Users/shiltian/Documents/code/build/openmp/release/runtime/test/ompt/loadtool/tool_available_search/Output/non_existing_file.so' (no such file)
Opening /Users/shiltian/Documents/code/build/openmp/release/runtime/test/ompt/loadtool/tool_available_search/Output/first_tool.so... Success.
Searching for ompt_start_tool in /Users/shiltian/Documents/code/build/openmp/release/runtime/test/ompt/loadtool/tool_available_search/Output/first_tool.so... Failed: dlsym(0x7ff90127b170, ompt_start_tool): symbol not found
Opening /Users/shiltian/Documents/code/build/openmp/release/runtime/test/ompt/loadtool/tool_available_search/Output/second_tool.so... Success.
Searching for ompt_start_tool in /Users/shiltian/Documents/code/build/openmp/release/runtime/test/ompt/loadtool/tool_available_search/Output/second_tool.so... 0: Do not initialize tool
Found but not using the OMPT interface.
Continuing search...
Opening /Users/shiltian/Documents/code/build/openmp/release/runtime/test/ompt/loadtool/tool_available_search/Output/third_tool.so... Success.
Searching for ompt_start_tool in /Users/shiltian/Documents/code/build/openmp/release/runtime/test/ompt/loadtool/tool_available_search/Output/third_tool.so... 0: Do initialize tool
Success.
Tool was started and is using the OMPT interface.
----- END LOGGING OF TOOL REGISTRATION -----
0: Tool initialized
0: ompt_event_thread_begin
0: control_tool()=-1
0: ompt_event_thread_begin
0: Tool finalized