Avoid CUDA Host/Device Constexpr Warning in Vector Reduction Identities
Problem
When building IPPL with CUDA on GH200, BareField tests emit warning #20013-D from the Kokkos::reduction_identity<ippl::Vector<T, Dim>> specialization in src/Field/BareField.hpp.
The warning is triggered by calling std::numeric_limits<T>::infinity() inside KOKKOS_FORCEINLINE_FUNCTION methods:
KOKKOS_FORCEINLINE_FUNCTION static ippl::Vector<T, Dim> min() {
return ippl::Vector<T, Dim>(std::numeric_limits<T>::infinity());
}
KOKKOS_FORCEINLINE_FUNCTION static ippl::Vector<T, Dim> max() {
return ippl::Vector<T, Dim>(-std::numeric_limits<T>::infinity());
}
NVCC diagnoses this because std::numeric_limits<T>::infinity() is treated as a constexpr host function being called from a host-device function.
We should avoid requiring the compiler workaround:
Proposed Fix
Delegate the scalar identity values back to Kokkos:
KOKKOS_FORCEINLINE_FUNCTION static ippl::Vector<T, Dim> min() {
return ippl::Vector<T, Dim>(Kokkos::reduction_identity<T>::min());
}
KOKKOS_FORCEINLINE_FUNCTION static ippl::Vector<T, Dim> max() {
return ippl::Vector<T, Dim>(Kokkos::reduction_identity<T>::max());
}
This matches Kokkos reduction semantics and keeps vector field reductions consistent with scalar field reductions. For float and double, Kokkos uses finite extrema (FLT_MAX, DBL_MAX) rather than infinities, which avoids the CUDA host/device constexpr warning.
Avoid CUDA Host/Device Constexpr Warning in Vector Reduction Identities
Problem
When building IPPL with CUDA on GH200,
BareFieldtests emit warning#20013-Dfrom theKokkos::reduction_identity<ippl::Vector<T, Dim>>specialization insrc/Field/BareField.hpp.The warning is triggered by calling
std::numeric_limits<T>::infinity()insideKOKKOS_FORCEINLINE_FUNCTIONmethods:NVCC diagnoses this because
std::numeric_limits<T>::infinity()is treated as a constexpr host function being called from a host-device function.We should avoid requiring the compiler workaround:
Proposed Fix
Delegate the scalar identity values back to Kokkos:
This matches Kokkos reduction semantics and keeps vector field reductions consistent with scalar field reductions. For
floatanddouble, Kokkos uses finite extrema (FLT_MAX,DBL_MAX) rather than infinities, which avoids the CUDA host/device constexpr warning.