brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.2 KiB · 5759de7 Raw
150 lines · c
1// clang-format off2// The OpenMP standard defines 3 ways of providing ompt_start_tool:3 4// RUN: mkdir -p %t.tool_dir5 6// 1. "statically-linking the tool’s definition of ompt_start_tool into an 7//     OpenMP application"8 9// RUN: %libomp-compile -DCODE -DTOOL && env OMP_TOOL_VERBOSE_INIT=stdout \10// RUN:    %libomp-run | FileCheck %s --check-prefixes CHECK,ADDRSPACE11 12// Note: We should compile the tool without -fopenmp as other tools developer13//      would do. Otherwise this test may pass for the wrong reasons on Darwin.14 15// RUN: %clang %flags -DTOOL -shared -fPIC %s -o %t.tool_dir/tool.so16 17// 2. "introducing a dynamically-linked library that includes the tool’s 18//    definition of ompt_start_tool into the application’s address space"19 20// 2.1 Link with tool during compilation21 22// RUN: %libomp-compile -DCODE %no-as-needed-flag %t.tool_dir/tool.so && \23// RUN:    env OMP_TOOL_VERBOSE_INIT=stdout %libomp-run | FileCheck %s \24// RUN:    --check-prefixes CHECK,ADDRSPACE 25 26// 2.2 Link with tool during compilation, but AFTER the runtime27 28// RUN: %libomp-compile -DCODE -lomp %no-as-needed-flag %t.tool_dir/tool.so && \29// RUN:    env OMP_TOOL_VERBOSE_INIT=stdout %libomp-run | FileCheck %s \30// RUN:    --check-prefixes CHECK,ADDRSPACE31 32// 2.3 Inject tool via the dynamic loader33 34// RUN: %libomp-compile -DCODE && env OMP_TOOL_VERBOSE_INIT=stdout \35// RUN:    %preload-tool %libomp-run | FileCheck %s \36// RUN:    --check-prefixes CHECK,ADDRSPACE37 38// 3. "providing the name of a dynamically-linked library appropriate for the39//    architecture and operating system used by the application in the 40//    tool-libraries-var ICV"41 42// 3.1 OMP_TOOL_VERBOSE_INIT not set 43 44// RUN: %libomp-compile -DCODE && \45// RUN:    env OMP_TOOL_LIBRARIES=%t.tool_dir/tool.so %libomp-run | FileCheck %s46 47// 3.2 OMP_TOOL_VERBOSE_INIT disabled48 49// RUN: env OMP_TOOL_LIBRARIES=%t.tool_dir/tool.so OMP_TOOL_VERBOSE_INIT=disabled \50// RUN:    %libomp-run | FileCheck %s51 52// 3.3 OMP_TOOL_VERBOSE_INIT to stdout53 54// RUN: %libomp-compile -DCODE && env OMP_TOOL_LIBRARIES=%t.tool_dir/tool.so \55// RUN:    OMP_TOOL_VERBOSE_INIT=stdout %libomp-run | \56// RUN:    FileCheck %s -DPARENTPATH=%t.tool_dir --check-prefixes CHECK,TOOLLIB57 58// 3.4 OMP_TOOL_VERBOSE_INIT to stderr, check merged stdout and stderr59 60// RUN: env OMP_TOOL_LIBRARIES=%t.tool_dir/tool.so OMP_TOOL_VERBOSE_INIT=stderr \61// RUN:    %libomp-run 2>&1 | \62// RUN:    FileCheck %s -DPARENTPATH=%t.tool_dir --check-prefixes CHECK,TOOLLIB63 64// 3.5 OMP_TOOL_VERBOSE_INIT to stderr, check just stderr65 66// RUN: env OMP_TOOL_LIBRARIES=%t.tool_dir/tool.so OMP_TOOL_VERBOSE_INIT=stderr \67// RUN:    %libomp-run 2>&1 >/dev/null | \68// RUN:    FileCheck %s -DPARENTPATH=%t.tool_dir --check-prefixes TOOLLIB69 70// 3.6 OMP_TOOL_VERBOSE_INIT to file "init.log"71 72// RUN: env OMP_TOOL_LIBRARIES=%t.tool_dir/tool.so OMP_TOOL_VERBOSE_INIT=%t.tool_dir/init.log \73// RUN:    %libomp-run | FileCheck %s && cat %t.tool_dir/init.log | \74// RUN:    FileCheck %s -DPARENTPATH=%t.tool_dir --check-prefixes TOOLLIB75 76 77// REQUIRES: ompt78// clang-format on79 80/*81 *  This file contains code for an OMPT shared library tool to be82 *  loaded and the code for the OpenMP executable.83 *  -DTOOL enables the code for the tool during compilation84 *  -DCODE enables the code for the executable during compilation85 */86 87// clang-format off88// Check if libomp supports the callbacks for this test.89// CHECK-NOT: {{^}}0: Could not register callback90 91// ADDRSPACE: ----- START LOGGING OF TOOL REGISTRATION -----92// ADDRSPACE-NEXT: Search for OMP tool in current address space... Success.93// ADDRSPACE-NEXT: Tool was started and is using the OMPT interface.94// ADDRSPACE-NEXT: ----- END LOGGING OF TOOL REGISTRATION -----95 96// TOOLLIB: ----- START LOGGING OF TOOL REGISTRATION -----97// TOOLLIB-NEXT: Search for OMP tool in current address space... Failed.98// TOOLLIB-NEXT: Searching tool libraries...99// TOOLLIB-NEXT: OMP_TOOL_LIBRARIES = [[PARENTPATH]]/tool.so100// TOOLLIB-NEXT: Opening [[PARENTPATH]]/tool.so... Success.101// TOOLLIB-NEXT: Searching for ompt_start_tool in102// TOOLLIB-SAME: [[PARENTPATH]]/tool.so... Success.103// TOOLLIB-NEXT: Tool was started and is using the OMPT interface.104// TOOLLIB-NEXT: ----- END LOGGING OF TOOL REGISTRATION -----105// clang-format on106 107#ifdef CODE108#include "omp.h"109 110int main() {111#pragma omp parallel num_threads(2)112  {113  }114 115  // clang-format off116  // CHECK-NOT: ----- START LOGGING OF TOOL REGISTRATION -----117  // CHECK-NOT: ----- END LOGGING OF TOOL REGISTRATION -----118 119  // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]120  // CHECK: {{^}}0: ompt_event_runtime_shutdown121  // clang-format on122 123  return 0;124}125 126#endif /* CODE */127 128#ifdef TOOL129 130#include <stdio.h>131#include <omp-tools.h>132 133int ompt_initialize(ompt_function_lookup_t lookup, int initial_device_num,134                    ompt_data_t *tool_data) {135  printf("0: NULL_POINTER=%p\n", (void *)NULL);136  return 1; // success137}138 139void ompt_finalize(ompt_data_t *tool_data) {140  printf("0: ompt_event_runtime_shutdown\n");141}142 143ompt_start_tool_result_t *ompt_start_tool(unsigned int omp_version,144                                          const char *runtime_version) {145  static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize,146                                                            &ompt_finalize, 0};147  return &ompt_start_tool_result;148}149#endif /* TOOL */150