git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@12457 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2014-09-09 21:15:33 +00:00
parent 3f53286836
commit b57945c40e
3 changed files with 55 additions and 76 deletions

View File

@ -95,7 +95,6 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) :
_gpu_mode = GPU_NEIGH;
_particle_split = 1.0;
int newtonflag = 0;
int nthreads = 1;
int threads_per_atom = -1;
double binsize = -1;
@ -113,14 +112,9 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) :
} else if (strcmp(arg[iarg],"split") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command");
_particle_split = force->numeric(FLERR,arg[iarg+1]);
if (_particle_split <= 0.0 || _particle_split > 1.0)
if (_particle_split == 0.0 || _particle_split > 1.0)
error->all(FLERR,"Illegal package GPU command");
iarg += 2;
} else if (strcmp(arg[iarg],"newton") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package gpu command");
if (strcmp(arg[iarg]+1,"off") == 0) newtonflag = 0;
else if (strcmp(arg[iarg]+1,"on") == 0) newtonflag = 1;
iarg += 2;
} else if (strcmp(arg[iarg],"gpuID") == 0) {
if (iarg+3 > narg) error->all(FLERR,"Illegal package gpu command");
first_gpu = force->inumeric(FLERR,arg[iarg+1]);
@ -158,6 +152,12 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) :
error->all(FLERR,"No OpenMP support compiled in");
#endif
// set newton_pair = 0 since required by all GPU pair styles
force->newton_pair = 0;
if (force->newton_pair || force->newton_bond) force->newton = 1;
else force->newton = 0;
// pass params to GPU library
int gpu_flag = lmp_init_device(universe->uworld, world, first_gpu, last_gpu,

View File

@ -54,8 +54,7 @@ Cuda::Cuda(LAMMPS* lmp) : Pointers(lmp)
cuda_exists = true;
lmp->cuda = this;
if(universe->me == 0)
printf("# Using LAMMPS_CUDA \n");
if (universe->me == 0) printf("# Using LAMMPS_CUDA \n");
shared_data.me = universe->me;
device_set = false;
@ -153,7 +152,6 @@ Cuda::Cuda(LAMMPS* lmp) : Pointers(lmp)
Cuda::~Cuda()
{
print_timings();
if (universe->me == 0) printf("# CUDA: Free memory...\n");
@ -204,78 +202,59 @@ Cuda::~Cuda()
void Cuda::accelerator(int narg, char** arg)
{
if (device_set) return;
if (universe->me == 0) printf("# CUDA: Activate GPU \n");
if(universe->me == 0)
printf("# CUDA: Activate GPU \n");
int pppn = force->inumeric(FLERR,arg[0]);
if (pppn <= 0) error->all(FLERR,"Illegal package cuda command");
// optional args
int* devicelist = NULL;
int pppn = 2;
for(int i = 0; i < narg; i++) {
if(strcmp(arg[i], "gpu/node") == 0) {
if(++i == narg)
error->all(FLERR, "Invalid Options for 'accelerator' command. Expecting a number after 'gpu/node' option.");
pppn = force->inumeric(FLERR,arg[i]);
}
if(strcmp(arg[i], "gpu/node/special") == 0) {
if(++i == narg)
error->all(FLERR, "Invalid Options for 'accelerator' command. Expecting number of GPUs to be used per node after keyword 'gpu/node/special'.");
pppn = force->inumeric(FLERR,arg[i]);
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'.");
if(i + pppn == narg)
error->all(FLERR, "Invalid Options for 'accelerator' command. Expecting list of device ids after keyword 'gpu/node special'.");
int iarg = 1;
while (iarg < narg) {
if (strcmp(arg[iarg],"gpuID") == 0) {
if (iarg+pppn+1 > narg) error->all(FLERR,"Illegal package cuda command");
devicelist = new int[pppn];
for(int k = 0; k < pppn; k++) {
i++;
devicelist[k] = force->inumeric(FLERR,arg[i]);
}
}
if(strcmp(arg[i], "pinned") == 0) {
if(++i == narg)
error->all(FLERR, "Invalid Options for 'accelerator' command. Expecting a number after 'pinned' option.");
pinned = force->inumeric(FLERR,arg[i]) == 0 ? false : true;
if((pinned == false) && (universe->me == 0)) printf(" #CUDA: Pinned memory is not used for communication\n");
}
if(strcmp(arg[i], "timing") == 0) {
for (int k = 0; k < pppn; k++)
devicelist[k] = force->inumeric(FLERR,arg[iarg+k+1]);
iarg += pppn + 1;
} else if (strcmp(arg[iarg],"timing") == 0) {
dotiming = true;
}
if(strcmp(arg[i], "suffix") == 0) {
if(++i == narg)
error->all(FLERR, "Invalid Options for 'accelerator' command. Expecting a string after 'suffix' option.");
strcpy(lmp->suffix, arg[i]);
}
if(strcmp(arg[i], "overlap_comm") == 0) {
shared_data.overlap_comm = 1;
}
if(strcmp(arg[i], "test") == 0) {
if(++i == narg)
error->all(FLERR, "Invalid Options for 'accelerator' command. Expecting a number after 'test' option.");
testatom = force->numeric(FLERR,arg[i]);
iarg++;
} else if (strcmp(arg[iarg],"test") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package cuda command");
testatom = force->numeric(FLERR,arg[iarg+1]);
dotestatom = true;
iarg += 2;
} else if (strcmp(arg[iarg],"thread") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package cuda command");
if (strcmp(arg[iarg+1],"auto") == 0)
shared_data.pair.override_block_per_atom = -1;
else if (strcmp(arg[iarg+1],"tpa") == 0)
shared_data.pair.override_block_per_atom = 0;
else if (strcmp(arg[iarg+1],"bpa") == 0)
shared_data.pair.override_block_per_atom = 1;
else error->all(FLERR,"Illegal package cuda command");
iarg += 2;
}
if(strcmp(arg[i], "override/bpa") == 0) {
if(++i == narg)
error->all(FLERR, "Invalid Options for 'accelerator' command. Expecting a number after 'override/bpa' option.");
// undocumented options
shared_data.pair.override_block_per_atom = force->inumeric(FLERR,arg[i]);
}
else if (strcmp(arg[iarg],"suffix") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package cuda command");
strcpy(lmp->suffix,arg[iarg+1]);
iarg += 2;
} else if (strcmp(arg[iarg],"overlap_comm") == 0) {
shared_data.overlap_comm = 1;
iarg++;
} else if (strcmp(arg[iarg],"pinned") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal package cuda command");
pinned = force->inumeric(FLERR,arg[iarg+1]) == 0 ? false : true;
if ((pinned == false) && (universe->me == 0))
printf(" #CUDA: Pinned memory is not used for communication\n");
iarg += 2;
} else error->all(FLERR,"Illegal package cuda command");
}
CudaWrapper_Init(0, (char**)0, universe->me, pppn, devicelist);

View File

@ -1439,14 +1439,14 @@ void Input::package()
delete [] fixarg;
} else if (strcmp(arg[0],"intel") == 0) {
if (!modify->check_package("Intel"))
if (!modify->check_package("INTEL"))
error->all(FLERR,
"Package intel command without USER-INTEL package installed");
char **fixarg = new char*[2+narg];
fixarg[0] = (char *) "package_intel";
fixarg[1] = (char *) "all";
fixarg[2] = (char *) "Intel";
fixarg[2] = (char *) "INTEL";
for (int i = 1; i < narg; i++) fixarg[i+2] = arg[i];
modify->add_fix(2+narg,fixarg);
delete [] fixarg;