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
111
112
113
114
115
116
117
|
/**
* This version is stamped on May 10, 2016
*
* Contact:
* Louis-Noel Pouchet <pouchet.ohio-state.edu>
* Tomofumi Yuki <tomofumi.yuki.fr>
*
* Web address: http://polybench.sourceforge.net
*/
/* mvt.c: this file is part of PolyBench/C */
#define plus(i) i = i + ONE
static
void init_array(int n,
int x1[ 40 + 0],
int x2[ 40 + 0],
int y_1[ 40 + 0],
int y_2[ 40 + 0],
int A[ 40 + 0][40 + 0])
{
int i, j;
int ONE = 1;
int THREE = 3;
for (i = 0; i < n; plus(i))
{
x1[i] = (int) (i % n) / n;
x2[i] = (int) ((i + ONE) % n) / n;
y_1[i] = (int) ((i + THREE) % n) / n;
y_2[i] = (int) ((i + 4) % n) / n;
for (j = 0; j < n; plus(j))
A[i][j] = (int) (i*j % n) / n;
}
}
static
int print_array(int n,
int x1[ 40 + 0],
int x2[ 40 + 0])
{
int i;
int ONE = 1;
int res = 0;
for (i = 0; i < n; plus(i)) {
res ^= x1[i];
}
for (i = 0; i < n; plus(i)) {
res ^= x2[i];
}
return res;
}
static
void kernel_mvt(int n,
int x1[ 40 + 0],
int x2[ 40 + 0],
int y_1[ 40 + 0],
int y_2[ 40 + 0],
int A[ 40 + 0][40 + 0])
{
int i, j;
int ONE = 1;
#pragma scop
for (i = 0; i < n; plus(i))
for (j = 0; j < n; plus(j))
x1[i] = x1[i] + A[i][j] * y_1[j];
for (i = 0; i < n; plus(i))
for (j = 0; j < n; plus(j))
x2[i] = x2[i] + A[j][i] * y_2[j];
#pragma endscop
}
int main()
{
int n = 40;
int A[40 + 0][40 + 0];
int x1[40 + 0];
int x2[40 + 0];
int y_1[40 + 0];
int y_2[40 + 0];
init_array (n,
x1,
x2,
y_1,
y_2,
A);
kernel_mvt (n,
x1,
x2,
y_1,
y_2,
A);
return print_array(n, x1, x2);
}
|