Commit 65b87fa2 authored by Aidan P. Thompson's avatar Aidan P. Thompson
Browse files

Updated SNAP in KOKKOS package so it compiles and runs

parent c5c03230
Loading
Loading
Loading
Loading
+1 −17
Original line number Diff line number Diff line
@@ -85,9 +85,6 @@ void PairSNAPKokkos<DeviceType>::init_style()
  if (force->newton_pair == 0)
    error->all(FLERR,"Pair style SNAP requires newton pair on");

  if (diagonalstyle != 3)
    error->all(FLERR,"Must use diagonal style = 3 with pair snap/kk");

  // irequest = neigh request made by parent class

  neighflag = lmp->kokkos->neighflag;
@@ -343,23 +340,12 @@ void PairSNAPKokkos<DeviceType>::coeff(int narg, char **arg)
  Kokkos::deep_copy(d_coeffelem,h_coeffelem);
  Kokkos::deep_copy(d_map,h_map);

  // deallocate non-kokkos sna

  if (sna) {
    for (int tid = 0; tid<nthreads; tid++)
      delete sna[tid];
    delete [] sna;
    sna = NULL;
  }

  // allocate memory for per OpenMP thread data which
  // is wrapped into the sna class

  snaKK = SNAKokkos<DeviceType>(rfac0,twojmax,
                  diagonalstyle,use_shared_arrays,
                  rmin0,switchflag,bzeroflag);
    //if (!use_shared_arrays)
  snaKK.grow_rij(nmax);
  snaKK.grow_rij(0);
  snaKK.init();
}

@@ -667,8 +653,6 @@ double PairSNAPKokkos<DeviceType>::memory_usage()
  int n = atom->ntypes+1;
  bytes += n*n*sizeof(int);
  bytes += n*n*sizeof(double);
  bytes += 3*nmax*sizeof(double);
  bytes += nmax*sizeof(int);
  bytes += (2*ncoeffall)*sizeof(double);
  bytes += (ncoeff*3)*sizeof(double);
  bytes += snaKK.memory_usage();
+1 −7
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ inline
  SNAKokkos(const SNAKokkos<DeviceType>& sna, const typename Kokkos::TeamPolicy<DeviceType>::member_type& team);

inline
  SNAKokkos(double, int, int, int, double, int, int);
  SNAKokkos(double, int, double, int, int);

  KOKKOS_INLINE_FUNCTION
  ~SNAKokkos();
@@ -178,12 +178,6 @@ inline
                       double, double, double, // compute_duidrj
                       double, double, double, double, double);

  // if number of atoms are small use per atom arrays
  // for twojmax arrays, rij, inside, bvec
  // this will increase the memory footprint considerably,
  // but allows parallel filling and reuse of these arrays
  int use_shared_arrays;

  // Sets the style for the switching function
  // 0 = none
  // 1 = cosine
+42 −65
Original line number Diff line number Diff line
@@ -27,19 +27,17 @@ static const double MY_PI = 3.14159265358979323846; // pi
template<class DeviceType>
inline
SNAKokkos<DeviceType>::SNAKokkos(double rfac0_in,
         int twojmax_in, int diagonalstyle_in, int use_shared_arrays_in,
         int twojmax_in,
         double rmin0_in, int switch_flag_in, int bzero_flag_in)
{
  wself = 1.0;

  use_shared_arrays = use_shared_arrays_in;
  rfac0 = rfac0_in;
  rmin0 = rmin0_in;
  switch_flag = switch_flag_in;
  bzero_flag = bzero_flag_in;

  twojmax = twojmax_in;
  diagonalstyle = diagonalstyle_in;

  ncoeff = compute_ncoeff();

@@ -70,14 +68,12 @@ KOKKOS_INLINE_FUNCTION
SNAKokkos<DeviceType>::SNAKokkos(const SNAKokkos<DeviceType>& sna, const typename Kokkos::TeamPolicy<DeviceType>::member_type& team) {
  wself = sna.wself;

  use_shared_arrays = sna.use_shared_arrays;
  rfac0 = sna.rfac0;
  rmin0 = sna.rmin0;
  switch_flag = sna.switch_flag;
  bzero_flag = sna.bzero_flag;

  twojmax = sna.twojmax;
  diagonalstyle = sna.diagonalstyle;

  ncoeff = sna.ncoeff;
  nmax = sna.nmax;
@@ -104,7 +100,6 @@ template<class DeviceType>
inline
void SNAKokkos<DeviceType>::build_indexlist()
{
  if(diagonalstyle == 3) {
  int idxj_count = 0;
  int idxj_full_count = 0;

@@ -146,8 +141,6 @@ void SNAKokkos<DeviceType>::build_indexlist()
  Kokkos::deep_copy(idxj_full,h_idxj_full);

}

}
/* ---------------------------------------------------------------------- */

template<class DeviceType>
@@ -1223,26 +1216,10 @@ int SNAKokkos<DeviceType>::compute_ncoeff()
  ncount = 0;

  for (int j1 = 0; j1 <= twojmax; j1++)
    if(diagonalstyle == 0) {
      for (int j2 = 0; j2 <= j1; j2++)
        for (int j = abs(j1 - j2);
            j <= MIN(twojmax, j1 + j2); j += 2)
          ncount++;
    } else if(diagonalstyle == 1) {
      int j2 = j1;

      for (int j = abs(j1 - j2);
          j <= MIN(twojmax, j1 + j2); j += 2)
        ncount++;
    } else if(diagonalstyle == 2) {
      ncount++;
    } else if(diagonalstyle == 3) {
    for (int j2 = 0; j2 <= j1; j2++)
      for (int j = abs(j1 - j2);
	   j <= MIN(twojmax, j1 + j2); j += 2)
	if (j >= j1) ncount++;
    }

  return ncount;
}

+0 −3
Original line number Diff line number Diff line
@@ -1208,9 +1208,6 @@ double SNA::memory_usage()
  bytes += nmax * sizeof(double);                        // wj
  bytes += nmax * sizeof(double);                        // rcutij

  printf("SNAP Z list Memory Usage %d\n",idxz_max * sizeof(double) * 2);
  printf("SNAP CG list Memory Usage %d\n",idxcg_max * sizeof(double));

  return bytes;
}
/* ---------------------------------------------------------------------- */