2012-01-25 23:31:54 +08:00
|
|
|
/***************************************************************************
|
|
|
|
eam.h
|
|
|
|
-------------------
|
|
|
|
Trung Dac Nguyen, W. Michael Brown (ORNL)
|
|
|
|
|
|
|
|
Class for acceleration of the eam pair style.
|
|
|
|
|
|
|
|
__________________________________________________________________________
|
|
|
|
This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
|
|
|
|
__________________________________________________________________________
|
|
|
|
|
2016-07-02 07:27:26 +08:00
|
|
|
begin :
|
2012-01-25 23:31:54 +08:00
|
|
|
email : brownw@ornl.gov nguyentd@ornl.gov
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef LAL_EAM_H
|
|
|
|
#define LAL_EAM_H
|
|
|
|
|
|
|
|
#include "lal_precision.h"
|
|
|
|
#include "lal_base_atomic.h"
|
|
|
|
|
|
|
|
namespace LAMMPS_AL {
|
|
|
|
|
|
|
|
template <class numtyp, class acctyp>
|
|
|
|
class EAM : public BaseAtomic<numtyp, acctyp> {
|
|
|
|
public:
|
|
|
|
EAM();
|
|
|
|
~EAM();
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
/// Clear any previous data and set up for a new LAMMPS run
|
|
|
|
/** \param max_nbors initial number of rows in the neighbor matrix
|
|
|
|
* \param cell_size cutoff + skin
|
|
|
|
* \param gpu_split fraction of particles handled by device
|
2016-07-02 07:27:26 +08:00
|
|
|
*
|
2012-01-25 23:31:54 +08:00
|
|
|
* Returns:
|
|
|
|
* - 0 if successfull
|
|
|
|
* - -1 if fix gpu not found
|
|
|
|
* - -3 if there is an out of memory error
|
|
|
|
* - -4 if the GPU library was not compiled for GPU
|
|
|
|
* - -5 Double precision is not supported on card **/
|
|
|
|
int init(const int ntypes, double host_cutforcesq, int **host_type2rhor,
|
|
|
|
int **host_type2z2r, int *host_type2frho, double ***host_rhor_spline,
|
|
|
|
double ***host_z2r_spline, double ***host_frho_spline, double rdr,
|
2016-07-02 07:27:26 +08:00
|
|
|
double rdrho, double rhomax, int nrhor, int nrho, int nz2r,
|
|
|
|
int nfrho, int nr, const int nlocal, const int nall,
|
2012-09-21 23:57:23 +08:00
|
|
|
const int max_nbors, const int maxspecial, const double cell_size,
|
|
|
|
const double gpu_split, FILE *_screen);
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
// Copy charges to device asynchronously
|
|
|
|
inline void add_fp_data() {
|
|
|
|
int nghost=this->atom->nall()-_nlocal;
|
|
|
|
if (nghost>0) {
|
|
|
|
UCL_H_Vec<numtyp> host_view;
|
|
|
|
UCL_D_Vec<numtyp> dev_view;
|
2012-08-21 21:57:32 +08:00
|
|
|
host_view.view_offset(_nlocal,_fp.host);
|
|
|
|
dev_view.view_offset(_nlocal,_fp.device);
|
2012-01-25 23:31:54 +08:00
|
|
|
ucl_copy(dev_view,host_view,nghost,true);
|
|
|
|
}
|
|
|
|
}
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
/// Clear all host and device data
|
|
|
|
/** \note This is called at the beginning of the init() routine **/
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
/// Returns memory usage on device per atom
|
|
|
|
int bytes_per_atom(const int max_nbors) const;
|
|
|
|
|
|
|
|
/// Total host memory used by library for pair style
|
|
|
|
double host_memory_usage() const;
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
/// Pair loop with host neighboring
|
|
|
|
void compute(const int f_ago, const int inum_full, const int, const int nall,
|
|
|
|
double **host_x, int *host_type, int *ilist, int *numj,
|
|
|
|
int **firstneigh, const bool eflag, const bool vflag,
|
|
|
|
const bool eatom, const bool vatom, int &host_start,
|
|
|
|
const double cpu_time, bool &success,
|
|
|
|
void **fp_ptr);
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
/// Pair loop with device neighboring
|
|
|
|
int** compute(const int ago, const int inum_full, const int nall,
|
|
|
|
double **host_x, int *host_type, double *sublo,
|
2014-01-26 07:53:12 +08:00
|
|
|
double *subhi, tagint *tag, int **nspecial,
|
2016-07-02 07:27:26 +08:00
|
|
|
tagint **special, const bool eflag, const bool vflag,
|
|
|
|
const bool eatom, const bool vatom, int &host_start,
|
2012-01-25 23:31:54 +08:00
|
|
|
int **ilist, int **numj, const double cpu_time, bool &success,
|
|
|
|
int &inum, void **fp_ptr);
|
|
|
|
|
|
|
|
/// Pair loop with host neighboring
|
2016-07-02 07:27:26 +08:00
|
|
|
void compute2(int *ilist, const bool eflag, const bool vflag,
|
2012-01-25 23:31:54 +08:00
|
|
|
const bool eatom, const bool vatom);
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
// ------------------------- DEVICE KERNELS -------------------------
|
|
|
|
UCL_Kernel k_energy, k_energy_fast;
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
// --------------------------- TEXTURES -----------------------------
|
|
|
|
UCL_Texture fp_tex;
|
|
|
|
UCL_Texture rhor_spline1_tex, rhor_spline2_tex;
|
|
|
|
UCL_Texture frho_spline1_tex, frho_spline2_tex;
|
|
|
|
UCL_Texture z2r_spline1_tex, z2r_spline2_tex;
|
|
|
|
|
|
|
|
// --------------------------- DEVICE DATA --------------------------
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
/// Device Timers
|
|
|
|
UCL_Timer time_pair2, time_fp1, time_fp2;
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
// --------------------------- TYPE DATA --------------------------
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
UCL_D_Vec<int2> type2rhor_z2r;
|
|
|
|
UCL_D_Vec<int> type2frho;
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
UCL_D_Vec<numtyp4> z2r_spline1, z2r_spline2;
|
|
|
|
UCL_D_Vec<numtyp4> frho_spline1, frho_spline2;
|
|
|
|
UCL_D_Vec<numtyp4> rhor_spline1, rhor_spline2;
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-09-21 23:57:23 +08:00
|
|
|
numtyp _cutforcesq,_rdr,_rdrho, _rhomax;
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
int _nfrho,_nrhor,_nrho,_nz2r,_nr;
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
/// If atom type constants fit in shared memory, use fast kernels
|
|
|
|
bool shared_types;
|
2016-07-02 07:27:26 +08:00
|
|
|
|
|
|
|
/// Number of atom types
|
2012-01-25 23:31:54 +08:00
|
|
|
int _ntypes;
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
int _max_fp_size;
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
/// True of energy kernels are compiled
|
|
|
|
bool _compiled_energy;
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
/// Per-atom arrays
|
2012-08-21 21:57:32 +08:00
|
|
|
UCL_Vector<numtyp,numtyp> _fp;
|
2016-07-02 07:27:26 +08:00
|
|
|
|
2012-01-25 23:31:54 +08:00
|
|
|
protected:
|
|
|
|
bool _allocated;
|
|
|
|
int _nlocal;
|
|
|
|
void loop(const bool _eflag, const bool _vflag);
|
|
|
|
void loop2(const bool _eflag, const bool _vflag);
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|