1 /* -*- c++ -*- ---------------------------------------------------------- 2 LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator 3 https://www.lammps.org/, Sandia National Laboratories 4 Steve Plimpton, sjplimp@sandia.gov 5 6 Copyright (2003) Sandia Corporation. Under the terms of Contract 7 DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains 8 certain rights in this software. This software is distributed under 9 the GNU General Public License. 10 11 See the README file in the top-level LAMMPS directory. 12 ------------------------------------------------------------------------- */ 13 14 #ifdef BOND_CLASS 15 // clang-format off 16 BondStyle(harmonic/kk,BondHarmonicKokkos<LMPDeviceType>); 17 BondStyle(harmonic/kk/device,BondHarmonicKokkos<LMPDeviceType>); 18 BondStyle(harmonic/kk/host,BondHarmonicKokkos<LMPHostType>); 19 // clang-format on 20 #else 21 22 // clang-format off 23 #ifndef LMP_BOND_HARMONIC_KOKKOS_H 24 #define LMP_BOND_HARMONIC_KOKKOS_H 25 26 #include "bond_harmonic.h" 27 #include "kokkos_type.h" 28 29 namespace LAMMPS_NS { 30 31 template<int NEWTON_BOND, int EVFLAG> 32 struct TagBondHarmonicCompute{}; 33 34 template<class DeviceType> 35 class BondHarmonicKokkos : public BondHarmonic { 36 37 public: 38 typedef DeviceType device_type; 39 typedef EV_FLOAT value_type; 40 41 BondHarmonicKokkos(class LAMMPS *); 42 virtual ~BondHarmonicKokkos(); 43 void compute(int, int); 44 void coeff(int, char **); 45 void read_restart(FILE *); 46 47 template<int NEWTON_BOND, int EVFLAG> 48 KOKKOS_INLINE_FUNCTION 49 void operator()(TagBondHarmonicCompute<NEWTON_BOND,EVFLAG>, const int&, EV_FLOAT&) const; 50 51 template<int NEWTON_BOND, int EVFLAG> 52 KOKKOS_INLINE_FUNCTION 53 void operator()(TagBondHarmonicCompute<NEWTON_BOND,EVFLAG>, const int&) const; 54 55 //template<int NEWTON_BOND> 56 KOKKOS_INLINE_FUNCTION 57 void ev_tally(EV_FLOAT &ev, const int &i, const int &j, 58 const F_FLOAT &ebond, const F_FLOAT &fbond, const F_FLOAT &delx, 59 const F_FLOAT &dely, const F_FLOAT &delz) const; 60 61 protected: 62 63 class NeighborKokkos *neighborKK; 64 65 typedef ArrayTypes<DeviceType> AT; 66 typename AT::t_x_array_randomread x; 67 typename Kokkos::View<double*[3],typename AT::t_f_array::array_layout,typename KKDevice<DeviceType>::value,Kokkos::MemoryTraits<Kokkos::Atomic> > f; 68 typename AT::t_int_2d bondlist; 69 70 typedef typename KKDevice<DeviceType>::value KKDeviceType; 71 Kokkos::DualView<E_FLOAT*,Kokkos::LayoutRight,KKDeviceType> k_eatom; 72 Kokkos::DualView<F_FLOAT*[6],Kokkos::LayoutRight,KKDeviceType> k_vatom; 73 Kokkos::View<E_FLOAT*,Kokkos::LayoutRight,KKDeviceType,Kokkos::MemoryTraits<Kokkos::Atomic> > d_eatom; 74 Kokkos::View<F_FLOAT*[6],Kokkos::LayoutRight,KKDeviceType,Kokkos::MemoryTraits<Kokkos::Atomic> > d_vatom; 75 76 int nlocal,newton_bond; 77 int eflag,vflag; 78 79 typename AT::t_ffloat_1d d_k; 80 typename AT::t_ffloat_1d d_r0; 81 82 void allocate(); 83 }; 84 85 } 86 87 #endif 88 #endif 89 90 /* ERROR/WARNING messages: 91 92 */ 93