1 /***************************************************************************
2                                    born.h
3                              -------------------
4                            Trung Dac Nguyen (ORNL)
5 
6   Class for acceleration of the born pair style.
7 
8  __________________________________________________________________________
9     This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
10  __________________________________________________________________________
11 
12     begin                :
13     email                : nguyentd@ornl.gov
14  ***************************************************************************/
15 
16 #ifndef LAL_BORN_H
17 #define LAL_BORN_H
18 
19 #include "lal_base_atomic.h"
20 
21 namespace LAMMPS_AL {
22 
23 template <class numtyp, class acctyp>
24 class Born : public BaseAtomic<numtyp, acctyp> {
25  public:
26   Born();
27   ~Born();
28 
29   /// Clear any previous data and set up for a new LAMMPS run
30   /** \param max_nbors initial number of rows in the neighbor matrix
31     * \param cell_size cutoff + skin
32     * \param gpu_split fraction of particles handled by device
33     *
34     * Returns:
35     * -  0 if successful
36     * - -1 if fix gpu not found
37     * - -3 if there is an out of memory error
38     * - -4 if the GPU library was not compiled for GPU
39     * - -5 Double precision is not supported on card **/
40   int init(const int ntypes, double **host_cutsq,
41            double **host_rhoinv, double **host_born1, double **host_born2,
42            double **host_born3, double **host_a, double **host_c,
43            double **host_d, double **host_sigma,
44            double **host_offset, double *host_special_lj,
45            const int nlocal, const int nall, const int max_nbors,
46            const int maxspecial, const double cell_size,
47            const double gpu_split, FILE *screen);
48 
49   /// Send updated coeffs from host to device (to be compatible with fix adapt)
50   void reinit(const int ntypes, double **host_rhoinv,
51               double **host_born1, double **host_born2,
52               double **host_born3, double **host_a, double **host_c,
53               double **host_d, double **host_offset);
54 
55   /// Clear all host and device data
56   /** \note This is called at the beginning of the init() routine **/
57   void clear();
58 
59   /// Returns memory usage on device per atom
60   int bytes_per_atom(const int max_nbors) const;
61 
62   /// Total host memory used by library for pair style
63   double host_memory_usage() const;
64 
65   // --------------------------- TYPE DATA --------------------------
66 
67   /// coeff1.x = rhoinv, coeff1.y = born1, coeff1.z = born2,
68   /// coeff1.w = born3
69   UCL_D_Vec<numtyp4> coeff1;
70   /// coeff2.x = a, coeff2.y = c, coeff2.z = d, coeff2.w = offset
71   UCL_D_Vec<numtyp4> coeff2;
72   /// cutsq_sigma
73   UCL_D_Vec<numtyp2> cutsq_sigma;
74   /// Special LJ values
75   UCL_D_Vec<numtyp> sp_lj;
76 
77   /// If atom type constants fit in shared memory, use fast kernels
78   bool shared_types;
79 
80   /// Number of atom types
81   int _lj_types;
82 
83  private:
84   bool _allocated;
85   int loop(const int eflag, const int vflag);
86 };
87 
88 }
89 
90 #endif
91