From 0647802695373f81ee02c9d75f35e0936e5b6e68 Mon Sep 17 00:00:00 2001 From: JackAKirk Date: Mon, 27 May 2024 13:51:53 +0100 Subject: [PATCH 1/2] Fix urUSMGetMemAllocInfo Now all devs are in a single platform this needs updating. Signed-off-by: JackAKirk --- source/adapters/cuda/usm.cpp | 12 +++++------- source/adapters/hip/usm.cpp | 12 +++++------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/source/adapters/cuda/usm.cpp b/source/adapters/cuda/usm.cpp index 4e6c6898d5..1104d83e37 100644 --- a/source/adapters/cuda/usm.cpp +++ b/source/adapters/cuda/usm.cpp @@ -258,16 +258,14 @@ urUSMGetMemAllocInfo(ur_context_handle_t hContext, const void *pMem, CU_POINTER_ATTRIBUTE_DEVICE_ORDINAL, (CUdeviceptr)pMem)); - // currently each device is in its own platform, so find the platform at - // the same index - std::vector Platforms; - Platforms.resize(DeviceIndex + 1); + // cuda backend has only one platform containing all devices + ur_platform_handle_t platform; ur_adapter_handle_t AdapterHandle = &adapter; - Result = urPlatformGet(&AdapterHandle, 1, DeviceIndex + 1, - Platforms.data(), nullptr); + Result = urPlatformGet(&AdapterHandle, 1, 1, + &platform, nullptr); // get the device from the platform - ur_device_handle_t Device = Platforms[DeviceIndex]->Devices[0].get(); + ur_device_handle_t Device = platform->Devices[DeviceIndex].get(); return ReturnValue(Device); } case UR_USM_ALLOC_INFO_POOL: { diff --git a/source/adapters/hip/usm.cpp b/source/adapters/hip/usm.cpp index e871f394f2..fcce0d0e8b 100644 --- a/source/adapters/hip/usm.cpp +++ b/source/adapters/hip/usm.cpp @@ -207,16 +207,14 @@ urUSMGetMemAllocInfo(ur_context_handle_t hContext, const void *pMem, int DeviceIdx = hipPointerAttributeType.device; - // currently each device is in its own platform, so find the platform at - // the same index - std::vector Platforms; - Platforms.resize(DeviceIdx + 1); + // hip backend has only one platform containing all devices + ur_platform_handle_t platform; ur_adapter_handle_t AdapterHandle = &adapter; - Result = urPlatformGet(&AdapterHandle, 1, DeviceIdx + 1, Platforms.data(), - nullptr); + Result = urPlatformGet(&AdapterHandle, 1, 1, + &platform, nullptr); // get the device from the platform - ur_device_handle_t Device = Platforms[DeviceIdx]->Devices[0].get(); + ur_device_handle_t Device = platform->Devices[DeviceIdx].get(); return ReturnValue(Device); } case UR_USM_ALLOC_INFO_POOL: { From 9868e3b03adf0caee36b919935623de3d3879f6b Mon Sep 17 00:00:00 2001 From: JackAKirk Date: Mon, 27 May 2024 14:54:16 +0100 Subject: [PATCH 2/2] Fix format. Signed-off-by: JackAKirk --- source/adapters/cuda/usm.cpp | 3 +-- source/adapters/hip/usm.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/source/adapters/cuda/usm.cpp b/source/adapters/cuda/usm.cpp index 1104d83e37..a7b3a60eac 100644 --- a/source/adapters/cuda/usm.cpp +++ b/source/adapters/cuda/usm.cpp @@ -261,8 +261,7 @@ urUSMGetMemAllocInfo(ur_context_handle_t hContext, const void *pMem, // cuda backend has only one platform containing all devices ur_platform_handle_t platform; ur_adapter_handle_t AdapterHandle = &adapter; - Result = urPlatformGet(&AdapterHandle, 1, 1, - &platform, nullptr); + Result = urPlatformGet(&AdapterHandle, 1, 1, &platform, nullptr); // get the device from the platform ur_device_handle_t Device = platform->Devices[DeviceIndex].get(); diff --git a/source/adapters/hip/usm.cpp b/source/adapters/hip/usm.cpp index fcce0d0e8b..f5df79cd7f 100644 --- a/source/adapters/hip/usm.cpp +++ b/source/adapters/hip/usm.cpp @@ -210,8 +210,7 @@ urUSMGetMemAllocInfo(ur_context_handle_t hContext, const void *pMem, // hip backend has only one platform containing all devices ur_platform_handle_t platform; ur_adapter_handle_t AdapterHandle = &adapter; - Result = urPlatformGet(&AdapterHandle, 1, 1, - &platform, nullptr); + Result = urPlatformGet(&AdapterHandle, 1, 1, &platform, nullptr); // get the device from the platform ur_device_handle_t Device = platform->Devices[DeviceIdx].get();