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 PAIR_CLASS 15 // clang-format off 16 PairStyle(buck/kk,PairBuckKokkos<LMPDeviceType>); 17 PairStyle(buck/kk/device,PairBuckKokkos<LMPDeviceType>); 18 PairStyle(buck/kk/host,PairBuckKokkos<LMPHostType>); 19 // clang-format on 20 #else 21 22 // clang-format off 23 #ifndef LMP_PAIR_BUCK_KOKKOS_H 24 #define LMP_PAIR_BUCK_KOKKOS_H 25 26 #include "pair_kokkos.h" 27 #include "pair_buck.h" 28 #include "neigh_list_kokkos.h" 29 30 namespace LAMMPS_NS { 31 32 template<class DeviceType> 33 class PairBuckKokkos : public PairBuck { 34 public: 35 enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF}; 36 enum {COUL_FLAG=0}; 37 typedef DeviceType device_type; 38 typedef ArrayTypes<DeviceType> AT; 39 PairBuckKokkos(class LAMMPS *); 40 ~PairBuckKokkos(); 41 42 void compute(int, int); 43 44 void init_style(); 45 double init_one(int, int); 46 47 struct params_buck{ 48 KOKKOS_INLINE_FUNCTION params_buckparams_buck49 params_buck() {cutsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; 50 KOKKOS_INLINE_FUNCTION params_buckparams_buck51 params_buck(int /*i*/) {cutsq=0;a=0;c=0;rhoinv=0;buck1=0;buck2=0;offset=0;}; 52 F_FLOAT cutsq,a,c,rhoinv,buck1,buck2,offset; 53 }; 54 55 protected: 56 template<bool STACKPARAMS, class Specialisation> 57 KOKKOS_INLINE_FUNCTION 58 F_FLOAT compute_fpair(const F_FLOAT& rsq, const int& i, const int&j, const int& itype, const int& jtype) const; 59 60 template<bool STACKPARAMS, class Specialisation> 61 KOKKOS_INLINE_FUNCTION 62 F_FLOAT compute_evdwl(const F_FLOAT& rsq, const int& i, const int&j, const int& itype, const int& jtype) const; 63 64 template<bool STACKPARAMS, class Specialisation> 65 KOKKOS_INLINE_FUNCTION compute_ecoul(const F_FLOAT &,const int &,const int &,const int &,const int &)66 F_FLOAT compute_ecoul(const F_FLOAT& /*rsq*/, const int& /*i*/, const int& /*j*/, 67 const int& /*itype*/, const int& /*jtype*/) const { return 0; } 68 69 Kokkos::DualView<params_buck**,Kokkos::LayoutRight,DeviceType> k_params; 70 typename Kokkos::DualView<params_buck**,Kokkos::LayoutRight,DeviceType>::t_dev_const_um params; 71 params_buck m_params[MAX_TYPES_STACKPARAMS+1][MAX_TYPES_STACKPARAMS+1]; // hardwired to space for 12 atom types 72 F_FLOAT m_cutsq[MAX_TYPES_STACKPARAMS+1][MAX_TYPES_STACKPARAMS+1]; 73 typename AT::t_x_array_randomread x; 74 typename AT::t_x_array c_x; 75 typename AT::t_f_array f; 76 typename AT::t_int_1d_randomread type; 77 typename AT::t_tagint_1d tag; 78 79 DAT::tdual_efloat_1d k_eatom; 80 DAT::tdual_virial_array k_vatom; 81 typename AT::t_efloat_1d d_eatom; 82 typename AT::t_virial_array d_vatom; 83 84 int newton_pair; 85 double special_lj[4]; 86 87 typename AT::tdual_ffloat_2d k_cutsq; 88 typename AT::t_ffloat_2d d_cutsq; 89 90 91 int neighflag; 92 int nlocal,nall,eflag,vflag; 93 94 void allocate(); 95 friend struct PairComputeFunctor<PairBuckKokkos,FULL,true>; 96 friend struct PairComputeFunctor<PairBuckKokkos,HALF,true>; 97 friend struct PairComputeFunctor<PairBuckKokkos,HALFTHREAD,true>; 98 friend struct PairComputeFunctor<PairBuckKokkos,FULL,false>; 99 friend struct PairComputeFunctor<PairBuckKokkos,HALF,false>; 100 friend struct PairComputeFunctor<PairBuckKokkos,HALFTHREAD,false>; 101 friend EV_FLOAT pair_compute_neighlist<PairBuckKokkos,FULL,void>(PairBuckKokkos*,NeighListKokkos<DeviceType>*); 102 friend EV_FLOAT pair_compute_neighlist<PairBuckKokkos,HALF,void>(PairBuckKokkos*,NeighListKokkos<DeviceType>*); 103 friend EV_FLOAT pair_compute_neighlist<PairBuckKokkos,HALFTHREAD,void>(PairBuckKokkos*,NeighListKokkos<DeviceType>*); 104 friend EV_FLOAT pair_compute<PairBuckKokkos,void>(PairBuckKokkos*,NeighListKokkos<DeviceType>*); 105 friend void pair_virial_fdotr_compute<PairBuckKokkos>(PairBuckKokkos*); 106 }; 107 108 } 109 110 #endif 111 #endif 112 113 /* ERROR/WARNING messages: 114 115 E: Cannot use Kokkos pair style with rRESPA inner/middle 116 117 Self-explanatory. 118 119 E: Cannot use chosen neighbor list style with buck/kk 120 121 That style is not supported by Kokkos. 122 123 */ 124