1 /* Validate static scheduling iteration dispatch. We only test with
2 even thread distributions here; there are multiple valid solutions
3 for uneven thread distributions. */
12 static int data[N][2];
13 static int INCR, NTHR, CHUNK;
15 static void clean_data (void)
17 memset (data, -1, sizeof (data));
20 static void test_data (void)
22 int n, i, c, thr, iter, chunk;
26 chunk = N / INCR / NTHR;
28 thr = iter = c = i = 0;
30 for (n = 0; n < N; ++n)
34 assert (data[n][0] == thr);
35 assert (data[n][1] == iter);
39 assert (data[n][0] == -1);
40 assert (data[n][1] == -1);
59 static void set_data (long i, int thr, int iter)
62 assert (i >= 0 && i < N);
63 old = __sync_lock_test_and_set (&data[i][0], thr);
65 old = __sync_lock_test_and_set (&data[i][1], iter);
69 static void f_static_1 (void *dummy)
71 int iam = omp_get_thread_num ();
72 long s0, e0, i, count = 0;
73 if (GOMP_loop_static_start (0, N, INCR, CHUNK, &s0, &e0))
76 for (i = s0; i < e0; i += INCR)
77 set_data (i, iam, count);
80 while (GOMP_loop_static_next (&s0, &e0));
84 static void test (void)
87 GOMP_parallel_start (f_static_1, NULL, NTHR);
99 INCR = 1, CHUNK = 0; /* chunk = 360 / 5 = 72 */
102 INCR = 4, CHUNK = 0; /* chunk = 360 / 4 / 5 = 18 */
105 INCR = 1, CHUNK = 4; /* 1 * 4 * 5 = 20 -> 360 / 20 = 18 iterations. */
108 INCR = 3, CHUNK = 4; /* 3 * 4 * 5 = 60 -> 360 / 60 = 6 iterations. */