-
Notifications
You must be signed in to change notification settings - Fork 2
/
helper.cuh
148 lines (114 loc) · 5.88 KB
/
helper.cuh
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#ifndef MILUPHPC_HELPER_CUH
#define MILUPHPC_HELPER_CUH
#include "parameter.h"
#include "cuda_utils/cuda_utilities.cuh"
#include <boost/mpi.hpp>
#include "utils/logger.h"
#include "cuda_utils/cuda_runtime.h"
struct Reduction
{
enum Type
{
min, max, sum
};
Type t_;
Reduction(Type t) : t_(t) {}
operator Reduction () const {return t_;}
private:
template<typename T>
operator T () const;
};
class Helper {
public:
/*integer *integerBuffer;
real *realBuffer;
keyType *keyTypeBuffer;
integer *integerVal;
real *realVal;
keyType *keyTypeVal;
CUDA_CALLABLE_MEMBER Helper();
CUDA_CALLABLE_MEMBER Helper(integer *integerVal, real *realVal, keyType *keyTypeVal, integer *integerBuffer,
real *realBuffer, keyType *keyTypeBuffer);
CUDA_CALLABLE_MEMBER ~Helper();
CUDA_CALLABLE_MEMBER void set(integer *integerVal, real *realVal, keyType *keyTypeVal, integer *integerBuffer,
real *realBuffer, keyType *keyTypeBuffer);
*/
integer *integerVal;
integer *integerVal1;
integer *integerVal2;
real *realVal;
real *realVal1;
real *realVal2;
keyType *keyTypeVal;
integer *integerBuffer;
integer *integerBuffer1; // numParticles (or numParticlesLocal)
integer *integerBuffer2; // numParticles (or numParticlesLocal)
integer *integerBuffer3; // numParticles (or numParticlesLocal)
integer *integerBuffer4; // numParticles (or numParticlesLocal)
integer *sendCount; // subDomainKeyTreeHandler->h_subDomainKeyTree->numProcesses
integer *sendCount1; // subDomainKeyTreeHandler->h_subDomainKeyTree->numProcesses
idInteger *idIntegerBuffer;
idInteger *idIntegerBuffer1;
real *realBuffer;
real *realBuffer1;
keyType *keyTypeBuffer; // numParticlesLocal
keyType *keyTypeBuffer1; // sumParticles
keyType *keyTypeBuffer2; //sumParticles
CUDA_CALLABLE_MEMBER Helper();
CUDA_CALLABLE_MEMBER Helper(integer *integerVal, integer *integerVal1, integer *integerVal2,
real *realVal, real *realVal1, real *realVal2, keyType *keyTypeVal,
integer *integerBuffer, integer *integerBuffer1, integer *integerBuffer2,
integer *integerBuffer3, integer *integerBuffer4,
integer *sendCount, integer *sendCount1, idInteger *idIntegerBuffer,
idInteger *idIntegerBuffer1, real *realBuffer, real *realBuffer1,
keyType *keyTypeBuffer, keyType *keyTypeBuffer1, keyType *keyTypeBuffer2);
CUDA_CALLABLE_MEMBER void set(integer *integerVal, integer *integerVal1, integer *integerVal2,
real *realVal, real *realVal1, real *realVal2, keyType *keyTypeVal,
integer *integerBuffer, integer *integerBuffer1, integer *integerBuffer2,
integer *integerBuffer3, integer *integerBuffer4,
integer *sendCount, integer *sendCount1, idInteger *idIntegerBuffer,
idInteger *idIntegerBuffer1, real *realBuffer, real *realBuffer1,
keyType *keyTypeBuffer, keyType *keyTypeBuffer1, keyType *keyTypeBuffer2);
CUDA_CALLABLE_MEMBER ~Helper();
};
namespace HelperNS {
namespace Kernel {
//__global__ void set(Helper *helper, integer *integerVal, real *realVal, keyType *keyTypeVal,
// integer *integerBuffer, real *realBuffer, keyType *keyTypeBuffer);
__global__ void set(Helper *helper, integer *integerVal, integer *integerVal1, integer *integerVal2,
real *realVal, real *realVal1, real *realVal2, keyType *keyTypeVal,
integer *integerBuffer, integer *integerBuffer1, integer *integerBuffer2,
integer *integerBuffer3, integer *integerBuffer4,
integer *sendCount, integer *sendCount1, idInteger *idIntegerBuffer,
idInteger *idIntegerBuffer1, real *realBuffer, real *realBuffer1,
keyType *keyTypeBuffer, keyType *keyTypeBuffer1, keyType *keyTypeBuffer2);
namespace Launch {
//void set(Helper *helper, integer *integerVal, real *realVal, keyType *keyTypeVal, integer *integerBuffer,
// real *realBuffer, keyType *keyTypeBuffer);
void set(Helper *helper, integer *integerVal, integer *integerVal1, integer *integerVal2,
real *realVal, real *realVal1, real *realVal2, keyType *keyTypeVal,
integer *integerBuffer, integer *integerBuffer1, integer *integerBuffer2,
integer *integerBuffer3, integer *integerBuffer4,
integer *sendCount, integer *sendCount1, idInteger *idIntegerBuffer,
idInteger *idIntegerBuffer1, real *realBuffer, real *realBuffer1,
keyType *keyTypeBuffer, keyType *keyTypeBuffer1, keyType *keyTypeBuffer2);
}
template <typename T>
__global__ void copyArray(T *targetArray, T *sourceArray, integer n);
template <typename T>
__global__ void resetArray(T *array, T value, integer n);
namespace Launch {
template <typename T>
real copyArray(T *targetArray, T *sourceArray, integer n);
template <typename T>
real resetArray(T *array, T value, integer n);
}
}
template <typename A>
real sortKeys(A *keysToSort, A *sortedKeys, int n);
template <typename A, typename B>
real sortArray(A *arrayToSort, A *sortedArray, B *keyIn, B *keyOut, integer n);
template <typename T>
T reduceAndGlobalize(T *d_sml, T *d_aggregate, integer n, Reduction::Type reductionType);
}
#endif //MILUPHPC_HELPER_CUH