~ubuntu-branches/debian/sid/lammps/sid

« back to all changes in this revision

Viewing changes to lib/gpu/lal_coul_long_ext.cpp

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2015-04-29 23:44:49 UTC
  • mfrom: (5.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20150429234449-mbhy9utku6hp6oq8
Tags: 0~20150313.gitfa668e1-1
Upload into unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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) {
34
35
  CLMF.clear();
35
36
  gpu_mode=CLMF.device->gpu_mode();
36
37
  double gpu_split=CLMF.device->particle_split();
47
48
    message=true;
48
49
 
49
50
  if (message) {
50
 
    fprintf(screen,"Initializing GPU and compiling on process 0...");
 
51
    fprintf(screen,"Initializing Device and compiling on process 0...");
51
52
    fflush(screen);
52
53
  }
53
54
 
54
55
  int init_ok=0;
55
56
  if (world_me==0)
56
 
    init_ok=CLMF.init(inum, nall, 300, maxspecial, cell_size, gpu_split,
57
 
                      screen, host_cut_coulsq, host_special_coul, qqrd2e,
58
 
                      g_ewald);
 
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);
59
60
 
60
61
  CLMF.device->world_barrier();
61
62
  if (message)
64
65
  for (int i=0; i<procs_per_gpu; i++) {
65
66
    if (message) {
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);
68
69
      else
69
 
        fprintf(screen,"Initializing GPUs %d-%d on core %d...",first_gpu,
 
70
        fprintf(screen,"Initializing Devices %d-%d on core %d...",first_gpu,
70
71
                last_gpu,i);
71
72
      fflush(screen);
72
73
    }
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,
76
 
                        qqrd2e, g_ewald);
 
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);
77
78
 
78
79
    CLMF.device->gpu_barrier();
79
80
    if (message)
87
88
  return init_ok;
88
89
}
89
90
 
 
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();
 
98
  
 
99
  if (world_me==0)
 
100
    CLMF.reinit(ntypes, host_scale);
 
101
  
 
102
  CLMF.device->world_barrier();
 
103
  
 
104
  for (int i=0; i<procs_per_gpu; i++) {
 
105
    if (gpu_rank==i && world_me!=0)
 
106
      CLMF.reinit(ntypes, host_scale);
 
107
    
 
108
    CLMF.device->gpu_barrier();
 
109
  }
 
110
}
 
111
 
90
112
void cl_gpu_clear() {
91
113
  CLMF.clear();
92
114
}