From 0494cd6ace4f70b882b48bac7951d52331c1c07e Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 12 Mar 2015 14:44:24 -0400
Subject: [PATCH] P4 to Git Change 1130172 by asalmanp@asalmanp-opencl-stg1 on
2015/03/12 14:15:06
EPR #394115 - Adding the environment variable "GPU_SELECT_COMPUTE_RINGS_ID" to select a specific compute queue for OCL submission. This EV was requested from KMD team for testing the CWSR demo on CZ.
ReviewBoardURL = http://ocltc.amd.com/reviews/r/7082/
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuvirtual.cpp#354 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp#111 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/rt/GSLDevice.h#44 edit
... //depot/stg/opencl/drivers/opencl/runtime/utils/flags.hpp#226 edit
---
rocclr/runtime/device/gpu/gpuvirtual.cpp | 3 +-
.../device/gpu/gslbe/src/rt/GSLDevice.cpp | 35 ++++++++++++++-----
.../device/gpu/gslbe/src/rt/GSLDevice.h | 7 +++-
rocclr/runtime/utils/flags.hpp | 2 ++
4 files changed, 36 insertions(+), 11 deletions(-)
diff --git a/rocclr/runtime/device/gpu/gpuvirtual.cpp b/rocclr/runtime/device/gpu/gpuvirtual.cpp
index 3b0438c3c9..2754cf4af4 100644
--- a/rocclr/runtime/device/gpu/gpuvirtual.cpp
+++ b/rocclr/runtime/device/gpu/gpuvirtual.cpp
@@ -495,7 +495,8 @@ VirtualGPU::create(
// hwRing_ should be set 0 if forced to have single scratch buffer
hwRing_ = (dev().settings().useSingleScratch_) ? 0 : idx;
- engineMask = dev().engines().getMask((gslEngineID)(GSL_ENGINEID_COMPUTE0 + idx));
+ engineMask = dev().engines().getMask((gslEngineID)(dev().isComputeRingIDForced() ?
+ dev().getforcedComputeEngineID() : (GSL_ENGINEID_COMPUTE0 + idx)));
if (dev().canDMA()) {
if (index() & 0x1) {
engineMask |= dev().engines().getMask(GSL_ENGINEID_DRMDMA0);
diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
index 5477bb2025..0f7c67a8b3 100644
--- a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
+++ b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
@@ -42,7 +42,8 @@ void CALGSLDevice::Initialize()
m_vpuMask = 1;
m_PerformLazyDeviceInit = false;
m_computeRing = false;
-
+ m_isComputeRingIDForced = false;
+ m_forcedComputeEngineID = GSL_ENGINEID_INVALID;
gslDeviceOps_ = NULL;
}
@@ -313,8 +314,6 @@ CALGSLDevice::open(uint32 gpuIndex, bool enableHighPerformanceState, bool report
return false;
}
- m_adp->queryAvailableEngines(&m_nEngines, m_engines);
-
if (m_PerformLazyDeviceInit)
{
// close the adaptor
@@ -411,7 +410,9 @@ CALGSLDevice::SetupAdapter(int32 &asic_id)
m_canDMA = hasDmaEngine;
- //Disable DRMDMA on CFX mode for linux on all GPUs.
+ m_adp->queryAvailableEngines(&m_nEngines, m_engines);
+
+ //Disable DRMDMA on CFX mode for linux on all GPUs.
#ifdef ATI_OS_LINUX
if ((m_vpucount > 1) && !DRMDMA_FOR_LNX_CF)
{
@@ -426,7 +427,7 @@ CALGSLDevice::SetupAdapter(int32 &asic_id)
m_computeRing = false;
}
else
- {
+ {
m_computeRing = true;
}
@@ -435,6 +436,22 @@ CALGSLDevice::SetupAdapter(int32 &asic_id)
m_computeRing = (GPU_NUM_COMPUTE_RINGS != 0);
}
+ if ((!flagIsDefault(GPU_SELECT_COMPUTE_RINGS_ID)) && (m_computeRing))
+ {
+ gslEngineID engineID;
+ engineID = static_cast(GPU_SELECT_COMPUTE_RINGS_ID + GSL_ENGINEID_COMPUTE0);
+ if ((engineID >= GSL_ENGINEID_COMPUTE0) && (engineID <= GSL_ENGINEID_COMPUTE7))
+ {
+ for (uint i = 0; i < m_nEngines; ++i) {
+ if (m_engines[i].id == engineID){
+ m_isComputeRingIDForced = true;
+ m_forcedComputeEngineID = engineID;
+ break;
+ }
+ }
+ }
+ }
+
if (m_computeRing && !hasComputeEngine)
{
return false;
@@ -446,8 +463,8 @@ CALGSLDevice::SetupAdapter(int32 &asic_id)
bool
CALGSLDevice::SetupContext(int32 &asic_id)
{
- gsl::gsCtx* temp_cs = m_adp->createComputeContext(m_computeRing ? GSL_ENGINEID_COMPUTE0 : GSL_ENGINEID_3DCOMPUTE0,
- m_canDMA ? GSL_ENGINEID_DRMDMA0 : GSL_ENGINEID_INVALID);
+ gsl::gsCtx* temp_cs = m_adp->createComputeContext(m_computeRing ? (m_isComputeRingIDForced ? m_forcedComputeEngineID : GSL_ENGINEID_COMPUTE0)
+ : GSL_ENGINEID_3DCOMPUTE0, m_canDMA ? GSL_ENGINEID_DRMDMA0 : GSL_ENGINEID_INVALID);
temp_cs->getMainSubCtx()->setVPUMask(m_vpuMask);
m_revision = temp_cs->getChipRev();
@@ -632,8 +649,8 @@ CALGSLDevice::PerformFullInitialization_int()
if (m_cs == 0)
{
- m_cs = m_adp->createComputeContext(m_computeRing ? GSL_ENGINEID_COMPUTE0 : GSL_ENGINEID_3DCOMPUTE0,
- m_canDMA ? GSL_ENGINEID_DRMDMA0 : GSL_ENGINEID_INVALID);
+ m_cs = m_adp->createComputeContext(m_computeRing ? (m_isComputeRingIDForced ? m_forcedComputeEngineID : GSL_ENGINEID_COMPUTE0)
+ : GSL_ENGINEID_3DCOMPUTE0, m_canDMA ? GSL_ENGINEID_DRMDMA0 : GSL_ENGINEID_INVALID);
m_cs->getMainSubCtx()->setVPUMask(m_vpuMask);
//
diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.h b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.h
index 9ab0f91ec8..bc0e87e17e 100644
--- a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.h
+++ b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.h
@@ -134,6 +134,9 @@ public:
gsl::gsCtx* gslCtx() const { return m_cs; }
+ bool isComputeRingIDForced() const { return m_isComputeRingIDForced; }
+ gslEngineID getforcedComputeEngineID() const { return m_forcedComputeEngineID; }
+
protected:
//
/// channel order enumerants
@@ -211,7 +214,7 @@ private:
CALdevicestatus m_deviceStatus;
gslTextureResourceObject m_textureResource;
gslSamplerObject m_textureSampler;
- bool m_isOpenCL200Device;
+ gslEngineID m_forcedComputeEngineID;
union {
struct {
@@ -222,6 +225,8 @@ private:
uint m_PerformLazyDeviceInit : 1;
uint m_vmMode : 1;
uint m_uavInCB : 1;
+ uint m_isComputeRingIDForced : 1;
+ bool m_isOpenCL200Device : 1;
};
};
diff --git a/rocclr/runtime/utils/flags.hpp b/rocclr/runtime/utils/flags.hpp
index 211b7dd323..b7b508c8cf 100644
--- a/rocclr/runtime/utils/flags.hpp
+++ b/rocclr/runtime/utils/flags.hpp
@@ -122,6 +122,8 @@ release(uint, GPU_SINGLE_ALLOC_PERCENT, 75, \
"Maximum size of a single allocation as percentage of total") \
release(uint, GPU_NUM_COMPUTE_RINGS, 2, \
"GPU number of compute rings. 0 - disabled, 1 , 2,.. - the number of compute rings") \
+release(int, GPU_SELECT_COMPUTE_RINGS_ID, -1, \
+ "GPU select the compute rings ID -1 - disabled, 0 , 1,.. - the forced compute rings ID for submission") \
release_on_stg(bool, C1X_ATOMICS, !IS_MAINLINE, \
"Runtime will report c1x atomics support") \
release(uint, GPU_WORKLOAD_SPLIT, 22, \