Create separate structs DeviceAtom and DeviceNeighbor with device pointers
Signed-off-by: Rafael Ravedutti <rafaelravedutti@gmail.com>
This commit is contained in:
@@ -48,6 +48,18 @@
|
||||
# define updateAtomsPbc updateAtomsPbc_cpu
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
MD_FLOAT *x, *y, *z;
|
||||
MD_FLOAT *vx, *vy, *vz;
|
||||
MD_FLOAT *fx, *fy, *fz;
|
||||
int *border_map;
|
||||
int *type;
|
||||
MD_FLOAT *epsilon;
|
||||
MD_FLOAT *sigma6;
|
||||
MD_FLOAT *cutforcesq;
|
||||
MD_FLOAT *cutneighsq;
|
||||
} DeviceAtom;
|
||||
|
||||
typedef struct {
|
||||
int Natoms, Nlocal, Nghost, Nmax;
|
||||
MD_FLOAT *x, *y, *z;
|
||||
@@ -60,10 +72,14 @@ typedef struct {
|
||||
MD_FLOAT *sigma6;
|
||||
MD_FLOAT *cutforcesq;
|
||||
MD_FLOAT *cutneighsq;
|
||||
|
||||
// DEM
|
||||
MD_FLOAT *radius;
|
||||
MD_FLOAT *av;
|
||||
MD_FLOAT *r;
|
||||
|
||||
// Device data
|
||||
DeviceAtom d_atom;
|
||||
} Atom;
|
||||
|
||||
extern void initAtom(Atom*);
|
||||
|
@@ -5,7 +5,7 @@
|
||||
|
||||
#ifndef __CUDA_ATOM_H_
|
||||
#define __CUDA_ATOM_H_
|
||||
extern void initCuda(Atom*, Neighbor*, Atom*, Neighbor*);
|
||||
extern void initCuda(Atom*, Neighbor*);
|
||||
extern void cuda_assert(const char *msg, cudaError_t err);
|
||||
extern void *allocateGPU(size_t bytesize);
|
||||
extern void *reallocateGPU(void *ptr, size_t new_bytesize);
|
||||
|
@@ -23,7 +23,7 @@
|
||||
#include <parameter.h>
|
||||
#include <atom.h>
|
||||
|
||||
void initialIntegrate_cpu(bool reneigh, Parameter *param, Atom *atom, Atom *c_atom) {
|
||||
void initialIntegrate_cpu(bool reneigh, Parameter *param, Atom *atom) {
|
||||
for(int i = 0; i < atom->Nlocal; i++) {
|
||||
atom_vx(i) += param->dtforce * atom_fx(i);
|
||||
atom_vy(i) += param->dtforce * atom_fy(i);
|
||||
@@ -34,7 +34,7 @@ void initialIntegrate_cpu(bool reneigh, Parameter *param, Atom *atom, Atom *c_at
|
||||
}
|
||||
}
|
||||
|
||||
void finalIntegrate_cpu(bool reneigh, Parameter *param, Atom *atom, Atom *c_atom) {
|
||||
void finalIntegrate_cpu(bool reneigh, Parameter *param, Atom *atom) {
|
||||
for(int i = 0; i < atom->Nlocal; i++) {
|
||||
atom_vx(i) += param->dtforce * atom_fx(i);
|
||||
atom_vy(i) += param->dtforce * atom_fy(i);
|
||||
@@ -43,6 +43,6 @@ void finalIntegrate_cpu(bool reneigh, Parameter *param, Atom *atom, Atom *c_atom
|
||||
}
|
||||
|
||||
#ifdef CUDA_TARGET
|
||||
void initialIntegrate_cuda(bool, Parameter*, Atom*, Atom*);
|
||||
void finalIntegrate_cuda(bool, Parameter*, Atom*, Atom*);
|
||||
void initialIntegrate_cuda(bool, Parameter*, Atom*);
|
||||
void finalIntegrate_cuda(bool, Parameter*, Atom*);
|
||||
#endif
|
||||
|
@@ -25,13 +25,22 @@
|
||||
|
||||
#ifndef __NEIGHBOR_H_
|
||||
#define __NEIGHBOR_H_
|
||||
|
||||
typedef struct {
|
||||
int *neighbors;
|
||||
int *numneigh;
|
||||
} DeviceNeighbor;
|
||||
|
||||
typedef struct {
|
||||
int every;
|
||||
int ncalls;
|
||||
int maxneighs;
|
||||
int half_neigh;
|
||||
int* neighbors;
|
||||
int* numneigh;
|
||||
int *neighbors;
|
||||
int *numneigh;
|
||||
|
||||
// Device data
|
||||
DeviceNeighbor d_neighbor;
|
||||
} Neighbor;
|
||||
|
||||
typedef struct {
|
||||
@@ -52,11 +61,11 @@ typedef struct {
|
||||
extern void initNeighbor(Neighbor*, Parameter*);
|
||||
extern void setupNeighbor(Parameter*);
|
||||
extern void binatoms(Atom*);
|
||||
extern void buildNeighbor_cpu(Atom*, Neighbor*, Atom*, Neighbor*);
|
||||
extern void buildNeighbor_cpu(Atom*, Neighbor*);
|
||||
extern void sortAtom(Atom*);
|
||||
|
||||
#ifdef CUDA_TARGET
|
||||
extern void buildNeighbor_cuda(Atom*, Neighbor*, Atom*, Neighbor*);
|
||||
extern void buildNeighbor_cuda(Atom*, Neighbor*);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -28,13 +28,13 @@
|
||||
#ifndef __PBC_H_
|
||||
#define __PBC_H_
|
||||
extern void initPbc();
|
||||
extern void updatePbc_cpu(Atom*, Atom*, Parameter*, bool);
|
||||
extern void updateAtomsPbc_cpu(Atom*, Atom*, Parameter*);
|
||||
extern void updatePbc_cpu(Atom*, Parameter*, bool);
|
||||
extern void updateAtomsPbc_cpu(Atom*, Parameter*);
|
||||
extern void setupPbc(Atom*, Parameter*);
|
||||
|
||||
#ifdef CUDA_TARGET
|
||||
extern void updatePbc_cuda(Atom*, Atom*, Parameter*, bool);
|
||||
extern void updateAtomsPbc_cuda(Atom*, Atom*, Parameter*);
|
||||
extern void updatePbc_cuda(Atom*, Parameter*, bool);
|
||||
extern void updateAtomsPbc_cuda(Atom*, Parameter*);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user