changed names of files, and added a lj12-5 function type.

This commit is contained in:
yskmiyazaki
2022-07-08 17:28:50 +09:00
parent c71e1cd470
commit fc741e0df6
8 changed files with 68 additions and 56 deletions

View File

@ -1,9 +1,9 @@
/*************************************************************************** /***************************************************************************
lj_sdk.cpp lj_spica.cpp
------------------- -------------------
W. Michael Brown (ORNL) W. Michael Brown (ORNL)
Class for acceleration of the lj/sdk/cut pair style Class for acceleration of the lj/spica/cut pair style
__________________________________________________________________________ __________________________________________________________________________
This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
@ -14,14 +14,14 @@
***************************************************************************/ ***************************************************************************/
#if defined(USE_OPENCL) #if defined(USE_OPENCL)
#include "lj_sdk_cl.h" #include "lj_spica_cl.h"
#elif defined(USE_CUDART) #elif defined(USE_CUDART)
const char *lj_sdk=0; const char *lj_spica=0;
#else #else
#include "lj_sdk_cubin.h" #include "lj_spica_cubin.h"
#endif #endif
#include "lal_lj_sdk.h" #include "lal_lj_spica.h"
#include <cassert> #include <cassert>
namespace LAMMPS_AL { namespace LAMMPS_AL {
#define CGCMMT CGCMM<numtyp, acctyp> #define CGCMMT CGCMM<numtyp, acctyp>
@ -53,33 +53,33 @@ int CGCMMT::init(const int ntypes, double **host_cutsq,
const double gpu_split, FILE *_screen) { const double gpu_split, FILE *_screen) {
int success; int success;
success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size,gpu_split, success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size,gpu_split,
_screen,lj_sdk,"k_lj_sdk"); _screen,lj_spica,"k_lj_spica");
if (success!=0) if (success!=0)
return success; return success;
// If atom type constants fit in shared memory use fast kernel // If atom type constants fit in shared memory use fast kernel
int sdk_types=ntypes; int spica_types=ntypes;
shared_types=false; shared_types=false;
int max_shared_types=this->device->max_shared_types(); int max_shared_types=this->device->max_shared_types();
if (sdk_types<=max_shared_types && this->_block_size>=max_shared_types) { if (spica_types<=max_shared_types && this->_block_size>=max_shared_types) {
sdk_types=max_shared_types; spica_types=max_shared_types;
shared_types=true; shared_types=true;
} }
_sdk_types=sdk_types; _spica_types=spica_types;
// Allocate a host write buffer for data initialization // Allocate a host write buffer for data initialization
UCL_H_Vec<numtyp> host_write(sdk_types*sdk_types*32,*(this->ucl_device), UCL_H_Vec<numtyp> host_write(spica_types*spica_types*32,*(this->ucl_device),
UCL_WRITE_ONLY); UCL_WRITE_ONLY);
for (int i=0; i<sdk_types*sdk_types; i++) for (int i=0; i<spica_types*spica_types; i++)
host_write[i]=0.0; host_write[i]=0.0;
lj1.alloc(sdk_types*sdk_types,*(this->ucl_device),UCL_READ_ONLY); lj1.alloc(spica_types*spica_types,*(this->ucl_device),UCL_READ_ONLY);
this->atom->type_pack4(ntypes,sdk_types,lj1,host_write,host_cutsq, this->atom->type_pack4(ntypes,spica_types,lj1,host_write,host_cutsq,
host_cg_type,host_lj1,host_lj2); host_cg_type,host_lj1,host_lj2);
lj3.alloc(sdk_types*sdk_types,*(this->ucl_device),UCL_READ_ONLY); lj3.alloc(spica_types*spica_types,*(this->ucl_device),UCL_READ_ONLY);
this->atom->type_pack4(ntypes,sdk_types,lj3,host_write,host_lj3,host_lj4, this->atom->type_pack4(ntypes,spica_types,lj3,host_write,host_lj3,host_lj4,
host_offset); host_offset);
UCL_H_Vec<double> dview; UCL_H_Vec<double> dview;
@ -132,7 +132,7 @@ int CGCMMT::loop(const int eflag, const int vflag) {
} else { } else {
this->k_pair.set_size(GX,BX); this->k_pair.set_size(GX,BX);
this->k_pair.run(&this->atom->x, &lj1, &lj3, this->k_pair.run(&this->atom->x, &lj1, &lj3,
&_sdk_types, &sp_lj, &this->nbor->dev_nbor, &_spica_types, &sp_lj, &this->nbor->dev_nbor,
&this->_nbor_data->begin(), &this->ans->force, &this->_nbor_data->begin(), &this->ans->force,
&this->ans->engv, &eflag, &vflag, &ainum, &this->ans->engv, &eflag, &vflag, &ainum,
&nbor_pitch, &this->_threads_per_atom); &nbor_pitch, &this->_threads_per_atom);

View File

@ -1,9 +1,9 @@
// ************************************************************************** // **************************************************************************
// lj_sdk.cu // lj_spica.cu
// ------------------- // -------------------
// W. Michael Brown (ORNL) // W. Michael Brown (ORNL)
// //
// Device code for acceleration of the lj/sdk pair style // Device code for acceleration of the lj/spica pair style
// //
// __________________________________________________________________________ // __________________________________________________________________________
// This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
@ -24,7 +24,7 @@ _texture_2d( pos_tex,int4);
#define pos_tex x_ #define pos_tex x_
#endif #endif
__kernel void k_lj_sdk(const __global numtyp4 *restrict x_, __kernel void k_lj_spica(const __global numtyp4 *restrict x_,
const __global numtyp4 *restrict lj1, const __global numtyp4 *restrict lj1,
const __global numtyp4 *restrict lj3, const __global numtyp4 *restrict lj3,
const int lj_types, const int lj_types,
@ -91,6 +91,9 @@ __kernel void k_lj_sdk(const __global numtyp4 *restrict x_,
} else if (lj1[mtype].y == 1) { } else if (lj1[mtype].y == 1) {
inv2=r2inv*ucl_sqrt(r2inv); inv2=r2inv*ucl_sqrt(r2inv);
inv1=inv2*inv2; inv1=inv2*inv2;
} else if (lj1[mtype].y == 4) {
inv1=r2inv*r2inv*ucl_sqrt(r2inv);
inv2=inv1*r2inv;
} else { } else {
inv1=r2inv*r2inv*r2inv; inv1=r2inv*r2inv*r2inv;
inv2=inv1; inv2=inv1;
@ -119,7 +122,7 @@ __kernel void k_lj_sdk(const __global numtyp4 *restrict x_,
ans,engv); ans,engv);
} }
__kernel void k_lj_sdk_fast(const __global numtyp4 *restrict x_, __kernel void k_lj_spica_fast(const __global numtyp4 *restrict x_,
const __global numtyp4 *restrict lj1_in, const __global numtyp4 *restrict lj1_in,
const __global numtyp4 *restrict lj3_in, const __global numtyp4 *restrict lj3_in,
const __global numtyp *restrict sp_lj_in, const __global numtyp *restrict sp_lj_in,
@ -192,6 +195,9 @@ __kernel void k_lj_sdk_fast(const __global numtyp4 *restrict x_,
} else if (lj1[mtype].y == (numtyp)1) { } else if (lj1[mtype].y == (numtyp)1) {
inv2=r2inv*ucl_sqrt(r2inv); inv2=r2inv*ucl_sqrt(r2inv);
inv1=inv2*inv2; inv1=inv2*inv2;
} else if (lj1[mtype].y == (numtyp)4) {
inv1=r2inv*r2inv*ucl_sqrt(r2inv);
inv2=inv1*r2inv;
} else { } else {
inv1=r2inv*r2inv*r2inv; inv1=r2inv*r2inv*r2inv;
inv2=inv1; inv2=inv1;

View File

@ -1,9 +1,9 @@
/*************************************************************************** /***************************************************************************
lj_sdk.h lj_spica.h
------------------- -------------------
W. Michael Brown (ORNL) W. Michael Brown (ORNL)
Class for acceleration of the lj/sdk pair style Class for acceleration of the lj/spica pair style
__________________________________________________________________________ __________________________________________________________________________
This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
@ -67,7 +67,7 @@ class CGCMM : public BaseAtomic<numtyp, acctyp> {
bool shared_types; bool shared_types;
/// Number of atom types /// Number of atom types
int _sdk_types; int _spica_types;
private: private:
bool _allocated; bool _allocated;

View File

@ -1,9 +1,9 @@
/*************************************************************************** /***************************************************************************
lj_sdk.h lj_spica.h
------------------- -------------------
W. Michael Brown (ORNL) W. Michael Brown (ORNL)
Functions for LAMMPS access to lj/sdk pair acceleration routines Functions for LAMMPS access to lj/spica pair acceleration routines
__________________________________________________________________________ __________________________________________________________________________
This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
@ -17,7 +17,7 @@
#include <cassert> #include <cassert>
#include <cmath> #include <cmath>
#include "lal_lj_sdk.h" #include "lal_lj_spica.h"
using namespace std; using namespace std;
using namespace LAMMPS_AL; using namespace LAMMPS_AL;
@ -27,7 +27,7 @@ static CGCMM<PRECISION,ACC_PRECISION> CMMMF;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Allocate memory on host and device and copy constants to device // Allocate memory on host and device and copy constants to device
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
int sdk_gpu_init(const int ntypes, double **cutsq, int **cg_types, int spica_gpu_init(const int ntypes, double **cutsq, int **cg_types,
double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj1, double **host_lj2, double **host_lj3,
double **host_lj4, double **offset, double *special_lj, double **host_lj4, double **offset, double *special_lj,
const int inum, const int nall, const int max_nbors, const int inum, const int nall, const int max_nbors,
@ -42,7 +42,7 @@ int sdk_gpu_init(const int ntypes, double **cutsq, int **cg_types,
int gpu_rank=CMMMF.device->gpu_rank(); int gpu_rank=CMMMF.device->gpu_rank();
int procs_per_gpu=CMMMF.device->procs_per_gpu(); int procs_per_gpu=CMMMF.device->procs_per_gpu();
CMMMF.device->init_message(screen,"lj/sdk",first_gpu,last_gpu); CMMMF.device->init_message(screen,"lj/spica",first_gpu,last_gpu);
bool message=false; bool message=false;
if (CMMMF.device->replica_me()==0 && screen) if (CMMMF.device->replica_me()==0 && screen)
@ -89,11 +89,11 @@ int sdk_gpu_init(const int ntypes, double **cutsq, int **cg_types,
return init_ok; return init_ok;
} }
void sdk_gpu_clear() { void spica_gpu_clear() {
CMMMF.clear(); CMMMF.clear();
} }
int** sdk_gpu_compute_n(const int ago, const int inum_full, int** spica_gpu_compute_n(const int ago, const int inum_full,
const int nall, double **host_x, int *host_type, const int nall, double **host_x, int *host_type,
double *sublo, double *subhi, tagint *tag, int **nspecial, double *sublo, double *subhi, tagint *tag, int **nspecial,
tagint **special, const bool eflag, const bool vflag, tagint **special, const bool eflag, const bool vflag,
@ -105,7 +105,7 @@ int** sdk_gpu_compute_n(const int ago, const int inum_full,
vatom, host_start, ilist, jnum, cpu_time, success); vatom, host_start, ilist, jnum, cpu_time, success);
} }
void sdk_gpu_compute(const int ago, const int inum_full, const int nall, void spica_gpu_compute(const int ago, const int inum_full, const int nall,
double **host_x, int *host_type, int *ilist, int *numj, double **host_x, int *host_type, int *ilist, int *numj,
int **firstneigh, const bool eflag, const bool vflag, int **firstneigh, const bool eflag, const bool vflag,
const bool eatom, const bool vatom, int &host_start, const bool eatom, const bool vatom, int &host_start,
@ -114,7 +114,7 @@ void sdk_gpu_compute(const int ago, const int inum_full, const int nall,
firstneigh,eflag,vflag,eatom,vatom,host_start,cpu_time,success); firstneigh,eflag,vflag,eatom,vatom,host_start,cpu_time,success);
} }
double sdk_gpu_bytes() { double spica_gpu_bytes() {
return CMMMF.host_memory_usage(); return CMMMF.host_memory_usage();
} }

View File

@ -1,9 +1,9 @@
/*************************************************************************** /***************************************************************************
lj_sdk_long.cpp lj_spica_long.cpp
------------------- -------------------
W. Michael Brown (ORNL) W. Michael Brown (ORNL)
Class for acceleration of the lj/sdk/coul/long pair style Class for acceleration of the lj/spica/coul/long pair style
__________________________________________________________________________ __________________________________________________________________________
This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
@ -14,14 +14,14 @@
***************************************************************************/ ***************************************************************************/
#if defined(USE_OPENCL) #if defined(USE_OPENCL)
#include "lj_sdk_long_cl.h" #include "lj_spica_long_cl.h"
#elif defined(USE_CUDART) #elif defined(USE_CUDART)
const char *lj_sdk_long=0; const char *lj_spica_long=0;
#else #else
#include "lj_sdk_long_cubin.h" #include "lj_spica_long_cubin.h"
#endif #endif
#include "lal_lj_sdk_long.h" #include "lal_lj_spica_long.h"
#include <cassert> #include <cassert>
namespace LAMMPS_AL { namespace LAMMPS_AL {
#define CGCMMLongT CGCMMLong<numtyp, acctyp> #define CGCMMLongT CGCMMLong<numtyp, acctyp>
@ -58,7 +58,7 @@ int CGCMMLongT::init(const int ntypes, double **host_cutsq,
const double g_ewald) { const double g_ewald) {
int success; int success;
success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size,gpu_split, success=this->init_atomic(nlocal,nall,max_nbors,maxspecial,cell_size,gpu_split,
_screen,lj_sdk_long,"k_lj_sdk_long"); _screen,lj_spica_long,"k_lj_spica_long");
if (success!=0) if (success!=0)
return success; return success;

View File

@ -1,9 +1,9 @@
// ************************************************************************** // **************************************************************************
// lj_sdk_long.cu // lj_spica_long.cu
// ------------------- // -------------------
// W. Michael Brown (ORNL) // W. Michael Brown (ORNL)
// //
// Device code for acceleration of the lj/sdk/coul/long pair style // Device code for acceleration of the lj/spica/coul/long pair style
// //
// __________________________________________________________________________ // __________________________________________________________________________
// This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) // This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
@ -29,7 +29,7 @@ _texture( q_tex,int2);
#define q_tex q_ #define q_tex q_
#endif #endif
__kernel void k_lj_sdk_long(const __global numtyp4 *restrict x_, __kernel void k_lj_spica_long(const __global numtyp4 *restrict x_,
const __global numtyp4 *restrict lj1, const __global numtyp4 *restrict lj1,
const __global numtyp4 *restrict lj3, const __global numtyp4 *restrict lj3,
const int lj_types, const int lj_types,
@ -107,6 +107,9 @@ __kernel void k_lj_sdk_long(const __global numtyp4 *restrict x_,
} else if (lj3[mtype].x == (numtyp)1) { } else if (lj3[mtype].x == (numtyp)1) {
inv2=r2inv*ucl_rsqrt(rsq); inv2=r2inv*ucl_rsqrt(rsq);
inv1=inv2*inv2; inv1=inv2*inv2;
} else if (lj3[mtype].x == (numtyp)4) {
inv1=r2inv*r2inv*ucl_rsqrt(rsq);
inv2=inv1*r2inv;
} else { } else {
inv1=r2inv*r2inv*r2inv; inv1=r2inv*r2inv*r2inv;
inv2=inv1; inv2=inv1;
@ -157,7 +160,7 @@ __kernel void k_lj_sdk_long(const __global numtyp4 *restrict x_,
vflag,ans,engv); vflag,ans,engv);
} }
__kernel void k_lj_sdk_long_fast(const __global numtyp4 *restrict x_, __kernel void k_lj_spica_long_fast(const __global numtyp4 *restrict x_,
const __global numtyp4 *restrict lj1_in, const __global numtyp4 *restrict lj1_in,
const __global numtyp4 *restrict lj3_in, const __global numtyp4 *restrict lj3_in,
const __global numtyp *restrict sp_lj_in, const __global numtyp *restrict sp_lj_in,
@ -236,6 +239,9 @@ __kernel void k_lj_sdk_long_fast(const __global numtyp4 *restrict x_,
} else if (lj3[mtype].x == (numtyp)1) { } else if (lj3[mtype].x == (numtyp)1) {
inv2=r2inv*ucl_rsqrt(rsq); inv2=r2inv*ucl_rsqrt(rsq);
inv1=inv2*inv2; inv1=inv2*inv2;
} else if (lj3[mtype].x == (numtyp)4) {
inv1=r2inv*r2inv*ucl_rsqrt(rsq);
inv2=inv1*r2inv;
} else { } else {
inv1=r2inv*r2inv*r2inv; inv1=r2inv*r2inv*r2inv;
inv2=inv1; inv2=inv1;

View File

@ -1,9 +1,9 @@
/*************************************************************************** /***************************************************************************
lj_sdk_long.h lj_spica_long.h
------------------- -------------------
W. Michael Brown (ORNL) W. Michael Brown (ORNL)
Class for acceleration of the lj/sdk/coul/long pair style Class for acceleration of the lj/spica/coul/long pair style
__________________________________________________________________________ __________________________________________________________________________
This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)

View File

@ -1,9 +1,9 @@
/*************************************************************************** /***************************************************************************
lj_sdk_long.h lj_spica_long.h
------------------- -------------------
W. Michael Brown (ORNL) W. Michael Brown (ORNL)
Functions for LAMMPS access to lj/sdk/coul/long acceleration functions Functions for LAMMPS access to lj/spica/coul/long acceleration functions
__________________________________________________________________________ __________________________________________________________________________
This file is part of the LAMMPS Accelerator Library (LAMMPS_AL) This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
@ -17,7 +17,7 @@
#include <cassert> #include <cassert>
#include <cmath> #include <cmath>
#include "lal_lj_sdk_long.h" #include "lal_lj_spica_long.h"
using namespace std; using namespace std;
using namespace LAMMPS_AL; using namespace LAMMPS_AL;
@ -27,7 +27,7 @@ static CGCMMLong<PRECISION,ACC_PRECISION> CMMLMF;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// Allocate memory on host and device and copy constants to device // Allocate memory on host and device and copy constants to device
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
int sdkl_gpu_init(const int ntypes, double **cutsq, int **cg_type, int spical_gpu_init(const int ntypes, double **cutsq, int **cg_type,
double **host_lj1, double **host_lj2, double **host_lj3, double **host_lj1, double **host_lj2, double **host_lj3,
double **host_lj4, double **offset, double *special_lj, double **host_lj4, double **offset, double *special_lj,
const int inum, const int nall, const int max_nbors, const int inum, const int nall, const int max_nbors,
@ -44,7 +44,7 @@ int sdkl_gpu_init(const int ntypes, double **cutsq, int **cg_type,
int gpu_rank=CMMLMF.device->gpu_rank(); int gpu_rank=CMMLMF.device->gpu_rank();
int procs_per_gpu=CMMLMF.device->procs_per_gpu(); int procs_per_gpu=CMMLMF.device->procs_per_gpu();
CMMLMF.device->init_message(screen,"lj/sdk/coul/long",first_gpu,last_gpu); CMMLMF.device->init_message(screen,"lj/spica/coul/long",first_gpu,last_gpu);
bool message=false; bool message=false;
if (CMMLMF.device->replica_me()==0 && screen) if (CMMLMF.device->replica_me()==0 && screen)
@ -93,11 +93,11 @@ int sdkl_gpu_init(const int ntypes, double **cutsq, int **cg_type,
return init_ok; return init_ok;
} }
void sdkl_gpu_clear() { void spical_gpu_clear() {
CMMLMF.clear(); CMMLMF.clear();
} }
int** sdkl_gpu_compute_n(const int ago, const int inum_full, int** spical_gpu_compute_n(const int ago, const int inum_full,
const int nall, double **host_x, int *host_type, const int nall, double **host_x, int *host_type,
double *sublo, double *subhi, tagint *tag, int **nspecial, double *sublo, double *subhi, tagint *tag, int **nspecial,
tagint **special, const bool eflag, const bool vflag, tagint **special, const bool eflag, const bool vflag,
@ -111,7 +111,7 @@ int** sdkl_gpu_compute_n(const int ago, const int inum_full,
host_q,boxlo,prd); host_q,boxlo,prd);
} }
void sdkl_gpu_compute(const int ago, const int inum_full, const int nall, void spical_gpu_compute(const int ago, const int inum_full, const int nall,
double **host_x, int *host_type, int *ilist, int *numj, double **host_x, int *host_type, int *ilist, int *numj,
int **firstneigh, const bool eflag, const bool vflag, int **firstneigh, const bool eflag, const bool vflag,
const bool eatom, const bool vatom, int &host_start, const bool eatom, const bool vatom, int &host_start,
@ -122,7 +122,7 @@ void sdkl_gpu_compute(const int ago, const int inum_full, const int nall,
host_q,nlocal,boxlo,prd); host_q,nlocal,boxlo,prd);
} }
double sdkl_gpu_bytes() { double spical_gpu_bytes() {
return CMMLMF.host_memory_usage(); return CMMLMF.host_memory_usage();
} }