From b7fdb3049bf13ae559a14f2e198ded20726dd760 Mon Sep 17 00:00:00 2001
From: foreman
Date: Mon, 16 Sep 2019 15:56:01 -0400
Subject: [PATCH] P4 to Git Change 1998899 by gandryey@gera-win10 on 2019/09/16
15:49:58
SWDEV-86035 - Swtich PAL to the new interface 533
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palbedefs#48 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#161 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.hpp#46 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#151 edit
---
rocclr/runtime/device/pal/paldevice.cpp | 46 ++++++++++++++----------
rocclr/runtime/device/pal/paldevice.hpp | 9 +++--
rocclr/runtime/device/pal/palvirtual.cpp | 25 +++++++------
3 files changed, 48 insertions(+), 32 deletions(-)
diff --git a/rocclr/runtime/device/pal/paldevice.cpp b/rocclr/runtime/device/pal/paldevice.cpp
index 1500fdb708..b4e0cb81f0 100644
--- a/rocclr/runtime/device/pal/paldevice.cpp
+++ b/rocclr/runtime/device/pal/paldevice.cpp
@@ -656,7 +656,7 @@ void NullDevice::fillDeviceInfo(const Pal::DeviceProperties& palProp,
info_.numAsyncQueues_ = numComputeRings;
info_.numRTQueues_ = numExclusiveComputeRings;
- info_.numRTCUs_ = palProp.engineProperties[Pal::EngineTypeExclusiveCompute].maxNumDedicatedCu;
+ info_.numRTCUs_ = palProp.engineProperties[Pal::EngineTypeCompute].maxNumDedicatedCu;
info_.threadTraceEnable_ = settings().threadTraceEnable_;
@@ -787,7 +787,6 @@ Device::Device()
xferRead_(nullptr),
mapCache_(nullptr),
resourceCache_(nullptr),
- numComputeEngines_(0),
numDmaEngines_(0),
heapInitComplete_(false),
xferQueue_(nullptr),
@@ -904,22 +903,28 @@ bool Device::create(Pal::IDevice* device) {
}
// Find the number of available engines
- numComputeEngines_ = properties().engineProperties[Pal::EngineTypeCompute].engineCount;
- if (properties().engineProperties[Pal::EngineTypeExclusiveCompute].maxNumDedicatedCu > 0) {
- for (uint i = 0; i < properties().engineProperties[Pal::EngineTypeExclusiveCompute].engineCount;
+ if (properties().engineProperties[Pal::EngineTypeCompute].maxNumDedicatedCu > 0) {
+ for (uint i = 0; i < properties().engineProperties[Pal::EngineTypeCompute].engineCount;
++i) {
- if (properties().engineProperties[Pal::EngineTypeExclusiveCompute].engineSubType[i] ==
- Pal::EngineSubType::RtCuHighCompute) {
- if (exclusiveComputeEnginesId_.find(ExclusiveQueueType::RealTime0) !=
+ if (properties().engineProperties[Pal::EngineTypeCompute].capabilities[i].flags.exclusive) {
+ if (properties()
+ .engineProperties[Pal::EngineTypeCompute]
+ .capabilities[i]
+ .queuePrioritySupport == Pal::SupportQueuePriorityRealtime) {
+ if (exclusiveComputeEnginesId_.find(ExclusiveQueueType::RealTime0) !=
exclusiveComputeEnginesId_.end()) {
- exclusiveComputeEnginesId_.insert({ExclusiveQueueType::RealTime1, i});
- } else {
- exclusiveComputeEnginesId_.insert({ExclusiveQueueType::RealTime0, i});
+ exclusiveComputeEnginesId_.insert({ExclusiveQueueType::RealTime1, i});
+ } else {
+ exclusiveComputeEnginesId_.insert({ExclusiveQueueType::RealTime0, i});
+ }
+ } else if (properties()
+ .engineProperties[Pal::EngineTypeCompute]
+ .capabilities[i]
+ .queuePrioritySupport == Pal::SupportQueuePriorityMedium) {
+ exclusiveComputeEnginesId_.insert({ExclusiveQueueType::Medium, i});
}
- }
- if (properties().engineProperties[Pal::EngineTypeExclusiveCompute].engineSubType[i] ==
- Pal::EngineSubType::RtCuMedCompute) {
- exclusiveComputeEnginesId_.insert({ExclusiveQueueType::Medium, i});
+ } else {
+ computeEnginesId_.push_back(i);
}
}
}
@@ -957,7 +962,7 @@ bool Device::create(Pal::IDevice* device) {
return false;
}
- numComputeEngines_ = std::min(numComputeEngines_, settings().numComputeRings_);
+ computeEnginesId_.resize(std::min(numComputeEngines(), settings().numComputeRings_));
amd::Context::Info info = {0};
std::vector devices;
@@ -1140,11 +1145,14 @@ bool Device::initializeHeapResources() {
Pal::DeviceFinalizeInfo finalizeInfo = {};
// Request all compute engines
- finalizeInfo.requestedEngineCounts[Pal::EngineTypeCompute].engines =
- ((1 << numComputeEngines_) - 1);
+ for (const auto& it : computeEnginesId_) {
+ // Request real time compute engines
+ finalizeInfo.requestedEngineCounts[Pal::EngineTypeCompute].engines |= (1 << it);
+ }
+
for (const auto& it : exclusiveComputeEnginesId_) {
// Request real time compute engines
- finalizeInfo.requestedEngineCounts[Pal::EngineTypeExclusiveCompute].engines |=
+ finalizeInfo.requestedEngineCounts[Pal::EngineTypeCompute].engines |=
(1 << it.second);
}
// Request all SDMA engines
diff --git a/rocclr/runtime/device/pal/paldevice.hpp b/rocclr/runtime/device/pal/paldevice.hpp
index 0ba85217d3..3347db4e25 100644
--- a/rocclr/runtime/device/pal/paldevice.hpp
+++ b/rocclr/runtime/device/pal/paldevice.hpp
@@ -400,7 +400,12 @@ class Device : public NullDevice {
ResourceCache& resourceCache() const { return *resourceCache_; }
//! Returns the number of available compute rings
- uint numComputeEngines() const { return numComputeEngines_; }
+ uint numComputeEngines() const { return computeEnginesId_.size(); }
+
+ //! Returns the vector of available compute rings with the engine index
+ const std::vector& computeEnginesId() const {
+ return computeEnginesId_;
+ }
//! Returns the number of available compute rings
uint numExclusiveComputeEngines() const { return exclusiveComputeEnginesId_.size(); }
@@ -595,9 +600,9 @@ class Device : public NullDevice {
XferBuffers* xferRead_; //!< Transfer buffers read
std::vector* mapCache_; //!< Map cache info structure
ResourceCache* resourceCache_; //!< Resource cache
- uint numComputeEngines_; //!< The number of available compute engines
std::map
exclusiveComputeEnginesId_; //!< The number of available compute engines
+ std::vector computeEnginesId_; //!< PAL index for compute engine
uint numDmaEngines_; //!< The number of available compute engines
bool heapInitComplete_; //!< Keep track of initialization status of heap resources
VirtualGPU* xferQueue_; //!< Transfer queue
diff --git a/rocclr/runtime/device/pal/palvirtual.cpp b/rocclr/runtime/device/pal/palvirtual.cpp
index 9223f084d2..78031b8ea1 100644
--- a/rocclr/runtime/device/pal/palvirtual.cpp
+++ b/rocclr/runtime/device/pal/palvirtual.cpp
@@ -50,10 +50,11 @@ VirtualGPU::Queue* VirtualGPU::Queue::Create(const VirtualGPU& gpu, Pal::QueueTy
Pal::Result result;
Pal::CmdBufferCreateInfo cmdCreateInfo = {};
Pal::QueueCreateInfo qCreateInfo = {};
- qCreateInfo.engineIndex = engineIdx;
+ qCreateInfo.engineIndex =
+ (queueType == Pal::QueueTypeCompute) ? gpu.dev().computeEnginesId()[engineIdx] : engineIdx;
qCreateInfo.aqlQueue = true;
qCreateInfo.queueType = queueType;
- qCreateInfo.priority = Pal::QueuePriority::Low;
+ qCreateInfo.priority = Pal::QueuePriority::Normal;
if (queueType == Pal::QueueTypeDma) {
cmdCreateInfo.engineType = qCreateInfo.engineType = Pal::EngineTypeDma;
@@ -64,7 +65,7 @@ VirtualGPU::Queue* VirtualGPU::Queue::Create(const VirtualGPU& gpu, Pal::QueueTy
if ((priority == amd::CommandQueue::Priority::Medium) &&
(amd::CommandQueue::RealTimeDisabled == rtCU)) {
it = gpu.dev().exclusiveComputeEnginesId().find(ExclusiveQueueType::Medium);
- cmdCreateInfo.engineType = qCreateInfo.engineType = Pal::EngineTypeExclusiveCompute;
+ cmdCreateInfo.engineType = qCreateInfo.engineType = Pal::EngineTypeCompute;
qCreateInfo.priority = Pal::QueuePriority::Medium;
} else if (amd::CommandQueue::RealTimeDisabled != rtCU) {
qCreateInfo.numReservedCu = rtCU;
@@ -73,18 +74,20 @@ VirtualGPU::Queue* VirtualGPU::Queue::Create(const VirtualGPU& gpu, Pal::QueueTy
} else {
it = gpu.dev().exclusiveComputeEnginesId().find(ExclusiveQueueType::RealTime0);
}
- cmdCreateInfo.engineType = qCreateInfo.engineType = Pal::EngineTypeExclusiveCompute;
+ cmdCreateInfo.engineType = qCreateInfo.engineType = Pal::EngineTypeCompute;
cmdCreateInfo.flags.realtimeComputeUnits = true;
qCreateInfo.priority = Pal::QueuePriority::Realtime;
- }
- // If the app creates an exclusive compute, then find the engine id
- if (qCreateInfo.engineType == Pal::EngineTypeExclusiveCompute) {
- if (it != gpu.dev().exclusiveComputeEnginesId().end()) {
- qCreateInfo.engineIndex = it->second;
- } else {
- return nullptr;
+
+ // If the app creates an exclusive compute, then find the engine id
+ if (qCreateInfo.engineType == Pal::EngineTypeCompute) {
+ if (it != gpu.dev().exclusiveComputeEnginesId().end()) {
+ qCreateInfo.engineIndex = it->second;
+ } else {
+ return nullptr;
+ }
}
}
+
// Find queue object size
size_t qSize = palDev->GetQueueSize(qCreateInfo, &result);
if (result != Pal::Result::Success) {