-
Notifications
You must be signed in to change notification settings - Fork 2
/
device_rhs.cu
49 lines (38 loc) · 1.32 KB
/
device_rhs.cu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "../include/device_rhs.cuh"
#include "../include/cuda_utils/cuda_launcher.cuh"
namespace Kernel {
__global__ void resetArrays(Tree *tree, Particles *particles, integer *mutex, integer n, integer m) {
integer bodyIndex = threadIdx.x + blockDim.x*blockIdx.x;
integer stride = blockDim.x*gridDim.x;
integer offset = 0;
while ((bodyIndex + offset) < m) {
tree->reset(bodyIndex + offset, n);
if ((bodyIndex + offset) >= n) {
particles->reset(bodyIndex + offset);
}
offset += stride;
}
if (bodyIndex == 0) {
*mutex = 0;
*tree->index = n;
*tree->minX = 0;
*tree->maxX = 0;
#if DIM > 1
*tree->minY = 0;
*tree->maxY = 0;
#if DIM == 3
*tree->minZ = 0;
*tree->maxZ = 0;
#endif
#endif
tree->toDeleteLeaf[0] = -1;
tree->toDeleteLeaf[1] = -1;
tree->toDeleteNode[0] = -1;
tree->toDeleteNode[1] = -1;
}
}
real Launch::resetArrays(Tree *tree, Particles *particles, integer *mutex, integer n, integer m, bool time) {
ExecutionPolicy executionPolicy;
return cuda::launch(time, executionPolicy, ::Kernel::resetArrays, tree, particles, mutex, n, m);
}
}