| 337 | } |
| 338 | |
| 339 | vector<Version> getOpenCLCDeviceVersion(const Device& device) { |
| 340 | // For OpenCL-HPP >= v2023.12.14 type is cl::Platform instead of |
| 341 | // cl_platform_id |
| 342 | Platform device_platform; |
| 343 | device_platform = device.getInfo<CL_DEVICE_PLATFORM>(); |
| 344 | |
| 345 | auto platform_version = device_platform.getInfo<CL_PLATFORM_VERSION>(); |
| 346 | vector<Version> out; |
| 347 | |
| 348 | /// The ifdef allows us to support BUILDING ArrayFire with older |
| 349 | /// versions of OpenCL where as the if condition in the ifdef allows us |
| 350 | /// to support older versions of OpenCL at runtime |
| 351 | #ifdef CL_DEVICE_OPENCL_C_ALL_VERSIONS |
| 352 | if (platform_version.substr(7).c_str()[0] >= '3') { |
| 353 | vector<cl_name_version> device_versions = |
| 354 | device.getInfo<CL_DEVICE_OPENCL_C_ALL_VERSIONS>(); |
| 355 | sort(begin(device_versions), end(device_versions), |
| 356 | [](const auto& lhs, const auto& rhs) { |
| 357 | return lhs.version < rhs.version; |
| 358 | }); |
| 359 | transform(begin(device_versions), end(device_versions), |
| 360 | std::back_inserter(out), [](const cl_name_version& version) { |
| 361 | return Version(CL_VERSION_MAJOR(version.version), |
| 362 | CL_VERSION_MINOR(version.version), |
| 363 | CL_VERSION_PATCH(version.version)); |
| 364 | }); |
| 365 | } else { |
| 366 | #endif |
| 367 | auto device_version = device.getInfo<CL_DEVICE_OPENCL_C_VERSION>(); |
| 368 | int major = atoi(device_version.substr(9, 1).c_str()); |
| 369 | int minor = atoi(device_version.substr(11, 1).c_str()); |
| 370 | out.emplace_back(major, minor); |
| 371 | #ifdef CL_DEVICE_OPENCL_C_ALL_VERSIONS |
| 372 | } |
| 373 | #endif |
| 374 | return out; |
| 375 | } |
| 376 | |
| 377 | size_t getDeviceMemorySize(int device) { |
| 378 | DeviceManager& devMngr = DeviceManager::getInstance(); |
| 379 | |
| 380 | cl::Device dev; |
| 381 | { |
| 382 | common::lock_guard_t lock(devMngr.deviceMutex); |
| 383 | // Assuming devices don't deallocate or are invalidated during execution |
| 384 | dev = *devMngr.mDevices[device]; |
| 385 | } |
| 386 | size_t msize = dev.getInfo<CL_DEVICE_GLOBAL_MEM_SIZE>(); |
| 387 | return msize; |
| 388 | } |
| 389 | |
| 390 | size_t getHostMemorySize() { return common::getHostMemorySize(); } |
| 391 | |
| 392 | cl_device_type getDeviceType() { |
| 393 | const cl::Device& device = getDevice(); |
| 394 | cl_device_type type = device.getInfo<CL_DEVICE_TYPE>(); |
| 395 | return type; |
| 396 | } |
no test coverage detected