From 0fe5f87cba8a05c2614fb910b20bb8e2fd01343d Mon Sep 17 00:00:00 2001
From: foreman
Date: Wed, 23 May 2018 13:40:52 -0400
Subject: [PATCH] P4 to Git Change 1558526 by
skudchad@skudchad_test2_win_opencl on 2018/05/23 13:34:33
SWDEV-145570 - [HIP] Implement hipPointerGetAttributes.
ReviewBoardURL = http://ocltc.amd.com/reviews/r/14938/diff/
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/hip/hip_memory.cpp#28 edit
---
api/hip/hip_memory.cpp | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/api/hip/hip_memory.cpp b/api/hip/hip_memory.cpp
index ebe630924b..04e3dc3c3a 100644
--- a/api/hip/hip_memory.cpp
+++ b/api/hip/hip_memory.cpp
@@ -1180,7 +1180,32 @@ hipError_t hipHostGetDevicePointer(void** devicePointer, void* hostPointer, unsi
hipError_t hipPointerGetAttributes(hipPointerAttribute_t* attributes, const void* ptr) {
HIP_INIT_API(attributes, ptr);
- assert(0 && "Unimplemented");
+ size_t offset = 0;
+ amd::Memory* memObj = getMemoryObject(ptr, offset);
+ amd::Context &memObjCtx = memObj->getContext();
+ int device = 0;
- return hipErrorUnknown;
+ if (memObj != nullptr) {
+ attributes->memoryType = hipMemoryTypeDevice;
+ attributes->hostPointer = memObj->getSvmPtr();
+ attributes->devicePointer = memObj->getSvmPtr();
+ attributes->isManaged = 0;
+ attributes->allocationFlags = memObj->getMemFlags();
+ for (auto& ctx : g_devices) {
+ ++device;
+ if (*ctx == memObjCtx) {
+ attributes->device = device;
+ break;
+ }
+ }
+ } else {
+ attributes->memoryType = hipMemoryTypeHost;
+ attributes->hostPointer = (void*)ptr;
+ attributes->devicePointer = 0;
+ attributes->device = -1;
+ attributes->isManaged = 0;
+ attributes->allocationFlags = 0;
+ }
+
+ return hipSuccess;
}