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(eam/alloy/kk,PairEAMAlloyKokkos<LMPDeviceType>); 17 PairStyle(eam/alloy/kk/device,PairEAMAlloyKokkos<LMPDeviceType>); 18 PairStyle(eam/alloy/kk/host,PairEAMAlloyKokkos<LMPHostType>); 19 // clang-format on 20 #else 21 22 // clang-format off 23 #ifndef LMP_PAIR_EAM_ALLOY_KOKKOS_H 24 #define LMP_PAIR_EAM_ALLOY_KOKKOS_H 25 26 #include "kokkos_base.h" 27 #include "pair_kokkos.h" 28 #include "pair_eam.h" 29 #include "neigh_list_kokkos.h" 30 31 namespace LAMMPS_NS { 32 33 struct TagPairEAMAlloyPackForwardComm{}; 34 struct TagPairEAMAlloyUnpackForwardComm{}; 35 struct TagPairEAMAlloyInitialize{}; 36 37 template<int NEIGHFLAG, int NEWTON_PAIR> 38 struct TagPairEAMAlloyKernelA{}; 39 40 template<int EFLAG> 41 struct TagPairEAMAlloyKernelB{}; 42 43 template<int EFLAG> 44 struct TagPairEAMAlloyKernelAB{}; 45 46 template<int NEIGHFLAG, int NEWTON_PAIR, int EVFLAG> 47 struct TagPairEAMAlloyKernelC{}; 48 49 // Cannot use virtual inheritance on the GPU 50 51 template<class DeviceType> 52 class PairEAMAlloyKokkos : public PairEAM, public KokkosBase { 53 public: 54 enum {EnabledNeighFlags=FULL|HALFTHREAD|HALF}; 55 enum {COUL_FLAG=0}; 56 typedef DeviceType device_type; 57 typedef ArrayTypes<DeviceType> AT; 58 typedef EV_FLOAT value_type; 59 60 PairEAMAlloyKokkos(class LAMMPS *); 61 virtual ~PairEAMAlloyKokkos(); 62 void compute(int, int); 63 void init_style(); extract(const char *,int &)64 void *extract(const char *, int &) { return nullptr; } 65 void coeff(int, char **); 66 67 KOKKOS_INLINE_FUNCTION 68 void operator()(TagPairEAMAlloyPackForwardComm, const int&) const; 69 70 KOKKOS_INLINE_FUNCTION 71 void operator()(TagPairEAMAlloyUnpackForwardComm, const int&) const; 72 73 KOKKOS_INLINE_FUNCTION 74 void operator()(TagPairEAMAlloyInitialize, const int&) const; 75 76 template<int NEIGHFLAG, int NEWTON_PAIR> 77 KOKKOS_INLINE_FUNCTION 78 void operator()(TagPairEAMAlloyKernelA<NEIGHFLAG,NEWTON_PAIR>, const int&) const; 79 80 template<int EFLAG> 81 KOKKOS_INLINE_FUNCTION 82 void operator()(TagPairEAMAlloyKernelB<EFLAG>, const int&, EV_FLOAT&) const; 83 84 template<int EFLAG> 85 KOKKOS_INLINE_FUNCTION 86 void operator()(TagPairEAMAlloyKernelB<EFLAG>, const int&) const; 87 88 template<int EFLAG> 89 KOKKOS_INLINE_FUNCTION 90 void operator()(TagPairEAMAlloyKernelAB<EFLAG>, const int&, EV_FLOAT&) const; 91 92 template<int EFLAG> 93 KOKKOS_INLINE_FUNCTION 94 void operator()(TagPairEAMAlloyKernelAB<EFLAG>, const int&) const; 95 96 template<int NEIGHFLAG, int NEWTON_PAIR, int EVFLAG> 97 KOKKOS_INLINE_FUNCTION 98 void operator()(TagPairEAMAlloyKernelC<NEIGHFLAG,NEWTON_PAIR,EVFLAG>, const int&, EV_FLOAT&) const; 99 100 template<int NEIGHFLAG, int NEWTON_PAIR, int EVFLAG> 101 KOKKOS_INLINE_FUNCTION 102 void operator()(TagPairEAMAlloyKernelC<NEIGHFLAG,NEWTON_PAIR,EVFLAG>, const int&) const; 103 104 template<int NEIGHFLAG, int NEWTON_PAIR> 105 KOKKOS_INLINE_FUNCTION 106 void ev_tally(EV_FLOAT &ev, const int &i, const int &j, 107 const F_FLOAT &epair, const F_FLOAT &fpair, const F_FLOAT &delx, 108 const F_FLOAT &dely, const F_FLOAT &delz) const; 109 110 int pack_forward_comm_kokkos(int, DAT::tdual_int_2d, int, DAT::tdual_xfloat_1d&, 111 int, int *); 112 void unpack_forward_comm_kokkos(int, int, DAT::tdual_xfloat_1d&); 113 int pack_forward_comm(int, int *, double *, int, int *); 114 void unpack_forward_comm(int, int, double *); 115 int pack_reverse_comm(int, int, double *); 116 void unpack_reverse_comm(int, int *, double *); 117 118 protected: 119 typename AT::t_x_array x; 120 typename AT::t_f_array f; 121 typename AT::t_int_1d type; 122 typename AT::t_tagint_1d tag; 123 124 DAT::tdual_efloat_1d k_eatom; 125 DAT::tdual_virial_array k_vatom; 126 typename ArrayTypes<DeviceType>::t_efloat_1d d_eatom; 127 typename ArrayTypes<DeviceType>::t_virial_array d_vatom; 128 129 int need_dup; 130 Kokkos::Experimental::ScatterView<F_FLOAT*, typename DAT::t_ffloat_1d::array_layout,typename KKDevice<DeviceType>::value,typename Kokkos::Experimental::ScatterSum,Kokkos::Experimental::ScatterDuplicated> dup_rho; 131 Kokkos::Experimental::ScatterView<F_FLOAT*[3], typename DAT::t_f_array::array_layout,typename KKDevice<DeviceType>::value,typename Kokkos::Experimental::ScatterSum,Kokkos::Experimental::ScatterDuplicated> dup_f; 132 Kokkos::Experimental::ScatterView<E_FLOAT*, typename DAT::t_efloat_1d::array_layout,typename KKDevice<DeviceType>::value,typename Kokkos::Experimental::ScatterSum,Kokkos::Experimental::ScatterDuplicated> dup_eatom; 133 Kokkos::Experimental::ScatterView<F_FLOAT*[6], typename DAT::t_virial_array::array_layout,typename KKDevice<DeviceType>::value,typename Kokkos::Experimental::ScatterSum,Kokkos::Experimental::ScatterDuplicated> dup_vatom; 134 Kokkos::Experimental::ScatterView<F_FLOAT*, typename DAT::t_ffloat_1d::array_layout,typename KKDevice<DeviceType>::value,typename Kokkos::Experimental::ScatterSum,Kokkos::Experimental::ScatterNonDuplicated> ndup_rho; 135 Kokkos::Experimental::ScatterView<F_FLOAT*[3], typename DAT::t_f_array::array_layout,typename KKDevice<DeviceType>::value,typename Kokkos::Experimental::ScatterSum,Kokkos::Experimental::ScatterNonDuplicated> ndup_f; 136 Kokkos::Experimental::ScatterView<E_FLOAT*, typename DAT::t_efloat_1d::array_layout,typename KKDevice<DeviceType>::value,typename Kokkos::Experimental::ScatterSum,Kokkos::Experimental::ScatterNonDuplicated> ndup_eatom; 137 Kokkos::Experimental::ScatterView<F_FLOAT*[6], typename DAT::t_virial_array::array_layout,typename KKDevice<DeviceType>::value,typename Kokkos::Experimental::ScatterSum,Kokkos::Experimental::ScatterNonDuplicated> ndup_vatom; 138 139 DAT::tdual_ffloat_1d k_rho; 140 DAT::tdual_ffloat_1d k_fp; 141 typename AT::t_ffloat_1d d_rho; 142 typename AT::t_ffloat_1d d_fp; 143 HAT::t_ffloat_1d h_rho; 144 HAT::t_ffloat_1d h_fp; 145 146 typename AT::t_int_1d d_type2frho; 147 typename AT::t_int_2d_dl d_type2rhor; 148 typename AT::t_int_2d_dl d_type2z2r; 149 150 typedef Kokkos::DualView<F_FLOAT**[7],DeviceType> tdual_ffloat_2d_n7; 151 typedef typename tdual_ffloat_2d_n7::t_dev_const t_ffloat_2d_n7; 152 typedef typename tdual_ffloat_2d_n7::t_host t_host_ffloat_2d_n7; 153 154 t_ffloat_2d_n7 d_frho_spline; 155 t_ffloat_2d_n7 d_rhor_spline; 156 t_ffloat_2d_n7 d_z2r_spline; 157 158 void file2array(); 159 void file2array_alloy(); 160 void array2spline(); 161 void interpolate(int, double, double *, t_host_ffloat_2d_n7, int); 162 void read_file(char *); 163 164 typename AT::t_neighbors_2d d_neighbors; 165 typename AT::t_int_1d d_ilist; 166 typename AT::t_int_1d d_numneigh; 167 //NeighListKokkos<DeviceType> k_list; 168 169 int iswap; 170 int first; 171 typename AT::t_int_2d d_sendlist; 172 typename AT::t_xfloat_1d_um v_buf; 173 174 int neighflag,newton_pair; 175 int nlocal,nall,eflag,vflag; 176 177 friend void pair_virial_fdotr_compute<PairEAMAlloyKokkos>(PairEAMAlloyKokkos*); 178 }; 179 180 } 181 182 #endif 183 #endif 184 185 /* ERROR/WARNING messages: 186 187 E: Cannot use chosen neighbor list style with pair eam/kk/alloy 188 189 Self-explanatory. 190 191 E: Incorrect args for pair coefficients 192 193 Self-explanatory. Check the input script or data file. 194 195 E: No matching element in EAM potential file 196 197 The EAM potential file does not contain elements that match the 198 requested elements. 199 200 E: Cannot open EAM potential file %s 201 202 The specified EAM potential file cannot be opened. Check that the 203 path and name are correct. 204 205 E: Incorrect element names in EAM potential file 206 207 The element names in the EAM file do not match those requested. 208 209 */ 210