mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
fix: Track Sub Device Hierarchy for use by Metrics Library
Related-To: LOCI-4819 - When communicating with the Metrics Libraries, if one is using a specific sub device, then the correct physical sub device index and number of sub devices must be used. - When Affinity Mask is set, this hierarchy information is lost, therefore the sub device hierarchy data is stored in a map to each "device" to be returned to the user allowing for the correct sub device information to be passed to the metrics library. Signed-off-by: Spruit, Neil R <neil.r.spruit@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
873b3d4241
commit
5c75449508
@@ -8,6 +8,7 @@
|
||||
#include "level_zero/tools/source/metrics/metric.h"
|
||||
|
||||
#include "shared/source/device/sub_device.h"
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
|
||||
#include "level_zero/core/source/device/device.h"
|
||||
#include "level_zero/core/source/device/device_imp.h"
|
||||
@@ -24,12 +25,24 @@ namespace L0 {
|
||||
|
||||
MetricDeviceContext::MetricDeviceContext(Device &inputDevice) : device(inputDevice) {
|
||||
auto deviceNeo = device.getNEODevice();
|
||||
bool isSubDevice = deviceNeo->isSubDevice();
|
||||
subDeviceIndex = isSubDevice
|
||||
? static_cast<NEO::SubDevice *>(deviceNeo)->getSubDeviceIndex()
|
||||
: 0;
|
||||
std::tuple<uint32_t, uint32_t, uint32_t> subDeviceMap;
|
||||
uint32_t hwSubDeviceIndex = 0u;
|
||||
bool requiresSubDeviceHierarchy = false;
|
||||
if (deviceNeo->getExecutionEnvironment()->getSubDeviceHierarchy(deviceNeo->getRootDeviceIndex(), &subDeviceMap)) {
|
||||
hwSubDeviceIndex = std::get<1>(subDeviceMap);
|
||||
requiresSubDeviceHierarchy = true;
|
||||
}
|
||||
if (requiresSubDeviceHierarchy) {
|
||||
subDeviceIndex = hwSubDeviceIndex;
|
||||
multiDeviceCapable = false;
|
||||
} else {
|
||||
bool isSubDevice = deviceNeo->isSubDevice();
|
||||
subDeviceIndex = isSubDevice
|
||||
? static_cast<NEO::SubDevice *>(deviceNeo)->getSubDeviceIndex()
|
||||
: 0;
|
||||
|
||||
multiDeviceCapable = !isSubDevice && device.isImplicitScalingCapable();
|
||||
multiDeviceCapable = !isSubDevice && device.isImplicitScalingCapable();
|
||||
}
|
||||
metricSources[MetricSource::SourceType::Oa] = OaMetricSourceImp::create(*this);
|
||||
metricSources[MetricSource::SourceType::IpSampling] = IpSamplingMetricSourceImp::create(*this);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#include "shared/source/helpers/engine_node_helper.h"
|
||||
#include "shared/source/helpers/gfx_core_helper.h"
|
||||
#include "shared/source/memory_manager/allocation_properties.h"
|
||||
@@ -209,7 +210,19 @@ void MetricsLibrary::getSubDeviceClientOptions(
|
||||
|
||||
auto &deviceImp = *static_cast<DeviceImp *>(&metricSource.getDevice());
|
||||
|
||||
if (!deviceImp.isSubdevice) {
|
||||
std::tuple<uint32_t, uint32_t, uint32_t> subDeviceMap;
|
||||
uint32_t hwSubDeviceIndex = 0u;
|
||||
uint32_t hwSubDevicesCount = 0u;
|
||||
bool requiresSubDeviceHierarchy = false;
|
||||
bool isSubDevice = deviceImp.isSubdevice;
|
||||
if (deviceImp.getNEODevice()->getExecutionEnvironment()->getSubDeviceHierarchy(deviceImp.getNEODevice()->getRootDeviceIndex(), &subDeviceMap)) {
|
||||
hwSubDeviceIndex = std::get<1>(subDeviceMap);
|
||||
hwSubDevicesCount = std::get<2>(subDeviceMap);
|
||||
requiresSubDeviceHierarchy = true;
|
||||
isSubDevice = true;
|
||||
}
|
||||
|
||||
if (!isSubDevice) {
|
||||
|
||||
// Root device.
|
||||
subDevice.Type = ClientOptionsType::SubDevice;
|
||||
@@ -231,10 +244,18 @@ void MetricsLibrary::getSubDeviceClientOptions(
|
||||
subDevice.SubDevice.Enabled = true;
|
||||
|
||||
subDeviceIndex.Type = ClientOptionsType::SubDeviceIndex;
|
||||
subDeviceIndex.SubDeviceIndex.Index = static_cast<uint8_t>(deviceImp.getPhysicalSubDeviceId());
|
||||
if (requiresSubDeviceHierarchy) {
|
||||
subDeviceIndex.SubDeviceIndex.Index = hwSubDeviceIndex;
|
||||
} else {
|
||||
subDeviceIndex.SubDeviceIndex.Index = static_cast<uint8_t>(deviceImp.getPhysicalSubDeviceId());
|
||||
}
|
||||
|
||||
subDeviceCount.Type = ClientOptionsType::SubDeviceCount;
|
||||
subDeviceCount.SubDeviceCount.Count = std::max(deviceImp.getNEODevice()->getRootDevice()->getNumSubDevices(), 1u);
|
||||
if (requiresSubDeviceHierarchy) {
|
||||
subDeviceCount.SubDeviceCount.Count = hwSubDevicesCount;
|
||||
} else {
|
||||
subDeviceCount.SubDeviceCount.Count = std::max(deviceImp.getNEODevice()->getRootDevice()->getNumSubDevices(), 1u);
|
||||
}
|
||||
|
||||
workloadPartition.Type = ClientOptionsType::WorkloadPartition;
|
||||
workloadPartition.WorkloadPartition.Enabled = isWorkloadPartitionEnabled;
|
||||
|
||||
@@ -500,8 +500,8 @@ TEST_F(MultiDeviceMetricQueryPoolAffinityMaskTest, givenAffinityMaskEnabledWhenG
|
||||
metricsLibrary.getSubDeviceClientOptions(subDevice, subDeviceIndex, subDeviceCount, workloadPartition);
|
||||
|
||||
EXPECT_EQ(subDevice.Type, MetricsLibraryApi::ClientOptionsType::SubDevice);
|
||||
// Still Root device
|
||||
EXPECT_EQ(subDevice.SubDevice.Enabled, false);
|
||||
// Expect Sub Device Enabled
|
||||
EXPECT_EQ(subDevice.SubDevice.Enabled, true);
|
||||
|
||||
EXPECT_EQ(subDeviceIndex.Type, MetricsLibraryApi::ClientOptionsType::SubDeviceIndex);
|
||||
// Enabled Sub Device index is used
|
||||
|
||||
Reference in New Issue
Block a user