blob: 6bb635bf9ea2592642ba0cd8eeca085273f0d9cc (
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
|
// { dg-additional-options "-std=c++11 -O0" }
#include <vector>
constexpr unsigned
fib (unsigned n)
{
return n <= 2 ? 1 : fib (n-1) + fib (n-2);
}
int
test1 ()
{
std::vector<int> v;
for (unsigned i = 0; i <= 9; i++)
v.push_back (1);
int sum = 0;
for (int k = 0; k < 10; k++)
#pragma omp tile sizes(fib(4))
for (int i : v) {
for (int j = 8; j != -2; --j)
sum = sum + i;
}
return sum;
}
int
test2 ()
{
std::vector<int> v;
for (unsigned i = 0; i <= 10; i++)
v.push_back (i);
int sum = 0;
for (int k = 0; k < 10; k++)
#pragma omp parallel for collapse(2) reduction(+:sum)
#pragma omp tile sizes(fib(4), 1)
for (int i : v)
for (int j = 8; j > -2; --j)
sum = sum + i;
return sum;
}
int
main ()
{
if (test1 () != 1000)
__builtin_abort ();
if (test2 () != 5500)
__builtin_abort ();
}
|