Skip to content
Snippets Groups Projects
Commit 4c734242 authored by Stéphane Del Pino's avatar Stéphane Del Pino
Browse files

optimization tests

parent 6f69d150
No related branches found
No related tags found
No related merge requests found
...@@ -173,8 +173,8 @@ KOKKOS_INLINE_FUNCTION ...@@ -173,8 +173,8 @@ KOKKOS_INLINE_FUNCTION
const Kokkos::View<const double*> const Kokkos::View<const double*>
AcousticSolver::inverse(const Kokkos::View<const double*>& x) const AcousticSolver::inverse(const Kokkos::View<const double*>& x) const
{ {
Kokkos::View<double*> inv_x("inv_x", m_nr); Kokkos::View<double*> inv_x("inv_x", x.size());
Kokkos::parallel_for(m_nr, KOKKOS_LAMBDA(const int& r) { Kokkos::parallel_for(x.size(), KOKKOS_LAMBDA(const int& r) {
inv_x(r) = 1./x(r); inv_x(r) = 1./x(r);
}); });
...@@ -206,12 +206,12 @@ void AcousticSolver::computeExplicitFluxes(const Kokkos::View<const double*>& xr ...@@ -206,12 +206,12 @@ void AcousticSolver::computeExplicitFluxes(const Kokkos::View<const double*>& xr
ur = computeUr(Ar, br); ur = computeUr(Ar, br);
#warning understand why this call diminishes performances #warning understand why this call diminishes performances
// Fjr = computeFjr(Ajr, ur, Cjr, uj, pj, cell_nodes); Fjr = computeFjr(Ajr, ur, Cjr, uj, pj, cell_nodes);
Kokkos::parallel_for(m_nj, KOKKOS_LAMBDA(const int& j) { // Kokkos::parallel_for(m_nj, KOKKOS_LAMBDA(const int& j) {
for (int r=0; r<2; ++r) { // for (int r=0; r<2; ++r) {
Fjr(j,r) = Ajr(j,r)*(uj(j)-ur(cell_nodes(j,r)))+Cjr(j,r)*pj(j); // Fjr(j,r) = Ajr(j,r)*(uj(j)-ur(cell_nodes(j,r)))+Cjr(j,r)*pj(j);
} // }
}); // });
} }
AcousticSolver::AcousticSolver(const long int& nj) AcousticSolver::AcousticSolver(const long int& nj)
...@@ -230,7 +230,6 @@ AcousticSolver::AcousticSolver(const long int& nj) ...@@ -230,7 +230,6 @@ AcousticSolver::AcousticSolver(const long int& nj)
Kokkos::View<double*> gammaj("gammaj",m_nj); Kokkos::View<double*> gammaj("gammaj",m_nj);
Kokkos::View<double*> cj("cj",m_nj); Kokkos::View<double*> cj("cj",m_nj);
Kokkos::View<double*> mj("mj",m_nj); Kokkos::View<double*> mj("mj",m_nj);
Kokkos::View<double*> inv_mj("inv_mj",m_nj);
Kokkos::View<double*> xr("xr", m_nr); Kokkos::View<double*> xr("xr", m_nr);
...@@ -314,6 +313,8 @@ AcousticSolver::AcousticSolver(const long int& nj) ...@@ -314,6 +313,8 @@ AcousticSolver::AcousticSolver(const long int& nj)
mj[j] = rhoj[j] * Vj[j]; mj[j] = rhoj[j] * Vj[j];
}); });
const Kokkos::View<const double*> inv_mj=inverse(mj);
const double tmax=0.2; const double tmax=0.2;
double t=0; double t=0;
...@@ -336,17 +337,13 @@ AcousticSolver::AcousticSolver(const long int& nj) ...@@ -336,17 +337,13 @@ AcousticSolver::AcousticSolver(const long int& nj)
} }
Kokkos::View<double*> ur; Kokkos::View<double*> ur;
// Kokkos::View<double*[2]> Fjr; Kokkos::View<double*[2]> Fjr;
Kokkos::View<double*[2]> Fjr("Fjr", m_nj);
computeExplicitFluxes(xr, xj, computeExplicitFluxes(xr, xj,
rhoj, uj, pj, cj, Vj, Cjr, rhoj, uj, pj, cj, Vj, Cjr,
cell_nodes, node_cells, node_nb_cells, node_cell_local_node, cell_nodes, node_cells, node_nb_cells, node_cell_local_node,
ur, Fjr); ur, Fjr);
// Kokkos::View<double*> new_uj("new_uj",m_nj);
// Kokkos::View<double*> new_Ej("new_Ej",m_nj);
Kokkos::parallel_for(nj, KOKKOS_LAMBDA(const int& j){ Kokkos::parallel_for(nj, KOKKOS_LAMBDA(const int& j){
double momentum_fluxes = 0; double momentum_fluxes = 0;
double energy_fluxes = 0; double energy_fluxes = 0;
...@@ -355,13 +352,10 @@ AcousticSolver::AcousticSolver(const long int& nj) ...@@ -355,13 +352,10 @@ AcousticSolver::AcousticSolver(const long int& nj)
momentum_fluxes += Fjr(j,R); momentum_fluxes += Fjr(j,R);
energy_fluxes += Fjr(j,R)*ur[r]; energy_fluxes += Fjr(j,R)*ur[r];
} }
uj[j] -= dt/mj[j]*(momentum_fluxes); uj[j] -= dt*inv_mj[j]*(momentum_fluxes);
Ej[j] -= dt/mj[j]*(energy_fluxes); Ej[j] -= dt*inv_mj[j]*(energy_fluxes);
}); });
// uj=new_uj;
// Ej=new_Ej;
Kokkos::parallel_for(nj, KOKKOS_LAMBDA(const int& j) { Kokkos::parallel_for(nj, KOKKOS_LAMBDA(const int& j) {
ej[j] = Ej[j] - 0.5 * uj[j]*uj[j]; ej[j] = Ej[j] - 0.5 * uj[j]*uj[j];
}); });
......
...@@ -172,6 +172,10 @@ MeshLessAcousticSolver::MeshLessAcousticSolver(const long int& nj) ...@@ -172,6 +172,10 @@ MeshLessAcousticSolver::MeshLessAcousticSolver(const long int& nj)
mj[j] = rhoj[j] * Vj[j]; mj[j] = rhoj[j] * Vj[j];
}); });
Kokkos::parallel_for(nj, KOKKOS_LAMBDA(const int& j){
inv_mj[j] = 1./mj[j];
});
const double tmax=0.2; const double tmax=0.2;
double t=0; double t=0;
...@@ -201,8 +205,8 @@ MeshLessAcousticSolver::MeshLessAcousticSolver(const long int& nj) ...@@ -201,8 +205,8 @@ MeshLessAcousticSolver::MeshLessAcousticSolver(const long int& nj)
int rm=j; int rm=j;
int rp=j+1; int rp=j+1;
new_uj[j] = uj[j] + dt/mj[j]*(pr[rm]-pr[rp]); new_uj[j] = uj[j] + dt*inv_mj[j]*(pr[rm]-pr[rp]);
new_Ej[j] = Ej[j] + dt/mj[j]*(pr[rm]*ur[rm]-pr[rp]*ur[rp]); new_Ej[j] = Ej[j] + dt*inv_mj[j]*(pr[rm]*ur[rm]-pr[rp]*ur[rp]);
}); });
uj=new_uj; uj=new_uj;
......
...@@ -185,6 +185,10 @@ void AcousticSolver(const long int& nj) ...@@ -185,6 +185,10 @@ void AcousticSolver(const long int& nj)
mj[j] = rhoj[j] * Vj[j]; mj[j] = rhoj[j] * Vj[j];
}); });
Kokkos::parallel_for(nj, KOKKOS_LAMBDA(const int& j){
inv_mj[j] = 1./mj[j];
});
const double tmax=0.2; const double tmax=0.2;
double t=0; double t=0;
...@@ -211,8 +215,8 @@ void AcousticSolver(const long int& nj) ...@@ -211,8 +215,8 @@ void AcousticSolver(const long int& nj)
int rm=j; int rm=j;
int rp=j+1; int rp=j+1;
uj[j] += dt/mj[j]*(pr[rm]-pr[rp]); uj[j] += dt*inv_mj[j]*(pr[rm]-pr[rp]);
Ej[j] += dt/mj[j]*(pr[rm]*ur[rm]-pr[rp]*ur[rp]); Ej[j] += dt*inv_mj[j]*(pr[rm]*ur[rm]-pr[rp]*ur[rp]);
}); });
Kokkos::parallel_for(nj, KOKKOS_LAMBDA(const int& j){ Kokkos::parallel_for(nj, KOKKOS_LAMBDA(const int& j){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment