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

« back to all changes in this revision

Viewing changes to src/USER-CUDA/cuda.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:
24
24
#include <cstdlib>
25
25
#include <cstdio>
26
26
#include <cstring>
27
 
#include "cuda.h"
 
27
#include "user_cuda.h"
28
28
#include "atom.h"
29
29
#include "domain.h"
30
30
#include "force.h"
47
47
 
48
48
using namespace LAMMPS_NS;
49
49
 
50
 
 
 
50
/* ---------------------------------------------------------------------- */
51
51
 
52
52
Cuda::Cuda(LAMMPS* lmp) : Pointers(lmp)
53
53
{
54
54
  cuda_exists = true;
55
55
  lmp->cuda = this;
56
56
 
57
 
  if(universe->me == 0)
58
 
    printf("# Using LAMMPS_CUDA \n");
 
57
  if (universe->me == 0) printf("# Using LAMMPS_CUDA \n");
59
58
 
60
59
  shared_data.me = universe->me;
 
60
 
61
61
  device_set = false;
 
62
  devicelist = NULL;
62
63
 
63
64
  Cuda_Cuda_GetCompileSettings(&shared_data);
64
65
 
65
 
  if(shared_data.compile_settings.prec_glob != sizeof(CUDA_FLOAT) / 4) printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n # CUDA WARNING: Global Precision: cuda %i cpp %i\n\n", shared_data.compile_settings.prec_glob, sizeof(CUDA_FLOAT) / 4);
66
 
 
67
 
  if(shared_data.compile_settings.prec_x != sizeof(X_FLOAT) / 4) printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n # CUDA WARNING: X Precision: cuda %i cpp %i\n\n", shared_data.compile_settings.prec_x, sizeof(X_FLOAT) / 4);
68
 
 
69
 
  if(shared_data.compile_settings.prec_v != sizeof(V_FLOAT) / 4) printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n # CUDA WARNING: V Precision: cuda %i cpp %i\n\n", shared_data.compile_settings.prec_v, sizeof(V_FLOAT) / 4);
70
 
 
71
 
  if(shared_data.compile_settings.prec_f != sizeof(F_FLOAT) / 4) printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n # CUDA WARNING: F Precision: cuda %i cpp %i\n\n", shared_data.compile_settings.prec_f, sizeof(F_FLOAT) / 4);
72
 
 
73
 
  if(shared_data.compile_settings.prec_pppm != sizeof(PPPM_FLOAT) / 4) printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n # CUDA WARNING: PPPM Precision: cuda %i cpp %i\n\n", shared_data.compile_settings.prec_pppm, sizeof(PPPM_FLOAT) / 4);
74
 
 
75
 
  if(shared_data.compile_settings.prec_fft != sizeof(FFT_FLOAT) / 4) printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n # CUDA WARNING: FFT Precision: cuda %i cpp %i\n\n", shared_data.compile_settings.prec_fft, sizeof(FFT_FLOAT) / 4);
 
66
  if (universe->me == 0) {
 
67
 
 
68
    if(shared_data.compile_settings.prec_glob != sizeof(CUDA_CFLOAT) / 4) 
 
69
      printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n"
 
70
                 " # CUDA WARNING: Global Precision: cuda %i cpp %i\n\n",
 
71
             shared_data.compile_settings.prec_glob, (int) sizeof(CUDA_CFLOAT) / 4);
 
72
 
 
73
    if(shared_data.compile_settings.prec_x != sizeof(X_CFLOAT) / 4)
 
74
      printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n"
 
75
                 " # CUDA WARNING: X Precision: cuda %i cpp %i\n\n",
 
76
             shared_data.compile_settings.prec_x, (int) sizeof(X_CFLOAT) / 4);
 
77
 
 
78
    if(shared_data.compile_settings.prec_v != sizeof(V_CFLOAT) / 4)
 
79
      printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n"
 
80
                 " # CUDA WARNING: V Precision: cuda %i cpp %i\n\n",
 
81
             shared_data.compile_settings.prec_v, (int) sizeof(V_CFLOAT) / 4);
 
82
 
 
83
    if(shared_data.compile_settings.prec_f != sizeof(F_CFLOAT) / 4)
 
84
      printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n"
 
85
                 " # CUDA WARNING: F Precision: cuda %i cpp %i\n\n",
 
86
             shared_data.compile_settings.prec_f, (int) sizeof(F_CFLOAT) / 4);
 
87
 
 
88
    if(shared_data.compile_settings.prec_pppm != sizeof(PPPM_CFLOAT) / 4)
 
89
      printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n"
 
90
                 " # CUDA WARNING: PPPM Precision: cuda %i cpp %i\n\n",
 
91
             shared_data.compile_settings.prec_pppm, (int) sizeof(PPPM_CFLOAT) / 4);
 
92
 
 
93
    if(shared_data.compile_settings.prec_fft != sizeof(FFT_CFLOAT) / 4)
 
94
      printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n"
 
95
                 " # CUDA WARNING: FFT Precision: cuda %i cpp %i\n\n",
 
96
             shared_data.compile_settings.prec_fft, (int) sizeof(FFT_CFLOAT) / 4);
76
97
 
77
98
#ifdef FFT_CUFFT
78
 
 
79
 
  if(shared_data.compile_settings.cufft != 1) printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n # CUDA WARNING: cufft: cuda %i cpp %i\n\n", shared_data.compile_settings.cufft, 1);
80
 
 
 
99
    if(shared_data.compile_settings.cufft != 1)
 
100
      printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n"
 
101
                 " # CUDA WARNING: cufft: cuda %i cpp %i\n\n",
 
102
             shared_data.compile_settings.cufft, 1);
81
103
#else
82
 
 
83
 
  if(shared_data.compile_settings.cufft != 0) printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n # CUDA WARNING: cufft: cuda %i cpp %i\n\n", shared_data.compile_settings.cufft, 0);
84
 
 
 
104
    if(shared_data.compile_settings.cufft != 0)
 
105
      printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n"
 
106
                 " # CUDA WARNING: cufft: cuda %i cpp %i\n\n",
 
107
             shared_data.compile_settings.cufft, 0);
85
108
#endif
86
109
 
87
 
  if(shared_data.compile_settings.arch != CUDA_ARCH)  printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n # CUDA WARNING: arch: cuda %i cpp %i\n\n", shared_data.compile_settings.cufft, CUDA_ARCH);
 
110
    if(shared_data.compile_settings.arch != CUDA_ARCH)
 
111
      printf("\n\n # CUDA WARNING: Compile Settings of cuda and cpp code differ! \n"
 
112
                 " # CUDA WARNING: arch: cuda %i cpp %i\n\n",
 
113
             shared_data.compile_settings.cufft, CUDA_ARCH);
 
114
  }
88
115
 
89
116
  cu_x          = 0;
90
117
  cu_v          = 0;
151
178
  //cCudaData<double, float, yx >
152
179
}
153
180
 
 
181
/* ---------------------------------------------------------------------- */
 
182
 
154
183
Cuda::~Cuda()
155
184
{
156
 
 
157
185
  print_timings();
158
186
 
159
 
  if(universe->me == 0) printf("# CUDA: Free memory...\n");
 
187
  if (universe->me == 0) printf("# CUDA: Free memory...\n");
 
188
 
 
189
  delete [] devicelist;
160
190
 
161
191
  delete cu_q;
162
192
  delete cu_x;
201
231
  }
202
232
}
203
233
 
204
 
void Cuda::accelerator(int narg, char** arg)
 
234
/* ----------------------------------------------------------------------
 
235
   package cuda command
 
236
   can be invoked multiple times: -c on, -pk, package command
 
237
   can only init GPUs once in activate(), so just store params here
 
238
------------------------------------------------------------------------- */
 
239
 
 
240
void Cuda::accelerator(int narg, char **arg)
205
241
{
206
 
  if(device_set) return;
207
 
 
208
 
  if(universe->me == 0)
209
 
    printf("# CUDA: Activate GPU \n");
210
 
 
211
 
  int* devicelist = NULL;
212
 
  int pppn = 2;
213
 
 
214
 
  for(int i = 0; i < narg; i++) {
215
 
    if(strcmp(arg[i], "gpu/node") == 0) {
216
 
      if(++i == narg)
217
 
        error->all(FLERR, "Invalid Options for 'accelerator' command. Expecting a number after 'gpu/node' option.");
218
 
 
219
 
      pppn = force->inumeric(FLERR,arg[i]);
220
 
    }
221
 
 
222
 
    if(strcmp(arg[i], "gpu/node/special") == 0) {
223
 
      if(++i == narg)
224
 
        error->all(FLERR, "Invalid Options for 'accelerator' command. Expecting number of GPUs to be used per node after keyword 'gpu/node/special'.");
225
 
 
226
 
      pppn = force->inumeric(FLERR,arg[i]);
227
 
 
228
 
      if(pppn < 1) error->all(FLERR, "Invalid Options for 'accelerator' command. Expecting number of GPUs to be used per node after keyword 'gpu/node special'.");
229
 
 
230
 
      if(i + pppn == narg)
231
 
        error->all(FLERR, "Invalid Options for 'accelerator' command. Expecting list of device ids after keyword 'gpu/node special'.");
232
 
 
 
242
  // this error should not happen 
 
243
 
 
244
  if (device_set) error->all(FLERR,"USER-CUDA device is already activated");
 
245
 
 
246
  // pppn = # of GPUs/node
 
247
 
 
248
  pppn = force->inumeric(FLERR,arg[0]);
 
249
  if (pppn <= 0) error->all(FLERR,"Illegal package cuda command");
 
250
 
 
251
  // optional args
 
252
 
 
253
  delete [] devicelist;
 
254
  devicelist = NULL;
 
255
  int newtonflag = 0;
 
256
 
 
257
  int iarg = 1;
 
258
  while (iarg < narg) {
 
259
    if (strcmp(arg[iarg],"newton") == 0) {
 
260
      if (iarg+2 > narg) error->all(FLERR,"Illegal package cuda command");
 
261
      if (strcmp(arg[iarg+1],"off") == 0) newtonflag = 0;
 
262
      else if (strcmp(arg[iarg+1],"on") == 0) newtonflag = 1;
 
263
      else error->all(FLERR,"Illegal package cuda command");
 
264
    } else if (strcmp(arg[iarg],"gpuID") == 0) {
 
265
      if (iarg+pppn+1 > narg) error->all(FLERR,"Illegal package cuda command");
233
266
      devicelist = new int[pppn];
234
 
 
235
 
      for(int k = 0; k < pppn; k++) {
236
 
        i++;
237
 
        devicelist[k] = force->inumeric(FLERR,arg[i]);
238
 
      }
239
 
    }
240
 
 
241
 
    if(strcmp(arg[i], "pinned") == 0) {
242
 
      if(++i == narg)
243
 
        error->all(FLERR, "Invalid Options for 'accelerator' command. Expecting a number after 'pinned' option.");
244
 
 
245
 
      pinned = force->inumeric(FLERR,arg[i]) == 0 ? false : true;
246
 
 
247
 
      if((pinned == false) && (universe->me == 0)) printf(" #CUDA: Pinned memory is not used for communication\n");
248
 
    }
249
 
 
250
 
    if(strcmp(arg[i], "timing") == 0) {
 
267
      for (int k = 0; k < pppn; k++)
 
268
        devicelist[k] = force->inumeric(FLERR,arg[iarg+k+1]);
 
269
      iarg += pppn + 1;
 
270
    } else if (strcmp(arg[iarg],"timing") == 0) {
251
271
      dotiming = true;
252
 
    }
253
 
 
254
 
    if(strcmp(arg[i], "suffix") == 0) {
255
 
      if(++i == narg)
256
 
        error->all(FLERR, "Invalid Options for 'accelerator' command. Expecting a string after 'suffix' option.");
257
 
 
258
 
      strcpy(lmp->suffix, arg[i]);
259
 
    }
260
 
 
261
 
    if(strcmp(arg[i], "overlap_comm") == 0) {
 
272
      iarg++;
 
273
    } else if (strcmp(arg[iarg],"test") == 0) {
 
274
      if (iarg+2 > narg) error->all(FLERR,"Illegal package cuda command");
 
275
      testatom = force->numeric(FLERR,arg[iarg+1]);
 
276
      dotestatom = true;
 
277
      iarg += 2;
 
278
    } else if (strcmp(arg[iarg],"thread") == 0) {
 
279
      if (iarg+2 > narg) error->all(FLERR,"Illegal package cuda command");
 
280
      if (strcmp(arg[iarg+1],"auto") == 0) 
 
281
        shared_data.pair.override_block_per_atom = -1;
 
282
      else if (strcmp(arg[iarg+1],"tpa") == 0) 
 
283
        shared_data.pair.override_block_per_atom = 0;
 
284
      else if (strcmp(arg[iarg+1],"bpa") == 0) 
 
285
        shared_data.pair.override_block_per_atom = 1;
 
286
      else error->all(FLERR,"Illegal package cuda command");
 
287
      iarg += 2;
 
288
    }
 
289
 
 
290
    // undocumented options
 
291
 
 
292
    else if (strcmp(arg[iarg],"suffix") == 0) {
 
293
      if (iarg+2 > narg) error->all(FLERR,"Illegal package cuda command");
 
294
      strcpy(lmp->suffix,arg[iarg+1]);
 
295
      iarg += 2;
 
296
    } else if (strcmp(arg[iarg],"overlap_comm") == 0) {
262
297
      shared_data.overlap_comm = 1;
263
 
    }
264
 
 
265
 
    if(strcmp(arg[i], "test") == 0) {
266
 
      if(++i == narg)
267
 
        error->all(FLERR, "Invalid Options for 'accelerator' command. Expecting a number after 'test' option.");
268
 
 
269
 
      testatom = force->numeric(FLERR,arg[i]);
270
 
      dotestatom = true;
271
 
    }
272
 
 
273
 
    if(strcmp(arg[i], "override/bpa") == 0) {
274
 
      if(++i == narg)
275
 
        error->all(FLERR, "Invalid Options for 'accelerator' command. Expecting a number after 'override/bpa' option.");
276
 
 
277
 
      shared_data.pair.override_block_per_atom = force->inumeric(FLERR,arg[i]);
278
 
    }
 
298
      iarg++;
 
299
    } else if (strcmp(arg[iarg],"pinned") == 0) {
 
300
      if (iarg+2 > narg) error->all(FLERR,"Illegal package cuda command");
 
301
      pinned = force->inumeric(FLERR,arg[iarg+1]) == 0 ? false : true;
 
302
      if ((pinned == false) && (universe->me == 0)) 
 
303
        printf(" #CUDA: Pinned memory is not used for communication\n");
 
304
      iarg += 2;
 
305
    } else error->all(FLERR,"Illegal package cuda command");
279
306
  }
280
307
 
 
308
  // set newton flags
 
309
 
 
310
  force->newton = force->newton_pair = force->newton_bond = newtonflag;
 
311
}
 
312
 
 
313
/* ----------------------------------------------------------------------
 
314
   activate the GPUs
 
315
   only done once with whatever settings used by the last package command
 
316
------------------------------------------------------------------------- */
 
317
 
 
318
void Cuda::activate()
 
319
{
 
320
  if (device_set) return;
 
321
  device_set = true;
 
322
 
 
323
  if (universe->me == 0) printf("# CUDA: Activate GPU \n");
 
324
 
281
325
  CudaWrapper_Init(0, (char**)0, universe->me, pppn, devicelist);
282
326
  //if(shared_data.overlap_comm)
283
327
  CudaWrapper_AddStreams(3);
311
355
 
312
356
  cu_binned_id  = 0;
313
357
  cu_binned_idnew = 0;
314
 
  device_set = true;
315
358
  allocate();
316
 
  delete devicelist;
317
359
}
318
360
 
 
361
/* ---------------------------------------------------------------------- */
 
362
 
319
363
void Cuda::setSharedDataZero()
320
364
{
321
365
  MYDBG(printf("# CUDA: Cuda::setSharedDataZero ...\n");)
361
405
 
362
406
void Cuda::allocate()
363
407
{
364
 
  accelerator(0, NULL);
365
408
  MYDBG(printf("# CUDA: Cuda::allocate ...\n");)
366
409
 
367
410
  if(not cu_virial) {
368
 
    cu_virial    = new cCudaData<double, ENERGY_FLOAT, x > (NULL, & shared_data.pair.virial , 6);
369
 
    cu_eng_vdwl  = new cCudaData<double, ENERGY_FLOAT, x > (NULL, & shared_data.pair.eng_vdwl , 1);
370
 
    cu_eng_coul  = new cCudaData<double, ENERGY_FLOAT, x > (NULL, & shared_data.pair.eng_coul , 1);
 
411
    cu_virial    = new cCudaData<double, ENERGY_CFLOAT, x > (NULL, & shared_data.pair.virial , 6);
 
412
    cu_eng_vdwl  = new cCudaData<double, ENERGY_CFLOAT, x > (NULL, & shared_data.pair.eng_vdwl , 1);
 
413
    cu_eng_coul  = new cCudaData<double, ENERGY_CFLOAT, x > (NULL, & shared_data.pair.eng_coul , 1);
371
414
    cu_extent          = new cCudaData<double, double, x> (extent, 6);
372
415
    shared_data.flag = CudaWrapper_AllocCudaData(sizeof(int));
373
416
    int size = 2 * CUDA_MAX_DEBUG_SIZE;
436
479
void Cuda::checkResize()
437
480
{
438
481
  MYDBG(printf("# CUDA: Cuda::checkResize ...\n");)
439
 
  accelerator(0, NULL);
440
482
  cuda_shared_atom* cu_atom = & shared_data.atom;
441
 
  cuda_shared_pair* cu_pair = & shared_data.pair;
442
483
  cu_atom->q_flag      = atom->q_flag;
443
484
  cu_atom->rmass_flag  = atom->rmass ? 1 : 0;
444
485
  cu_atom->nall = atom->nlocal + atom->nghost;
448
489
  // do we have more atoms to upload than currently allocated memory on device? (also true if nothing yet allocated)
449
490
  if(atom->nmax > cu_atom->nmax || cu_tag == NULL) {
450
491
    delete cu_x;
451
 
    cu_x         = new cCudaData<double, X_FLOAT, yx> ((double*)atom->x , & cu_atom->x        , atom->nmax, 3, 0, true); //cu_x->set_buffer(&(shared_data.buffer),&(shared_data.buffersize),true);
 
492
    cu_x         = new cCudaData<double, X_CFLOAT, yx> ((double*)atom->x , & cu_atom->x        , atom->nmax, 3, 0, true); //cu_x->set_buffer(&(shared_data.buffer),&(shared_data.buffersize),true);
452
493
    delete cu_v;
453
 
    cu_v         = new cCudaData<double, V_FLOAT, yx> ((double*)atom->v, & cu_atom->v         , atom->nmax, 3);
 
494
    cu_v         = new cCudaData<double, V_CFLOAT, yx> ((double*)atom->v, & cu_atom->v         , atom->nmax, 3);
454
495
    delete cu_f;
455
 
    cu_f         = new cCudaData<double, F_FLOAT, yx> ((double*)atom->f, & cu_atom->f         , atom->nmax, 3, 0, true);
 
496
    cu_f         = new cCudaData<double, F_CFLOAT, yx> ((double*)atom->f, & cu_atom->f         , atom->nmax, 3, 0, true);
456
497
    delete cu_tag;
457
498
    cu_tag       = new cCudaData<int   , int    , x > (atom->tag       , & cu_atom->tag       , atom->nmax, 0, true);
458
499
    delete cu_type;
464
505
 
465
506
    if(atom->rmass) {
466
507
      delete cu_rmass;
467
 
      cu_rmass     = new cCudaData<double, V_FLOAT, x > (atom->rmass     , & cu_atom->rmass     , atom->nmax);
 
508
      cu_rmass     = new cCudaData<double, V_CFLOAT, x > (atom->rmass     , & cu_atom->rmass     , atom->nmax);
468
509
    }
469
510
 
470
511
    if(cu_atom->q_flag) {
471
512
      delete cu_q;
472
 
      cu_q         = new cCudaData<double, F_FLOAT, x > ((double*)atom->q, & cu_atom->q         , atom->nmax, 0 , true);
 
513
      cu_q         = new cCudaData<double, F_CFLOAT, x > ((double*)atom->q, & cu_atom->q         , atom->nmax, 0 , true);
473
514
    }// cu_q->set_buffer(&(copy_buffer),&(copy_buffersize),true);}
474
515
 
475
516
    if(atom->radius) {
476
517
      delete cu_radius;
477
 
      cu_radius    = new cCudaData<double, X_FLOAT, x > (atom->radius    , & cu_atom->radius     , atom->nmax);
 
518
      cu_radius    = new cCudaData<double, X_CFLOAT, x > (atom->radius    , & cu_atom->radius     , atom->nmax);
478
519
      delete cu_v_radius;
479
 
      cu_v_radius  = new cCudaData<V_FLOAT, V_FLOAT, x> (v_radius , & cu_atom->v_radius      , atom->nmax * 4);
 
520
      cu_v_radius  = new cCudaData<V_CFLOAT, V_CFLOAT, x> (v_radius , & cu_atom->v_radius      , atom->nmax * 4);
480
521
      delete cu_omega_rmass;
481
 
      cu_omega_rmass  = new cCudaData<V_FLOAT, V_FLOAT, x> (omega_rmass , & cu_atom->omega_rmass      , atom->nmax * 4);
 
522
      cu_omega_rmass  = new cCudaData<V_CFLOAT, V_CFLOAT, x> (omega_rmass , & cu_atom->omega_rmass      , atom->nmax * 4);
482
523
    }
483
524
 
484
525
    if(atom->omega) {
485
526
      delete cu_omega;
486
 
      cu_omega     = new cCudaData<double, V_FLOAT, yx > (((double*) atom->omega)    , & cu_atom->omega     , atom->nmax, 3);
 
527
      cu_omega     = new cCudaData<double, V_CFLOAT, yx > (((double*) atom->omega)    , & cu_atom->omega     , atom->nmax, 3);
487
528
    }
488
529
 
489
530
    if(atom->torque) {
490
531
      delete cu_torque;
491
 
      cu_torque    = new cCudaData<double, F_FLOAT, yx > (((double*) atom->torque)   , & cu_atom->torque     , atom->nmax, 3);
 
532
      cu_torque    = new cCudaData<double, F_CFLOAT, yx > (((double*) atom->torque)   , & cu_atom->torque     , atom->nmax, 3);
492
533
    }
493
534
 
494
535
    if(atom->special) {
514
555
    cu_atom->nmax        = atom->nmax;
515
556
 
516
557
    delete cu_x_type;
517
 
    cu_x_type   = new cCudaData<X_FLOAT, X_FLOAT, x> (x_type , & cu_atom->x_type      , atom->nmax * 4);
 
558
    cu_x_type   = new cCudaData<X_CFLOAT, X_CFLOAT, x> (x_type , & cu_atom->x_type      , atom->nmax * 4);
518
559
  }
519
560
 
520
561
  if(((cu_xhold == NULL) || (cu_xhold->get_dim()[0] < neighbor->maxhold)) && neighbor->xhold) {
521
562
    delete cu_xhold;
522
 
    cu_xhold     = new cCudaData<double, X_FLOAT, yx> ((double*)neighbor->xhold, & cu_atom->xhold         , neighbor->maxhold, 3);
 
563
    cu_xhold     = new cCudaData<double, X_CFLOAT, yx> ((double*)neighbor->xhold, & cu_atom->xhold         , neighbor->maxhold, 3);
523
564
    shared_data.atom.maxhold = neighbor->maxhold;
524
565
  }
525
566
 
526
567
  if(atom->mass && !cu_mass) {
527
 
    cu_mass      = new cCudaData<double, V_FLOAT, x > (atom->mass      , & cu_atom->mass      , atom->ntypes + 1);
 
568
    cu_mass      = new cCudaData<double, V_CFLOAT, x > (atom->mass      , & cu_atom->mass      , atom->ntypes + 1);
528
569
  }
529
570
 
530
571
  cu_atom->mass_host   = atom->mass;
531
572
 
532
573
  if(atom->map_style == 1) {
533
 
    if((cu_map_array == NULL)) {
 
574
    if(cu_map_array == NULL) {
534
575
      cu_map_array   = new cCudaData<int, int, x > (atom->get_map_array()   , & cu_atom->map_array     , atom->get_map_size());
535
576
    } else if(cu_map_array->dev_size() / sizeof(int) < atom->get_map_size()) {
536
577
      delete cu_map_array;
602
643
{
603
644
  if(eflag_atom) {
604
645
    if(not cu_eatom)
605
 
      cu_eatom         = new cCudaData<double, ENERGY_FLOAT, x > (force->pair->eatom, & (shared_data.atom.eatom)         , atom->nmax);  // cu_eatom->set_buffer(&(copy_buffer),&(copy_buffersize),true);}
 
646
      cu_eatom         = new cCudaData<double, ENERGY_CFLOAT, x > (force->pair->eatom, & (shared_data.atom.eatom)         , atom->nmax);  // cu_eatom->set_buffer(&(copy_buffer),&(copy_buffersize),true);}
606
647
 
607
648
    if(cu_eatom->get_dim()[0] != atom->nmax) {
608
649
      //delete cu_eatom;
609
 
      //cu_eatom         = new cCudaData<double, ENERGY_FLOAT, x > (force->pair->eatom, & (shared_data.atom.eatom)         , atom->nmax  );// cu_eatom->set_buffer(&(copy_buffer),&(copy_buffersize),true);}
 
650
      //cu_eatom         = new cCudaData<double, ENERGY_CFLOAT, x > (force->pair->eatom, & (shared_data.atom.eatom)         , atom->nmax  );// cu_eatom->set_buffer(&(copy_buffer),&(copy_buffersize),true);}
610
651
      shared_data.atom.update_nmax = 2;
611
652
    }
612
653
 
616
657
 
617
658
  if(vflag_atom) {
618
659
    if(not cu_vatom)
619
 
      cu_vatom         = new cCudaData<double, ENERGY_FLOAT, yx > ((double*)force->pair->vatom, & (shared_data.atom.vatom)         , atom->nmax , 6);// cu_vatom->set_buffer(&(copy_buffer),&(copy_buffersize),true);}
 
660
      cu_vatom         = new cCudaData<double, ENERGY_CFLOAT, yx > ((double*)force->pair->vatom, & (shared_data.atom.vatom)         , atom->nmax , 6);// cu_vatom->set_buffer(&(copy_buffer),&(copy_buffersize),true);}
620
661
 
621
662
    if(cu_vatom->get_dim()[0] != atom->nmax) {
622
663
      //delete cu_vatom;
623
 
      //cu_vatom         = new cCudaData<double, ENERGY_FLOAT, yx > ((double*)force->pair->vatom, & (shared_data.atom.vatom)         , atom->nmax ,6 );// cu_vatom->set_buffer(&(copy_buffer),&(copy_buffersize),true);}
 
664
      //cu_vatom         = new cCudaData<double, ENERGY_CFLOAT, yx > ((double*)force->pair->vatom, & (shared_data.atom.vatom)         , atom->nmax ,6 );// cu_vatom->set_buffer(&(copy_buffer),&(copy_buffersize),true);}
624
665
      shared_data.atom.update_nmax = 2;
625
666
    }
626
667
 
883
924
  if(this->shared_data.atom.maxhold < atom->nmax) {
884
925
    maxhold = atom->nmax;
885
926
    delete this->cu_xhold;
886
 
    this->cu_xhold     = new cCudaData<double, X_FLOAT, yx> ((double*)xhold, & this->shared_data.atom.xhold         , maxhold, 3);
 
927
    this->cu_xhold     = new cCudaData<double, X_CFLOAT, yx> ((double*)xhold, & this->shared_data.atom.xhold         , maxhold, 3);
887
928
  }
888
929
 
889
930
  this->shared_data.atom.maxhold = maxhold;
890
 
  CudaWrapper_CopyData(this->cu_xhold->dev_data(), this->cu_x->dev_data(), 3 * atom->nmax * sizeof(X_FLOAT));
 
931
  CudaWrapper_CopyData(this->cu_xhold->dev_data(), this->cu_x->dev_data(), 3 * atom->nmax * sizeof(X_CFLOAT));
891
932
}
892
933
 
893
934
void Cuda::setTimingsZero()