[lld][WebAssembly] Introduce Ctx::arg
[llvm-project.git] / openmp / runtime / test / ompt / loadtool / tool_available / tool_available.c
blobba6ce32b921ea3cb06bcc2a02f808a14c163c226
1 // The OpenMP standard defines 3 ways of providing ompt_start_tool:
3 // 1. "statically-linking the tool’s definition of ompt_start_tool into an
4 // OpenMP application"
6 // RUN: %libomp-compile -DCODE -DTOOL && env OMP_TOOL_VERBOSE_INIT=stdout \
7 // RUN: %libomp-run | FileCheck %s --check-prefixes CHECK,ADDRSPACE
9 // Note: We should compile the tool without -fopenmp as other tools developer
10 // would do. Otherwise this test may pass for the wrong reasons on Darwin.
12 // RUN: %clang %flags -DTOOL -shared -fPIC %s -o %T/tool.so
14 // 2. "introducing a dynamically-linked library that includes the tool’s
15 // definition of ompt_start_tool into the application’s address space"
17 // 2.1 Link with tool during compilation
19 // RUN: %libomp-compile -DCODE %no-as-needed-flag %T/tool.so && \
20 // RUN: env OMP_TOOL_VERBOSE_INIT=stdout %libomp-run | FileCheck %s \
21 // RUN: --check-prefixes CHECK,ADDRSPACE
23 // 2.2 Link with tool during compilation, but AFTER the runtime
25 // RUN: %libomp-compile -DCODE -lomp %no-as-needed-flag %T/tool.so && \
26 // RUN: env OMP_TOOL_VERBOSE_INIT=stdout %libomp-run | FileCheck %s \
27 // RUN: --check-prefixes CHECK,ADDRSPACE
29 // 2.3 Inject tool via the dynamic loader
31 // RUN: %libomp-compile -DCODE && env OMP_TOOL_VERBOSE_INIT=stdout \
32 // RUN: %preload-tool %libomp-run | FileCheck %s \
33 // RUN: --check-prefixes CHECK,ADDRSPACE
35 // 3. "providing the name of a dynamically-linked library appropriate for the
36 // architecture and operating system used by the application in the
37 // tool-libraries-var ICV"
39 // 3.1 OMP_TOOL_VERBOSE_INIT not set
41 // RUN: %libomp-compile -DCODE && \
42 // RUN: env OMP_TOOL_LIBRARIES=%T/tool.so %libomp-run | FileCheck %s
44 // 3.2 OMP_TOOL_VERBOSE_INIT disabled
46 // RUN: env OMP_TOOL_LIBRARIES=%T/tool.so OMP_TOOL_VERBOSE_INIT=disabled \
47 // RUN: %libomp-run | FileCheck %s
49 // 3.3 OMP_TOOL_VERBOSE_INIT to stdout
51 // RUN: %libomp-compile -DCODE && env OMP_TOOL_LIBRARIES=%T/tool.so \
52 // RUN: OMP_TOOL_VERBOSE_INIT=stdout %libomp-run | \
53 // RUN: FileCheck %s -DPARENTPATH=%T --check-prefixes CHECK,TOOLLIB
55 // 3.4 OMP_TOOL_VERBOSE_INIT to stderr, check merged stdout and stderr
57 // RUN: env OMP_TOOL_LIBRARIES=%T/tool.so OMP_TOOL_VERBOSE_INIT=stderr \
58 // RUN: %libomp-run 2>&1 | \
59 // RUN: FileCheck %s -DPARENTPATH=%T --check-prefixes CHECK,TOOLLIB
61 // 3.5 OMP_TOOL_VERBOSE_INIT to stderr, check just stderr
63 // RUN: env OMP_TOOL_LIBRARIES=%T/tool.so OMP_TOOL_VERBOSE_INIT=stderr \
64 // RUN: %libomp-run 2>&1 >/dev/null | \
65 // RUN: FileCheck %s -DPARENTPATH=%T --check-prefixes TOOLLIB
67 // 3.6 OMP_TOOL_VERBOSE_INIT to file "init.log"
69 // RUN: env OMP_TOOL_LIBRARIES=%T/tool.so OMP_TOOL_VERBOSE_INIT=%T/init.log \
70 // RUN: %libomp-run | FileCheck %s && cat %T/init.log | \
71 // RUN: FileCheck %s -DPARENTPATH=%T --check-prefixes TOOLLIB
74 // REQUIRES: ompt
77 * This file contains code for an OMPT shared library tool to be
78 * loaded and the code for the OpenMP executable.
79 * -DTOOL enables the code for the tool during compilation
80 * -DCODE enables the code for the executable during compilation
83 // Check if libomp supports the callbacks for this test.
84 // CHECK-NOT: {{^}}0: Could not register callback
86 // ADDRSPACE: ----- START LOGGING OF TOOL REGISTRATION -----
87 // ADDRSPACE-NEXT: Search for OMP tool in current address space... Success.
88 // ADDRSPACE-NEXT: Tool was started and is using the OMPT interface.
89 // ADDRSPACE-NEXT: ----- END LOGGING OF TOOL REGISTRATION -----
91 // TOOLLIB: ----- START LOGGING OF TOOL REGISTRATION -----
92 // TOOLLIB-NEXT: Search for OMP tool in current address space... Failed.
93 // TOOLLIB-NEXT: Searching tool libraries...
94 // TOOLLIB-NEXT: OMP_TOOL_LIBRARIES = [[PARENTPATH]]/tool.so
95 // TOOLLIB-NEXT: Opening [[PARENTPATH]]/tool.so... Success.
96 // TOOLLIB-NEXT: Searching for ompt_start_tool in
97 // TOOLLIB-SAME: [[PARENTPATH]]/tool.so... Success.
98 // TOOLLIB-NEXT: Tool was started and is using the OMPT interface.
99 // TOOLLIB-NEXT: ----- END LOGGING OF TOOL REGISTRATION -----
101 #ifdef CODE
102 #include "omp.h"
104 int main()
106 #pragma omp parallel num_threads(2)
110 // CHECK-NOT: ----- START LOGGING OF TOOL REGISTRATION -----
111 // CHECK-NOT: ----- END LOGGING OF TOOL REGISTRATION -----
113 // CHECK: {{^}}0: NULL_POINTER=[[NULL:.*$]]
114 // CHECK: {{^}}0: ompt_event_runtime_shutdown
116 return 0;
119 #endif /* CODE */
121 #ifdef TOOL
123 #include <stdio.h>
124 #include <omp-tools.h>
126 int ompt_initialize(ompt_function_lookup_t lookup, int initial_device_num,
127 ompt_data_t *tool_data) {
128 printf("0: NULL_POINTER=%p\n", (void*)NULL);
129 return 1; //success
132 void ompt_finalize(ompt_data_t* tool_data)
134 printf("0: ompt_event_runtime_shutdown\n");
137 ompt_start_tool_result_t* ompt_start_tool(
138 unsigned int omp_version,
139 const char *runtime_version)
141 static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize,&ompt_finalize, 0};
142 return &ompt_start_tool_result;
144 #endif /* TOOL */