This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] [OMPD] [5/6] Implementation of OMPD debugging library - libompd. gdb-plugin: A Plugin code to gdb to leverage libompd to provide debugging support.
ClosedPublic

Authored by Vigneshbalu on Apr 9 2021, 5:27 AM.

Details

Summary

This is part of the review: https://reviews.llvm.org/D100181

This patch includes python based plugin code to gdb that enables gdb to support OpenMP specific debugging through OMPD.
Loading of this plugin causes a few new gdb commands to be added ("ompd icv", "ompd parallel", "ompd bt", etc). The invocation of these commands results in the OMPD APIs being invoked with the required arguments to provide the user the needed information.
The plugin code also includes basic wrapper implementations of the callback routines.
Other than these, a few unit tests are included to verify if the return codes of the OMPD APIs align with what is specified in the standard. (ompdAPITests.c)

Diff Detail

Event Timeline

Vigneshbalu created this revision.Apr 9 2021, 5:27 AM
Vigneshbalu requested review of this revision.Apr 9 2021, 5:27 AM
Herald added a project: Restricted Project. · View Herald Transcript
Vigneshbalu changed the visibility from "Public (No Login Required)" to "Vigneshbalu (Vignesh Balasubramanian)".Apr 9 2021, 7:55 AM
Vigneshbalu changed the visibility from "Vigneshbalu (Vignesh Balasubramanian)" to "Public (No Login Required)".Apr 11 2021, 9:48 AM

Rebasing the patch.

Rebasing the patch.

Vigneshbalu edited the summary of this revision. (Show Details)Aug 10 2021, 2:05 AM

Rebasing the patch.

Gentle Reminder. !

Gentle reminder, as it is one of the last two patches to complete OMPD.

hbae added a comment.Jan 28 2022, 7:29 PM

The change looks good in general.
I tested basic usage of the ompd plugin, and it seems to work fine as expected.
I encountered python-related build issues on some of my test systems (e.g., Ubuntu 18.04) which I cannot resolve by installing required python packages, so I wonder if we need to make this (ompd test infrastructure) an optional feature for those who are interested.

The change looks good in general.
I tested basic usage of the ompd plugin, and it seems to work fine as expected.
I encountered python-related build issues on some of my test systems (e.g., Ubuntu 18.04) which I cannot resolve by installing required python packages, so I wonder if we need to make this (ompd test infrastructure) an optional feature for those who are interested.

I will try to fix it by skipping the plugin build, if the build system is incompatible.
Please give me some time, I will revert with details.

Fixes the build failure because of python (pip).

Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2022, 3:02 AM

The change looks good in general.
I tested basic usage of the ompd plugin, and it seems to work fine as expected.
I encountered python-related build issues on some of my test systems (e.g., Ubuntu 18.04) which I cannot resolve by installing required python packages, so I wonder if we need to make this (ompd test infrastructure) an optional feature for those who are interested.

Ubuntu and debian have its own patch on python pip which was causing failure.
Made changes in CMake to pick proper flag depend upon distributions and pip versions.
Tested the same on debian, ubuntu (wiht 9.01 and 21+ pip versions), centos and rhel.

Gentle Reminder

koops added a subscriber: koops.Jun 15 2022, 10:11 PM

This looks good to me. Is there a particular version of gdb that this plugin depends on? I didn't see that documented.

Since, the gdb interface code is written in python. GDB that uses libompd should be built with python 3.5 or above.

This is captured in "gdb-plugin/README.txt" under "NOTES" Section.

dreachem accepted this revision.Jul 11 2022, 8:13 AM

LGTM.

This revision is now accepted and ready to land.Jul 11 2022, 8:13 AM
jdoerfert reopened this revision.Jul 14 2022, 12:40 PM

This caused additional and undisclosed dependences to python packages, e.g. setuptools.
Please introduce a check + message for those and avoid build errors if they are missing.

This revision is now accepted and ready to land.Jul 14 2022, 12:40 PM
jdoerfert requested changes to this revision.Jul 18 2022, 11:10 AM
This revision now requires changes to proceed.Jul 18 2022, 11:10 AM

Removing python packages dependencies.

Gentle reminder !

jdoerfert resigned from this revision.Aug 31 2022, 7:19 AM

Deepak approved.

This revision is now accepted and ready to land.Aug 31 2022, 7:19 AM
aaronpuchert added inline comments.
openmp/libompd/CMakeLists.txt
14

Could you introduce this as cache variable? Something like

set(DISABLE_OMPD_GDB_PLUGIN OFF CACHE BOOL "<Some description>")

See also https://cmake.org/cmake/help/latest/command/set.html#set-cache-entry.

And perhaps we could choose the default based on the availability of Python 3 development files?

openmp/libompd/gdb-plugin/CMakeLists.txt
18

Isn't this the same as the Development component from the previous line? Down there I don't see direct usage of PythonLibs, only Python3_INCLUDE_DIRS and Python3_LIBRARIES from the previous line.

CMake documentation also says that this is deprecated in favor of Python3 that you're already using. So this line can likely simply be removed.

kaz7 added a subscriber: kaz7.Sep 13 2022, 10:40 PM

Hi, I'm having following errors after this patch. I'm compiling llvm and runtimes for X86. Is Python3_INCLUDE_DIRS required for the debugging purpose? Thanks!

