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

via Openmp-commits openmp-commits at lists.llvm.org
Wed Feb 25 09:06:26 PST 2026


================
@@ -4,14 +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()); }
 
 #pragma omp parallel
 #pragma omp single
   {
-    if (omp_get_num_threads() != 3)
+    if (omp_get_num_threads() != N)
----------------
jprotze wrote:

According to the spec, this is also wrong. I think, the check should be `omp_get_num_threads() <= N+1`. It cannot be more than omp_get_max_threads() returns before the parallel.

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


More information about the Openmp-commits mailing list