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

This commit is contained in:
sjplimp
2012-08-28 15:07:23 +00:00
parent 664b3aff1d
commit 8a97b39ea3
2 changed files with 118 additions and 90 deletions

View File

@ -38,116 +38,118 @@
namespace LAMMPS_NS
{
class Cuda : protected Pointers
{
public:
Cuda(class LAMMPS *);
~Cuda();
//static void setDevice(class LAMMPS*);
void allocate();
class Cuda : protected Pointers
{
public:
Cuda(class LAMMPS*);
~Cuda();
//static void setDevice(class LAMMPS*);
void allocate();
void accelerator(int, char **);
void accelerator(int, char**);
void setSharedDataZero();
void setSystemParams();
void setSharedDataZero();
void setSystemParams();
void setDomainParams();
void setDomainParams();
void checkResize();
void evsetup_eatom_vatom(int eflag_atom,int vflag_atom);
void uploadAll();
void downloadAll();
void downloadX();
void checkResize();
void evsetup_eatom_vatom(int eflag_atom, int vflag_atom);
void uploadAll();
void downloadAll();
void upload(int datamask);
void download(int datamask);
void downloadX();
class CudaNeighList* registerNeighborList(class NeighList* neigh_list);
void uploadAllNeighborLists();
void downloadAllNeighborLists();
void set_neighinit(int dist_check, double triggerneighsq)
{
shared_data.atom.dist_check=dist_check;
shared_data.atom.triggerneighsq = triggerneighsq;
}
bool decide_by_integrator()
{
return neighbor_decide_by_integrator && cu_xhold && finished_setup;
}
void update_xhold(int &maxhold,double* xhold);
class CudaNeighList* registerNeighborList(class NeighList* neigh_list);
void uploadAllNeighborLists();
void downloadAllNeighborLists();
void set_neighinit(int dist_check, double triggerneighsq) {
shared_data.atom.dist_check = dist_check;
shared_data.atom.triggerneighsq = triggerneighsq;
}
bool decide_by_integrator() {
return neighbor_decide_by_integrator && cu_xhold && finished_setup;
}
void update_xhold(int &maxhold, double* xhold);
void setTimingsZero();
void print_timings();
void setTimingsZero();
void print_timings();
void cu_x_download() {cu_x->download();}
bool device_set;
bool dotiming;
bool dotestatom;
int testatom;
void cu_x_download() {
cu_x->download();
}
bool device_set;
bool dotiming;
bool dotestatom;
int testatom;
double uploadtime,downloadtime;
bool finished_setup,begin_setup;
bool oncpu;
bool finished_run;
double uploadtime, downloadtime;
bool finished_setup, begin_setup;
bool oncpu;
bool finished_run;
int self_comm;
int self_comm;
int cuda_exists;
int cuda_exists;
double extent[6];
int* debugdata;
// data shared between host code and device code
// (number of atoms, device pointers for up- & download)
cuda_shared_data shared_data;
double extent[6];
int* debugdata;
// data shared between host code and device code
// (number of atoms, device pointers for up- & download)
cuda_shared_data shared_data;
cCudaData<double , F_FLOAT , x >* cu_q;
cCudaData<double , F_FLOAT , yx>* cu_f;
cCudaData<double , V_FLOAT , x >* cu_mass;
cCudaData<double , V_FLOAT , x >* cu_rmass;
cCudaData<double , V_FLOAT , yx>* cu_v;
cCudaData<double , X_FLOAT , yx>* cu_x;
cCudaData<double , X_FLOAT , yx>* cu_xhold;
cCudaData<int , int , x >* cu_mask;
cCudaData<int , int , x >* cu_tag;
cCudaData<int , int , x >* cu_type;
cCudaData<int , int , x >* cu_image;
cCudaData<double , ENERGY_FLOAT, x >* cu_eatom;
cCudaData<double , ENERGY_FLOAT, yx>* cu_vatom;
cCudaData<double , ENERGY_FLOAT, x >* cu_virial;
cCudaData<double , ENERGY_FLOAT, x >* cu_eng_vdwl;
cCudaData<double , ENERGY_FLOAT, x >* cu_eng_coul;
cCudaData<double , double , x >* cu_extent;
int* binned_id;
cCudaData<int , int , xx >* cu_binned_id;
int* binned_idnew;
cCudaData<int , int , xx >* cu_binned_idnew;
cCudaData<int , int , x >* cu_debugdata;
cCudaData<double , X_FLOAT , x>* cu_radius;
cCudaData<double , F_FLOAT , x>* cu_density;
cCudaData<double , V_FLOAT , yx>* cu_omega;
cCudaData<double , F_FLOAT , yx>* cu_torque;
cCudaData<int , int , yx >* cu_special;
cCudaData<int , int , yx >* cu_nspecial;
cCudaData<int , int , x >* cu_molecule;
cCudaData<double , F_FLOAT , x >* cu_q;
cCudaData<double , F_FLOAT , yx>* cu_f;
cCudaData<double , V_FLOAT , x >* cu_mass;
cCudaData<double , V_FLOAT , x >* cu_rmass;
cCudaData<double , V_FLOAT , yx>* cu_v;
cCudaData<double , X_FLOAT , yx>* cu_x;
cCudaData<double , X_FLOAT , yx>* cu_xhold;
cCudaData<int , int , x >* cu_mask;
cCudaData<int , int , x >* cu_tag;
cCudaData<int , int , x >* cu_type;
cCudaData<int , int , x >* cu_image;
cCudaData<double , ENERGY_FLOAT, x >* cu_eatom;
cCudaData<double , ENERGY_FLOAT, yx>* cu_vatom;
cCudaData<double , ENERGY_FLOAT, x >* cu_virial;
cCudaData<double , ENERGY_FLOAT, x >* cu_eng_vdwl;
cCudaData<double , ENERGY_FLOAT, x >* cu_eng_coul;
cCudaData<double , double , x >* cu_extent;
int* binned_id;
cCudaData<int , int , xx >* cu_binned_id;
int* binned_idnew;
cCudaData<int , int , xx >* cu_binned_idnew;
cCudaData<int , int , x >* cu_debugdata;
cCudaData<double , X_FLOAT , x>* cu_radius;
cCudaData<double , F_FLOAT , x>* cu_density;
cCudaData<double , V_FLOAT , yx>* cu_omega;
cCudaData<double , F_FLOAT , yx>* cu_torque;
cCudaData<int , int , yx >* cu_special;
cCudaData<int , int , yx >* cu_nspecial;
cCudaData<int , int , x >* cu_molecule;
cCudaData<X_FLOAT , X_FLOAT , x>* cu_x_type;
X_FLOAT* x_type;
cCudaData<X_FLOAT , X_FLOAT , x>* cu_x_type;
X_FLOAT* x_type;
cCudaData<V_FLOAT , V_FLOAT , x>* cu_v_radius;
V_FLOAT* v_radius;
cCudaData<V_FLOAT , V_FLOAT , x>* cu_v_radius;
V_FLOAT* v_radius;
cCudaData<V_FLOAT , V_FLOAT , x>* cu_omega_rmass;
V_FLOAT* omega_rmass;
cCudaData<V_FLOAT , V_FLOAT , x>* cu_omega_rmass;
V_FLOAT* omega_rmass;
cCudaData<int , int , x >* cu_map_array;
int neighbor_decide_by_integrator;
cCudaData<int , int , x >* cu_map_array;
int neighbor_decide_by_integrator;
bool pinned;
bool pinned;
void* copy_buffer;
int copy_buffersize;
void* copy_buffer;
int copy_buffersize;
private:
std::map<class NeighList*, class CudaNeighList*> neigh_lists;
};
private:
std::map<class NeighList*, class CudaNeighList*> neigh_lists;
};
}
#endif // CUDA_H

View File

@ -25,7 +25,10 @@
#include "fix.h"
#include "compute.h"
#include "output.h"
#include "input.h"
#include "variable.h"
#include "dump.h"
#include "memory.h"
#include "error.h"
using namespace LAMMPS_NS;
@ -241,6 +244,29 @@ void Group::assign(int narg, char **arg)
delete [] list;
// style = variable
} else if (strcmp(arg[1],"variable") == 0) {
int ivar = input->variable->find(arg[2]);
if (ivar < 0) error->all(FLERR,"Variable name for group does not exist");
if (!input->variable->atomstyle(ivar))
error->all(FLERR,"Variable for group is invalid style");
double *aflag;
// aflag = evaluation of per-atom variable
memory->create(aflag,nlocal,"group:aflag");
input->variable->compute_atom(ivar,0,aflag,1,0);
// add to group if per-atom variable evaluated to non-zero
for (i = 0; i < nlocal; i++)
if (aflag[i] != 0.0) mask[i] |= bit;
memory->destroy(aflag);
// style = subtract
} else if (strcmp(arg[1],"subtract") == 0) {