blob: 9d626c028df04962a9efaa032eaf554691373af3 (
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
// PR c++/
// { dg-do run }
// { dg-options "-std=c++0x -fopenmp" }
extern "C" void abort ();
int cnt;
template <typename T>
void
f0 (T, int)
{
abort ();
}
template <>
void
f0<int> (int, int type)
{
if (type != 0)
abort ();
#pragma omp atomic
cnt++;
}
template <>
void
f0<const char *> (const char *, int type)
{
if (type != 1)
abort ();
#pragma omp atomic
cnt++;
}
template <typename T>
void
f1 ()
{
#pragma omp parallel for
for (auto i = 0; i < 10; i++)
f0 (i, 0);
}
template <typename T>
void
f2 ()
{
#pragma omp parallel for
for (auto i = T (0); i < T (10); i += T (1))
f0 (i, 0);
}
void
f3 ()
{
#pragma omp parallel for
for (auto i = 0; i < 10; i++)
f0 (i, 0);
}
const char *p = "abcdefghij";
template <typename T>
void
f4 ()
{
#pragma omp parallel for
for (auto i = p; i < p + 10; i++)
f0 (i, 1);
}
template <typename T>
void
f5 ()
{
#pragma omp parallel for
for (auto i = T (p); i < T (p + 10); i++)
f0 (i, 1);
}
void
f6 ()
{
#pragma omp parallel for
for (auto i = p; i < p + 10; i++)
f0 (i, 1);
}
int
main ()
{
f1<int> ();
if (cnt != 10)
abort ();
f2<int> ();
if (cnt != 20)
abort ();
f3 ();
if (cnt != 30)
abort ();
f4<int> ();
if (cnt != 40)
abort ();
f5<const char *> ();
if (cnt != 50)
abort ();
f6 ();
if (cnt != 60)
abort ();
}
|