1
/***************************************************************************
6
Functions for LAMMPS access to coul/cut acceleration routines.
8
__________________________________________________________________________
9
This file is part of the LAMMPS Accelerator Library (LAMMPS_AL)
10
__________________________________________________________________________
13
email : ndtrung@umich.edu
14
***************************************************************************/
23
using namespace LAMMPS_AL;
25
static Coul<PRECISION,ACC_PRECISION> COULMF;
27
// ---------------------------------------------------------------------------
28
// Allocate memory on host and device and copy constants to device
29
// ---------------------------------------------------------------------------
30
int coul_gpu_init(const int ntypes, double **host_scale,
31
double **cutsq, double *special_coul,
32
const int inum, const int nall, const int max_nbors,
33
const int maxspecial, const double cell_size,
34
int &gpu_mode, FILE *screen, const double qqrd2e) {
36
gpu_mode=COULMF.device->gpu_mode();
37
double gpu_split=COULMF.device->particle_split();
38
int first_gpu=COULMF.device->first_device();
39
int last_gpu=COULMF.device->last_device();
40
int world_me=COULMF.device->world_me();
41
int gpu_rank=COULMF.device->gpu_rank();
42
int procs_per_gpu=COULMF.device->procs_per_gpu();
44
COULMF.device->init_message(screen,"coul/cut",first_gpu,last_gpu);
47
if (COULMF.device->replica_me()==0 && screen)
51
fprintf(screen,"Initializing GPU and compiling on process 0...");
57
init_ok=COULMF.init(ntypes, host_scale, cutsq, special_coul, inum, nall, 300,
58
maxspecial, cell_size, gpu_split, screen, qqrd2e);
60
COULMF.device->world_barrier();
62
fprintf(screen,"Done.\n");
64
for (int i=0; i<procs_per_gpu; i++) {
66
if (last_gpu-first_gpu==0)
67
fprintf(screen,"Initializing GPU %d on core %d...",first_gpu,i);
69
fprintf(screen,"Initializing GPUs %d-%d on core %d...",first_gpu,
73
if (gpu_rank==i && world_me!=0)
74
init_ok=COULMF.init(ntypes, host_scale, cutsq, special_coul, inum, nall, 300,
75
maxspecial, cell_size, gpu_split, screen, qqrd2e);
77
COULMF.device->gpu_barrier();
79
fprintf(screen,"Done.\n");
85
COULMF.estimate_gpu_overhead();
89
// ---------------------------------------------------------------------------
90
// Copy updated constants to device
91
// ---------------------------------------------------------------------------
92
void coul_gpu_reinit(const int ntypes, double **host_scale) {
93
int world_me=COULMF.device->world_me();
94
int gpu_rank=COULMF.device->gpu_rank();
95
int procs_per_gpu=COULMF.device->procs_per_gpu();
98
COULMF.reinit(ntypes, host_scale);
100
COULMF.device->world_barrier();
102
for (int i=0; i<procs_per_gpu; i++) {
103
if (gpu_rank==i && world_me!=0)
104
COULMF.reinit(ntypes, host_scale);
106
COULMF.device->gpu_barrier();
110
void coul_gpu_clear() {
114
int** coul_gpu_compute_n(const int ago, const int inum_full,
115
const int nall, double **host_x, int *host_type,
116
double *sublo, double *subhi, tagint *tag, int **nspecial,
117
tagint **special, const bool eflag, const bool vflag,
118
const bool eatom, const bool vatom, int &host_start,
119
int **ilist, int **jnum, const double cpu_time,
120
bool &success, double *host_q, double *boxlo,
122
return COULMF.compute(ago, inum_full, nall, host_x, host_type, sublo,
123
subhi, tag, nspecial, special, eflag, vflag, eatom,
124
vatom, host_start, ilist, jnum, cpu_time, success,
128
void coul_gpu_compute(const int ago, const int inum_full, const int nall,
129
double **host_x, int *host_type, int *ilist, int *numj,
130
int **firstneigh, const bool eflag, const bool vflag,
131
const bool eatom, const bool vatom, int &host_start,
132
const double cpu_time, bool &success, double *host_q,
133
const int nlocal, double *boxlo, double *prd) {
134
COULMF.compute(ago,inum_full,nall,host_x,host_type,ilist,numj,firstneigh,eflag,
135
vflag,eatom,vatom,host_start,cpu_time,success,host_q,
139
double coul_gpu_bytes() {
140
return COULMF.host_memory_usage();