Unverified Commit 7e5e741e authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

update code for ufm/gpu to match changes in base class where uf4 is removed

parent d271ee65
Loading
Loading
Loading
Loading
+15 −16
Original line number Diff line number Diff line
@@ -48,7 +48,7 @@ template <class numtyp, class acctyp>
int UFMT::init(const int ntypes,
                          double **host_cutsq, double **host_uf1,
                          double **host_uf2, double **host_uf3,
                          double **host_uf4, double **host_offset, 
                          double **host_offset,
                          double *host_special_lj, const int nlocal,
                          const int nall, const int max_nbors,
                          const int maxspecial, const double cell_size,
@@ -81,7 +81,7 @@ int UFMT::init(const int ntypes,
                         host_cutsq);

  uf3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY);
  this->atom->type_pack4(ntypes,lj_types,uf3,host_write,host_uf3,host_uf4,
  this->atom->type_pack4(ntypes,lj_types,uf3,host_write,host_uf3,host_uf2,
                         host_offset);

  UCL_H_Vec<double> dview;
@@ -96,8 +96,7 @@ int UFMT::init(const int ntypes,

template <class numtyp, class acctyp>
void UFMT::reinit(const int ntypes, double **host_cutsq, double **host_uf1,
                 double **host_uf2, double **host_uf3,
                 double **host_uf4, double **host_offset) {
                 double **host_uf2, double **host_uf3, double **host_offset) {
  // Allocate a host write buffer for data initialization
  UCL_H_Vec<numtyp> host_write(_lj_types*_lj_types*32,*(this->ucl_device),
                               UCL_WRITE_ONLY);
@@ -107,7 +106,7 @@ void UFMT::reinit(const int ntypes, double **host_cutsq, double **host_uf1,

  this->atom->type_pack4(ntypes,_lj_types,uf1,host_write,host_uf1,host_uf2,
                         host_cutsq);
  this->atom->type_pack4(ntypes,_lj_types,uf3,host_write,host_uf3,host_uf4,
  this->atom->type_pack4(ntypes,_lj_types,uf3,host_write,host_uf3,host_uf2,
                         host_offset);
}

+11 −12
Original line number Diff line number Diff line
@@ -41,15 +41,14 @@ class UFM : public BaseAtomic<numtyp, acctyp> {
    * - -5 Double precision is not supported on card **/
  int init(const int ntypes, double **host_cutsq,
           double **host_uf1, double **host_uf2, double **host_uf3,
           double **host_uf4, double **host_offset, double *host_special_lj,
           double **host_offset, double *host_special_lj,
           const int nlocal, const int nall, const int max_nbors,
           const int maxspecial, const double cell_size,
           const double gpu_split, FILE *screen);

  /// Send updated coeffs from host to device (to be compatible with fix adapt)
  void reinit(const int ntypes, double **host_cutsq,
              double **host_uf1, double **host_uf2, double **host_uf3,
              double **host_uf4, double **host_offset);
  void reinit(const int ntypes, double **host_cutsq, double **host_uf1,
              double **host_uf2, double **host_uf3, double **host_offset);

  /// Clear all host and device data
  /** \note This is called at the beginning of the init() routine **/
@@ -65,7 +64,7 @@ class UFM : public BaseAtomic<numtyp, acctyp> {

  /// uf1.x = uf1, uf1.y = uf2, uf1.z = cutsq
  UCL_D_Vec<numtyp4> uf1;
  /// uf3.x = uf3, uf3.y = uf4, uf3.z = offset
  /// uf3.x = uf3, uf3.y = uf2, uf3.z = offset
  UCL_D_Vec<numtyp4> uf3;
  /// Special LJ values
  UCL_D_Vec<numtyp> sp_lj;
+16 −17
Original line number Diff line number Diff line
@@ -30,8 +30,8 @@ static UFM<PRECISION,ACC_PRECISION> UFMLMF;
// Allocate memory on host and device and copy constants to device
// ---------------------------------------------------------------------------
int ufml_gpu_init(const int ntypes, double **cutsq, double **host_uf1,
                 double **host_uf2, double **host_uf3, double **host_uf4,
                 double **offset, double *special_lj, const int inum, const int nall,
                 double **host_uf2, double **host_uf3, double **offset,
                 double *special_lj, const int inum, const int nall,
                 const int max_nbors,  const int maxspecial, const double cell_size,
                 int &gpu_mode, FILE *screen) {
  UFMLMF.clear();
@@ -57,7 +57,7 @@ int ufml_gpu_init(const int ntypes, double **cutsq, double **host_uf1,
  int init_ok=0;
  if (world_me==0)
    init_ok=UFMLMF.init(ntypes, cutsq, host_uf1, host_uf2, host_uf3,
                       host_uf4, offset, special_lj, inum, nall, 300,
                        offset, special_lj, inum, nall, 300,
                        maxspecial, cell_size, gpu_split, screen);

  UFMLMF.device->world_barrier();
@@ -74,7 +74,7 @@ int ufml_gpu_init(const int ntypes, double **cutsq, double **host_uf1,
      fflush(screen);
    }
    if (gpu_rank==i && world_me!=0)
      init_ok=UFMLMF.init(ntypes, cutsq, host_uf1, host_uf2, host_uf3, host_uf4,
      init_ok=UFMLMF.init(ntypes, cutsq, host_uf1, host_uf2, host_uf3,
                         offset, special_lj, inum, nall, 300, maxspecial,
                         cell_size, gpu_split, screen);

@@ -94,19 +94,18 @@ int ufml_gpu_init(const int ntypes, double **cutsq, double **host_uf1,
// Copy updated coeffs from host to device
// ---------------------------------------------------------------------------
void ufml_gpu_reinit(const int ntypes, double **cutsq, double **host_uf1,
                    double **host_uf2, double **host_uf3, double **host_uf4,
                    double **offset) {
                    double **host_uf2, double **host_uf3, double **offset) {
  int world_me=UFMLMF.device->world_me();
  int gpu_rank=UFMLMF.device->gpu_rank();
  int procs_per_gpu=UFMLMF.device->procs_per_gpu();

  if (world_me==0)
    UFMLMF.reinit(ntypes, cutsq, host_uf1, host_uf2, host_uf3, host_uf4, offset);
    UFMLMF.reinit(ntypes, cutsq, host_uf1, host_uf2, host_uf3, offset);
  UFMLMF.device->world_barrier();

  for (int i=0; i<procs_per_gpu; i++) {
    if (gpu_rank==i && world_me!=0)
      UFMLMF.reinit(ntypes, cutsq, host_uf1, host_uf2, host_uf3, host_uf4, offset);
      UFMLMF.reinit(ntypes, cutsq, host_uf1, host_uf2, host_uf3, offset);
    UFMLMF.device->gpu_barrier();
  }
}
+4 −4
Original line number Diff line number Diff line
@@ -43,13 +43,13 @@ using namespace LAMMPS_NS;
// External functions from cuda library for atom decomposition

int ufml_gpu_init(const int ntypes, double **cutsq, double **host_uf1,
                 double **host_uf2, double **host_uf3, double **host_uf4,
                 double **host_uf2, double **host_uf3,
                 double **offset, double *special_lj, const int nlocal,
                 const int nall, const int max_nbors, const int maxspecial,
                 const double cell_size, int &gpu_mode, FILE *screen);

int ufml_gpu_reinit(const int ntypes, double **cutsq, double **host_uf1,
                   double **host_uf2, double **host_uf3, double **host_uf4,
                   double **host_uf2, double **host_uf3,
                   double **offset);

void ufml_gpu_clear();
@@ -166,7 +166,7 @@ void PairUFMGPU::init_style()
  int maxspecial=0;
  if (atom->molecular)
    maxspecial=atom->maxspecial;
  int success = ufml_gpu_init(atom->ntypes+1, cutsq, uf1, uf2, uf3, uf4,
  int success = ufml_gpu_init(atom->ntypes+1, cutsq, uf1, uf2, uf3,
                             offset, force->special_lj, atom->nlocal,
                             atom->nlocal+atom->nghost, 300, maxspecial,
                             cell_size, gpu_mode, screen);
@@ -185,7 +185,7 @@ void PairUFMGPU::reinit()
{
  Pair::reinit();

  ufml_gpu_reinit(atom->ntypes+1, cutsq, uf1, uf2, uf3, uf4, offset);
  ufml_gpu_reinit(atom->ntypes+1, cutsq, uf1, uf2, uf3, offset);
}

/* ---------------------------------------------------------------------- */