From 3f0b25f6bf5239e4537630d835dc0c697dd62b75 Mon Sep 17 00:00:00 2001
From: foreman
Date: Mon, 25 Jun 2018 13:29:56 -0400
Subject: [PATCH] P4 to Git Change 1572348 by
skudchad@skudchad_test2_win_opencl on 2018/06/25 13:21:41
SWDEV-145570 - [HIP] - Fix hipHostGetDevicePointer. hipHostRegister tests now passes
ReviewBoardURL = http://ocltc.amd.com/reviews/r/15261/diff/
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/hip/hip_memory.cpp#34 edit
---
api/hip/hip_memory.cpp | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/api/hip/hip_memory.cpp b/api/hip/hip_memory.cpp
index 376b2b155f..424fbec633 100644
--- a/api/hip/hip_memory.cpp
+++ b/api/hip/hip_memory.cpp
@@ -38,7 +38,7 @@ extern void getDrvChannelOrderAndType(const enum hipArray_Format Format,
amd::Memory* getMemoryObject(const void* ptr, size_t& offset) {
amd::Memory *memObj = amd::MemObjMap::FindMemObj(ptr);
- if (memObj != nullptr) {
+ if (memObj != nullptr && memObj->getSvmPtr() != nullptr) {
offset = reinterpret_cast(ptr) - reinterpret_cast(memObj->getSvmPtr());
}
return memObj;
@@ -1314,11 +1314,13 @@ hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w, hipChannel
hipError_t hipHostGetDevicePointer(void** devicePointer, void* hostPointer, unsigned flags) {
HIP_INIT_API(devicePointer, hostPointer, flags);
- if (!amd::MemObjMap::FindMemObj(hostPointer)) {
+ size_t offset = 0;
+
+ amd::Memory* memObj = getMemoryObject(hostPointer, offset);
+ if (!memObj) {
return hipErrorInvalidValue;
}
- // right now we have SVM
- *devicePointer = hostPointer;
+ *devicePointer = reinterpret_cast(memObj->getDeviceMemory(*hip::getCurrentContext()->devices()[0])->virtualAddress() + offset);
return hipSuccess;
}