-
Notifications
You must be signed in to change notification settings - Fork 0
/
box3d1r.c
91 lines (83 loc) · 3.32 KB
/
box3d1r.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 53
#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] =
0.0375f*A[t%2][i-1][j][k] +
0.0371f*A[t%2][i-1][j-1][k-1] +
0.0372f*A[t%2][i-1][j-1][k] +
0.0373f*A[t%2][i-1][j-1][k+1] +
0.0374f*A[t%2][i-1][j][k-1] +
0.0376f*A[t%2][i-1][j][k+1] +
0.0377f*A[t%2][i-1][j+1][k-1] +
0.0378f*A[t%2][i-1][j+1][k] +
0.0379f*A[t%2][i-1][j+1][k+1] +
0.0355f*A[t%2][i][j][k] +
0.0351f*A[t%2][i][j-1][k-1] +
0.0352f*A[t%2][i][j-1][k] +
0.0353f*A[t%2][i][j-1][k+1] +
0.0354f*A[t%2][i][j][k-1] +
0.0356f*A[t%2][i][j][k+1] +
0.0357f*A[t%2][i][j+1][k-1] +
0.0358f*A[t%2][i][j+1][k] +
0.0359f*A[t%2][i][j+1][k+1] +
0.0365f*A[t%2][i+1][j][k] +
0.0361f*A[t%2][i+1][j-1][k-1] +
0.0362f*A[t%2][i+1][j-1][k] +
0.0363f*A[t%2][i+1][j-1][k+1] +
0.0364f*A[t%2][i+1][j][k-1] +
0.0366f*A[t%2][i+1][j][k+1] +
0.0367f*A[t%2][i+1][j+1][k-1] +
0.0368f*A[t%2][i+1][j+1][k] +
0.0369f*A[t%2][i+1][j+1][k+1];
#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.0375f*A[t%2][i-1][j][k] +
0.0371f*A[t%2][i-1][j-1][k-1] +
0.0372f*A[t%2][i-1][j-1][k] +
0.0373f*A[t%2][i-1][j-1][k+1] +
0.0374f*A[t%2][i-1][j][k-1] +
0.0376f*A[t%2][i-1][j][k+1] +
0.0377f*A[t%2][i-1][j+1][k-1] +
0.0378f*A[t%2][i-1][j+1][k] +
0.0379f*A[t%2][i-1][j+1][k+1] +
0.0355f*A[t%2][i][j][k] +
0.0351f*A[t%2][i][j-1][k-1] +
0.0352f*A[t%2][i][j-1][k] +
0.0353f*A[t%2][i][j-1][k+1] +
0.0354f*A[t%2][i][j][k-1] +
0.0356f*A[t%2][i][j][k+1] +
0.0357f*A[t%2][i][j+1][k-1] +
0.0358f*A[t%2][i][j+1][k] +
0.0359f*A[t%2][i][j+1][k+1] +
0.0365f*A[t%2][i+1][j][k] +
0.0361f*A[t%2][i+1][j-1][k-1] +
0.0362f*A[t%2][i+1][j-1][k] +
0.0363f*A[t%2][i+1][j-1][k+1] +
0.0364f*A[t%2][i+1][j][k-1] +
0.0366f*A[t%2][i+1][j][k+1] +
0.0367f*A[t%2][i+1][j+1][k-1] +
0.0368f*A[t%2][i+1][j+1][k] +
0.0369f*A[t%2][i+1][j+1][k+1];
}
return (((end_time != 0.0) ? end_time : sb_time()) - start_time);
}