From ff9a6c0c58f9ff225ccefbe801905e5268e028a2 Mon Sep 17 00:00:00 2001
From: foreman
Date: Mon, 21 Sep 2015 14:46:15 -0400
Subject: [PATCH] P4 to Git Change 1192638 by xcui@merged_opencl_jxcwin on
2015/09/21 14:34:25
SWDEV-17662 - EPR #426715 - for CZ enabled PX system, we need discrete GPU be the first device to do SVM allocation, and the fine grain system capable device do the allocation after discrete GPU.
precheckin:
http://ocltc.amd.com:8111/viewModification.html?modId=58725&personal=true&buildTypeId=&tab=vcsModificationBuilds&show_all_builds=true
code review:
http://ocltc.amd.com/reviews/r/8513/
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#255 edit
... //depot/stg/opencl/drivers/opencl/runtime/platform/context.cpp#36 edit
---
rocclr/runtime/device/device.hpp | 5 +++++
rocclr/runtime/platform/context.cpp | 20 ++++++++++++++++----
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/rocclr/runtime/device/device.hpp b/rocclr/runtime/device/device.hpp
index 41a4a9a51d..74d551b895 100644
--- a/rocclr/runtime/device/device.hpp
+++ b/rocclr/runtime/device/device.hpp
@@ -1537,6 +1537,11 @@ public:
CL_DEVICE_SVM_FINE_GRAIN_SYSTEM)) != 0 ? true : false;
}
+ //! check svm FGS support capability.
+ inline bool isFineGrainedSystem() const {
+ return (info().svmCapabilities_ & CL_DEVICE_SVM_FINE_GRAIN_SYSTEM) != 0 ? true : false;
+ }
+
//! Return this device's type.
cl_device_type type() const {
return info().type_ & ~(CL_DEVICE_TYPE_DEFAULT | CL_HSA_ENABLED_AMD
diff --git a/rocclr/runtime/platform/context.cpp b/rocclr/runtime/platform/context.cpp
index f21eea2faf..b097ee7c1b 100644
--- a/rocclr/runtime/platform/context.cpp
+++ b/rocclr/runtime/platform/context.cpp
@@ -40,10 +40,22 @@ Context::Context(
svmAllocDevice_.push_back(device);
}
}
- //make sure the first device is GPU
- if ((svmAllocDevice_.size() > 1)
- && (svmAllocDevice_.front()->type() == CL_DEVICE_TYPE_CPU)) {
- std::swap(svmAllocDevice_.front(), svmAllocDevice_.back());
+ if (svmAllocDevice_.size() > 1) {
+ //make sure the CPU is the last device to do allocation.
+ if ((svmAllocDevice_.front()->type() == CL_DEVICE_TYPE_CPU)) {
+ std::swap(svmAllocDevice_.front(), svmAllocDevice_.back());
+ }
+
+ uint isFirstDeviceFGSEnabled = svmAllocDevice_.front()->isFineGrainedSystem();
+ for (auto& dev : svmAllocDevice_) {
+ //allocation on fine - grained system incapable device first
+ if (isFirstDeviceFGSEnabled && (dev->type() == CL_DEVICE_TYPE_GPU)
+ && (!(dev->isFineGrainedSystem()))) {
+ std::swap(svmAllocDevice_.front(), dev);
+ break;
+ }
+ }
+
}
}