Commit 7a788759 authored by smoore's avatar smoore
Browse files

Fix issues in Kokkos pair snap and zbl

parent 22d2d1cd
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ public:
  
  void coeff(int, char**);
  void init_style();
  double init_one(int, int);
  void compute(int, int);
  double memory_usage();

@@ -118,8 +119,8 @@ inline double dist2(double* x,double* y);
  Kokkos::View<F_FLOAT**, Kokkos::LayoutRight, DeviceType> d_coeffelem;           // element bispectrum coefficients
  Kokkos::View<T_INT*, DeviceType> d_map;                     // mapping from atom types to elements

  typedef Kokkos::View<F_FLOAT**, DeviceType> t_fparams;
  t_fparams d_cutsq;
  typedef Kokkos::DualView<F_FLOAT**, DeviceType> tdual_fparams;
  tdual_fparams k_cutsq;
  typedef Kokkos::View<const F_FLOAT**, DeviceType,
      Kokkos::MemoryTraits<Kokkos::RandomAccess> > t_fparams_rnd;
  t_fparams_rnd rnd_cutsq;
+17 −9
Original line number Diff line number Diff line
@@ -58,7 +58,9 @@ PairSNAPKokkos<DeviceType>::PairSNAPKokkos(LAMMPS *lmp) : PairSNAP(lmp)
  datamask_modify = EMPTY_MASK;

  vector_length = 8;
  d_cutsq = t_fparams("PairSNAPKokkos::cutsq",atom->ntypes+1,atom->ntypes+1);
  k_cutsq = tdual_fparams("PairSNAPKokkos::cutsq",atom->ntypes+1,atom->ntypes+1);
  auto d_cutsq = k_cutsq.template view<DeviceType>();
  rnd_cutsq = d_cutsq;
}

/* ---------------------------------------------------------------------- */
@@ -160,6 +162,7 @@ void PairSNAPKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
  x = atomKK->k_x.view<DeviceType>();
  f = atomKK->k_f.view<DeviceType>();
  type = atomKK->k_type.view<DeviceType>();
  k_cutsq.template sync<DeviceType>();

  NeighListKokkos<DeviceType>* k_list = static_cast<NeighListKokkos<DeviceType>*>(list);
  d_numneigh = k_list->d_numneigh;
@@ -268,6 +271,19 @@ void PairSNAPKokkos<DeviceType>::allocate()
  d_map = Kokkos::View<T_INT*, DeviceType>("PairSNAPKokkos::map",n+1);
}


/* ----------------------------------------------------------------------
   init for one type pair i,j and corresponding j,i
------------------------------------------------------------------------- */

template<class DeviceType>
double PairSNAPKokkos<DeviceType>::init_one(int i, int j)
{
  double cutone = PairSNAP::init_one(i,j);
  k_cutsq.h_view(i,j) = k_cutsq.h_view(j,i) = cutone*cutone;
  k_cutsq.template modify<LMPHostType>();
}

/* ----------------------------------------------------------------------
   set coeffs for one or more type pairs
------------------------------------------------------------------------- */
@@ -287,7 +303,6 @@ void PairSNAPKokkos<DeviceType>::coeff(int narg, char **arg)
  auto h_wjelem = Kokkos::create_mirror_view(d_wjelem);
  auto h_coeffelem = Kokkos::create_mirror_view(d_coeffelem);
  auto h_map = Kokkos::create_mirror_view(d_map);
  auto h_cutsq = Kokkos::create_mirror_view(d_cutsq);

  for (int ielem = 0; ielem < nelements; ielem++) {
    h_radelem(ielem) = radelem[ielem];
@@ -299,19 +314,12 @@ void PairSNAPKokkos<DeviceType>::coeff(int narg, char **arg)

  for (int i = 1; i <= atom->ntypes; i++) {
    h_map(i) = map[i];
    for (int j = 1; j <= atom->ntypes; j++) {
      double cutone = (radelem[map[i]] +
        radelem[map[j]])*rcutfac;
      h_cutsq(i,j) = cutone*cutone;
    }
  }

  Kokkos::deep_copy(d_radelem,h_radelem);
  Kokkos::deep_copy(d_wjelem,h_wjelem);
  Kokkos::deep_copy(d_coeffelem,h_coeffelem);
  Kokkos::deep_copy(d_map,h_map);
  Kokkos::deep_copy(d_cutsq,h_cutsq);
  rnd_cutsq = d_cutsq;

  // deallocate non-kokkos sna

+12 −11
Original line number Diff line number Diff line
@@ -287,16 +287,17 @@ double PairZBLKokkos<DeviceType>::init_one(int i, int j)
  double cutone = PairZBL::init_one(i,j);

  k_z.h_view(i) = z[i];
  k_d1a.h_view(i,j) = d1a[i][j];
  k_d2a.h_view(i,j) = d2a[i][j];
  k_d3a.h_view(i,j) = d3a[i][j];
  k_d4a.h_view(i,j) = d4a[i][j];
  k_zze.h_view(i,j) = zze[i][j];
  k_sw1.h_view(i,j) = sw1[i][j];
  k_sw2.h_view(i,j) = sw2[i][j];
  k_sw3.h_view(i,j) = sw3[i][j];
  k_sw4.h_view(i,j) = sw4[i][j];
  k_sw5.h_view(i,j) = sw5[i][j];
  k_z.h_view(j) = z[j];
  k_d1a.h_view(i,j) = k_d1a.h_view(j,i) = d1a[i][j];
  k_d2a.h_view(i,j) = k_d2a.h_view(j,i) = d2a[i][j];
  k_d3a.h_view(i,j) = k_d3a.h_view(j,i) = d3a[i][j];
  k_d4a.h_view(i,j) = k_d4a.h_view(j,i) = d4a[i][j];
  k_zze.h_view(i,j) = k_zze.h_view(j,i) = zze[i][j];
  k_sw1.h_view(i,j) = k_sw1.h_view(j,i) = sw1[i][j];
  k_sw2.h_view(i,j) = k_sw2.h_view(j,i) = sw2[i][j];
  k_sw3.h_view(i,j) = k_sw3.h_view(j,i) = sw3[i][j];
  k_sw4.h_view(i,j) = k_sw4.h_view(j,i) = sw4[i][j];
  k_sw5.h_view(i,j) = k_sw5.h_view(j,i) = sw5[i][j];

  k_z.modify<LMPHostType>();
  k_d1a.modify<LMPHostType>();
@@ -311,7 +312,7 @@ double PairZBLKokkos<DeviceType>::init_one(int i, int j)
  k_sw5.modify<LMPHostType>();

  if(i<MAX_TYPES_STACKPARAMS+1 && j<MAX_TYPES_STACKPARAMS+1) {
    m_cutsq[j][i] = m_cutsq[i][j] = cutone*cutone;
    m_cutsq[i][j] = m_cutsq[j][i] = cutone*cutone;
  }

  return cutone;
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ public:
  void settings(int, char **);
  virtual void coeff(int, char **);
  virtual void init_style();
  double init_one(int, int);
  virtual double init_one(int, int);
  virtual double memory_usage();

protected: