MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / initialize_curand

Function initialize_curand

tensorflow/stream_executor/cuda/cuda_rng.cc:231–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229} // namespace gpu
230
231void initialize_curand() {
232 port::Status status =
233 PluginRegistry::Instance()->RegisterFactory<PluginRegistry::RngFactory>(
234 cuda::kCudaPlatformId, gpu::kGpuRandPlugin, "cuRAND",
235 [](internal::StreamExecutorInterface* parent) -> rng::RngSupport* {
236 gpu::GpuExecutor* cuda_executor =
237 dynamic_cast<gpu::GpuExecutor*>(parent);
238 if (cuda_executor == nullptr) {
239 LOG(ERROR)
240 << "Attempting to initialize an instance of the cuRAND "
241 << "support library with a non-CUDA StreamExecutor";
242 return nullptr;
243 }
244
245 gpu::GpuRng* rng = new gpu::GpuRng(cuda_executor);
246 if (!rng->Init()) {
247 // Note: Init() will log a more specific error.
248 delete rng;
249 return nullptr;
250 }
251 return rng;
252 });
253
254 if (!status.ok()) {
255 LOG(ERROR) << "Unable to register cuRAND factory: "
256 << status.error_message();
257 }
258
259 PluginRegistry::Instance()->SetDefaultFactory(
260 cuda::kCudaPlatformId, PluginKind::kRng, gpu::kGpuRandPlugin);
261}
262
263} // namespace stream_executor
264

Callers 1

cuda_rng.ccFile · 0.85

Calls 3

SetDefaultFactoryMethod · 0.80
InitMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected