[Openmp-commits] [openmp] [openmp] Fix bug63197.c test with 3 cores (PR #183269)

Nikita Popov via Openmp-commits openmp-commits at lists.llvm.org
Wed Feb 25 06:14:33 PST 2026


https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/183269

>From 999a6849c2ab34350aea51e3912fa72907d7e701 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Wed, 25 Feb 2026 11:11:18 +0100
Subject: [PATCH 1/2] [openmp] Fix bug63197.c test with 3 cores

This test assumes that the number of available threads is not 3,
otherwise `#pragma omp parallel` and `#pragma omp parallel
num_thread(3)` are naturally going to do the same thing.

Add a check against `omp_get_max_threads()` and PASS the test in
that case.
---
 openmp/runtime/test/parallel/bug63197.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/openmp/runtime/test/parallel/bug63197.c b/openmp/runtime/test/parallel/bug63197.c
index c60f400b19a8f..a8367b4a15cc3 100644
--- a/openmp/runtime/test/parallel/bug63197.c
+++ b/openmp/runtime/test/parallel/bug63197.c
@@ -8,6 +8,13 @@ int main(int argc, char *argv[]) {
 #pragma omp single
   { printf("BBB %2d\n", omp_get_num_threads()); }
 
+  // This test relies on the number of available threads
+  // being something other than 3.
+  if (omp_get_max_threads() == 3) {
+    printf("PASS\n");
+    return 0;
+  }
+
 #pragma omp parallel
 #pragma omp single
   {

>From c0836a5e85e54723ea1e6c758cba02a23c4686d1 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Wed, 25 Feb 2026 15:14:01 +0100
Subject: [PATCH 2/2] Pick number based on max threads instead

---
 openmp/runtime/test/parallel/bug63197.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/openmp/runtime/test/parallel/bug63197.c b/openmp/runtime/test/parallel/bug63197.c
index a8367b4a15cc3..734f5c89c0a2d 100644
--- a/openmp/runtime/test/parallel/bug63197.c
+++ b/openmp/runtime/test/parallel/bug63197.c
@@ -4,21 +4,15 @@
 #include <stdio.h>
 
 int main(int argc, char *argv[]) {
-#pragma omp parallel num_threads(3) if (0)
+  unsigned N = omp_get_max_threads() - 1;
+#pragma omp parallel num_threads(N) if (0)
 #pragma omp single
   { printf("BBB %2d\n", omp_get_num_threads()); }
 
-  // This test relies on the number of available threads
-  // being something other than 3.
-  if (omp_get_max_threads() == 3) {
-    printf("PASS\n");
-    return 0;
-  }
-
 #pragma omp parallel
 #pragma omp single
   {
-    if (omp_get_num_threads() != 3)
+    if (omp_get_num_threads() != N)
       printf("PASS\n");
   }
   return 0;



More information about the Openmp-commits mailing list