-
Notifications
You must be signed in to change notification settings - Fork 1
/
j3d27pt.c
91 lines (83 loc) · 3.33 KB
/
j3d27pt.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
90
91
#define BENCH_DIM 3
#define BENCH_FPP 54
#define BENCH_RAD 1
#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 i = BENCH_RAD; i < dimsize - BENCH_RAD; i++)
for (int j = BENCH_RAD; j < dimsize - BENCH_RAD; j++)
for (int k = BENCH_RAD; k < dimsize - BENCH_RAD; k++)
A[(t+1)%2][i][j][k] =
(1.500f*A[t%2][i-1][j][k] +
0.500f*A[t%2][i-1][j-1][k-1] +
0.700f*A[t%2][i-1][j-1][k] +
0.900f*A[t%2][i-1][j-1][k+1] +
1.200f*A[t%2][i-1][j][k-1] +
1.201f*A[t%2][i-1][j][k+1] +
0.901f*A[t%2][i-1][j+1][k-1] +
0.701f*A[t%2][i-1][j+1][k] +
0.501f*A[t%2][i-1][j+1][k+1] +
1.510f*A[t%2][i][j][k] +
0.510f*A[t%2][i][j-1][k-1] +
0.710f*A[t%2][i][j-1][k] +
0.910f*A[t%2][i][j-1][k+1] +
1.210f*A[t%2][i][j][k-1] +
1.211f*A[t%2][i][j][k+1] +
0.911f*A[t%2][i][j+1][k-1] +
0.711f*A[t%2][i][j+1][k] +
0.511f*A[t%2][i][j+1][k+1] +
1.520f*A[t%2][i+1][j][k] +
0.520f*A[t%2][i+1][j-1][k-1] +
0.720f*A[t%2][i+1][j-1][k] +
0.920f*A[t%2][i+1][j-1][k+1] +
1.220f*A[t%2][i+1][j][k-1] +
1.221f*A[t%2][i+1][j][k+1] +
0.921f*A[t%2][i+1][j+1][k-1] +
0.721f*A[t%2][i+1][j+1][k] +
0.521f*A[t%2][i+1][j+1][k+1]) / 159;
#pragma endscop
}
else {
for (int t = 0; t < timestep; t++)
#pragma omp parallel for
for (int i = BENCH_RAD; i < dimsize - BENCH_RAD; i++)
for (int j = BENCH_RAD; j < dimsize - BENCH_RAD; j++)
for (int k = BENCH_RAD; k < dimsize - BENCH_RAD; k++)
A[(t+1)%2][i][j][k] =
(1.500f*A[t%2][i-1][j][k] +
0.500f*A[t%2][i-1][j-1][k-1] +
0.700f*A[t%2][i-1][j-1][k] +
0.900f*A[t%2][i-1][j-1][k+1] +
1.200f*A[t%2][i-1][j][k-1] +
1.201f*A[t%2][i-1][j][k+1] +
0.901f*A[t%2][i-1][j+1][k-1] +
0.701f*A[t%2][i-1][j+1][k] +
0.501f*A[t%2][i-1][j+1][k+1] +
1.510f*A[t%2][i][j][k] +
0.510f*A[t%2][i][j-1][k-1] +
0.710f*A[t%2][i][j-1][k] +
0.910f*A[t%2][i][j-1][k+1] +
1.210f*A[t%2][i][j][k-1] +
1.211f*A[t%2][i][j][k+1] +
0.911f*A[t%2][i][j+1][k-1] +
0.711f*A[t%2][i][j+1][k] +
0.511f*A[t%2][i][j+1][k+1] +
1.520f*A[t%2][i+1][j][k] +
0.520f*A[t%2][i+1][j-1][k-1] +
0.720f*A[t%2][i+1][j-1][k] +
0.920f*A[t%2][i+1][j-1][k+1] +
1.220f*A[t%2][i+1][j][k-1] +
1.221f*A[t%2][i+1][j][k+1] +
0.921f*A[t%2][i+1][j+1][k-1] +
0.721f*A[t%2][i+1][j+1][k] +
0.521f*A[t%2][i+1][j+1][k+1]) / 159;
}
return (((end_time != 0.0) ? end_time : sb_time()) - start_time);
}