...
[115/124] Performing build step for 'runtimes-x86_64-unknown-linux-gnu'
[0/1] Re-running CMake...
-- Using libunwind testing configuration: /home/jam/llvm-dev/llvm-project/libunwind/test/configs/llvm-libunwind-shared.cfg.in
-- Failed to locate sphinx-build executable (missing: SPHINX_EXECUTABLE)
-- Using libc++abi testing configuration: /home/jam/llvm-dev/llvm-project/libcxxabi/test/configs/llvm-libc++abi-shared.cfg.in
-- Could not find ParallelSTL, libc++abi will not attempt to use it but the build may fail if the libc++ in use needs it to be available.
-- Using libc++ testing configuration: /home/jam/llvm-dev/llvm-project/libcxx/test/configs/llvm-libc++-shared.cfg.in
CMake Warning at /home/jam/llvm-dev/llvm-project/libcxx/benchmarks/CMakeLists.txt:2 (message):
  The libc++ benchmarks won't be available because the version of CMake is
  too old to support them.


-- Cannot find llvm-lit.
-- Please put llvm-lit in your PATH, set OPENMP_LLVM_LIT_EXECUTABLE to its full path, or point OPENMP_LLVM_TOOLS_DIR to its directory.
CMake Warning at /home/jam/llvm-dev/llvm-project/openmp/cmake/OpenMPTesting.cmake:22 (message):
  The check targets will not be available!
Call Stack (most recent call first):
  /home/jam/llvm-dev/llvm-project/openmp/cmake/OpenMPTesting.cmake:51 (find_stan
dalone_test_dependencies)
  /home/jam/llvm-dev/llvm-project/openmp/CMakeLists.txt:59 (include)


-- LIBOMP: Operating System     -- Linux
-- LIBOMP: Target Architecture  -- x86_64
-- LIBOMP: Build Type           -- Release
-- LIBOMP: Library Kind         -- SHARED
-- LIBOMP: Library Type         -- normal
-- LIBOMP: Fortran Modules      -- FALSE
-- LIBOMP: Build                -- 20140926
-- LIBOMP: Use Stats-gathering  -- FALSE
-- LIBOMP: Use Debugger-support -- FALSE
-- LIBOMP: Use ITT notify       -- TRUE
-- LIBOMP: Use OMPT-support     -- TRUE
-- LIBOMP: Use OMPT-optional  -- TRUE
-- LIBOMP: Use OMPD-support     -- TRUE
-- LIBOMP: Use Adaptive locks   -- TRUE
-- LIBOMP: Use quad precision   -- FALSE
-- LIBOMP: Use Hwloc library    -- FALSE
-- check-libomp does nothing.
-- check-ompt does nothing.
-- Could NOT find Python3 (missing: Python3_INCLUDE_DIRS Development) (found version "3.8.10")
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find PythonLibs (missing: PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.16/Modules/FindPythonLibs.cmake:310 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  /home/jam/llvm-dev/llvm-project/openmp/libompd/gdb-plugin/CMakeLists.txt:17 (find_package)


-- Configuring incomplete, errors occurred!
See also "/home/jam/llvm-dev/build/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/CMakeFiles/CMakeOutput.log".
See also "/home/jam/llvm-dev/build/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/CMakeFiles/CMakeError.log".
FAILED: build.ninja
/usr/bin/cmake -S/home/jam/llvm-dev/llvm-project/runtimes -B/home/jam/llvm-dev/build/runtimes/runtimes-x86_64-unknown-linux-gnu-bins
ninja: error: rebuilding 'build.ninja': subcommand failed
[121/124] Linking CXX executable bin/opt
FAILED: runtimes/runtimes-x86_64-unknown-linux-gnu-stamps/runtimes-x86_64-unknown-linux-gnu-build
cd /home/jam/llvm-dev/build/runtimes/runtimes-x86_64-unknown-linux-gnu-bins && /usr/bin/cmake --build .
ninja: build stopped: subcommand failed.
make: *** [Makefile:68: build] Error 1
Vigneshbalu added inline comments.Sep 13 2022, 11:08 PM
openmp/libompd/CMakeLists.txt
14

thanks for the comments.
I will make it as cache variable.
yes, we can disable when python is not available, with a warning.
Let me check with others and update.

openmp/libompd/gdb-plugin/CMakeLists.txt
18

thanks for the catch. It seems redundant.
Let me verify and remove it.

python3 is required to build gdb-plugin code. It is used as an interface between gdb, libompd and openmp runtime (libomp).
please use configuration variable "DISABLE_OMPD_GDB_PLUGIN" to disable the plugin code.

I will see if we can disable by default when python is not available.

kaz7 added a comment.Sep 13 2022, 11:32 PM

python3 is required to build gdb-plugin code. It is used as an interface between gdb, libompd and openmp runtime (libomp).
please use configuration variable "DISABLE_OMPD_GDB_PLUGIN" to disable the plugin code.

I will see if we can disable by default when python is not available.

Thanks. It works fine if I install not only python3 but also python3-dev, but it worth to modify CMakefile to handle users who install only python3.

mgorny added inline comments.Sep 16 2022, 12:27 AM
openmp/libompd/CMakeLists.txt
14

Also please use positive logic and LIBOMP* or OPENMP* prefix, for consistency with other options.