[Openmp-commits] [openmp] d44e417 - [openmp][tests] Fix bug63197.c (#183508)
via Openmp-commits
openmp-commits at lists.llvm.org
Thu Feb 26 08:26:52 PST 2026
Author: Joachim
Date: 2026-02-26T17:26:47+01:00
New Revision: d44e41794540d7fa85f857228a7616ec8592a7c4
URL: https://github.com/llvm/llvm-project/commit/d44e41794540d7fa85f857228a7616ec8592a7c4
DIFF: https://github.com/llvm/llvm-project/commit/d44e41794540d7fa85f857228a7616ec8592a7c4.diff
LOG: [openmp][tests] Fix bug63197.c (#183508)
#183269 tried to fix the test, but the test can still randomly fail. The
OpenMP spec does not prevent the runtime to chose a smaller team size
than returned from omp_max_threads() for the second parallel region.
Using a larger value than `omp_max_threads()` in a `num_threads` clause
is valid OpenMP code. With a correct OpenMP implementation, the
team-size of the second parallel region must still be smaller or equal
the value returned from `omp_max_threads()`.
Added:
Modified:
openmp/runtime/test/parallel/bug63197.c
Removed:
################################################################################
diff --git a/openmp/runtime/test/parallel/bug63197.c b/openmp/runtime/test/parallel/bug63197.c
index 734f5c89c0a2d..ac4c196d53743 100644
--- a/openmp/runtime/test/parallel/bug63197.c
+++ b/openmp/runtime/test/parallel/bug63197.c
@@ -3,16 +3,22 @@
#include <omp.h>
#include <stdio.h>
+/* This code tests that state pushed for the num_threads clause does not
+ reach the next parallel region. omp_get_max_threads() + 1 can never
+ be chosen as team size for the second parallel and could only be the
+ result of some left-over state from the first parallel.
+ */
+
int main(int argc, char *argv[]) {
- unsigned N = omp_get_max_threads() - 1;
-#pragma omp parallel num_threads(N) if (0)
+ unsigned N = omp_get_max_threads();
+#pragma omp parallel num_threads(N + 1) if (0)
#pragma omp single
{ printf("BBB %2d\n", omp_get_num_threads()); }
#pragma omp parallel
#pragma omp single
{
- if (omp_get_num_threads() != N)
+ if (omp_get_num_threads() <= N)
printf("PASS\n");
}
return 0;
More information about the Openmp-commits
mailing list