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

This commit is contained in:
sjplimp 2009-08-12 16:46:29 +00:00
parent 323fb937c3
commit bd0d78aeac
7 changed files with 104 additions and 78 deletions

View File

@ -21,18 +21,18 @@ namespace LAMMPS_NS {
class PairGayBerne : public Pair {
public:
PairGayBerne(LAMMPS *lmp);
~PairGayBerne();
void compute(int, int);
void settings(int, char **);
virtual ~PairGayBerne();
virtual void compute(int, int);
virtual void settings(int, char **);
void coeff(int, char **);
void init_style();
virtual void init_style();
double init_one(int, int);
void write_restart(FILE *);
void read_restart(FILE *);
void write_restart_settings(FILE *);
void read_restart_settings(FILE *);
private:
protected:
double cut_global;
double **cut;

View File

@ -18,7 +18,6 @@
#include "math.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "pair_gayberne_gpu.h"
#include "math_extra.h"
#include "atom.h"
@ -33,6 +32,8 @@
#include "neigh_request.h"
#include "universe.h"
#include <string>
#ifdef GB_GPU_OMP
#include "omp.h"
#endif
@ -41,6 +42,7 @@
#define MAX(a,b) ((a) > (b) ? (a) : (b))
// External functions from cuda library for atom decomposition
int * gb_gpu_init(int &ij_size, const int ntypes, const double gamma,
const double upsilon, const double mu, double **shape,
double **well, double **cutsq, double **sigma,
@ -91,7 +93,7 @@ PairGayBerneGPU::~PairGayBerneGPU()
printf("\n-------------------------------------");
printf("--------------------------------\n");
gb_gpu_time(my_thread);
std::cout << "Procs: " << universe->nprocs << std::endl;
printf("Procs: %d\n",comm->nprocs);
printf("-------------------------------------");
printf("--------------------------------\n\n");
}
@ -226,32 +228,31 @@ void PairGayBerneGPU::compute(int eflag, int vflag)
void PairGayBerneGPU::settings(int narg, char **arg)
{
if (narg != 4 && narg != 6) error->all("Illegal pair_style command");
// Set multi_gpu_mode to one_node for multiple gpus on 1 node
// -- param is starting gpu id
// Set multi_gpu_mode to one_gpu to select the same gpu id on every node
// -- param is id of gpu
// Set multi_gpu_mode to multi_gpu to get ma
// -- param is number of gpus per node
multi_gpu_mode=ONE_NODE;
multi_gpu_param=0;
if (narg==6) {
multi_gpu_param=atoi(arg[5]);
if (strcmp("one_node",arg[4])==0)
multi_gpu_mode=ONE_NODE;
else if (strcmp("one_gpu",arg[4])==0)
multi_gpu_mode=ONE_GPU;
else if (strcmp("multi_gpu",arg[4])==0) {
multi_gpu_mode=MULTI_GPU;
if (multi_gpu_param<1)
error->all("Illegal pair_style command");
} else
error->all("Illegal pair_style command");
narg-=2;
}
// strip off GPU keyword/value and send remaining args to parent
PairGayBerne::settings(narg,arg);
if (narg < 2) error->all("Illegal pair_style command");
// set multi_gpu_mode to one/node for multiple gpus on 1 node
// -- param is starting gpu id
// set multi_gpu_mode to one/gpu to select the same gpu id on every node
// -- param is id of gpu
// set multi_gpu_mode to multi/gpu to get ma
// -- param is number of gpus per node
if (strcmp(arg[0],"one/node") == 0)
multi_gpu_mode = ONE_NODE;
else if (strcmp(arg[0],"one/gpu") == 0)
multi_gpu_mode = ONE_GPU;
else if (strcmp(arg[0],"multi/gpu") == 0)
multi_gpu_mode = MULTI_GPU;
else error->all("Illegal pair_style command");
multi_gpu_param = atoi(arg[1]);
if (multi_gpu_mode == MULTI_GPU && multi_gpu_param < 1)
error->all("Illegal pair_style command");
PairGayBerne::settings(narg-2,&arg[2]);
}
/* ----------------------------------------------------------------------
@ -260,7 +261,15 @@ void PairGayBerneGPU::settings(int narg, char **arg)
void PairGayBerneGPU::init_style()
{
// Set the GPU ID
if (force->pair_match("gpu",0) == NULL)
error->all("Cannot use pair hybrid with multiple GPU pair styles");
if (!atom->quat_flag || !atom->torque_flag || !atom->avec->shape_type)
error->all("Pair gayberne requires atom attributes quat, torque, shape");
if (atom->radius_flag)
error->all("Pair gayberne cannot be used with atom attribute diameter");
// set the GPU ID
int my_gpu=comm->me+multi_gpu_param;
int ngpus=universe->nprocs;
if (multi_gpu_mode==ONE_GPU) {
@ -272,11 +281,6 @@ void PairGayBerneGPU::init_style()
if (ngpus>universe->nprocs)
ngpus=universe->nprocs;
}
if (!atom->quat_flag || !atom->torque_flag || !atom->avec->shape_type)
error->all("Pair gayberne requires atom attributes quat, torque, shape");
if (atom->radius_flag)
error->all("Pair gayberne cannot be used with atom attribute diameter");
int irequest = neighbor->request(this);

View File

@ -18,7 +18,6 @@
#include "math.h"
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "pair_lj_cut_gpu.h"
#include "math_extra.h"
#include "atom.h"
@ -33,10 +32,13 @@
#include "neigh_request.h"
#include "universe.h"
#include <string>
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
// External functions from cuda library for force decomposition
int * lj_gpu_init(int &ij_size, const int ntypes, double **cutsq,
double **sigma, double **epsilon, double **host_lj1,
double **host_lj2, double **host_lj3, double **host_lj4,
@ -80,7 +82,7 @@ PairLJCutGPU::~PairLJCutGPU()
printf("\n-------------------------------------");
printf("--------------------------------\n");
lj_gpu_time();
std::cout << "Procs: " << universe->nprocs << std::endl;
printf("Procs: %d\n",comm->nprocs);
printf("-------------------------------------");
printf("--------------------------------\n\n");
}
@ -167,32 +169,31 @@ void PairLJCutGPU::compute(int eflag, int vflag)
void PairLJCutGPU::settings(int narg, char **arg)
{
if (narg != 1 && narg != 3) error->all("Illegal pair_style command");
// Set multi_gpu_mode to one_node for multiple gpus on 1 node
// -- param is starting gpu id
// Set multi_gpu_mode to one_gpu to select the same gpu id on every node
// -- param is id of gpu
// Set multi_gpu_mode to multi_gpu to get ma
// -- param is number of gpus per node
multi_gpu_mode=ONE_NODE;
multi_gpu_param=0;
if (narg==3) {
multi_gpu_param=atoi(arg[2]);
if (strcmp("one_node",arg[1])==0)
multi_gpu_mode=ONE_NODE;
else if (strcmp("one_gpu",arg[1])==0)
multi_gpu_mode=ONE_GPU;
else if (strcmp("multi_gpu",arg[1])==0) {
multi_gpu_mode=MULTI_GPU;
if (multi_gpu_param<1)
error->all("Illegal pair_style command");
} else
error->all("Illegal pair_style command");
narg-=2;
}
// strip off GPU keyword/value and send remaining args to parent
PairLJCut::settings(narg,arg);
if (narg < 2) error->all("Illegal pair_style command");
// set multi_gpu_mode to one/node for multiple gpus on 1 node
// -- param is starting gpu id
// set multi_gpu_mode to one/gpu to select the same gpu id on every node
// -- param is id of gpu
// set multi_gpu_mode to multi/gpu to get ma
// -- param is number of gpus per node
if (strcmp(arg[0],"one/node") == 0)
multi_gpu_mode = ONE_NODE;
else if (strcmp(arg[0],"one/gpu") == 0)
multi_gpu_mode = ONE_GPU;
else if (strcmp(arg[0],"multi/gpu") == 0)
multi_gpu_mode = MULTI_GPU;
else error->all("Illegal pair_style command");
multi_gpu_param = atoi(arg[1]);
if (multi_gpu_mode == MULTI_GPU && multi_gpu_param < 1)
error->all("Illegal pair_style command");
PairLJCut::settings(narg-2,&arg[2]);
}
/* ----------------------------------------------------------------------
@ -201,7 +202,11 @@ void PairLJCutGPU::settings(int narg, char **arg)
void PairLJCutGPU::init_style()
{
// Set the GPU ID
if (force->pair_match("gpu",0) == NULL)
error->all("Cannot use pair hybrid with multiple GPU pair styles");
// set the GPU ID
int my_gpu=comm->me+multi_gpu_param;
int ngpus=universe->nprocs;
if (multi_gpu_mode==ONE_GPU) {

View File

@ -1,6 +1,6 @@
# Settings for libraries used by specific LAMMPS packages
# this file is auto-edited when those packages are included/excluded
PKGINC = -I../../lib/poems -I../../lib/meam -I../../lib/reax
PKGPATH = -L../../lib/poems -L../../lib/meam -L../../lib/reax
PKGLIB = -lpoems -lmeam -lreax
PKGINC = -I../../lib/reax -I../../lib/poems -I../../lib/meam
PKGPATH = -L../../lib/reax -L../../lib/poems -L../../lib/meam -L../../lib/gpu
PKGLIB = -lreax -lpoems -lmeam -lgpu

View File

@ -156,30 +156,44 @@ Pair *Force::new_pair(const char *style)
return ptr to current pair class or hybrid sub-class
if exact, then style name must be exact match to word
if not exact, style name must contain word
else return NULL
return NULL if no match
return NULL if not exact and multiple hybrid sub-styles match
------------------------------------------------------------------------- */
Pair *Force::pair_match(const char *word, int exact)
{
int iwhich,count;
if (exact && strcmp(pair_style,word) == 0) return pair;
else if (!exact && strstr(pair_style,word)) return pair;
else if (strcmp(pair_style,"hybrid") == 0) {
PairHybrid *hybrid = (PairHybrid *) pair;
count = 0;
for (int i = 0; i < hybrid->nstyles; i++) {
if (exact && strcmp(hybrid->keywords[i],word) == 0)
return hybrid->styles[i];
else if (!exact && strstr(hybrid->keywords[i],word))
return hybrid->styles[i];
if (!exact && strstr(hybrid->keywords[i],word)) {
iwhich = i;
count++;
}
}
if (!exact && count == 1) return hybrid->styles[iwhich];
} else if (strcmp(pair_style,"hybrid/overlay") == 0) {
PairHybridOverlay *hybrid = (PairHybridOverlay *) pair;
count = 0;
for (int i = 0; i < hybrid->nstyles; i++) {
if (exact && strcmp(hybrid->keywords[i],word) == 0)
return hybrid->styles[i];
else if (!exact && strstr(hybrid->keywords[i],word))
return hybrid->styles[i];
else if (!exact && strstr(hybrid->keywords[i],word)) {
iwhich = i;
count++;
}
}
if (!exact && count == 1) return hybrid->styles[iwhich];
}
return NULL;
}

View File

@ -194,6 +194,7 @@ void PairHybrid::settings(int narg, char **arg)
// count sub-styles by skipping numeric args
// one exception is 1st arg of style "table", which is non-numeric word
// one exception is 1st two args of style "lj/coul", which are non-numeric
// one exception is 1st two args of style "lj/coul", which are non-numeric
// need a better way to skip these exceptions
nstyles = 0;
@ -213,8 +214,9 @@ void PairHybrid::settings(int narg, char **arg)
// allocate each sub-style and call its settings() with subset of args
// define subset of args for a sub-style by skipping numeric args
// one exception is 1st arg of style "table", which is non-numeric word
// one exception is 1st arg of style "table", which is non-numeric
// one exception is 1st two args of style "lj/coul", which are non-numeric
// one exception is 1st arg of any "gpu" style, which is non-numeric
// need a better way to skip these exceptions
nstyles = 0;
@ -233,6 +235,7 @@ void PairHybrid::settings(int narg, char **arg)
istyle = i;
if (strcmp(arg[i],"table") == 0) i++;
if (strcmp(arg[i],"lj/coul") == 0) i += 2;
if (strstr(arg[i],"gpu")) i++;
i++;
while (i < narg && !isalpha(arg[i][0])) i++;
styles[nstyles]->settings(i-istyle-1,&arg[istyle+1]);

View File

@ -22,10 +22,10 @@ class PairLJCut : public Pair {
public:
PairLJCut(class LAMMPS *);
~PairLJCut();
void compute(int, int);
void settings(int, char **);
virtual void compute(int, int);
virtual void settings(int, char **);
void coeff(int, char **);
void init_style();
virtual void init_style();
void init_list(int, class NeighList *);
double init_one(int, int);
void write_restart(FILE *);