From 25bfbb8085f2be02323676c00ff9ac74545f1fac Mon Sep 17 00:00:00 2001
From: foreman
Date: Tue, 20 Oct 2015 11:02:14 -0400
Subject: [PATCH] P4 to Git Change 1201490 by xcui@merged_opencl_jxcwin on
2015/10/20 10:47:18
SWDEV-41018 - if system is equal to or less than 2GB memory, disable CPU and APU for OpenCL, and force the device to be 1.2 if it is a discrete GPU.
precheckin:
http://ocltc.amd.com:8111/viewModification.html?modId=60516&personal=true&buildTypeId=&tab=vcsModificationBuilds&show_all_builds=true
code review:
http://ocltc.amd.com/reviews/r/8738/
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/cpu/cpudevice.cpp#277 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#531 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpusettings.cpp#331 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpusettings.hpp#95 edit
---
rocclr/runtime/device/cpu/cpudevice.cpp | 4 ++++
rocclr/runtime/device/gpu/gpudevice.cpp | 9 +++++++--
rocclr/runtime/device/gpu/gpusettings.cpp | 9 +++++++++
rocclr/runtime/device/gpu/gpusettings.hpp | 1 +
4 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/rocclr/runtime/device/cpu/cpudevice.cpp b/rocclr/runtime/device/cpu/cpudevice.cpp
index 1f4f4b0a61..5fd20143b7 100644
--- a/rocclr/runtime/device/cpu/cpudevice.cpp
+++ b/rocclr/runtime/device/cpu/cpudevice.cpp
@@ -235,6 +235,10 @@ Device::init()
virtualMemSize =
(uintptr_t) std::min(statex.ullTotalPageFile, statex.ullTotalVirtual);
#endif
+ //disable CPU device if system memory is equal to or less than 2GB
+ if (info.globalMemSize_ <= 2 * Gi) {
+ return true;
+ }
maxWorkerThreads_ = (size_t) (virtualMemSize /
(uintptr_t) ((CPU_WORKER_THREAD_STACK_SIZE +
diff --git a/rocclr/runtime/device/gpu/gpudevice.cpp b/rocclr/runtime/device/gpu/gpudevice.cpp
index fe2a87214f..134db00f65 100644
--- a/rocclr/runtime/device/gpu/gpudevice.cpp
+++ b/rocclr/runtime/device/gpu/gpudevice.cpp
@@ -762,9 +762,14 @@ Device::create(CALuint ordinal, CALuint numOfDevices)
{
appProfile_.init();
+ bool smallMemSystem = false;
+ if (amd::Os::hostTotalPhysicalMemory() < 2 * Gi) {
+ smallMemSystem = true;
+ }
+
// Open GSL device
if (!open(ordinal, appProfile_.enableHighPerformanceState(),
- appProfile_.reportAsOCL12Device() || (OPENCL_VERSION < 200))) {
+ smallMemSystem || appProfile_.reportAsOCL12Device() || (OPENCL_VERSION < 200))) {
return false;
}
@@ -776,7 +781,7 @@ Device::create(CALuint ordinal, CALuint numOfDevices)
settings_ = new gpu::Settings();
gpu::Settings* gpuSettings = reinterpret_cast(settings_);
if ((gpuSettings == NULL) || !gpuSettings->create(getAttribs()
- , appProfile_.reportAsOCL12Device()
+ , appProfile_.reportAsOCL12Device(), smallMemSystem
)) {
return false;
}
diff --git a/rocclr/runtime/device/gpu/gpusettings.cpp b/rocclr/runtime/device/gpu/gpusettings.cpp
index 2f1b449a88..b7eedc8e52 100644
--- a/rocclr/runtime/device/gpu/gpusettings.cpp
+++ b/rocclr/runtime/device/gpu/gpusettings.cpp
@@ -146,6 +146,7 @@ bool
Settings::create(
const CALdeviceattribs& calAttr
, bool reportAsOCL12Device
+ , bool smallMemSystem
)
{
CALuint target = calAttr.target;
@@ -228,6 +229,14 @@ Settings::create(
oclVersion_ = !reportAsOCL12Device && calAttr.isOpenCL200Device ?
XCONCAT(OpenCL, XCONCAT(OPENCL_MAJOR, OPENCL_MINOR)) : OpenCL12;
}
+ if (smallMemSystem) { //force the dGPU to be 1.2 device for small memory system.
+ if (apuSystem_) {
+ return false;
+ }
+ else {
+ oclVersion_ = OpenCL12;
+ }
+ }
if (GPU_FORCE_OCL20_32BIT) {
force32BitOcl20_ = true;
oclVersion_ = !reportAsOCL12Device && calAttr.isOpenCL200Device ?
diff --git a/rocclr/runtime/device/gpu/gpusettings.hpp b/rocclr/runtime/device/gpu/gpusettings.hpp
index fca4a2c6c4..585e2711d8 100644
--- a/rocclr/runtime/device/gpu/gpusettings.hpp
+++ b/rocclr/runtime/device/gpu/gpusettings.hpp
@@ -110,6 +110,7 @@ public:
bool create(
const CALdeviceattribs& calAttr //!< CAL attributes structure
, bool reportAsOCL12Device = false //!< Report As OpenCL1.2 Device
+ , bool smallMemSystem = false //!< report the sys memory is small
);
private: