-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathENERGY-Seq.cpp
More file actions
186 lines (139 loc) · 4.86 KB
/
Copy pathENERGY-Seq.cpp
File metadata and controls
186 lines (139 loc) · 4.86 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
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
// Copyright (c) Lawrence Livermore National Security, LLC and other
// RAJA Project Developers. See top-level LICENSE and COPYRIGHT
// files for dates and other details. No copyright assignment is required
// to contribute to RAJA Performance Suite.
//
// SPDX-License-Identifier: (BSD-3-Clause)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
#include "ENERGY.hpp"
#include "RAJA/RAJA.hpp"
#include <iostream>
namespace rajaperf
{
namespace apps
{
void ENERGY::runSeqVariant(VariantID vid)
{
const Index_type run_reps = getRunReps();
const Index_type ibegin = 0;
const Index_type iend = getActualProblemSize();
ENERGY_DATA_SETUP;
#if defined(RUN_RAJA_SEQ)
auto energy_lam1 = [=](Index_type i) {
ENERGY_BODY1;
};
auto energy_lam2 = [=](Index_type i) {
ENERGY_BODY2;
};
auto energy_lam3 = [=](Index_type i) {
ENERGY_BODY3;
};
auto energy_lam4 = [=](Index_type i) {
ENERGY_BODY4;
};
auto energy_lam5 = [=](Index_type i) {
ENERGY_BODY5;
};
auto energy_lam6 = [=](Index_type i) {
ENERGY_BODY6;
};
#endif
switch ( vid ) {
case Base_Seq : {
startTimer();
// Loop counter increment uses macro to quiet C++20 compiler warning
for (RepIndex_type irep = 0; irep < run_reps; RP_REPCOUNTINC(irep)) {
for (Index_type i = ibegin; i < iend; ++i ) {
ENERGY_BODY1;
}
for (Index_type i = ibegin; i < iend; ++i ) {
ENERGY_BODY2;
}
for (Index_type i = ibegin; i < iend; ++i ) {
ENERGY_BODY3;
}
for (Index_type i = ibegin; i < iend; ++i ) {
ENERGY_BODY4;
}
for (Index_type i = ibegin; i < iend; ++i ) {
ENERGY_BODY5;
}
for (Index_type i = ibegin; i < iend; ++i ) {
ENERGY_BODY6;
}
}
stopTimer();
break;
}
#if defined(RUN_RAJA_SEQ)
case Lambda_Seq : {
startTimer();
// Loop counter increment uses macro to quiet C++20 compiler warning
for (RepIndex_type irep = 0; irep < run_reps; RP_REPCOUNTINC(irep)) {
for (Index_type i = ibegin; i < iend; ++i ) {
energy_lam1(i);
}
for (Index_type i = ibegin; i < iend; ++i ) {
energy_lam2(i);
}
for (Index_type i = ibegin; i < iend; ++i ) {
energy_lam3(i);
}
for (Index_type i = ibegin; i < iend; ++i ) {
energy_lam4(i);
}
for (Index_type i = ibegin; i < iend; ++i ) {
energy_lam5(i);
}
for (Index_type i = ibegin; i < iend; ++i ) {
energy_lam6(i);
}
}
stopTimer();
break;
}
case RAJA_Seq : {
auto res{getHostResource()};
startTimer();
// Loop counter increment uses macro to quiet C++20 compiler warning
for (RepIndex_type irep = 0; irep < run_reps; RP_REPCOUNTINC(irep)) {
RAJA::region<RAJA::seq_region>( [=]() {
RP_CALI_MARK_BEGIN(RP_CALI_REGION(ENERGY_1));
RAJA::forall<RAJA::seq_exec>( res,
RAJA::RangeSegment(ibegin, iend), energy_lam1);
RP_CALI_MARK_END(RP_CALI_REGION(ENERGY_1));
RP_CALI_MARK_BEGIN(RP_CALI_REGION(ENERGY_2));
RAJA::forall<RAJA::seq_exec>( res,
RAJA::RangeSegment(ibegin, iend), energy_lam2);
RP_CALI_MARK_END(RP_CALI_REGION(ENERGY_2));
RP_CALI_MARK_BEGIN(RP_CALI_REGION(ENERGY_3));
RAJA::forall<RAJA::seq_exec>( res,
RAJA::RangeSegment(ibegin, iend), energy_lam3);
RP_CALI_MARK_END(RP_CALI_REGION(ENERGY_3));
RP_CALI_MARK_BEGIN(RP_CALI_REGION(ENERGY_4));
RAJA::forall<RAJA::seq_exec>( res,
RAJA::RangeSegment(ibegin, iend), energy_lam4);
RP_CALI_MARK_END(RP_CALI_REGION(ENERGY_4));
RP_CALI_MARK_BEGIN(RP_CALI_REGION(ENERGY_5));
RAJA::forall<RAJA::seq_exec>( res,
RAJA::RangeSegment(ibegin, iend), energy_lam5);
RP_CALI_MARK_END(RP_CALI_REGION(ENERGY_5));
RP_CALI_MARK_BEGIN(RP_CALI_REGION(ENERGY_6));
RAJA::forall<RAJA::seq_exec>( res,
RAJA::RangeSegment(ibegin, iend), energy_lam6);
RP_CALI_MARK_END(RP_CALI_REGION(ENERGY_6));
}); // end sequential region (for single-source code)
}
stopTimer();
break;
}
#endif // RUN_RAJA_SEQ
default : {
getCout() << "\n ENERGY : Unknown variant id = " << vid << std::endl;
}
}
}
RAJAPERF_DEFAULT_TUNING_DEFINE_BOILERPLATE(ENERGY, Seq, Base_Seq, Lambda_Seq, RAJA_Seq)
} // end namespace apps
} // end namespace rajaperf