27
27
// ---------------------------------------------------------------------------
28
28
// Allocate memory on host and device and copy constants to device
29
29
// ---------------------------------------------------------------------------
30
int cl_gpu_init(const int inum, const int nall, const int max_nbors,
31
const int maxspecial, const double cell_size, int &gpu_mode,
32
FILE *screen, double host_cut_coulsq, double *host_special_coul,
33
const double qqrd2e, const double g_ewald) {
30
int cl_gpu_init(const int ntypes, double **host_scale,
31
const int inum, const int nall, const int max_nbors,
32
const int maxspecial, const double cell_size, int &gpu_mode,
33
FILE *screen, double host_cut_coulsq, double *host_special_coul,
34
const double qqrd2e, const double g_ewald) {
35
36
gpu_mode=CLMF.device->gpu_mode();
36
37
double gpu_split=CLMF.device->particle_split();
50
fprintf(screen,"Initializing GPU and compiling on process 0...");
51
fprintf(screen,"Initializing Device and compiling on process 0...");
56
init_ok=CLMF.init(inum, nall, 300, maxspecial, cell_size, gpu_split,
57
screen, host_cut_coulsq, host_special_coul, qqrd2e,
57
init_ok=CLMF.init(ntypes, host_scale, inum, nall, 300, maxspecial,
58
cell_size, gpu_split, screen, host_cut_coulsq,
59
host_special_coul, qqrd2e, g_ewald);
60
61
CLMF.device->world_barrier();
64
65
for (int i=0; i<procs_per_gpu; i++) {
66
67
if (last_gpu-first_gpu==0)
67
fprintf(screen,"Initializing GPU %d on core %d...",first_gpu,i);
68
fprintf(screen,"Initializing Device %d on core %d...",first_gpu,i);
69
fprintf(screen,"Initializing GPUs %d-%d on core %d...",first_gpu,
70
fprintf(screen,"Initializing Devices %d-%d on core %d...",first_gpu,
73
74
if (gpu_rank==i && world_me!=0)
74
init_ok=CLMF.init(inum, nall, 300, maxspecial, cell_size, gpu_split,
75
screen, host_cut_coulsq, host_special_coul,
75
init_ok=CLMF.init(ntypes, host_scale, inum, nall, 300, maxspecial,
76
cell_size, gpu_split, screen, host_cut_coulsq,
77
host_special_coul, qqrd2e, g_ewald);
78
79
CLMF.device->gpu_barrier();
91
// ---------------------------------------------------------------------------
92
// Copy updated coeffs from host to device
93
// ---------------------------------------------------------------------------
94
void cl_gpu_reinit(const int ntypes, double **host_scale) {
95
int world_me=CLMF.device->world_me();
96
int gpu_rank=CLMF.device->gpu_rank();
97
int procs_per_gpu=CLMF.device->procs_per_gpu();
100
CLMF.reinit(ntypes, host_scale);
102
CLMF.device->world_barrier();
104
for (int i=0; i<procs_per_gpu; i++) {
105
if (gpu_rank==i && world_me!=0)
106
CLMF.reinit(ntypes, host_scale);
108
CLMF.device->gpu_barrier();
90
112
void cl_gpu_clear() {