Skip to content

[OpenMP] Move tool tests out of individual folders #150780

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

boomanaiden154
Copy link
Contributor

I did not realize that these were originally in separate folders to allow for the use of %T. Now that we have switched over to creating dirs using %t, we can move these into a common folder and make things a little bit more clean.

I did not realize that these were originally in separate folders to
allow for the use of %T. Now that we have switched over to creating dirs
using %t, we can move these into a common folder and make things a
little bit more clean.
@llvmbot llvmbot added the openmp:libomp OpenMP host runtime label Jul 26, 2025
Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff HEAD~1 HEAD --extensions c -- openmp/runtime/test/ompt/loadtool/tool_available.c openmp/runtime/test/ompt/loadtool/tool_available_search.c openmp/runtime/test/ompt/loadtool/tool_not_available.c
View the diff from clang-format here.
diff --git a/openmp/runtime/test/ompt/loadtool/tool_available.c b/openmp/runtime/test/ompt/loadtool/tool_available.c
index a08581b9a..05b36cd7f 100644
--- a/openmp/runtime/test/ompt/loadtool/tool_available.c
+++ b/openmp/runtime/test/ompt/loadtool/tool_available.c
@@ -2,7 +2,7 @@
 
 // RUN: mkdir -p %t.tool_dir
 
-// 1. "statically-linking the tool’s definition of ompt_start_tool into an 
+// 1. "statically-linking the tool’s definition of ompt_start_tool into an
 //     OpenMP application"
 
 // RUN: %libomp-compile -DCODE -DTOOL && env OMP_TOOL_VERBOSE_INIT=stdout \
@@ -13,14 +13,14 @@
 
 // RUN: %clang %flags -DTOOL -shared -fPIC %s -o %t.tool_dir/tool.so
 
-// 2. "introducing a dynamically-linked library that includes the tool’s 
+// 2. "introducing a dynamically-linked library that includes the tool’s
 //    definition of ompt_start_tool into the application’s address space"
 
 // 2.1 Link with tool during compilation
 
 // RUN: %libomp-compile -DCODE %no-as-needed-flag %t.tool_dir/tool.so && \
 // RUN:    env OMP_TOOL_VERBOSE_INIT=stdout %libomp-run | FileCheck %s \
-// RUN:    --check-prefixes CHECK,ADDRSPACE 
+// RUN:    --check-prefixes CHECK,ADDRSPACE
 
 // 2.2 Link with tool during compilation, but AFTER the runtime
 
@@ -35,10 +35,10 @@
 // RUN:    --check-prefixes CHECK,ADDRSPACE
 
 // 3. "providing the name of a dynamically-linked library appropriate for the
-//    architecture and operating system used by the application in the 
+//    architecture and operating system used by the application in the
 //    tool-libraries-var ICV"
 
-// 3.1 OMP_TOOL_VERBOSE_INIT not set 
+// 3.1 OMP_TOOL_VERBOSE_INIT not set
 
 // RUN: %libomp-compile -DCODE && \
 // RUN:    env OMP_TOOL_LIBRARIES=%t.tool_dir/tool.so %libomp-run | FileCheck %s
@@ -72,7 +72,6 @@
 // RUN:    %libomp-run | FileCheck %s && cat %t.tool_dir/init.log | \
 // RUN:    FileCheck %s -DPARENTPATH=%t.tool_dir --check-prefixes TOOLLIB
 
-
 // REQUIRES: ompt
 
 /*
@@ -103,9 +102,8 @@
 #ifdef CODE
 #include "omp.h"
 
-int main()
-{
-  #pragma omp parallel num_threads(2)
+int main() {
+#pragma omp parallel num_threads(2)
   {
   }
 
@@ -127,20 +125,18 @@ int main()
 
 int ompt_initialize(ompt_function_lookup_t lookup, int initial_device_num,
                     ompt_data_t *tool_data) {
-  printf("0: NULL_POINTER=%p\n", (void*)NULL);
-  return 1; //success
+  printf("0: NULL_POINTER=%p\n", (void *)NULL);
+  return 1; // success
 }
 
-void ompt_finalize(ompt_data_t* tool_data)
-{
+void ompt_finalize(ompt_data_t *tool_data) {
   printf("0: ompt_event_runtime_shutdown\n");
 }
 
-ompt_start_tool_result_t* ompt_start_tool(
-  unsigned int omp_version,
-  const char *runtime_version)
-{
-  static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize,&ompt_finalize, 0};
+ompt_start_tool_result_t *ompt_start_tool(unsigned int omp_version,
+                                          const char *runtime_version) {
+  static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize,
+                                                            &ompt_finalize, 0};
   return &ompt_start_tool_result;
 }
 #endif /* TOOL */
