From dabed031a02da94d031d93ab12521ad74d30a3af Mon Sep 17 00:00:00 2001 From: Julia Jiang Date: Thu, 10 Feb 2022 20:00:12 -0500 Subject: [PATCH] SWDEV-321654 - fix hipPointerGetAttribute API Change-Id: Icafdda147eb16e08048d6c435c0c5714f3f8d143 --- hipamd/src/hip_memory.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/hipamd/src/hip_memory.cpp b/hipamd/src/hip_memory.cpp index 1369a2176b..fbcbaafc25 100644 --- a/hipamd/src/hip_memory.cpp +++ b/hipamd/src/hip_memory.cpp @@ -2711,7 +2711,7 @@ hipError_t ihipPointerGetAttributes(void** data, int* attributes, static_cast(memObj->getSvmPtr()) + offset; } } else { - *reinterpret_cast(data[idx]) = nullptr; + status = hipErrorInvalidValue; } } else { // Host Memory *reinterpret_cast(data[idx]) = static_cast(ptr); @@ -2776,8 +2776,9 @@ hipError_t ihipPointerGetAttributes(void** data, int* attributes, *reinterpret_cast(data[idx]) = reinterpret_cast(devMem->virtualAddress()); } - } else { // Host Memory - *reinterpret_cast(data[idx]) = static_cast(ptr); + } else { + // Input is host memory pointer, invalid for device. + status = hipErrorInvalidValue; } break; } @@ -2801,8 +2802,8 @@ hipError_t ihipPointerGetAttributes(void** data, int* attributes, } case HIP_POINTER_ATTRIBUTE_IS_GPU_DIRECT_RDMA_CAPABLE : { // GPUDirect RDMA API is not yet supported, hence returning 0 - LogPrintfWarning("attribute %d is not supported, defaults to 0", attributes[i]); - *reinterpret_cast(data[idx]) = 0; + LogPrintfWarning("attribute %d is not supported.", attributes[i]); + status = hipErrorNotSupported; break; } case HIP_POINTER_ATTRIBUTE_ACCESS_FLAGS : { @@ -2815,8 +2816,8 @@ hipError_t ihipPointerGetAttributes(void** data, int* attributes, } case HIP_POINTER_ATTRIBUTE_MEMPOOL_HANDLE : { // allocations from mempool are not yet supported, hence returning 0 - LogPrintfWarning("attribute %d is not supported, defaults to 0", attributes[i]); - *reinterpret_cast(data[idx]) = 0; + LogPrintfWarning("attribute %d is not supported.", attributes[i]); + status = hipErrorNotSupported; break; } default: {