Skip to content

Commit

Permalink
Merge Pull Request #12359 from rppawlo/Trilinos/phalanx-fix-cuda-12
Browse files Browse the repository at this point in the history
Automatically Merged using Trilinos Pull Request AutoTester
PR Title: b'Phalanx: fix unit test for cuda 12'
PR Author: rppawlo
  • Loading branch information
trilinos-autotester authored Oct 4, 2023
2 parents 36909c0 + a8142a9 commit f90adc4
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions packages/phalanx/test/Kokkos/tKokkosScalarFunctionsFad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,24 +238,29 @@ Teuchos::StackedTimer:12.5579 [1] (0)

void evaluate()
{
EquationOfState eos;
EquationOfState eos_tmp;
Kokkos::TeamPolicy<PHX::exec_space> policy(num_cells,Kokkos::AUTO(),1);
PHX::Device().fence();
Kokkos::parallel_for("compute a with return type",policy, KOKKOS_CLASS_LAMBDA (const team_t& team) {
const int c = team.league_rank();
// implicit lambda capture outside of constexpr if (cuda restriction)
auto rho = rho_;
auto p = p_;
auto a = a_;
auto eos = eos_tmp;
Kokkos::parallel_for(Kokkos::TeamThreadRange(team,0,num_points), [&] (const int i) {
if constexpr (std::is_same_v<EquationOfState,EoS_FUNC>) {
auto rho = rho_(c,i);
auto p = p_(c,i);
auto&& a = a_(c,i);
eos.a(rho,p,a);
auto rho_i = rho(c,i);
auto p_i = p(c,i);
auto&& a_i = a(c,i);
eos.a(rho_i,p_i,a_i);
} else if constexpr(std::is_same_v<EquationOfState,EoS_Baseline>) {
a_(c,i) = std::sqrt(eos.gamma_ * p_(c,i) / rho_(c,i));
a(c,i) = std::sqrt(eos.gamma_ * p(c,i) / rho(c,i));
} else { // Scalar or auto
auto rho = rho_(c,i);
auto p = p_(c,i);
auto&& a = a_(c,i);
a = eos.a(rho,p);
auto rho_i = rho(c,i);
auto p_i = p(c,i);
auto&& a_i = a(c,i);
a_i = eos.a(rho_i,p_i);
}
});
});
Expand Down

0 comments on commit f90adc4

Please sign in to comment.