diff --git a/openmp/runtime/test/ompt/loadtool/tool_available_search.c b/openmp/runtime/test/ompt/loadtool/tool_available_search.c
index 73e2dea1b..ff9fa255a 100644
--- a/openmp/runtime/test/ompt/loadtool/tool_available_search.c
+++ b/openmp/runtime/test/ompt/loadtool/tool_available_search.c
@@ -1,10 +1,12 @@
 // RUN: mkdir -p %t.tool_dir
 // RUN: %clang %flags -shared -fPIC %s -o %t.tool_dir/first_tool.so
-// RUN: %clang %flags -DTOOL -DSECOND_TOOL -shared -fPIC %s -o %t.tool_dir/second_tool.so
-// RUN: %clang %flags -DTOOL -DTHIRD_TOOL -shared -fPIC %s -o %t.tool_dir/third_tool.so
-// RUN: %libomp-compile -DCODE
-// RUN: env OMP_TOOL_LIBRARIES=%t.tool_dir/non_existing_file.so:%t.tool_dir/first_tool.so:%t.tool_dir/second_tool.so:%t.tool_dir/third_tool.so \
-// RUN: OMP_TOOL_VERBOSE_INIT=stdout %libomp-run | FileCheck %s -DPARENTPATH=%t.tool_dir
+// RUN: %clang %flags -DTOOL -DSECOND_TOOL -shared -fPIC %s -o
+// %t.tool_dir/second_tool.so RUN: %clang %flags -DTOOL -DTHIRD_TOOL -shared
+// -fPIC %s -o %t.tool_dir/third_tool.so RUN: %libomp-compile -DCODE
+// RUN: env
+// OMP_TOOL_LIBRARIES=%t.tool_dir/non_existing_file.so:%t.tool_dir/first_tool.so:%t.tool_dir/second_tool.so:%t.tool_dir/third_tool.so
+// \ RUN: OMP_TOOL_VERBOSE_INIT=stdout %libomp-run | FileCheck %s
+// -DPARENTPATH=%t.tool_dir
 
 // REQUIRES: ompt
 // XFAIL: darwin
@@ -27,16 +29,15 @@
 // CHECK-SAME: [[PARENTPATH]]/second_tool.so
 // CHECK-SAME: [[PARENTPATH]]/third_tool.so
 // CHECK-NEXT: Opening [[PARENTPATH]]/non_existing_file.so... Failed:
-// CHECK-SAME: [[PARENTPATH]]/non_existing_file.so: {{cannot open shared object file|open failed}}:
-// CHECK-SAME: No such file or directory
-// CHECK-NEXT: Opening [[PARENTPATH]]/first_tool.so... Success.
-// CHECK-NEXT: Searching for ompt_start_tool in
-// CHECK-SAME: [[PARENTPATH]]/first_tool.so... Failed:
-// CHECK-SAME: {{.*/first_tool.so: undefined symbol: ompt_start_tool|ld.so.1: .*: ompt_start_tool: can't find symbol}}
-// CHECK-NEXT: Opening [[PARENTPATH]]/second_tool.so... Success.
-// CHECK-NEXT: Searching for ompt_start_tool in
-// CHECK-SAME: [[PARENTPATH]]/second_tool.so... 0: Do not initialize tool
-// CHECK-NEXT: Found but not using the OMPT interface.
+// CHECK-SAME: [[PARENTPATH]]/non_existing_file.so: {{cannot open shared object
+// file|open failed}}: CHECK-SAME: No such file or directory CHECK-NEXT: Opening
+// [[PARENTPATH]]/first_tool.so... Success. CHECK-NEXT: Searching for
+// ompt_start_tool in CHECK-SAME: [[PARENTPATH]]/first_tool.so... Failed:
+// CHECK-SAME: {{.*/first_tool.so: undefined symbol: ompt_start_tool|ld.so.1:
+// .*: ompt_start_tool: can't find symbol}} CHECK-NEXT: Opening
+// [[PARENTPATH]]/second_tool.so... Success. CHECK-NEXT: Searching for
+// ompt_start_tool in CHECK-SAME: [[PARENTPATH]]/second_tool.so... 0: Do not
+// initialize tool CHECK-NEXT: Found but not using the OMPT interface.
 // CHECK-NEXT: Continuing search...
 // CHECK-NEXT: Opening [[PARENTPATH]]/third_tool.so... Success.
 // CHECK-NEXT: Searching for ompt_start_tool in
@@ -54,24 +55,21 @@
 // CHECK-DAG: {{^}}0: control_tool()=-1
 // CHECK: {{^}}0: Tool finalized
 
-
 #ifdef CODE
 #include "stdio.h"
 #include "omp.h"
 #include "omp-tools.h"
 
-int main()
-{
-  #pragma omp parallel num_threads(2)
+int main() {
+#pragma omp parallel num_threads(2)
   {
-    #pragma omp master
+#pragma omp master
     {
       int result = omp_control_tool(omp_control_tool_start, 0, NULL);
       printf("0: control_tool()=%d\n", result);
     }
   }
 
-
   return 0;
 }
 
@@ -84,10 +82,8 @@ int main()
 
 #ifdef SECOND_TOOL
 // The second tool has an implementation of ompt_start_tool that returns NULL
-ompt_start_tool_result_t* ompt_start_tool(
-  unsigned int omp_version,
-  const char *runtime_version)
-{
+ompt_start_tool_result_t *ompt_start_tool(unsigned int omp_version,
+                                          const char *runtime_version) {
   printf("0: Do not initialize tool\n");
   return NULL;
 }
@@ -95,33 +91,28 @@ ompt_start_tool_result_t* ompt_start_tool(
 // The third tool has an implementation of ompt_start_tool that returns a
 // pointer to a valid instance of ompt_start_tool_result_t
 
-static void
-on_ompt_callback_thread_begin(
-  ompt_thread_t thread_type,
-  ompt_data_t *thread_data)
-{
+static void on_ompt_callback_thread_begin(ompt_thread_t thread_type,
+                                          ompt_data_t *thread_data) {
   printf("0: ompt_event_thread_begin\n");
 }
 
 int ompt_initialize(ompt_function_lookup_t lookup, int initial_device_num,
                     ompt_data_t *tool_data) {
-  ompt_set_callback_t ompt_set_callback = (ompt_set_callback_t) lookup("ompt_set_callback");
-  ompt_set_callback(ompt_callback_thread_begin, (ompt_callback_t)on_ompt_callback_thread_begin);
+  ompt_set_callback_t ompt_set_callback =
+      (ompt_set_callback_t)lookup("ompt_set_callback");
+  ompt_set_callback(ompt_callback_thread_begin,
+                    (ompt_callback_t)on_ompt_callback_thread_begin);
   printf("0: Tool initialized\n");
   return 1;
 }
 
-void ompt_finalize(ompt_data_t *tool_data)
-{
-  printf("0: Tool finalized\n");
-}
+void ompt_finalize(ompt_data_t *tool_data) { printf("0: Tool finalized\n"); }
 
-ompt_start_tool_result_t* ompt_start_tool(
-  unsigned int omp_version,
-  const char *runtime_version)
-{
+ompt_start_tool_result_t *ompt_start_tool(unsigned int omp_version,
+                                          const char *runtime_version) {
   printf("0: Do initialize tool\n");
-  static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize,&ompt_finalize, 0};
+  static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize,
+                                                            &ompt_finalize, 0};
   return &ompt_start_tool_result;
 }
 #endif
diff --git a/openmp/runtime/test/ompt/loadtool/tool_not_available.c b/openmp/runtime/test/ompt/loadtool/tool_not_available.c
index df56d31cb..6d6077775 100644
--- a/openmp/runtime/test/ompt/loadtool/tool_not_available.c
+++ b/openmp/runtime/test/ompt/loadtool/tool_not_available.c
@@ -7,14 +7,14 @@
 
 // RUN: %libomp-compile -DCODE -DTOOL && \
 // RUN:    env OMP_TOOL_VERBOSE_INIT=stdout %libomp-run | \
-// RUN:    FileCheck %s --check-prefixes CHECK,ADDRSPACE 
+// RUN:    FileCheck %s --check-prefixes CHECK,ADDRSPACE
 
 // Note: We should compile the tool without -fopenmp as other tools developer
 //      would do. Otherwise this test may pass for the wrong reasons on Darwin.
 
 // RUN: %clang %flags -DTOOL -shared -fPIC %s -o %t.tool_dir/tool.so
 
-// 2. "introducing a dynamically-linked library that includes the tool’s 
+// 2. "introducing a dynamically-linked library that includes the tool’s
 //    definition of ompt_start_tool into the application’s address space"
 
 // 2.1 Link with tool during compilation
@@ -27,16 +27,16 @@
 
 // RUN: %libomp-compile -DCODE -lomp %no-as-needed-flag %t.tool_dir/tool.so && \
 // RUN:    env OMP_TOOL_VERBOSE_INIT=stdout %libomp-run | \
-// RUN:    FileCheck %s --check-prefixes CHECK,ADDRSPACE 
+// RUN:    FileCheck %s --check-prefixes CHECK,ADDRSPACE
 
 // 2.3 Inject tool via the dynamic loader
 
 // RUN: %libomp-compile -DCODE && \
 // RUN:    env OMP_TOOL_VERBOSE_INIT=stdout %preload-tool %libomp-run | \
-// RUN:    FileCheck %s --check-prefixes CHECK,ADDRSPACE 
+// RUN:    FileCheck %s --check-prefixes CHECK,ADDRSPACE
 
 // 3. "providing the name of a dynamically-linked library appropriate for the
-//    architecture and operating system used by the application in the 
+//    architecture and operating system used by the application in the
 //    tool-libraries-var ICV"
 
 // RUN: %libomp-compile -DCODE && env OMP_TOOL_LIBRARIES=%t.tool_dir/tool.so \
@@ -46,8 +46,8 @@
 // REQUIRES: ompt
 
 /*
- *  This file contains code for an OMPT shared library tool to be 
- *  loaded and the code for the OpenMP executable. 
+ *  This file contains code for an OMPT shared library tool to be
+ *  loaded and the code for the OpenMP executable.
  *  -DTOOL enables the code for the tool during compilation
  *  -DCODE enables the code for the executable during compilation
  */
@@ -57,18 +57,16 @@
 #include "omp.h"
 #include "omp-tools.h"
 
-int main()
-{
-  #pragma omp parallel num_threads(2)
+int main() {
+#pragma omp parallel num_threads(2)
   {
-    #pragma omp master
+#pragma omp master
     {
       int result = omp_control_tool(omp_control_tool_start, 0, NULL);
       printf("0: control_tool()=%d\n", result);
     }
   }
 
-
   // Check if libomp supports the callbacks for this test.
   // CHECK-NOT: {{^}}0: Could not register callback
 
@@ -98,7 +96,6 @@ int main()
   // TOOLLIB-NEXT: ----- END LOGGING OF TOOL REGISTRATION -----
 
   // CHECK: {{^}}0: control_tool()=-2
-  
 
   return 0;
 }
@@ -110,10 +107,8 @@ int main()
 #include <omp-tools.h>
 #include "stdio.h"
 
-ompt_start_tool_result_t* ompt_start_tool(
-  unsigned int omp_version,
-  const char *runtime_version)
-{
+ompt_start_tool_result_t *ompt_start_tool(unsigned int omp_version,
+                                          const char *runtime_version) {
   printf("0: Do not initialize tool\n");
   return NULL;
 }

@jprotze
Copy link
Collaborator

jprotze commented Jul 26, 2025

Is there any policy to deal with clang-format and long RUN/CHECK lines in tests? Can we set ColumnLimit:0 for the test directory?

@boomanaiden154
Copy link
Contributor Author

Is there any policy to deal with clang-format and long RUN/CHECK lines in tests? Can we set ColumnLimit:0 for the test directory?

I've seen some tests use the // clang-format off blocks around the run lines. Trying to keep the code in the test conformant with line length rules I think still makes sense.

@boomanaiden154 boomanaiden154 merged commit 8c07a63 into llvm:main Jul 26, 2025
10 of 11 checks passed
@boomanaiden154 boomanaiden154 deleted the openmp-move-tests-common-folder-capital-t branch July 26, 2025 18:07
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Jul 28, 2025
I did not realize that these were originally in separate folders to
allow for the use of %T. Now that we have switched over to creating dirs
using %t, we can move these into a common folder and make things a
little bit more clean.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
openmp:libomp OpenMP host runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants