-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Reland: [OpenMP] Add ompTest library to OpenMP #154786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
mjklemm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
|
My local build still fails during linking openmp/tools/omptest/libomptest.so: |
Description
===========
OpenMP Tooling Interface Testing Library (ompTest)
ompTest is a unit testing framework for testing OpenMP implementations.
It offers a simple-to-use framework that allows a tester to check for
OMPT events in addition to regular unit testing code, supported by
linking against GoogleTest by default. It also facilitates writing
concise tests while bridging the semantic gap between the unit under
test and the OMPT-event testing.
Background
==========
This library has been developed to provide the means of testing OMPT
implementations with reasonable effort. Especially, asynchronous or
unordered events are supported and can be verified with ease, which may
prove to be challenging with LIT-based tests. Additionally, since the
assertions are part of the code being tested, ompTest can reference all
corresponding variables during assertion.
Basic Usage
===========
OMPT event assertions are placed before the code, which shall be tested.
These assertion can either be provided as one block or interleaved with
the test code. There are two types of asserters: (1) sequenced
"order-sensitive" and (2) set "unordered" assserters. Once the test is
being run, the corresponding events are triggered by the OpenMP runtime
and can be observed. Each of these observed events notifies asserters,
which then determine if the test should pass or fail.
Example (partial, interleaved)
==============================
int N = 100000;
int a[N];
int b[N];
OMPT_ASSERT_SEQUENCE(Target, TARGET, BEGIN, 0);
OMPT_ASSERT_SEQUENCE(TargetDataOp, ALLOC, N * sizeof(int)); // a ?
OMPT_ASSERT_SEQUENCE(TargetDataOp, H2D, N * sizeof(int), &a);
OMPT_ASSERT_SEQUENCE(TargetDataOp, ALLOC, N * sizeof(int)); // b ?
OMPT_ASSERT_SEQUENCE(TargetDataOp, H2D, N * sizeof(int), &b);
OMPT_ASSERT_SEQUENCE(TargetSubmit, 1);
OMPT_ASSERT_SEQUENCE(TargetDataOp, D2H, N * sizeof(int), nullptr, &b);
OMPT_ASSERT_SEQUENCE(TargetDataOp, D2H, N * sizeof(int), nullptr, &a);
OMPT_ASSERT_SEQUENCE(TargetDataOp, DELETE);
OMPT_ASSERT_SEQUENCE(TargetDataOp, DELETE);
OMPT_ASSERT_SEQUENCE(Target, TARGET, END, 0);
#pragma omp target parallel for
{
for (int j = 0; j < N; j++)
a[j] = b[j];
}
References
==========
This work has been presented at SC'24 workshops, see:
https://ieeexplore.ieee.org/document/10820689
Current State and Future Work
=============================
ompTest's development was mostly device-centric and aimed at OMPT device
callbacks and device-side tracing. Consequentially, a substantial part
of host-related events or features may not be supported in its current
state. However, we are confident that the related functionality can be
added and ompTest provides a general foundation for future OpenMP and
especially OMPT testing. This PR will allow us to upstream the
corresponding features, like OMPT device-side tracing in the future with
significantly reduced risk of introducing regressions in the process.
Build
=====
ompTest is linked against LLVM's GoogleTest by default, but can also be
built 'standalone'. Additionally, it comes with a set of unit tests,
which in turn require GoogleTest (overriding a standalone build). The
unit tests are added to the `check-openmp` target.
Use the following parameters to perform the corresponding build:
`LIBOMPTEST_BUILD_STANDALONE` (Default: ${OPENMP_STANDALONE_BUILD})
`LIBOMPTEST_BUILD_UNITTESTS` (Default: OFF)
---------
Co-authored-by: Jan-Patrick Lehr <[email protected]>
Co-authored-by: Joachim <[email protected]>
Adapted minimum CMake version Fixed llvm_gtest linking - Replaced archive path with target name - Fixed related warning and added checks for llvm_gtest
jprotze
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
With the additional dependencies a fresh libc++-first build succeeds.
aa3bb7b to
880552c
Compare
|
Apologies @jprotze I was working on this and blindly force-pushed as I was not aware of your commit. |
|
Thank you Joachim, much appreciated! :) |
|
|
|
|
||
| # Add LLVM-provided GoogleTest include directories. | ||
| target_include_directories(omptest PRIVATE | ||
| ${LLVM_THIRD_PARTY_DIR}/unittest/googletest/include) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Shouldn't this be covered on the PUBLIC target_include_directories on llvm_gtest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think you're right. AFAICT this can be removed.
|
|
||
| # TODO: Re-visit ABI breaking checks, disable for now. | ||
| target_compile_definitions(omptest PUBLIC | ||
| -DLLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? This looks very fishy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I had build failures without it, but this seems to depend on how you link LLVMSupport.
It seems to be implicitly linked as PRIVATE but needs PUBLIC from what I found out during tests.
|
|
||
| # Link llvm_gtest as whole-archive to expose required symbols | ||
| set(GTEST_LINK_CMD "-Wl,--whole-archive" llvm_gtest | ||
| "-Wl,--no-whole-archive" LLVMSupport) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really need this now that you're using the llvm_gtest target? None of the other places that use llvm_gtest require this. Why does this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually "yes", ompTest should be usable like an OMPT-extended version of GoogleTest.
Thus, my goal is pulling in all symbols, but I'm by no means an expert on this matter.
The issue is that without it, there are linker errors when a user-test links against libomptest.so.
That's because of missing symbols, like e.g. testing::Test::Test() or testing::internal::GTestLog::~GTestLog().
Advice on how to improve this part would be greatly appreciated.
One possibility I saw was to use an intermediate build file, similar to this:
[...]
set(GTEST_OBJECT "build/third-party/unittest/CMakeFiles/llvm_gtest.dir/googletest/src/gtest-all.cc.o")
# Add GoogleTest-based header and merge pre-built object
target_sources(omptest PRIVATE
./include/OmptTesterGoogleTest.h
"${GTEST_OBJECT}")
[...]Apart from locating that file properly, I'm not sure which other dependencies this approach would imply (maybe compiler-rt?).
|
I'm seeing build failures with this change, while using runtimes build: and similar. Configured via: The file's present, so I guess it's a missing include directory: |
|
The other tools have this line in their CMake config: |
|
@mhalk, ping. |
Add missing `LIBOMP_INCLUDE_DIR` include directory to fix build failures in omptest, as reported in llvm#154786 (comment). Thanks fo @jprotze for the suggested fix. Signed-off-by: Michał Górny <[email protected]>
Add missing `LIBOMP_INCLUDE_DIR` include directory to fix build failures in omptest, as reported in #154786 (comment). Thanks fo @jprotze for the suggested fix. Signed-off-by: Michał Górny <[email protected]>
…56194) Add missing `LIBOMP_INCLUDE_DIR` include directory to fix build failures in omptest, as reported in llvm/llvm-project#154786 (comment). Thanks fo @jprotze for the suggested fix. Signed-off-by: Michał Górny <[email protected]>
|
Apologies for the radio-silence, I'll re-check all comments -- thanks for the input. |
Reland of #147381
Added changes to fix observed BuildBot failures:
3.20, was:3.22)./build/lib/libllvm_gtest.a)#include "llvm/Support/raw_os_ostream.h")