| 2415 | } // namespace gpu |
| 2416 | |
| 2417 | void initialize_rocblas() { |
| 2418 | auto rocBlasAlreadyRegistered = PluginRegistry::Instance()->HasFactory( |
| 2419 | rocm::kROCmPlatformId, PluginKind::kBlas, gpu::kRocBlasPlugin); |
| 2420 | |
| 2421 | if (!rocBlasAlreadyRegistered) { |
| 2422 | port::Status status = |
| 2423 | PluginRegistry::Instance() |
| 2424 | ->RegisterFactory<PluginRegistry::BlasFactory>( |
| 2425 | rocm::kROCmPlatformId, gpu::kRocBlasPlugin, "rocBLAS", |
| 2426 | [](internal::StreamExecutorInterface *parent) |
| 2427 | -> blas::BlasSupport * { |
| 2428 | gpu::GpuExecutor *rocm_executor = |
| 2429 | dynamic_cast<gpu::GpuExecutor *>(parent); |
| 2430 | if (rocm_executor == nullptr) { |
| 2431 | LOG(ERROR) |
| 2432 | << "Attempting to initialize an instance of the " |
| 2433 | "rocBLAS " |
| 2434 | << "support library with a non-ROCM StreamExecutor"; |
| 2435 | return nullptr; |
| 2436 | } |
| 2437 | |
| 2438 | gpu::ROCMBlas *blas = new gpu::ROCMBlas(rocm_executor); |
| 2439 | if (!blas->Init()) { |
| 2440 | // Note: Init() will log a more specific error. |
| 2441 | delete blas; |
| 2442 | return nullptr; |
| 2443 | } |
| 2444 | return blas; |
| 2445 | }); |
| 2446 | |
| 2447 | if (!status.ok()) { |
| 2448 | LOG(ERROR) << "Unable to register rocBLAS factory: " |
| 2449 | << status.error_message(); |
| 2450 | } |
| 2451 | |
| 2452 | PluginRegistry::Instance()->SetDefaultFactory( |
| 2453 | rocm::kROCmPlatformId, PluginKind::kBlas, gpu::kRocBlasPlugin); |
| 2454 | } |
| 2455 | } |
| 2456 | |
| 2457 | } // namespace stream_executor |
| 2458 |
no test coverage detected