AVR: Assert minimal required bit width of section_common::flags.
[gcc.git] / libgomp / testsuite / libgomp.c / ordered-2.c
blob91564371ab238ea92dcf795c51ee7745dac09bc5
1 /* Trivial test of ordered. */
3 /* { dg-require-effective-target sync_int_long } */
5 #include <omp.h>
6 #include <string.h>
7 #include <assert.h>
8 #include "libgomp_g.h"
11 #define N 100
12 static int next;
13 static int CHUNK, NTHR;
15 static void clean_data (void)
17 next = 0;
20 static void set_data (long i)
22 int n = __sync_fetch_and_add (&next, 1);
23 assert (n == i);
27 #define TMPL_1(sched) \
28 static void f_##sched##_1 (void *dummy) \
29 { \
30 long s0, e0, i; \
31 if (GOMP_loop_ordered_##sched##_start (0, N, 1, CHUNK, &s0, &e0)) \
32 do \
33 { \
34 for (i = s0; i < e0; ++i) \
35 { \
36 GOMP_ordered_start (); \
37 set_data (i); \
38 GOMP_ordered_end (); \
39 } \
40 } \
41 while (GOMP_loop_ordered_##sched##_next (&s0, &e0)); \
42 GOMP_loop_end (); \
43 } \
44 static void t_##sched##_1 (void) \
45 { \
46 clean_data (); \
47 GOMP_parallel_start (f_##sched##_1, NULL, NTHR); \
48 f_##sched##_1 (NULL); \
49 GOMP_parallel_end (); \
52 TMPL_1(static)
53 TMPL_1(dynamic)
54 TMPL_1(guided)
56 static void test (void)
58 t_static_1 ();
59 t_dynamic_1 ();
60 t_guided_1 ();
63 int main()
65 omp_set_dynamic (0);
67 NTHR = 4;
69 CHUNK = 1;
70 test ();
72 CHUNK = 5;
73 test ();
75 CHUNK = 7;
76 test ();
78 CHUNK = 0;
79 t_static_1 ();
81 return 0;