From 6add1f72d57d3d72cb4a659a79730f0e7788e796 Mon Sep 17 00:00:00 2001
From: foreman
Date: Tue, 22 Sep 2015 18:59:36 -0400
Subject: [PATCH] P4 to Git Change 1193228 by xcui@merged_opencl_jxcwin on
2015/09/22 18:52:47
SWDEV-59579 - resubmit the changelist 1193161. refactory the Coare-grained SVM and fine grain buffer SVM code path, so that if the device SVM running on supports fine grain system, then the SVM API operation will be on system memory, no need to go through GPU backend. In addition, added support for PX system with CZ on windows 10, which supports SVM fine grain system.
code review:
http://ocltc.amd.com/reviews/r/8530/
precheckin:
http://ocltc.amd.com:8111/viewModification.html?modId=58913&personal=true&buildTypeId=&tab=vcsModificationBuilds&show_all_builds=true
Affected files ...
... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_svm.cpp#15 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#527 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.hpp#152 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.cpp#382 edit
[ROCm/clr commit: 9379424ce336bb262659718e6810ba91275261bb]
---
.../clr/opencl/api/opencl/amdocl/cl_svm.cpp | 89 ++++++++++---------
1 file changed, 48 insertions(+), 41 deletions(-)
diff --git a/projects/clr/opencl/api/opencl/amdocl/cl_svm.cpp b/projects/clr/opencl/api/opencl/amdocl/cl_svm.cpp
index 3fa9fbb403..acc1a346be 100644
--- a/projects/clr/opencl/api/opencl/amdocl/cl_svm.cpp
+++ b/projects/clr/opencl/api/opencl/amdocl/cl_svm.cpp
@@ -746,41 +746,46 @@ RUNTIME_ENTRY(cl_int, clEnqueueSVMMap, (
}
amd::HostQueue& hostQueue = *queue;
size_t offset = 0;
+ amd::Memory * svmMem = NULL;
+ if ((queue->device()).isFineGrainedSystem()) {
+ //leave blank on purpose for FGS no op
+ }
+ else {
+ svmMem = amd::SvmManager::FindSvmBuffer(svm_ptr);
+ if (NULL != svmMem) {
+ //make sure the context is the same as the context of creation of svm space
+ if (hostQueue.context() != svmMem->getContext()) {
+ LogWarning("different contexts");
+ return CL_INVALID_CONTEXT;
+ }
- //make sure the context is the same as the context of creation of svm space
- amd::Memory * svmMem = amd::SvmManager::FindSvmBuffer(svm_ptr);
- if (NULL != svmMem) {
- if (hostQueue.context() != svmMem->getContext()) {
- LogWarning("different contexts");
- return CL_INVALID_CONTEXT;
- }
-
- offset = static_cast(svm_ptr) - static_cast(svmMem->getSvmPtr());
- if (offset < 0 || offset + size > svmMem->getSize()) {
- LogWarning("wrong svm address ");
- return CL_INVALID_VALUE;
- }
- amd::Buffer* srcBuffer = svmMem->asBuffer();
-
- amd::Coord3D srcSize(size);
- amd::Coord3D srcOffset(offset);
- if (NULL != srcBuffer) {
- if (!srcBuffer->validateRegion(srcOffset, srcSize)) {
+ offset = static_cast(svm_ptr) - static_cast(svmMem->getSvmPtr());
+ if (offset < 0 || offset + size > svmMem->getSize()) {
+ LogWarning("wrong svm address ");
return CL_INVALID_VALUE;
}
- }
+ amd::Buffer* srcBuffer = svmMem->asBuffer();
- // Make sure we have memory for the command execution
- device::Memory* mem = svmMem->getDeviceMemory(queue->device());
- if (NULL == mem) {
- LogPrintfError("Can't allocate memory size - 0x%08X bytes!",
- svmMem->getSize());
- return CL_OUT_OF_RESOURCES;
- }
- // Attempt to allocate the map target now (whether blocking or non-blocking)
- void* mapPtr = (queue->device()).allocMapTarget(*svmMem, srcOffset, srcSize, map_flags);
- if (NULL == mapPtr || mapPtr != svm_ptr) {
- return CL_OUT_OF_RESOURCES;
+ amd::Coord3D srcSize(size);
+ amd::Coord3D srcOffset(offset);
+ if (NULL != srcBuffer) {
+ if (!srcBuffer->validateRegion(srcOffset, srcSize)) {
+ return CL_INVALID_VALUE;
+ }
+ }
+
+ // Make sure we have memory for the command execution
+ device::Memory* mem = svmMem->getDeviceMemory(queue->device());
+ if (NULL == mem) {
+ LogPrintfError("Can't allocate memory size - 0x%08X bytes!",
+ svmMem->getSize());
+ return CL_OUT_OF_RESOURCES;
+ }
+ // Attempt to allocate the map target now (whether blocking or non-blocking)
+ void* mapPtr = (queue->device()).allocMapTarget(*svmMem, srcOffset, srcSize, map_flags);
+ if (NULL == mapPtr || mapPtr != svm_ptr) {
+ return CL_OUT_OF_RESOURCES;
+ }
}
}
@@ -881,17 +886,19 @@ RUNTIME_ENTRY(cl_int, clEnqueueSVMUnmap, (
return CL_INVALID_COMMAND_QUEUE;
}
amd::HostQueue& hostQueue = *queue;
-
- //check if the ptr is in the svm space
- amd::Memory * svmMem = amd::SvmManager::FindSvmBuffer(svm_ptr);
- // Make sure we have memory for the command execution
- if (NULL != svmMem) {
+ amd::Memory * svmMem = NULL;
+ if (!(queue->device()).isFineGrainedSystem()) {
+ //check if the ptr is in the svm space
+ svmMem = amd::SvmManager::FindSvmBuffer(svm_ptr);
// Make sure we have memory for the command execution
- device::Memory* mem = svmMem->getDeviceMemory(queue->device());
- if (NULL == mem) {
- LogPrintfError("Can't allocate memory size - 0x%08X bytes!",
- svmMem->getSize());
- return CL_INVALID_VALUE;
+ if (NULL != svmMem) {
+ // Make sure we have memory for the command execution
+ device::Memory* mem = svmMem->getDeviceMemory(queue->device());
+ if (NULL == mem) {
+ LogPrintfError("Can't allocate memory size - 0x%08X bytes!",
+ svmMem->getSize());
+ return CL_INVALID_VALUE;
+ }
}
}