From 0b64eec921ddb725d84fe57f81f5cd23214fa6e4 Mon Sep 17 00:00:00 2001 From: "Assiouras, Ioannis" Date: Wed, 21 May 2025 16:48:05 +0100 Subject: [PATCH] SWDEV-508962 - [6.4 Preview] Update hipPointerGetAttributes to match CUDA > 11.0 behavior (#120) (#363) --- hipamd/src/hip_memory.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hipamd/src/hip_memory.cpp b/hipamd/src/hip_memory.cpp index 41273c4126..af7ac78233 100644 --- a/hipamd/src/hip_memory.cpp +++ b/hipamd/src/hip_memory.cpp @@ -3357,11 +3357,11 @@ hipError_t hipHostGetDevicePointer(void** devicePointer, void* hostPointer, unsi hipError_t hipPointerGetAttributes(hipPointerAttribute_t* attributes, const void* ptr) { HIP_INIT_API(hipPointerGetAttributes, attributes, ptr); - if (attributes == nullptr || ptr == nullptr) { + if (attributes == nullptr) { HIP_RETURN(hipErrorInvalidValue); } size_t offset = 0; - amd::Memory* memObj = getMemoryObject(ptr, offset); + amd::Memory* memObj = (ptr != nullptr) ? getMemoryObject(ptr, offset) : nullptr; int device = 0; device::Memory* devMem = nullptr; memset(attributes, 0, sizeof(hipPointerAttribute_t)); @@ -3406,7 +3406,9 @@ hipError_t hipPointerGetAttributes(hipPointerAttribute_t* attributes, const void attributes->isManaged = false; attributes->allocationFlags = 0; attributes->device = hipInvalidDeviceId; - LogPrintfError("Cannot get amd_mem_obj for ptr: %p", ptr); + if (ptr != nullptr) { + LogPrintfError("Cannot get amd_mem_obj for ptr: %p", ptr); + } } HIP_RETURN(hipSuccess); }