-
Notifications
You must be signed in to change notification settings - Fork 0
/
3d125pt.c
89 lines (77 loc) · 7.66 KB
/
3d125pt.c
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
#define BENCH_DIM 3
#define BENCH_FPP 130
#define BENCH_RAD 2
#include "common.h"
double kernel_stencil(SB_TYPE *A1, int compsize, int timestep, bool scop)
{
double start_time = sb_time(), end_time = 0.0;
int dimsize = compsize + BENCH_RAD * 2;
SB_TYPE (*A)[dimsize][dimsize][dimsize]
= (SB_TYPE (*)[dimsize][dimsize][dimsize])A1;
if (scop) {
#pragma scop
for (int t = 0; t < timestep; t++)
for (int k = BENCH_RAD; k < dimsize - BENCH_RAD; k++)
for (int j = BENCH_RAD; j < dimsize - BENCH_RAD; j++)
for (int i = BENCH_RAD; i < dimsize - BENCH_RAD; i++)
A[(t+1)%2][k][j][i] =
0.75 * (A[t%2][k-2][j-2][i-2] + A[t%2][k-2][j-2][i+2] + A[t%2][k-2][j+2][i-2] + A[t%2][k-2][j+2][i+2] + A[t%2][k-1][j-1][i-1] + A[t%2][k-1][j-1][i+1] + A[t%2][k-1][j+1][i-1] + A[t%2][k-1][j+1][i+1] +
A[t%2][k][j-1][i] + A[t%2][k][j][i-1] + A[t%2][k][j][i+1] + A[t%2][k][j+1][i] +
A[t%2][k+1][j-1][i-1] + A[t%2][k+1][j-1][i+1] + A[t%2][k+1][j+1][i-1] + A[t%2][k+1][j+1][i+1]) +
0.76 * (A[t%2][k-2][j-2][i-2] + A[t%2][k-2][j-2][i+2] + A[t%2][k-2][j+2][i-2] + A[t%2][k-2][j+2][i+2]) +
1.132 * (A[t%2][k-2][j-2][i-1] + A[t%2][k-2][j-2][i+1] + A[t%2][k-2][j-1][i-2] + A[t%2][k-2][j-1][i+2] + A[t%2][k-2][j][i] + A[t%2][k-2][j+1][i-2] + A[t%2][k-2][j+1][i+2] + A[t%2][k-2][j+2][i-1] + A[t%2][k-2][j+2][i+1] +
A[t%2][k-1][j-2][i-2] + A[t%2][k-1][j-2][i+2] + A[t%2][k-1][j+2][i-2] + A[t%2][k-1][j+2][i+2] +
A[t%2][k][j-2][i] + A[t%2][k][j][i-2] + A[t%2][k][j][i+2] + A[t%2][k][j+2][i] +
A[t%2][k+1][j-2][i-2] + A[t%2][k+1][j-2][i+2] + A[t%2][k+1][j+2][i-2] + A[t%2][k+1][j+2][i+2] +
A[t%2][k-2][j-2][i-1] + A[t%2][k-2][j-2][i+1] + A[t%2][k-2][j-1][i-2] + A[t%2][k-2][j-1][i+2] + A[t%2][k-2][j][i] + A[t%2][k-2][j+1][i-2] + A[t%2][k-2][j+1][i+2] + A[t%2][k-2][j+2][i-1] + A[t%2][k-2][j+2][i+1]) +
0.217 * (A[t%2][k-2][j-2][i] + A[t%2][k-2][j][i-2] + A[t%2][k-2][j][i+2] + A[t%2][k-2][j+2][i] +
A[t%2][k-1][j-1][i] + A[t%2][k-1][j][i-1] + A[t%2][k-1][j][i+1] + A[t%2][k-1][j+1][i] +
A[t%2][k][j-2][i-2] + A[t%2][k][j-2][i+2] + A[t%2][k][j+2][i-2] + A[t%2][k][j+2][i+2] +
A[t%2][k+1][j-1][i] + A[t%2][k+1][j][i-1] + A[t%2][k+1][j][i+1] + A[t%2][k+1][j+1][i] +
A[t%2][k-2][j-2][i] + A[t%2][k-2][j][i-2] + A[t%2][k-2][j][i+2] + A[t%2][k-2][j+2][i]) +
2.13 * (A[t%2][k-2][j-1][i] + A[t%2][k-2][j][i-1] + A[t%2][k-2][j][i+1] + A[t%2][k-2][j+1][i] +
A[t%2][k-1][j-2][i] + A[t%2][k-1][j][i-2] + A[t%2][k-1][j][i+2] + A[t%2][k-1][j+2][i] +
A[t%2][k][j-2][i-1] + A[t%2][k][j-2][i+1] + A[t%2][k][j-1][i-2] + A[t%2][k][j-1][i+2] + A[t%2][k][j][i] + A[t%2][k][j+1][i-2] + A[t%2][k][j+1][i+2] + A[t%2][k][j+2][i-1] + A[t%2][k][j+2][i+1] +
A[t%2][k+1][j-2][i] + A[t%2][k+1][j][i-2] + A[t%2][k+1][j][i+2] + A[t%2][k+1][j+2][i] +
A[t%2][k-2][j-1][i] + A[t%2][k-2][j][i-1] + A[t%2][k-2][j][i+1] + A[t%2][k-2][j+1][i]) +
0.331 * (A[t%2][k-2][j-1][i-1] + A[t%2][k-2][j-1][i+1] + A[t%2][k-2][j+1][i-1] + A[t%2][k-2][j+1][i+1] +
A[t%2][k-1][j-2][i-1] + A[t%2][k-1][j-2][i+1] + A[t%2][k-1][j-1][i-2] + A[t%2][k-1][j-1][i+2] + A[t%2][k-1][j][i] + A[t%2][k-1][j+1][i-2] + A[t%2][k-1][j+1][i+2] + A[t%2][k-1][j+2][i-1] + A[t%2][k-1][j+2][i+1] +
A[t%2][k][j-1][i-1] + A[t%2][k][j-1][i+1] + A[t%2][k][j+1][i-1] + A[t%2][k][j+1][i+1] +
A[t%2][k+1][j-2][i-1] + A[t%2][k+1][j-2][i+1] + A[t%2][k+1][j-1][i-2] + A[t%2][k+1][j-1][i+2] + A[t%2][k+1][j][i] + A[t%2][k+1][j+1][i-2] + A[t%2][k+1][j+1][i+2] + A[t%2][k+1][j+2][i-1] + A[t%2][k+1][j+2][i+1]) +
0.332 * (A[t%2][k-2][j-1][i-1] + A[t%2][k-2][j-1][i+1] + A[t%2][k-2][j+1][i-1] + A[t%2][k-2][j+1][i+1]);
#pragma endscop
}
else {
for (int t = 0; t < timestep; t++)
#pragma omp parallel for
for (int k = BENCH_RAD; k < dimsize - BENCH_RAD; k++)
for (int j = BENCH_RAD; j < dimsize - BENCH_RAD; j++)
for (int i = BENCH_RAD; i < dimsize - BENCH_RAD; i++)
A[(t+1)%2][k][j][i] =
0.75 * (A[t%2][k-2][j-2][i-2] + A[t%2][k-2][j-2][i+2] + A[t%2][k-2][j+2][i-2] + A[t%2][k-2][j+2][i+2] + A[t%2][k-1][j-1][i-1] + A[t%2][k-1][j-1][i+1] + A[t%2][k-1][j+1][i-1] + A[t%2][k-1][j+1][i+1] +
A[t%2][k][j-1][i] + A[t%2][k][j][i-1] + A[t%2][k][j][i+1] + A[t%2][k][j+1][i] +
A[t%2][k+1][j-1][i-1] + A[t%2][k+1][j-1][i+1] + A[t%2][k+1][j+1][i-1] + A[t%2][k+1][j+1][i+1]) +
0.76 * (A[t%2][k-2][j-2][i-2] + A[t%2][k-2][j-2][i+2] + A[t%2][k-2][j+2][i-2] + A[t%2][k-2][j+2][i+2]) +
1.132 * (A[t%2][k-2][j-2][i-1] + A[t%2][k-2][j-2][i+1] + A[t%2][k-2][j-1][i-2] + A[t%2][k-2][j-1][i+2] + A[t%2][k-2][j][i] + A[t%2][k-2][j+1][i-2] + A[t%2][k-2][j+1][i+2] + A[t%2][k-2][j+2][i-1] + A[t%2][k-2][j+2][i+1] +
A[t%2][k-1][j-2][i-2] + A[t%2][k-1][j-2][i+2] + A[t%2][k-1][j+2][i-2] + A[t%2][k-1][j+2][i+2] +
A[t%2][k][j-2][i] + A[t%2][k][j][i-2] + A[t%2][k][j][i+2] + A[t%2][k][j+2][i] +
A[t%2][k+1][j-2][i-2] + A[t%2][k+1][j-2][i+2] + A[t%2][k+1][j+2][i-2] + A[t%2][k+1][j+2][i+2] +
A[t%2][k-2][j-2][i-1] + A[t%2][k-2][j-2][i+1] + A[t%2][k-2][j-1][i-2] + A[t%2][k-2][j-1][i+2] + A[t%2][k-2][j][i] + A[t%2][k-2][j+1][i-2] + A[t%2][k-2][j+1][i+2] + A[t%2][k-2][j+2][i-1] + A[t%2][k-2][j+2][i+1]) +
0.217 * (A[t%2][k-2][j-2][i] + A[t%2][k-2][j][i-2] + A[t%2][k-2][j][i+2] + A[t%2][k-2][j+2][i] +
A[t%2][k-1][j-1][i] + A[t%2][k-1][j][i-1] + A[t%2][k-1][j][i+1] + A[t%2][k-1][j+1][i] +
A[t%2][k][j-2][i-2] + A[t%2][k][j-2][i+2] + A[t%2][k][j+2][i-2] + A[t%2][k][j+2][i+2] +
A[t%2][k+1][j-1][i] + A[t%2][k+1][j][i-1] + A[t%2][k+1][j][i+1] + A[t%2][k+1][j+1][i] +
A[t%2][k-2][j-2][i] + A[t%2][k-2][j][i-2] + A[t%2][k-2][j][i+2] + A[t%2][k-2][j+2][i]) +
2.13 * (A[t%2][k-2][j-1][i] + A[t%2][k-2][j][i-1] + A[t%2][k-2][j][i+1] + A[t%2][k-2][j+1][i] +
A[t%2][k-1][j-2][i] + A[t%2][k-1][j][i-2] + A[t%2][k-1][j][i+2] + A[t%2][k-1][j+2][i] +
A[t%2][k][j-2][i-1] + A[t%2][k][j-2][i+1] + A[t%2][k][j-1][i-2] + A[t%2][k][j-1][i+2] + A[t%2][k][j][i] + A[t%2][k][j+1][i-2] + A[t%2][k][j+1][i+2] + A[t%2][k][j+2][i-1] + A[t%2][k][j+2][i+1] +
A[t%2][k+1][j-2][i] + A[t%2][k+1][j][i-2] + A[t%2][k+1][j][i+2] + A[t%2][k+1][j+2][i] +
A[t%2][k-2][j-1][i] + A[t%2][k-2][j][i-1] + A[t%2][k-2][j][i+1] + A[t%2][k-2][j+1][i]) +
0.331 * (A[t%2][k-2][j-1][i-1] + A[t%2][k-2][j-1][i+1] + A[t%2][k-2][j+1][i-1] + A[t%2][k-2][j+1][i+1] +
A[t%2][k-1][j-2][i-1] + A[t%2][k-1][j-2][i+1] + A[t%2][k-1][j-1][i-2] + A[t%2][k-1][j-1][i+2] + A[t%2][k-1][j][i] + A[t%2][k-1][j+1][i-2] + A[t%2][k-1][j+1][i+2] + A[t%2][k-1][j+2][i-1] + A[t%2][k-1][j+2][i+1] +
A[t%2][k][j-1][i-1] + A[t%2][k][j-1][i+1] + A[t%2][k][j+1][i-1] + A[t%2][k][j+1][i+1] +
A[t%2][k+1][j-2][i-1] + A[t%2][k+1][j-2][i+1] + A[t%2][k+1][j-1][i-2] + A[t%2][k+1][j-1][i+2] + A[t%2][k+1][j][i] + A[t%2][k+1][j+1][i-2] + A[t%2][k+1][j+1][i+2] + A[t%2][k+1][j+2][i-1] + A[t%2][k+1][j+2][i+1]) +
0.332 * (A[t%2][k-2][j-1][i-1] + A[t%2][k-2][j-1][i+1] + A[t%2][k-2][j+1][i-1] + A[t%2][k-2][j+1][i+1]);
}
return (((end_time != 0.0) ? end_time : sb_time()) - start_time);
}