From f436a9791a91d0d357a8ddaa4bd190707c0b2d4b 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
[ROCm/clr commit: 113c711b81acf74c3e333c721b3369d027de10ab]
---
projects/clr/hipamd/api/hip/hip_memory.cpp | 29 ++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/projects/clr/hipamd/api/hip/hip_memory.cpp b/projects/clr/hipamd/api/hip/hip_memory.cpp
index ebe630924b..04e3dc3c3a 100644
--- a/projects/clr/hipamd/api/hip/hip_memory.cpp
+++ b/projects/clr/hipamd/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;
}