
Reland of https://github.com/llvm/llvm-project/pull/147381 Added changes to fix observed BuildBot failures: * CMake version (reduced minimum to `3.20`, was: `3.22`) * GoogleTest linking (missing `./build/lib/libllvm_gtest.a`) * Related header issue (missing `#include "llvm/Support/raw_os_ostream.h"`) Original message 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) ============================== ```c++ 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 <JanPatrick.Lehr@amd.com> Co-authored-by: Joachim <protze@rz.rwth-aachen.de> Co-authored-by: Joachim Jenke <jenke@itc.rwth-aachen.de>
86 lines
4.0 KiB
C++
86 lines
4.0 KiB
C++
//===- OmptAliases.h - Shorthand aliases for OMPT enum values ---*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
///
|
|
/// \file
|
|
/// Defines shorthand aliases for OMPT enum values, providing improved
|
|
/// ease-of-use and readability.
|
|
///
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef OPENMP_TOOLS_OMPTEST_INCLUDE_OMPTALIASES_H
|
|
#define OPENMP_TOOLS_OMPTEST_INCLUDE_OMPTALIASES_H
|
|
|
|
#include <omp-tools.h>
|
|
|
|
/// Aliases for enum: ompt_scope_endpoint_t
|
|
constexpr ompt_scope_endpoint_t BEGIN = ompt_scope_begin;
|
|
constexpr ompt_scope_endpoint_t END = ompt_scope_end;
|
|
constexpr ompt_scope_endpoint_t BEGINEND = ompt_scope_beginend;
|
|
|
|
/// Aliases for enum: ompt_target_t
|
|
constexpr ompt_target_t TARGET = ompt_target;
|
|
constexpr ompt_target_t ENTER_DATA = ompt_target_enter_data;
|
|
constexpr ompt_target_t EXIT_DATA = ompt_target_exit_data;
|
|
constexpr ompt_target_t UPDATE = ompt_target_update;
|
|
constexpr ompt_target_t TARGET_NOWAIT = ompt_target_nowait;
|
|
constexpr ompt_target_t ENTER_DATA_NOWAIT = ompt_target_enter_data_nowait;
|
|
constexpr ompt_target_t EXIT_DATA_NOWAIT = ompt_target_exit_data_nowait;
|
|
constexpr ompt_target_t UPDATE_NOWAIT = ompt_target_update_nowait;
|
|
|
|
/// Aliases for enum: ompt_target_data_op_t
|
|
constexpr ompt_target_data_op_t ALLOC = ompt_target_data_alloc;
|
|
constexpr ompt_target_data_op_t H2D = ompt_target_data_transfer_to_device;
|
|
constexpr ompt_target_data_op_t D2H = ompt_target_data_transfer_from_device;
|
|
constexpr ompt_target_data_op_t DELETE = ompt_target_data_delete;
|
|
constexpr ompt_target_data_op_t ASSOCIATE = ompt_target_data_associate;
|
|
constexpr ompt_target_data_op_t DISASSOCIATE = ompt_target_data_disassociate;
|
|
constexpr ompt_target_data_op_t ALLOC_ASYNC = ompt_target_data_alloc_async;
|
|
constexpr ompt_target_data_op_t H2D_ASYNC =
|
|
ompt_target_data_transfer_to_device_async;
|
|
constexpr ompt_target_data_op_t D2H_ASYNC =
|
|
ompt_target_data_transfer_from_device_async;
|
|
constexpr ompt_target_data_op_t DELETE_ASYNC = ompt_target_data_delete_async;
|
|
|
|
/// Aliases for enum: ompt_callbacks_t (partial)
|
|
constexpr ompt_callbacks_t CB_TARGET = ompt_callback_target;
|
|
constexpr ompt_callbacks_t CB_DATAOP = ompt_callback_target_data_op;
|
|
constexpr ompt_callbacks_t CB_KERNEL = ompt_callback_target_submit;
|
|
|
|
/// Aliases for enum: ompt_work_t
|
|
constexpr ompt_work_t WORK_LOOP = ompt_work_loop;
|
|
constexpr ompt_work_t WORK_SECT = ompt_work_sections;
|
|
constexpr ompt_work_t WORK_EXEC = ompt_work_single_executor;
|
|
constexpr ompt_work_t WORK_SINGLE = ompt_work_single_other;
|
|
constexpr ompt_work_t WORK_SHARE = ompt_work_workshare;
|
|
constexpr ompt_work_t WORK_DIST = ompt_work_distribute;
|
|
constexpr ompt_work_t WORK_TASK = ompt_work_taskloop;
|
|
constexpr ompt_work_t WORK_SCOPE = ompt_work_scope;
|
|
constexpr ompt_work_t WORK_LOOP_STA = ompt_work_loop_static;
|
|
constexpr ompt_work_t WORK_LOOP_DYN = ompt_work_loop_dynamic;
|
|
constexpr ompt_work_t WORK_LOOP_GUI = ompt_work_loop_guided;
|
|
constexpr ompt_work_t WORK_LOOP_OTH = ompt_work_loop_other;
|
|
|
|
/// Aliases for enum: ompt_sync_region_t
|
|
constexpr ompt_sync_region_t SR_BARRIER = ompt_sync_region_barrier;
|
|
constexpr ompt_sync_region_t SR_BARRIER_IMPL =
|
|
ompt_sync_region_barrier_implicit;
|
|
constexpr ompt_sync_region_t SR_BARRIER_EXPL =
|
|
ompt_sync_region_barrier_explicit;
|
|
constexpr ompt_sync_region_t SR_BARRIER_IMPLEMENTATION =
|
|
ompt_sync_region_barrier_implementation;
|
|
constexpr ompt_sync_region_t SR_TASKWAIT = ompt_sync_region_taskwait;
|
|
constexpr ompt_sync_region_t SR_TASKGROUP = ompt_sync_region_taskgroup;
|
|
constexpr ompt_sync_region_t SR_REDUCTION = ompt_sync_region_reduction;
|
|
constexpr ompt_sync_region_t SR_BARRIER_IMPL_WORKSHARE =
|
|
ompt_sync_region_barrier_implicit_workshare;
|
|
constexpr ompt_sync_region_t SR_BARRIER_IMPL_PARALLEL =
|
|
ompt_sync_region_barrier_implicit_parallel;
|
|
constexpr ompt_sync_region_t SR_BARRIER_TEAMS = ompt_sync_region_barrier_teams;
|
|
|
|
#endif
|