From d4106ee51ea3e8b381a484f692f69c865f66197c Mon Sep 17 00:00:00 2001
From: foreman
Date: Fri, 13 Feb 2015 17:49:06 -0500
Subject: [PATCH] P4 to Git Change 1122235 by xcui@merged_opencl_jxcwin on
2015/02/13 17:28:52
EPR #413091 - move commit svm host memory into allocmaptarget and added hostmemref as the backing store for multiple gpu cases
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_memobj.cpp#73 edit
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_svm.cpp#11 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpukernel.cpp#280 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpumemory.cpp#118 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/memory.cpp#115 edit
[ROCm/clr commit: 072a37562919402d61144e86bd7d6255e6daa650]
---
.../rocclr/runtime/device/gpu/gpukernel.cpp | 3 +++
.../rocclr/runtime/device/gpu/gpumemory.cpp | 18 +++++++++++++++---
.../clr/rocclr/runtime/platform/memory.cpp | 2 +-
3 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/projects/clr/rocclr/runtime/device/gpu/gpukernel.cpp b/projects/clr/rocclr/runtime/device/gpu/gpukernel.cpp
index edab454abd..b332749399 100644
--- a/projects/clr/rocclr/runtime/device/gpu/gpukernel.cpp
+++ b/projects/clr/rocclr/runtime/device/gpu/gpukernel.cpp
@@ -3902,6 +3902,9 @@ HSAILKernel::loadArguments(
}
if (nativeMem) {
gpuMem = *reinterpret_cast(paramaddr);
+ if (NULL != gpuMem) {
+ mem = gpuMem->owner();
+ }
}
else {
mem = *reinterpret_cast(paramaddr);
diff --git a/projects/clr/rocclr/runtime/device/gpu/gpumemory.cpp b/projects/clr/rocclr/runtime/device/gpu/gpumemory.cpp
index e9a4590329..7a659c15d2 100644
--- a/projects/clr/rocclr/runtime/device/gpu/gpumemory.cpp
+++ b/projects/clr/rocclr/runtime/device/gpu/gpumemory.cpp
@@ -922,8 +922,22 @@ Memory::allocMapTarget(
address mapAddress = NULL;
size_t offset = origin[0];
- incIndMapCount();
+ //For SVM implementation, we cannot use cached map. if svm space, use the svm host pointer
+ void *initHostPtr = owner()->getSvmPtr();
+ if (NULL != initHostPtr) {
+ owner()->commitSvmMemory();
+ }
+ if (owner()->numDevices() > 1) {
+ if ((NULL == initHostPtr) && (owner()->getHostMem() == NULL)) {
+ static const bool forceAllocHostMem = true;
+ if (!owner()->allocHostMemory(NULL, forceAllocHostMem)) {
+ return NULL;
+ }
+ }
+ }
+
+ incIndMapCount();
// If host memory exists, use it
if ((owner()->getHostMem() != NULL) && isDirectMap()) {
mapAddress = reinterpret_cast(owner()->getHostMem());
@@ -953,8 +967,6 @@ Memory::allocMapTarget(
bool failed = false;
amd::Memory* memory = NULL;
// Search for a possible indirect resource
- //For SVM implementation, we cannot use cached map. if svm space, use the svm host pointer
- void *initHostPtr = owner()->getSvmPtr();
cl_mem_flags flag = 0;
bool canBeCached = true;
if (NULL != initHostPtr) {
diff --git a/projects/clr/rocclr/runtime/platform/memory.cpp b/projects/clr/rocclr/runtime/platform/memory.cpp
index 2b4088997a..8e35fe9764 100644
--- a/projects/clr/rocclr/runtime/platform/memory.cpp
+++ b/projects/clr/rocclr/runtime/platform/memory.cpp
@@ -251,7 +251,7 @@ Memory::allocHostMemory(void* initFrom, bool allocHostMem, bool forceCopy)
pipe->end_idx = asPipe()->getMaxNumPackets();
}
- if (flags_ & (CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR)) {
+ if ((flags_ & (CL_MEM_USE_HOST_PTR | CL_MEM_COPY_HOST_PTR)) && (NULL == lastWriter_)) {
// Signal write, so coherency mechanism will initialize
// memory on all devices
signalWrite(NULL);