blob: 91564371ab238ea92dcf795c51ee7745dac09bc5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/* Trivial test of ordered. */
/* { dg-require-effective-target sync_int_long } */
#include <omp.h>
#include <string.h>
#include <assert.h>
#include "libgomp_g.h"
#define N 100
static int next;
static int CHUNK, NTHR;
static void clean_data (void)
{
next = 0;
}
static void set_data (long i)
{
int n = __sync_fetch_and_add (&next, 1);
assert (n == i);
}
#define TMPL_1(sched) \
static void f_##sched##_1 (void *dummy) \
{ \
long s0, e0, i; \
if (GOMP_loop_ordered_##sched##_start (0, N, 1, CHUNK, &s0, &e0)) \
do \
{ \
for (i = s0; i < e0; ++i) \
{ \
GOMP_ordered_start (); \
set_data (i); \
GOMP_ordered_end (); \
} \
} \
while (GOMP_loop_ordered_##sched##_next (&s0, &e0)); \
GOMP_loop_end (); \
} \
static void t_##sched##_1 (void) \
{ \
clean_data (); \
GOMP_parallel_start (f_##sched##_1, NULL, NTHR); \
f_##sched##_1 (NULL); \
GOMP_parallel_end (); \
}
TMPL_1(static)
TMPL_1(dynamic)
TMPL_1(guided)
static void test (void)
{
t_static_1 ();
t_dynamic_1 ();
t_guided_1 ();
}
int main()
{
omp_set_dynamic (0);
NTHR = 4;
CHUNK = 1;
test ();
CHUNK = 5;
test ();
CHUNK = 7;
test ();
CHUNK = 0;
t_static_1 ();
return 0;
}
|