Skip to content

Commit

Permalink
Fix issues when using CUDA: use Kokkos::min/max instead of std::min/max
Browse files Browse the repository at this point in the history
and replace one KOKKOS_LAMBDA with KOKKOS_CLASS_LAMBDA
  • Loading branch information
Rombur committed Feb 6, 2024
1 parent e12650e commit 91f9503
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions source/MaterialProperty.templates.hh
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ void MaterialProperty<dim, MemorySpaceType>::reinit_dofs()
Kokkos::Rank<2>>(
{{0, 0}},
{{g_n_material_states, static_cast<int>(_dofs_map.size())}}),
KOKKOS_LAMBDA(int i, int j) {
KOKKOS_CLASS_LAMBDA(int i, int j) {
_state(i, j) = std::numeric_limits<double>::signaling_NaN();
});
}
Expand Down Expand Up @@ -316,10 +316,10 @@ void MaterialProperty<dim, MemorySpaceType>::update(
// Because the powder can only become liquid, the solid can only
// become liquid, and the liquid can only become solid, the ratio of
// powder can only decrease.
powder_ratio = std::min(1. - liquid_ratio, _state(powder, dof));
powder_ratio = Kokkos::min(1. - liquid_ratio, _state(powder, dof));
// Use max to make sure that we don't create matter because of
// round-off.
solid_ratio = std::max(1 - liquid_ratio - powder_ratio, 0.);
solid_ratio = Kokkos::max(1 - liquid_ratio - powder_ratio, 0.);

// Update the value
_state(liquid, dof) = liquid_ratio;
Expand Down Expand Up @@ -689,9 +689,9 @@ void MaterialProperty<dim, MemorySpaceType>::set_state_device(
_state(liquid_state, mp_dof(i)) = liquid_ratio_sum / n_q_points;
_state(powder_state, mp_dof(i)) = powder_ratio_sum / n_q_points;
_state(solid_state, mp_dof(i)) =
std::max(1. - _state(liquid_state, mp_dof(i)) -
_state(powder_state, mp_dof(i)),
0.);
Kokkos::max(1. - _state(liquid_state, mp_dof(i)) -
_state(powder_state, mp_dof(i)),
0.);
});
}

Expand Down

0 comments on commit 91f9503

Please sign in to comment.