changa  3.5
 All Classes Files Functions Variables Typedefs Enumerations Friends Macros Groups Pages
cuda_typedef.h
Go to the documentation of this file.
1 #ifndef CUDA_TYPEDEF_H_
2 #define CUDA_TYPEDEF_H_
3 
9 #include "cosmoType.h"
10 
12 typedef float cudatype;
14 typedef cosmoType hosttype;
15 
16 // set these to appropriate values (in millions)
17 // local
18 #define NODE_INTERACTIONS_PER_REQUEST_L 1.0
19 #define PART_INTERACTIONS_PER_REQUEST_L 0.1
20 // remote, no-resume
21 #define NODE_INTERACTIONS_PER_REQUEST_RNR 1.0
22 #define PART_INTERACTIONS_PER_REQUEST_RNR 0.1
23 // remote, resume
24 #define NODE_INTERACTIONS_PER_REQUEST_RR 1.0
25 #define PART_INTERACTIONS_PER_REQUEST_RR 0.1
26 
27 #ifdef HAPI_TRACE
28 #define CUDA_SER_TREE 9900
29 #define CUDA_SER_LIST 9901
30 
31 #define CUDA_LOCAL_NODE_KERNEL 9910
32 #define CUDA_REMOTE_NODE_KERNEL 9911
33 #define CUDA_REMOTE_RESUME_NODE_KERNEL 9912
34 #define CUDA_LOCAL_PART_KERNEL 9913
35 #define CUDA_REMOTE_PART_KERNEL 9914
36 #define CUDA_REMOTE_RESUME_PART_KERNEL 9915
37 
38 #endif
39 
40 // TODO: Fix small phase code
41 #define TP_LARGE_PHASE_THRESHOLD_DEFAULT 0.0
42 #define AVG_SOURCE_PARTICLES_PER_ACTIVE 10
43 
46 typedef struct CudaVector3D{
47  cudatype x,y,z;
48 #if __cplusplus && !defined __CUDACC__
49  inline CudaVector3D& operator=(Vector3D<hosttype> &a){
50  x = a.x;
51  y = a.y;
52  z = a.z;
53  return *this;
54  }
55 
56  inline Vector3D<hosttype> operator+(Vector3D<hosttype> &v){
57  return Vector3D<hosttype>(x + v.x, y + v.y, z + v.z);
58  }
59 
60  CudaVector3D(Vector3D<hosttype> &o){
61  x = o.x;
62  y = o.y;
63  z = o.z;
64  }
65 
66  CudaVector3D(){}
67 #endif
69 
70 #ifdef GPU_LOCAL_TREE_WALK
71 typedef struct CudaSphere {
73  CudaVector3D origin;
75  cudatype radius;
76 }CudaSphere;
77 
78 enum CudaNodeType {
79  CudaInvalid = 1,
80  CudaBucket = 2,
81  CudaInternal = 3,
82  CudaBoundary = 4,
83  CudaNonLocal = 5,
84  CudaEmpty = 6,
85  CudaTop = 7,
86  CudaNonLocalBucket = 8,
87  CudaCached = 9,
88  CudaCachedBucket = 10,
89  CudaCachedEmpty = 11
90 };
91 #endif //GPU_LOCAL_TREE_WALK
92 
95 typedef struct CudaMultipoleMoments{
96  cudatype radius;
97  cudatype soft;
98  cudatype totalMass;
99  CudaVector3D cm;
100 
101 #ifdef GPU_LOCAL_TREE_WALK
102  // We need tree node's spatial and tree structural information to do GPU
103  // tree walk. The spatial info is used for force computation, and the
104  // structural data is needed in tree traversal.
105  CudaVector3D lesser_corner;
106  CudaVector3D greater_corner;
107  int bucketStart;
108  int bucketSize;
109  int particleCount;
110  int nodeArrayIndex;
111  int children[2];
112  int type;
113 #endif //GPU_LOCAL_TREE_WALK
114 
115 #ifdef HEXADECAPOLE
116  cudatype xx, xy, xz, yy, yz;
117  cudatype xxx,xyy,xxy,yyy,xxz,yyz,xyz;
118  cudatype xxxx,xyyy,xxxy,yyyy,xxxz,yyyz,xxyy,xxyz,xyyz;
119 #else
120  cudatype xx, xy, xz, yy, yz, zz;
121 #endif
122 
123 #if __cplusplus && !defined __CUDACC__
126  *this = mom;
127  }
128  inline CudaMultipoleMoments& operator=(MultipoleMoments &m){
129  radius = m.radius;
130  soft = m.soft;
131  totalMass = m.totalMass;
132 
133  cm = m.cm;
134 #if ! defined(HEXADECAPOLE)
135  xx = m.xx;
136  xy = m.xy;
137  xz = m.xz;
138  yy = m.yy;
139  yz = m.yz;
140  zz = m.zz;
141 #else
142  xx = m.mom.xx;
143  yy = m.mom.yy;
144  xy = m.mom.xy;
145  xz = m.mom.xz;
146  yz = m.mom.yz;
147  xxx = m.mom.xxx;
148  xyy = m.mom.xyy;
149  xxy = m.mom.xxy;
150  yyy = m.mom.yyy;
151  xxz = m.mom.xxz;
152  yyz = m.mom.yyz;
153  xyz = m.mom.xyz;
154  xxxx = m.mom.xxxx;
155  xyyy = m.mom.xyyy;
156  xxxy = m.mom.xxxy;
157  yyyy = m.mom.yyyy;
158  xxxz = m.mom.xxxz;
159  yyyz = m.mom.yyyz;
160  xxyy = m.mom.xxyy;
161  xxyz = m.mom.xxyz;
162  xyyz = m.mom.xyyz;
163 #endif
164 
165  return *this;
166  }
167 #endif
169 
170 #ifdef GPU_LOCAL_TREE_WALK
171 struct CUDATreeNode
172 {
173  cudatype radius;
174  cudatype soft;
175  cudatype totalMass;
176  CudaVector3D cm;
177 
178  int bucketStart;
179  int bucketSize;
180  int particleCount;
181  int children[2];
182  int type;
183 };
184 
185 struct CUDABucketNode
186 {
187  cudatype radius;
188  cudatype soft;
189  cudatype totalMass;
190  CudaVector3D cm;
191 
192  CudaVector3D lesser_corner;
193  CudaVector3D greater_corner;
194 };
195 #endif //GPU_LOCAL_TREE_WALK
196 
199 typedef struct ILPart{
201  int index;
203  int off;
205  int num;
206 
207 #if __cplusplus && !defined __CUDACC__
208  ILPart() {}
209  //ILPart() : index(-1), numParticles(-1) {}
210  ILPart(int i, int o, int n) : index(i), off(o), num(n) {}
211 #endif
212 }ILPart;
213 
216 typedef struct ILCell{
218  int index;
220  int offsetID;
221 #if __cplusplus && !defined __CUDACC__
222  ILCell() {}
223  //ILCell() :index(-1), offsetID(-1) {}
224  ILCell(int ind, int off) : index(ind), offsetID(off) {}
225 #endif
226 }ILCell;
227 
231 typedef struct CompactPartData{
232  cudatype mass;
233  cudatype soft;
234  CudaVector3D position;
235 
236 #ifdef GPU_LOCAL_TREE_WALK
237  int nodeId;
238 #endif
239 
240 #if __cplusplus && !defined __CUDACC__
241  CompactPartData(){}
243  *this = egp;
244  }
245  CompactPartData(cudatype m, cudatype s, Vector3D<hosttype> &rr) : mass(m), soft(s), position(rr){}
246 
247  inline CompactPartData& operator=(ExternalGravityParticle &gp){
248  mass = gp.mass;
249  soft = gp.soft;
250  position = gp.position;
251  return *this;
252  }
253 #endif
255 
259 typedef struct VariablePartData{
260  CudaVector3D a;
261  cudatype potential;
262  cudatype dtGrav;
264 
265 
266 #endif /* CUDA_TYPEDEF_H_*/
struct CudaMultipoleMoments CudaMultipoleMoments
Version of MultipoleMoments using cudatype.
Definition: MultipoleMoments.h:164
A representation of a multipole expansion.
Definition: MultipoleMoments.h:163
cosmoType hosttype
floating point type on the host
Definition: cuda_typedef.h:14
int index
Definition: cuda_typedef.h:201
int off
Definition: cuda_typedef.h:203
struct ILPart ILPart
Bucket of particles on the interaction list for the GPU.
int index
Definition: cuda_typedef.h:218
Version of MultipoleMoments using cudatype.
Definition: cuda_typedef.h:95
int num
Definition: cuda_typedef.h:205
int offsetID
Definition: cuda_typedef.h:220
struct CompactPartData CompactPartData
Particle data needed on the GPU to calculate gravity.
struct ILCell ILCell
Cell on the interaction list for the GPU.
Particle data that gets calculated by the GPU.
Definition: cuda_typedef.h:259
Bucket of particles on the interaction list for the GPU.
Definition: cuda_typedef.h:199
float cudatype
floating point type on the GPU
Definition: cuda_typedef.h:12
Information needed to calculate gravity.
Definition: GravityParticle.h:33
Particle data needed on the GPU to calculate gravity.
Definition: cuda_typedef.h:231
struct CudaVector3D CudaVector3D
3D vector of cudatype.
cosmoType totalMass
The total mass represented by this expansion.
Definition: MultipoleMoments.h:172
unsigned int bucketSize
Definition: ParallelGravity.cpp:125
struct VariablePartData VariablePartData
Particle data that gets calculated by the GPU.
Cell on the interaction list for the GPU.
Definition: cuda_typedef.h:216
3D vector of cudatype.
Definition: cuda_typedef.h:46
Vector3D< cosmoType > cm
The center of mass (zeroth order multipole)
Definition: MultipoleMoments.h:174