| 168 | } |
| 169 | |
| 170 | unique_handle<cusparseHandle_t> *cusparseManager(const int deviceId) { |
| 171 | thread_local unique_handle<cusparseHandle_t> |
| 172 | handles[DeviceManager::MAX_DEVICES]; |
| 173 | thread_local once_flag initFlags[DeviceManager::MAX_DEVICES]; |
| 174 | call_once(initFlags[deviceId], [&] { |
| 175 | auto &_ = getCusparsePlugin(); |
| 176 | handles[deviceId].create(); |
| 177 | // TODO(pradeep) When multiple streams per device |
| 178 | // is added to CUDA backend, move the cublasSetStream |
| 179 | // call outside of call_once scope. |
| 180 | CUSPARSE_CHECK( |
| 181 | _.cusparseSetStream(handles[deviceId], getStream(deviceId))); |
| 182 | }); |
| 183 | return &handles[deviceId]; |
| 184 | } |
| 185 | |
| 186 | DeviceManager::~DeviceManager() { |
| 187 | try { |
no test coverage detected