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

This commit is contained in:
Axel Kohlmeyer
2020-08-03 08:12:09 -04:00
parent d271ee65e8
commit 7e5e741ea1
4 changed files with 46 additions and 49 deletions

View File

@ -48,7 +48,7 @@ template <class numtyp, class acctyp>
int UFMT::init(const int ntypes, int UFMT::init(const int ntypes,
double **host_cutsq, double **host_uf1, double **host_cutsq, double **host_uf1,
double **host_uf2, double **host_uf3, double **host_uf2, double **host_uf3,
double **host_uf4, double **host_offset, double **host_offset,
double *host_special_lj, const int nlocal, double *host_special_lj, const int nlocal,
const int nall, const int max_nbors, const int nall, const int max_nbors,
const int maxspecial, const double cell_size, const int maxspecial, const double cell_size,
@ -78,11 +78,11 @@ int UFMT::init(const int ntypes,
uf1.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); uf1.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY);
this->atom->type_pack4(ntypes,lj_types,uf1,host_write,host_uf1,host_uf2, this->atom->type_pack4(ntypes,lj_types,uf1,host_write,host_uf1,host_uf2,
host_cutsq); host_cutsq);
uf3.alloc(lj_types*lj_types,*(this->ucl_device),UCL_READ_ONLY); 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); host_offset);
UCL_H_Vec<double> dview; UCL_H_Vec<double> dview;
sp_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY); sp_lj.alloc(4,*(this->ucl_device),UCL_READ_ONLY);
@ -96,8 +96,7 @@ int UFMT::init(const int ntypes,
template <class numtyp, class acctyp> template <class numtyp, class acctyp>
void UFMT::reinit(const int ntypes, double **host_cutsq, double **host_uf1, void UFMT::reinit(const int ntypes, double **host_cutsq, double **host_uf1,
double **host_uf2, double **host_uf3, double **host_uf2, double **host_uf3, double **host_offset) {
double **host_uf4, double **host_offset) {
// Allocate a host write buffer for data initialization // Allocate a host write buffer for data initialization
UCL_H_Vec<numtyp> host_write(_lj_types*_lj_types*32,*(this->ucl_device), UCL_H_Vec<numtyp> host_write(_lj_types*_lj_types*32,*(this->ucl_device),
UCL_WRITE_ONLY); 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, this->atom->type_pack4(ntypes,_lj_types,uf1,host_write,host_uf1,host_uf2,
host_cutsq); 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); host_offset);
} }

View File

@ -41,15 +41,14 @@ class UFM : public BaseAtomic<numtyp, acctyp> {
* - -5 Double precision is not supported on card **/ * - -5 Double precision is not supported on card **/
int init(const int ntypes, double **host_cutsq, int init(const int ntypes, double **host_cutsq,
double **host_uf1, double **host_uf2, double **host_uf3, 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 nlocal, const int nall, const int max_nbors,
const int maxspecial, const double cell_size, const int maxspecial, const double cell_size,
const double gpu_split, FILE *screen); const double gpu_split, FILE *screen);
/// Send updated coeffs from host to device (to be compatible with fix adapt) /// Send updated coeffs from host to device (to be compatible with fix adapt)
void reinit(const int ntypes, double **host_cutsq, void reinit(const int ntypes, double **host_cutsq, double **host_uf1,
double **host_uf1, double **host_uf2, double **host_uf3, double **host_uf2, double **host_uf3, double **host_offset);
double **host_uf4, double **host_offset);
/// Clear all host and device data /// Clear all host and device data
/** \note This is called at the beginning of the init() routine **/ /** \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 /// uf1.x = uf1, uf1.y = uf2, uf1.z = cutsq
UCL_D_Vec<numtyp4> uf1; 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; UCL_D_Vec<numtyp4> uf3;
/// Special LJ values /// Special LJ values
UCL_D_Vec<numtyp> sp_lj; UCL_D_Vec<numtyp> sp_lj;

View File

@ -30,10 +30,10 @@ static UFM<PRECISION,ACC_PRECISION> UFMLMF;
// Allocate memory on host and device and copy constants to device // Allocate memory on host and device and copy constants to device
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
int ufml_gpu_init(const int ntypes, double **cutsq, double **host_uf1, 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 **offset, double *special_lj, const int inum, const int nall, double *special_lj, const int inum, const int nall,
const int max_nbors, const int maxspecial, const double cell_size, const int max_nbors, const int maxspecial, const double cell_size,
int &gpu_mode, FILE *screen) { int &gpu_mode, FILE *screen) {
UFMLMF.clear(); UFMLMF.clear();
gpu_mode=UFMLMF.device->gpu_mode(); gpu_mode=UFMLMF.device->gpu_mode();
double gpu_split=UFMLMF.device->particle_split(); double gpu_split=UFMLMF.device->particle_split();
@ -57,8 +57,8 @@ int ufml_gpu_init(const int ntypes, double **cutsq, double **host_uf1,
int init_ok=0; int init_ok=0;
if (world_me==0) if (world_me==0)
init_ok=UFMLMF.init(ntypes, cutsq, host_uf1, host_uf2, host_uf3, 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); maxspecial, cell_size, gpu_split, screen);
UFMLMF.device->world_barrier(); UFMLMF.device->world_barrier();
if (message) if (message)
@ -74,7 +74,7 @@ int ufml_gpu_init(const int ntypes, double **cutsq, double **host_uf1,
fflush(screen); fflush(screen);
} }
if (gpu_rank==i && world_me!=0) 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, offset, special_lj, inum, nall, 300, maxspecial,
cell_size, gpu_split, screen); 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 // Copy updated coeffs from host to device
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
void ufml_gpu_reinit(const int ntypes, double **cutsq, double **host_uf1, void 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) {
double **offset) {
int world_me=UFMLMF.device->world_me(); int world_me=UFMLMF.device->world_me();
int gpu_rank=UFMLMF.device->gpu_rank(); int gpu_rank=UFMLMF.device->gpu_rank();
int procs_per_gpu=UFMLMF.device->procs_per_gpu(); int procs_per_gpu=UFMLMF.device->procs_per_gpu();
if (world_me==0) 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(); UFMLMF.device->world_barrier();
for (int i=0; i<procs_per_gpu; i++) { for (int i=0; i<procs_per_gpu; i++) {
if (gpu_rank==i && world_me!=0) 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(); UFMLMF.device->gpu_barrier();
} }
} }

View File

@ -43,13 +43,13 @@ using namespace LAMMPS_NS;
// External functions from cuda library for atom decomposition // External functions from cuda library for atom decomposition
int ufml_gpu_init(const int ntypes, double **cutsq, double **host_uf1, 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, double **offset, double *special_lj, const int nlocal,
const int nall, const int max_nbors, const int maxspecial, const int nall, const int max_nbors, const int maxspecial,
const double cell_size, int &gpu_mode, FILE *screen); const double cell_size, int &gpu_mode, FILE *screen);
int ufml_gpu_reinit(const int ntypes, double **cutsq, double **host_uf1, 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); double **offset);
void ufml_gpu_clear(); void ufml_gpu_clear();
@ -166,7 +166,7 @@ void PairUFMGPU::init_style()
int maxspecial=0; int maxspecial=0;
if (atom->molecular) if (atom->molecular)
maxspecial=atom->maxspecial; 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, offset, force->special_lj, atom->nlocal,
atom->nlocal+atom->nghost, 300, maxspecial, atom->nlocal+atom->nghost, 300, maxspecial,
cell_size, gpu_mode, screen); cell_size, gpu_mode, screen);
@ -185,7 +185,7 @@ void PairUFMGPU::reinit()
{ {
Pair::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);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */