aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/libgomp/testsuite/libgomp.c/thread-limit-1.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc-4.9/libgomp/testsuite/libgomp.c/thread-limit-1.c')
-rw-r--r--gcc-4.9/libgomp/testsuite/libgomp.c/thread-limit-1.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc-4.9/libgomp/testsuite/libgomp.c/thread-limit-1.c b/gcc-4.9/libgomp/testsuite/libgomp.c/thread-limit-1.c
new file mode 100644
index 000000000..6cc716bee
--- /dev/null
+++ b/gcc-4.9/libgomp/testsuite/libgomp.c/thread-limit-1.c
@@ -0,0 +1,41 @@
+/* { dg-do run } */
+/* { dg-set-target-env-var OMP_THREAD_LIMIT "6" } */
+
+#include <stdlib.h>
+#include <unistd.h>
+
+int
+main ()
+{
+ if (omp_get_thread_limit () != 6)
+ return 0;
+ omp_set_dynamic (0);
+ omp_set_nested (1);
+ #pragma omp parallel num_threads (3)
+ if (omp_get_num_threads () != 3)
+ abort ();
+ #pragma omp parallel num_threads (3)
+ if (omp_get_num_threads () != 3)
+ abort ();
+ #pragma omp parallel num_threads (8)
+ if (omp_get_num_threads () > 6)
+ abort ();
+ #pragma omp parallel num_threads (6)
+ if (omp_get_num_threads () != 6)
+ abort ();
+ int cnt = 0;
+ #pragma omp parallel num_threads (5)
+ #pragma omp parallel num_threads (5)
+ #pragma omp parallel num_threads (2)
+ {
+ int v;
+ #pragma omp atomic capture
+ v = ++cnt;
+ if (v > 6)
+ abort ();
+ usleep (10000);
+ #pragma omp atomic
+ --cnt;
+ }
+ return 0;
+}