ippl icon indicating copy to clipboard operation
ippl copied to clipboard

Fix warnings in current master

Open srikrrish opened this issue 3 months ago • 4 comments

The current Ippl master compiles with several warnings (mostly host_device functions calling host only functions). It would be good to fix them (at least most if not all) so that it doesn't get unmanageable. Below I list these warnings, what could be the potential cause and how we can may be fix it.

i)

/p/project1/pepcexa/muralikrishnan1/ippl_11_2025_master/ippl/src/Expression/IpplOperations.h(176): warning #20013-D: calling a constexpr __host__ function("std::__cxx11::basic_string<char, ::std::char_traits<char> , ::std::allocator<char> > ::~basic_string()") from a __host__ __device__ function("ippl::detail::ParticleAttribBase< ::Kokkos::CudaSpace> ::~ParticleAttribBase") is not allowed.

I think this is occurring due to the std::string here https://github.com/IPPL-framework/ippl/blob/master/src/Particle/ParticleAttribBase.h#L71 recently added by @klappi-s for vis. Can we use something else instead of std::string or modify string itself in a way that this warning does not happen?

ii)

warning #20011-D: calling a __host__ function("ippl::FEMVector<double> ::FEMVector(const ippl::FEMVector<double> &)") from a __host__ __device__ function("ippl::Subtract< ::ippl::FEMVector<double> , ::ippl::Multiply< ::ippl::detail::Scalar<double> , ::ippl::FEMVector<double> > > ::Subtract") is not allowed

As the message says FEMVector seems to be host only and all the Multiply, Subtract, Add etc. are host_device. @s-mayani Can we make FEMVector also host_device using Kokkos Macros?

iii) Warning #20208-D: 'long double' is treated as 'double' in device code . I think this is due to https://github.com/IPPL-framework/ippl/blob/master/src/FEM/Quadrature/GaussJacobiQuadrature.h#L31 in FEM. Is really long double needed there @s-mayani ? and if yes are there may be ways to do it in device code not sure.

iv)

/p/project1/pepcexa/muralikrishnan1/ippl_11_2025_master/ippl/src/Expression/IpplOperations.h(177): warning #20013-D: calling a constexpr __host__ function("std::array< ::std::variant< ::ippl::LoggingBufferHandler< ::Kokkos::HostSpace> , ::ippl::LoggingBufferHandler< ::Kokkos::CudaUVMSpace> , ::ippl::LoggingBufferHandler< ::Kokkos::CudaHostPinnedSpace> , ::ippl::LoggingBufferHandler< ::Kokkos::CudaSpace> > , (unsigned long)4ul> ::array(const ::std::array< ::std::variant< ::ippl::LoggingBufferHandler< ::Kokkos::HostSpace> , ::ippl::LoggingBufferHandler< ::Kokkos::CudaUVMSpace> , ::ippl::LoggingBufferHandler< ::Kokkos::CudaHostPinnedSpace> , ::ippl::LoggingBufferHandler< ::Kokkos::CudaSpace> > , (unsigned long)4ul> &)") from a __host__ __device__ function("ippl::detail::MultispaceContainer< ::ippl::LoggingBufferHandler, ::Kokkos::CudaSpace, ::Kokkos::CudaHostPinnedSpace, ::Kokkos::CudaUVMSpace, ::Kokkos::HostSpace > ::MultispaceContainer") is not allowed

This seems to be due to use of std::array which is not host_device but I am not sure exactly where the usage is as it is something to do with MultispaceContainer and may be LoggingBufferHandler

srikrrish avatar Nov 07 '25 12:11 srikrrish

With https://github.com/IPPL-framework/ippl/pull/448 (ii) and (iii) are fixed. I no longer also don't see (iv) from the CI compilation tests. But I missed one more warning from unit tests as I was not turning it on in my builds. It is things like

/p/home/jusers/muralikrishnan1/juwels/.jacamar-ci/builds/ippl_6975/002/muralikrishnan1/ippl/src/Field/BareField.hpp(30): warning #20013-D: calling a constexpr __host__ function("infinity") from a __host__ __device__ function("max") is not allowed. The experimental flag '--expt-relaxed-constexpr' can be used to allow this.
              return ippl::Vector<T, Dim>(-std::numeric_limits<T>::infinity());

This seems to be due to the use of std::numeric_limits<T>::infinity() which is host only.

srikrrish avatar Nov 07 '25 14:11 srikrrish

I have found it hard to find an equivalent of the numeric_limits in Kokkos. I looked up the Kokkos numeric traits but they also seem to work host only (or at least how I've tried to call them). See https://kokkos.org/kokkos-core-wiki/API/core/numerics/numeric-traits.html.

s-mayani avatar Nov 11 '25 07:11 s-mayani

Thanks for the link. I am not sure why it should be host only as looking at the page it seems infinity_v should work. I will give it a try.

srikrrish avatar Nov 11 '25 07:11 srikrrish

I think the page is not up to date, I tried it and couldn't get it to work. Maybe a question for the Kokkos slack channel if you do not manage to make it work.

s-mayani avatar Nov 11 '25 07:11 s-mayani