| 282 | } // namespace gpu |
| 283 | |
| 284 | void initialize_rocrand() { |
| 285 | auto rocRandAlreadyRegistered = PluginRegistry::Instance()->HasFactory( |
| 286 | rocm::kROCmPlatformId, PluginKind::kRng, gpu::kGpuRandPlugin); |
| 287 | |
| 288 | if (!rocRandAlreadyRegistered) { |
| 289 | port::Status status = |
| 290 | PluginRegistry::Instance()->RegisterFactory<PluginRegistry::RngFactory>( |
| 291 | rocm::kROCmPlatformId, gpu::kGpuRandPlugin, "rocRAND", |
| 292 | [](internal::StreamExecutorInterface* parent) -> rng::RngSupport* { |
| 293 | gpu::GpuExecutor* rocm_executor = |
| 294 | dynamic_cast<gpu::GpuExecutor*>(parent); |
| 295 | if (rocm_executor == nullptr) { |
| 296 | LOG(ERROR) |
| 297 | << "Attempting to initialize an instance of the hipRAND " |
| 298 | << "support library with a non-ROCM StreamExecutor"; |
| 299 | return nullptr; |
| 300 | } |
| 301 | |
| 302 | gpu::GpuRng* rng = new gpu::GpuRng(rocm_executor); |
| 303 | if (!rng->Init()) { |
| 304 | // Note: Init() will log a more specific error. |
| 305 | delete rng; |
| 306 | return nullptr; |
| 307 | } |
| 308 | return rng; |
| 309 | }); |
| 310 | |
| 311 | if (!status.ok()) { |
| 312 | LOG(ERROR) << "Unable to register rocRAND factory: " |
| 313 | << status.error_message(); |
| 314 | } |
| 315 | |
| 316 | PluginRegistry::Instance()->SetDefaultFactory( |
| 317 | rocm::kROCmPlatformId, PluginKind::kRng, gpu::kGpuRandPlugin); |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | } // namespace stream_executor |
| 322 |
no test coverage detected