MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / generateBatch

Method generateBatch

cpp/4_CUDA_Libraries/randomFog/rng.cpp:137–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135}
136
137void RNG::generateBatch(void)
138{
139 using std::runtime_error;
140 using std::string;
141
142 cudaError_t cudaResult;
143 curandStatus_t curandResult;
144
145 // Generate random numbers
146 curandResult = curandGenerateUniform(*m_pCurrent, m_d_samples, m_nSamplesBatchActual);
147
148 if (curandResult != CURAND_STATUS_SUCCESS) {
149 string msg("Could not generate random numbers: ");
150 msg += curandResult;
151 throw runtime_error(msg);
152 }
153
154 // Copy random numbers to host
155 cudaResult = cudaMemcpy(m_h_samples, m_d_samples, m_nSamplesBatchActual * sizeof(float), cudaMemcpyDeviceToHost);
156
157 if (cudaResult != cudaSuccess) {
158 string msg("Could not copy random numbers to host: ");
159 msg += cudaGetErrorString(cudaResult);
160 throw runtime_error(msg);
161 }
162}
163
164float RNG::getNextU01(void)
165{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected