-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathPOLYBENCH_2MM-Seq.cpp
More file actions
189 lines (152 loc) · 5.25 KB
/
POLYBENCH_2MM-Seq.cpp
File metadata and controls
189 lines (152 loc) · 5.25 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Copyright (c) 2017-20, Lawrence Livermore National Security, LLC
// and RAJA Performance Suite project contributors.
// See the RAJAPerf/COPYRIGHT file for details.
//
// SPDX-License-Identifier: (BSD-3-Clause)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
#include "POLYBENCH_2MM.hpp"
#include "RAJA/RAJA.hpp"
#include <iostream>
namespace rajaperf
{
namespace polybench
{
void POLYBENCH_2MM::runSeqVariant(VariantID vid)
{
const Index_type run_reps= getRunReps();
POLYBENCH_2MM_DATA_SETUP;
auto poly_2mm_base_lam2 = [=](Index_type i, Index_type j,
Index_type k, Real_type &dot) {
POLYBENCH_2MM_BODY2;
};
auto poly_2mm_base_lam3 = [=](Index_type i, Index_type j,
Real_type &dot) {
POLYBENCH_2MM_BODY3;
};
auto poly_2mm_base_lam5 = [=](Index_type i, Index_type l,
Index_type j, Real_type &dot) {
POLYBENCH_2MM_BODY5;
};
auto poly_2mm_base_lam6 = [=](Index_type i, Index_type l,
Real_type &dot) {
POLYBENCH_2MM_BODY6;
};
POLYBENCH_2MM_VIEWS_RAJA;
auto poly_2mm_lam1 = [=](Real_type &dot) {
POLYBENCH_2MM_BODY1_RAJA;
};
auto poly_2mm_lam2 = [=](Index_type i, Index_type j, Index_type k,
Real_type &dot) {
POLYBENCH_2MM_BODY2_RAJA;
};
auto poly_2mm_lam3 = [=](Index_type i, Index_type j, Real_type &dot) {
POLYBENCH_2MM_BODY3_RAJA;
};
auto poly_2mm_lam4 = [=](Real_type &dot) {
POLYBENCH_2MM_BODY4_RAJA;
};
auto poly_2mm_lam5 = [=](Index_type i, Index_type l, Index_type j,
Real_type &dot) {
POLYBENCH_2MM_BODY5_RAJA;
};
auto poly_2mm_lam6 = [=](Index_type i, Index_type l, Real_type &dot) {
POLYBENCH_2MM_BODY6_RAJA;
};
switch ( vid ) {
case Base_Seq : {
startTimer();
for (RepIndex_type irep = 0; irep < run_reps; ++irep) {
for (Index_type i = 0; i < ni; i++ ) {
for (Index_type j = 0; j < nj; j++) {
POLYBENCH_2MM_BODY1;
for (Index_type k = 0; k < nk; k++) {
POLYBENCH_2MM_BODY2;
}
POLYBENCH_2MM_BODY3;
}
}
for (Index_type i = 0; i < ni; i++) {
for (Index_type l = 0; l < nl; l++) {
POLYBENCH_2MM_BODY4;
for (Index_type j = 0; j < nj; j++) {
POLYBENCH_2MM_BODY5;
}
POLYBENCH_2MM_BODY6;
}
}
}
stopTimer();
break;
}
#if defined(RUN_RAJA_SEQ)
case Lambda_Seq : {
startTimer();
for (RepIndex_type irep = 0; irep < run_reps; ++irep) {
for (Index_type i = 0; i < ni; i++ ) {
for(Index_type j = 0; j < nj; j++) {
POLYBENCH_2MM_BODY1;
for (Index_type k = 0; k < nk; k++) {
poly_2mm_base_lam2(i, j, k, dot);
}
poly_2mm_base_lam3(i, j, dot);
}
}
for(Index_type i = 0; i < ni; i++) {
for(Index_type l = 0; l < nl; l++) {
POLYBENCH_2MM_BODY4;
for (Index_type j = 0; j < nj; j++) {
poly_2mm_base_lam5(i, l, j, dot);
}
poly_2mm_base_lam6(i, l, dot);
}
}
}
stopTimer();
break;
}
case RAJA_Seq : {
using EXEC_POL =
RAJA::KernelPolicy<
RAJA::statement::For<0, RAJA::loop_exec,
RAJA::statement::For<1, RAJA::loop_exec,
RAJA::statement::Lambda<0, RAJA::Params<0>>,
RAJA::statement::For<2, RAJA::loop_exec,
RAJA::statement::Lambda<1, RAJA::Segs<0,1,2>, RAJA::Params<0>>,
RAJA::statement::Lambda<2, RAJA::Segs<0,1>, RAJA::Params<0>>
>
>
>
>;
startTimer();
for (RepIndex_type irep = 0; irep < run_reps; ++irep) {
RAJA::kernel_param<EXEC_POL>(
RAJA::make_tuple(RAJA::RangeSegment(0, ni),
RAJA::RangeSegment(0, nj),
RAJA::RangeSegment(0, nk)),
RAJA::tuple<Real_type> {0.0},
poly_2mm_lam1,
poly_2mm_lam2,
poly_2mm_lam3
);
RAJA::kernel_param<EXEC_POL>(
RAJA::make_tuple(RAJA::RangeSegment(0, ni),
RAJA::RangeSegment(0, nl),
RAJA::RangeSegment(0, nj)),
RAJA::tuple<Real_type> {0.0},
poly_2mm_lam4,
poly_2mm_lam5,
poly_2mm_lam6
);
}
stopTimer();
break;
}
#endif // RUN_RAJA_SEQ
default : {
std::cout << "\n POLYBENCH_2MM : Unknown variant id = " << vid << std::endl;
}
}
}
} // end namespace polybench
} // end namespace rajaperf