| 465 | } |
| 466 | |
| 467 | void removeDeviceContext(sycl::device& dev, sycl::context& ctx) { |
| 468 | if (getDevice() == dev && getContext() == ctx) { |
| 469 | AF_ERROR("Cannot pop the device currently in use", AF_ERR_ARG); |
| 470 | } |
| 471 | |
| 472 | DeviceManager& devMngr = DeviceManager::getInstance(); |
| 473 | |
| 474 | int deleteIdx = -1; |
| 475 | { |
| 476 | common::lock_guard_t lock(devMngr.deviceMutex); |
| 477 | |
| 478 | const int dCount = static_cast<int>(devMngr.mDevices.size()); |
| 479 | for (int i = 0; i < dCount; ++i) { |
| 480 | if (*devMngr.mDevices[i] == dev && *devMngr.mContexts[i] == ctx) { |
| 481 | deleteIdx = i; |
| 482 | break; |
| 483 | } |
| 484 | } |
| 485 | } |
| 486 | |
| 487 | if (deleteIdx < static_cast<int>(devMngr.mUserDeviceOffset)) { |
| 488 | AF_ERROR("Cannot pop ArrayFire internal devices", AF_ERR_ARG); |
| 489 | } else if (deleteIdx == -1) { |
| 490 | AF_ERROR("No matching device found", AF_ERR_ARG); |
| 491 | } else { |
| 492 | // remove memory management for device added by user outside of the lock |
| 493 | memoryManager().removeMemoryManagement(deleteIdx); |
| 494 | |
| 495 | common::lock_guard_t lock(devMngr.deviceMutex); |
| 496 | // FIXME: this case can potentially cause issues due to the |
| 497 | // modification of the device pool stl containers. |
| 498 | |
| 499 | // IF the current active device is enumerated at a position |
| 500 | // that lies ahead of the device that has been requested |
| 501 | // to be removed. We just pop the entries from pool since it |
| 502 | // has no side effects. |
| 503 | devMngr.mDevices.erase(devMngr.mDevices.begin() + deleteIdx); |
| 504 | devMngr.mContexts.erase(devMngr.mContexts.begin() + deleteIdx); |
| 505 | devMngr.mQueues.erase(devMngr.mQueues.begin() + deleteIdx); |
| 506 | devMngr.mPlatforms.erase(devMngr.mPlatforms.begin() + deleteIdx); |
| 507 | |
| 508 | // FIXME: add OpenGL Interop for user provided contexts later |
| 509 | devMngr.mIsGLSharingOn.erase(devMngr.mIsGLSharingOn.begin() + |
| 510 | deleteIdx); |
| 511 | |
| 512 | // OTHERWISE, update(decrement) the thread local active device ids |
| 513 | device_id_t& devId = tlocalActiveDeviceId(); |
| 514 | |
| 515 | if (deleteIdx < static_cast<int>(devId.first)) { |
| 516 | device_id_t newVals = make_pair(devId.first - 1, devId.second - 1); |
| 517 | devId = newVals; |
| 518 | } |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | unsigned getMemoryBusWidth(const sycl::device& device) { |
| 523 | return device.get_info<sycl::info::device::global_mem_cache_line_size>(); |
nothing calls this directly
no test coverage detected