@@ -100,40 +100,26 @@ namespace libcloudphxx
100
100
101
101
rng (int seed)
102
102
{
103
- {
104
- int status = curandCreateGenerator (&gen, CURAND_RNG_PSEUDO_MTGP32);
105
- assert (status == CURAND_STATUS_SUCCESS /* && "curandCreateGenerator failed"*/ );
106
- _unused (status);
107
- }
108
- {
109
- int status = curandSetPseudoRandomGeneratorSeed (gen, seed);
110
- assert (status == CURAND_STATUS_SUCCESS /* && "curandSetPseudoRandomGeneratorSeed failed"*/ );
111
- _unused (status);
112
- }
103
+ gpuErrchk (curandCreateGenerator (&gen, CURAND_RNG_PSEUDO_MTGP32));
104
+ gpuErrchk (curandSetPseudoRandomGeneratorSeed (gen, seed));
113
105
}
114
106
115
107
void reseed (int seed)
116
108
{
117
- int status = curandSetPseudoRandomGeneratorSeed (gen, seed);
118
- assert (status == CURAND_STATUS_SUCCESS /* && "curandSetPseudoRandomGeneratorSeed failed"*/ );
119
- _unused (status);
109
+ gpuErrchk (curandSetPseudoRandomGeneratorSeed (gen, seed));
120
110
}
121
111
122
112
~rng ()
123
113
{
124
- int status = curandDestroyGenerator (gen);
125
- assert (status == CURAND_STATUS_SUCCESS /* && "curandDestroyGenerator failed"*/ );
126
- _unused (status);
114
+ gpuErrchk (curandDestroyGenerator (gen));
127
115
}
128
116
129
117
void generate_n (
130
118
thrust_device::vector<float > &v,
131
119
const thrust_size_t n
132
120
)
133
121
{
134
- int status = curandGenerateUniform (gen, thrust::raw_pointer_cast (v.data ()), n); // (0,1] range
135
- assert (status == CURAND_STATUS_SUCCESS /* && "curandGenerateUniform failed"*/ );
136
- _unused (status);
122
+ gpuErrchk (curandGenerateUniform (gen, thrust::raw_pointer_cast (v.data ()), n)); // (0,1] range
137
123
// shift into the expected [0,1) range
138
124
namespace arg = thrust::placeholders;
139
125
thrust::transform (v.begin (), v.begin () + n, v.begin (), float (1 ) - arg::_1);
@@ -144,9 +130,7 @@ namespace libcloudphxx
144
130
const thrust_size_t n
145
131
)
146
132
{
147
- int status = curandGenerateUniformDouble (gen, thrust::raw_pointer_cast (v.data ()), n); // (0,1] range
148
- assert (status == CURAND_STATUS_SUCCESS /* && "curandGenerateUniform failed"*/ );
149
- _unused (status);
133
+ gpuErrchk (curandGenerateUniformDouble (gen, thrust::raw_pointer_cast (v.data ()), n)); // (0,1] range
150
134
// shift into the expected [0,1) range
151
135
namespace arg = thrust::placeholders;
152
136
thrust::transform (v.begin (), v.begin () + n, v.begin (), double (1 ) - arg::_1);
@@ -157,29 +141,23 @@ namespace libcloudphxx
157
141
const thrust_size_t n
158
142
)
159
143
{
160
- int status = curandGenerateNormal (gen, thrust::raw_pointer_cast (v.data ()), n, float (0 ), float (1 ));
161
- assert (status == CURAND_STATUS_SUCCESS /* && "curandGenerateUniform failed"*/ );
162
- _unused (status);
144
+ gpuErrchk (curandGenerateNormal (gen, thrust::raw_pointer_cast (v.data ()), n, float (0 ), float (1 )));
163
145
}
164
146
165
147
void generate_normal_n (
166
148
thrust_device::vector<double > &v,
167
149
const thrust_size_t n
168
150
)
169
151
{
170
- int status = curandGenerateNormalDouble (gen, thrust::raw_pointer_cast (v.data ()), n, double (0 ), double (1 ));
171
- assert (status == CURAND_STATUS_SUCCESS /* && "curandGenerateUniform failed"*/ );
172
- _unused (status);
152
+ gpuErrchk (curandGenerateNormalDouble (gen, thrust::raw_pointer_cast (v.data ()), n, double (0 ), double (1 )));
173
153
}
174
154
175
155
void generate_n (
176
156
thrust_device::vector<unsigned int > &v,
177
157
const thrust_size_t n
178
158
)
179
159
{
180
- int status = curandGenerate (gen, thrust::raw_pointer_cast (v.data ()), n);
181
- assert (status == CURAND_STATUS_SUCCESS /* && "curandGenerateUniform failed"*/ );
182
- _unused (status);
160
+ gpuErrchk (curandGenerate (gen, thrust::raw_pointer_cast (v.data ()), n));
183
161
}
184
162
#endif
185
163
};
0 commit comments