move d_ubuf to kokkos_type.h

https://matsci.org/t/a-few-kokkos-development-questions/56598/8 (Q11)
"More correct would be to use a union with ubuf as is done in the atom_vec styles, so that no precision is lost for converting a huge 64-bit integer to a double."
This commit is contained in:
alphataubio
2024-10-30 11:32:24 -04:00
parent 0e1137aee7
commit 50dd95e6e1
2 changed files with 10 additions and 11 deletions

View File

@ -24,17 +24,6 @@
namespace LAMMPS_NS {
union d_ubuf {
double d;
int64_t i;
KOKKOS_INLINE_FUNCTION
d_ubuf(double arg) : d(arg) {}
KOKKOS_INLINE_FUNCTION
d_ubuf(int64_t arg) : i(arg) {}
KOKKOS_INLINE_FUNCTION
d_ubuf(int arg) : i(arg) {}
};
class AtomVecKokkos : virtual public AtomVec {
public:
AtomVecKokkos(class LAMMPS *);

View File

@ -41,6 +41,16 @@ constexpr int HALF = 4;
#define MAX_TYPES_STACKPARAMS 12
static constexpr LAMMPS_NS::bigint LMP_KOKKOS_AV_DELTA = 10;
namespace LAMMPS_NS {
union d_ubuf {
double d;
int64_t i;
KOKKOS_INLINE_FUNCTION d_ubuf(double arg) : d(arg) {}
KOKKOS_INLINE_FUNCTION d_ubuf(int64_t arg) : i(arg) {}
KOKKOS_INLINE_FUNCTION d_ubuf(int arg) : i(arg) {}
};
}
namespace Kokkos {
static auto NoInit = [](std::string const& label) {
return Kokkos::view_alloc(Kokkos::WithoutInitializing, label);