35#include "../RiemannSolvers/RoeSolver.h"
46int main(
int argc,
char const *argv[])
65 nEle = std::stoi(argv[1]);
68 std::cout <<
"number of faces\t" << nEle
69 <<
"\t(assuming 4*4 nodes per face)\n";
71 size_t sizeScalar = 4 * 4 * nEle;
73 size_t spaceDim = nVars - 2;
74 size_t sizeVec = sizeScalar / vec_t::width;
78 std::vector<std::vector<double>> Fwd(nVars), Bwd(nVars), Flux(nVars);
80 for (
size_t i = 0; i < nVars; ++i)
82 Fwd[i] = std::vector<double>(sizeScalar);
83 Bwd[i] = std::vector<double>(sizeScalar);
84 Flux[i] = std::vector<double>(sizeScalar);
86 for (
size_t j = 0; j < sizeScalar; ++j)
100 std::vector<std::vector<vec_t, allocator<vec_t>>> alignedFwd(nVars),
101 alignedBwd(nVars), alignedFlux(nVars);
103 for (
size_t i = 0; i < nVars; ++i)
105 alignedFwd[i] = std::vector<vec_t, allocator<vec_t>>(sizeVec);
106 alignedBwd[i] = std::vector<vec_t, allocator<vec_t>>(sizeVec);
107 alignedFlux[i] = std::vector<vec_t, allocator<vec_t>>(sizeVec);
109 for (
size_t j = 0; j < sizeVec; ++j)
111 alignedFwd[i][j] = 1.;
112 alignedBwd[i][j] = 1.;
116 alignedFwd[i][j] = 10.;
117 alignedBwd[i][j] = 10.;
119 alignedFlux[i][j] = 0.;
124 constexpr size_t experiments = 1 << 18;
127 for (
size_t j = 0; j < experiments; ++j)
131 for (
size_t i = 0; i < sizeScalar; ++i)
133 double rhoL{}, rhouL{}, rhovL{}, rhowL{}, EL{};
134 double rhoR{}, rhouR{}, rhovR{}, rhowR{}, ER{};
139 EL = Fwd[spaceDim + 1][i];
142 ER = Bwd[spaceDim + 1][i];
149 else if (spaceDim == 3)
157 double rhof{}, rhouf{}, rhovf{}, rhowf{}, Ef{};
159 RoeKernel(rhoL, rhouL, rhovL, rhowL, EL, rhoR, rhouR, rhovR, rhowR,
160 ER, rhof, rhouf, rhovf, rhowf, Ef, gamma);
165 Flux[nVars - 1][i] = Ef;
170 else if (spaceDim == 3)
180 constexpr short CPU_CLK_UNHALTED_REF_id = 2;
182 std::vector<double> events(nevents);
183 [[maybe_unused]]
double time;
184 [[maybe_unused]]
int count;
189 events[CPU_CLK_UNHALTED_REF_id] / sizeScalar / experiments;
190 std::cout <<
"scalar likwid CPE\t" << cpeScalar <<
'\n';
192 std::cout << Flux[0][0] << std::endl;
196 for (
size_t j = 0; j < experiments; ++j)
199 for (
size_t i = 0; i < sizeScalar; i += vec_t::width)
201 vec_t rhoL{}, rhouL{}, rhovL{}, rhowL{}, EL{};
202 vec_t rhoR{}, rhouR{}, rhovR{}, rhowR{}, ER{};
217 else if (spaceDim == 3)
225 vec_t rhof{}, rhouf{}, rhovf{}, rhowf{}, Ef{};
227 RoeKernel(rhoL, rhouL, rhovL, rhowL, EL, rhoR, rhouR, rhovR, rhowR,
228 ER, rhof, rhouf, rhovf, rhowf, Ef, gamma);
238 else if (spaceDim == 3)
251 events[CPU_CLK_UNHALTED_REF_id] / sizeScalar / experiments;
252 std::cout <<
"vector likwid CPE\t" << cpeVector <<
'\t'
253 << cpeScalar / cpeVector <<
" %\n";
255 std::cout << Flux[0][0] << std::endl;
259 for (
size_t j = 0; j < experiments; ++j)
262 for (
size_t i = 0; i < sizeVec; ++i)
264 vec_t rhoL{}, rhouL{}, rhovL{}, rhowL{}, EL{};
265 vec_t rhoR{}, rhouR{}, rhovR{}, rhowR{}, ER{};
268 rhoL = alignedFwd[0][i];
269 rhouL = alignedFwd[1][i];
270 EL = alignedFwd[spaceDim + 1][i];
271 rhoR = alignedBwd[0][i];
272 rhouR = alignedBwd[1][i];
273 ER = alignedBwd[spaceDim + 1][i];
277 rhovL = alignedFwd[2][i];
278 rhovR = alignedBwd[2][i];
280 else if (spaceDim == 3)
282 rhovL = alignedFwd[2][i];
283 rhowL = alignedFwd[3][i];
284 rhovR = alignedBwd[2][i];
285 rhowR = alignedBwd[3][i];
288 vec_t rhof{}, rhouf{}, rhovf{}, rhowf{}, Ef{};
290 RoeKernel(rhoL, rhouL, rhovL, rhowL, EL, rhoR, rhouR, rhovR, rhowR,
291 ER, rhof, rhouf, rhovf, rhowf, Ef, gamma);
294 alignedFlux[0][i] = rhof;
295 alignedFlux[1][i] = rhouf;
296 alignedFlux[nVars - 1][i] = Ef;
299 alignedFlux[2][i] = rhovf;
301 else if (spaceDim == 3)
303 alignedFlux[2][i] = rhovf;
304 alignedFlux[3][i] = rhowf;
313 double cpevectorOfVector =
314 events[CPU_CLK_UNHALTED_REF_id] / sizeScalar / experiments;
315 std::cout <<
"vectorOfVector likwid CPE\t" << cpevectorOfVector <<
'\t'
316 << cpeScalar / cpevectorOfVector <<
" %\n";
318 std::cout << alignedFlux[0][0][0] << std::endl;
#define LIKWID_MARKER_THREADINIT
#define LIKWID_MARKER_START(regionTag)
#define LIKWID_MARKER_CLOSE
#define LIKWID_MARKER_INIT
#define LIKWID_MARKER_REGISTER(regionTag)
#define LIKWID_MARKER_STOP(regionTag)
#define LIKWID_MARKER_GET(regionTag, nevents, events, time, count)
int main(int argc, char const *argv[])
void RoeKernel(T &rhoL, T &rhouL, T &rhovL, T &rhowL, T &EL, T &rhoR, T &rhouR, T &rhovR, T &rhowR, T &ER, T &rhof, T &rhouf, T &rhovf, T &rhowf, T &Ef, NekDouble gamma)
tinysimd::simd< NekDouble > vec_t
static constexpr struct tinysimd::is_not_aligned_t is_not_aligned
typename abi< ScalarType, width >::type simd