1 /* Test that all loop iterations are touched. This doesn't verify
2 scheduling order, merely coverage. */
4 /* { dg-require-effective-target sync_int_long } */
13 static int S
, E
, INCR
, CHUNK
, NTHR
;
16 static void clean_data (void)
18 memset (data
, -1, sizeof (data
));
21 static void test_data (void)
25 for (i
= 0; i
< S
; ++i
)
26 assert (data
[i
] == -1);
28 for (j
= 0; i
< E
; ++i
, j
= (j
+ 1) % INCR
)
30 assert (data
[i
] != -1);
32 assert (data
[i
] == -1);
35 assert (data
[i
] == -1);
38 static void set_data (long i
, int val
)
41 assert (i
>= 0 && i
< N
);
42 old
= __sync_lock_test_and_set (data
+i
, val
);
47 #define TMPL_1(sched) \
48 static void f_##sched##_1 (void *dummy) \
50 int iam = omp_get_thread_num (); \
52 if (GOMP_loop_##sched##_start (S, E, INCR, CHUNK, &s0, &e0)) \
55 for (i = s0; i < e0; i += INCR) \
58 while (GOMP_loop_##sched##_next (&s0, &e0)); \
61 static void t_##sched##_1 (void) \
64 GOMP_parallel_start (f_##sched##_1, NULL, NTHR); \
65 f_##sched##_1 (NULL); \
66 GOMP_parallel_end (); \
74 #define TMPL_2(sched) \
75 static void f_##sched##_2 (void *dummy) \
77 int iam = omp_get_thread_num (); \
79 while (GOMP_loop_##sched##_next (&s0, &e0)) \
81 for (i = s0; i < e0; i += INCR) \
84 GOMP_loop_end_nowait (); \
86 static void t_##sched##_2 (void) \
89 GOMP_parallel_loop_##sched##_start \
90 (f_##sched##_2, NULL, NTHR, S, E, INCR, CHUNK); \
91 f_##sched##_2 (NULL); \
92 GOMP_parallel_end (); \
100 static void test (void)
116 S
= 0, E
= N
, INCR
= 1, CHUNK
= 4;
119 S
= 0, E
= N
, INCR
= 2, CHUNK
= 4;
122 S
= 1, E
= N
-1, INCR
= 1, CHUNK
= 5;
125 S
= 1, E
= N
-1, INCR
= 2, CHUNK
= 5;
128 S
= 2, E
= 4, INCR
= 1, CHUNK
= 1;
131 S
= 0, E
= N
, INCR
= 1, CHUNK
= 0;
135 S
= 1, E
= N
-1, INCR
= 1, CHUNK
= 0;