mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-09 06:23:01 +08:00
Improve Device getter to support EngineInstanced Device with single Engine
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
7ed804a4bb
commit
92000bd75b
@@ -23,7 +23,7 @@
|
||||
|
||||
namespace NEO {
|
||||
|
||||
ClDevice::ClDevice(Device &device, Platform *platform) : device(device), platformId(platform) {
|
||||
ClDevice::ClDevice(Device &device, ClDevice &rootClDevice, Platform *platform) : device(device), rootClDevice(rootClDevice), platformId(platform) {
|
||||
device.incRefInternal();
|
||||
device.setSpecializedDevice(this);
|
||||
deviceExtensions.reserve(1000);
|
||||
@@ -39,7 +39,7 @@ ClDevice::ClDevice(Device &device, Platform *platform) : device(device), platfor
|
||||
if (numAvailableDevices > 1) {
|
||||
for (uint32_t i = 0; i < numAvailableDevices; i++) {
|
||||
auto &coreSubDevice = static_cast<SubDevice &>(*device.getSubDevice(i));
|
||||
auto pClSubDevice = std::make_unique<ClDevice>(coreSubDevice, platform);
|
||||
auto pClSubDevice = std::make_unique<ClDevice>(coreSubDevice, rootClDevice, platform);
|
||||
pClSubDevice->incRefInternal();
|
||||
pClSubDevice->decRefApi();
|
||||
|
||||
@@ -61,6 +61,9 @@ ClDevice::ClDevice(Device &device, Platform *platform) : device(device), platfor
|
||||
}
|
||||
}
|
||||
|
||||
ClDevice::ClDevice(Device &device, Platform *platformId) : ClDevice(device, *this, platformId) {
|
||||
}
|
||||
|
||||
ClDevice::~ClDevice() {
|
||||
|
||||
if (getSharedDeviceInfo().debuggerActive && getSourceLevelDebugger()) {
|
||||
@@ -123,7 +126,17 @@ ClDevice *ClDevice::getSubDevice(uint32_t deviceId) const {
|
||||
return subDevices[deviceId].get();
|
||||
}
|
||||
|
||||
ClDevice *ClDevice::getThisOrNextNonRootCsrDevice(uint32_t deviceId) {
|
||||
ClDevice *ClDevice::getNearestGenericSubDevice(uint32_t deviceId) {
|
||||
/*
|
||||
* EngineInstanced: Upper level
|
||||
* Generic SubDevice: 'this'
|
||||
* RootCsr Device: Next level SubDevice (generic)
|
||||
*/
|
||||
|
||||
if (getDevice().isEngineInstanced()) {
|
||||
return rootClDevice.getNearestGenericSubDevice(Math::log2(static_cast<uint32_t>(getDeviceBitfield().to_ulong())));
|
||||
}
|
||||
|
||||
if (subDevices.empty() || !getDevice().hasRootCsr()) {
|
||||
return const_cast<ClDevice *>(this);
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ class ClDevice : public BaseObject<_cl_device_id> {
|
||||
ClDevice(const ClDevice &) = delete;
|
||||
|
||||
explicit ClDevice(Device &device, Platform *platformId);
|
||||
explicit ClDevice(Device &device, ClDevice &rootClDevice, Platform *platformId);
|
||||
~ClDevice() override;
|
||||
|
||||
void incRefInternal();
|
||||
@@ -116,7 +117,7 @@ class ClDevice : public BaseObject<_cl_device_id> {
|
||||
const ClDeviceInfo &getDeviceInfo() const { return deviceInfo; }
|
||||
const DeviceInfo &getSharedDeviceInfo() const;
|
||||
ClDevice *getSubDevice(uint32_t deviceId) const;
|
||||
ClDevice *getThisOrNextNonRootCsrDevice(uint32_t deviceId);
|
||||
ClDevice *getNearestGenericSubDevice(uint32_t deviceId);
|
||||
const std::string &peekCompilerExtensions() const;
|
||||
const std::string &peekCompilerExtensionsWithFeatures() const;
|
||||
DeviceBitfield getDeviceBitfield() const;
|
||||
@@ -138,6 +139,7 @@ class ClDevice : public BaseObject<_cl_device_id> {
|
||||
const std::string getClDeviceName(const HardwareInfo &hwInfo) const;
|
||||
|
||||
Device &device;
|
||||
ClDevice &rootClDevice;
|
||||
std::vector<std::unique_ptr<ClDevice>> subDevices;
|
||||
cl_platform_id platformId;
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ CommandQueue::CommandQueue(Context *context, ClDevice *device, const cl_queue_pr
|
||||
deferredTimestampPackets = std::make_unique<TimestampPacketContainer>();
|
||||
}
|
||||
if (bcsAllowed) {
|
||||
auto &neoDevice = device->getThisOrNextNonRootCsrDevice(0)->getDevice();
|
||||
auto &neoDevice = device->getNearestGenericSubDevice(0)->getDevice();
|
||||
auto &selectorCopyEngine = neoDevice.getSelectorCopyEngine();
|
||||
auto bcsEngineType = EngineHelpers::getBcsEngineType(hwInfo, device->getDeviceBitfield(), selectorCopyEngine, internalUsage);
|
||||
bcsEngine = neoDevice.tryGetEngine(bcsEngineType, EngineUsage::Regular);
|
||||
@@ -113,7 +113,7 @@ CommandQueue::~CommandQueue() {
|
||||
}
|
||||
|
||||
if (bcsEngine) {
|
||||
auto &selectorCopyEngine = device->getThisOrNextNonRootCsrDevice(0)->getSelectorCopyEngine();
|
||||
auto &selectorCopyEngine = device->getNearestGenericSubDevice(0)->getSelectorCopyEngine();
|
||||
EngineHelpers::releaseBcsEngineType(bcsEngine->getEngineType(), selectorCopyEngine);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ class CommandQueueHw : public CommandQueue {
|
||||
|
||||
if (clPriority & static_cast<cl_queue_priority_khr>(CL_QUEUE_PRIORITY_LOW_KHR)) {
|
||||
priority = QueuePriority::LOW;
|
||||
this->gpgpuEngine = &device->getThisOrNextNonRootCsrDevice(0)->getEngine(getChosenEngineType(device->getHardwareInfo()), EngineUsage::LowPriority);
|
||||
this->gpgpuEngine = &device->getNearestGenericSubDevice(0)->getEngine(getChosenEngineType(device->getHardwareInfo()), EngineUsage::LowPriority);
|
||||
} else if (clPriority & static_cast<cl_queue_priority_khr>(CL_QUEUE_PRIORITY_MED_KHR)) {
|
||||
priority = QueuePriority::MEDIUM;
|
||||
} else if (clPriority & static_cast<cl_queue_priority_khr>(CL_QUEUE_PRIORITY_HIGH_KHR)) {
|
||||
|
||||
@@ -55,7 +55,7 @@ Program::Program(Context *context, bool isBuiltIn, const ClDeviceVector &clDevic
|
||||
deviceBuildInfos[device] = {};
|
||||
if (device->getNumAvailableDevices() > 1) {
|
||||
for (auto i = 0u; i < device->getNumAvailableDevices(); i++) {
|
||||
auto subDevice = device->getThisOrNextNonRootCsrDevice(i);
|
||||
auto subDevice = device->getNearestGenericSubDevice(i);
|
||||
if (isDeviceAssociated(*subDevice)) {
|
||||
deviceBuildInfos[device].associatedSubDevices.push_back(subDevice);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user