-
Notifications
You must be signed in to change notification settings - Fork 1
/
star3d4r.c
67 lines (55 loc) · 2.86 KB
/
star3d4r.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
#define BENCH_DIM 3
#define BENCH_FPP 49
#define BENCH_RAD 4
#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] =
0.25000f * A[t%2][i][j][k]
+ 0.03228f * A[t%2][i][j][k-4] + 0.03138f * A[t%2][i][j][k-3]
+ 0.03118f * A[t%2][i][j][k-2] + 0.03027f * A[t%2][i][j][k-1]
+ 0.03022f * A[t%2][i][j][k+1] + 0.03112f * A[t%2][i][j][k+2]
+ 0.03132f * A[t%2][i][j][k+3] + 0.03222f * A[t%2][i][j][k+4]
+ 0.03026f * A[t%2][i-1][j][k] + 0.03024f * A[t%2][i+1][j][k]
+ 0.03027f * A[t%2][i][j-1][k] + 0.03023f * A[t%2][i][j+1][k]
+ 0.03116f * A[t%2][i-2][j][k] + 0.03114f * A[t%2][i+2][j][k]
+ 0.03117f * A[t%2][i][j-2][k] + 0.03113f * A[t%2][i][j+2][k]
+ 0.03136f * A[t%2][i-3][j][k] + 0.03134f * A[t%2][i+3][j][k]
+ 0.03137f * A[t%2][i][j-3][k] + 0.03133f * A[t%2][i][j+3][k]
+ 0.03226f * A[t%2][i-4][j][k] + 0.03224f * A[t%2][i+4][j][k]
+ 0.03227f * A[t%2][i][j-4][k] + 0.03223f * A[t%2][i][j+4][k];
#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] =
0.25000f * A[t%2][i][j][k]
+ 0.03228f * A[t%2][i][j][k-4] + 0.03138f * A[t%2][i][j][k-3]
+ 0.03118f * A[t%2][i][j][k-2] + 0.03027f * A[t%2][i][j][k-1]
+ 0.03022f * A[t%2][i][j][k+1] + 0.03112f * A[t%2][i][j][k+2]
+ 0.03132f * A[t%2][i][j][k+3] + 0.03222f * A[t%2][i][j][k+4]
+ 0.03026f * A[t%2][i-1][j][k] + 0.03024f * A[t%2][i+1][j][k]
+ 0.03027f * A[t%2][i][j-1][k] + 0.03023f * A[t%2][i][j+1][k]
+ 0.03116f * A[t%2][i-2][j][k] + 0.03114f * A[t%2][i+2][j][k]
+ 0.03117f * A[t%2][i][j-2][k] + 0.03113f * A[t%2][i][j+2][k]
+ 0.03136f * A[t%2][i-3][j][k] + 0.03134f * A[t%2][i+3][j][k]
+ 0.03137f * A[t%2][i][j-3][k] + 0.03133f * A[t%2][i][j+3][k]
+ 0.03226f * A[t%2][i-4][j][k] + 0.03224f * A[t%2][i+4][j][k]
+ 0.03227f * A[t%2][i][j-4][k] + 0.03223f * A[t%2][i][j+4][k];
}
return (((end_time != 0.0) ? end_time : sb_time()) - start_time);
}