Add support for ze_scheduling_hint_exp_properties

Related-To: LOCI-2319
Signed-off-by: Young Jin Yoon <young.jin.yoon@intel.com>
This commit is contained in:
Young Jin Yoon
2021-09-10 00:37:27 +00:00
committed by Compute-Runtime-Automation
parent 895e9e5116
commit 4234a19b69
6 changed files with 152 additions and 3 deletions

View File

@@ -356,17 +356,38 @@ ze_result_t DeviceImp::getKernelProperties(ze_device_module_properties_t *pKerne
pKernelProperties->printfBufferSize = static_cast<uint32_t>(this->neoDevice->getDeviceInfo().printfBufferSize);
if (pKernelProperties->pNext) {
auto &hwInfo = this->getHwInfo();
auto &hwInfoConfig = *NEO::HwInfoConfig::get(hwInfo.platform.eProductFamily);
void *pNext = pKernelProperties->pNext;
while (pNext) {
ze_base_desc_t *extendedProperties = reinterpret_cast<ze_base_desc_t *>(pKernelProperties->pNext);
if (extendedProperties->stype == ZE_STRUCTURE_TYPE_FLOAT_ATOMIC_EXT_PROPERTIES) {
ze_float_atomic_ext_properties_t *floatProperties =
reinterpret_cast<ze_float_atomic_ext_properties_t *>(extendedProperties);
auto &hwInfo = this->getHwInfo();
auto &hwInfoConfig = *NEO::HwInfoConfig::get(hwInfo.platform.eProductFamily);
hwInfoConfig.getKernelExtendedProperties(&floatProperties->fp16Flags,
&floatProperties->fp32Flags,
&floatProperties->fp64Flags);
} else if (extendedProperties->stype == ZE_STRUCTURE_TYPE_SCHEDULING_HINT_EXP_PROPERTIES) {
ze_scheduling_hint_exp_properties_t *hintProperties =
reinterpret_cast<ze_scheduling_hint_exp_properties_t *>(extendedProperties);
auto supportedThreadArbitrationPolicies = hwInfoConfig.getKernelSupportedThreadArbitrationPolicies();
hintProperties->schedulingHintFlags = 0;
for (uint32_t &p : supportedThreadArbitrationPolicies) {
switch (p) {
case NEO::ThreadArbitrationPolicy::AgeBased:
hintProperties->schedulingHintFlags |= ZE_SCHEDULING_HINT_EXP_FLAG_OLDEST_FIRST;
break;
case NEO::ThreadArbitrationPolicy::RoundRobin:
hintProperties->schedulingHintFlags |= ZE_SCHEDULING_HINT_EXP_FLAG_ROUND_ROBIN;
break;
case NEO::ThreadArbitrationPolicy::RoundRobinAfterDependency:
hintProperties->schedulingHintFlags |= ZE_SCHEDULING_HINT_EXP_FLAG_STALL_BASED_ROUND_ROBIN;
break;
}
}
}
pNext = const_cast<void *>(extendedProperties->pNext);
}
return ZE_RESULT_SUCCESS;

View File

@@ -7,6 +7,7 @@
#include "shared/source/device/root_device.h"
#include "shared/source/helpers/bindless_heaps_helper.h"
#include "shared/source/helpers/preamble.h"
#include "shared/source/os_interface/hw_info_config.h"
#include "shared/source/os_interface/os_inc_base.h"
#include "shared/source/os_interface/os_time.h"
@@ -509,6 +510,116 @@ TEST_F(DeviceTest, givenKernelExtendedPropertiesStructureWhenKernelPropertiesCal
EXPECT_EQ(maxValue, kernelExtendedProperties.fp64Flags);
}
HWTEST_F(DeviceTest, whenPassingSchedulingHintExpStructToGetPropertiesThenPropertiesWithCorrectFlagIsReturned) {
ze_device_module_properties_t kernelProperties = {};
kernelProperties.stype = ZE_STRUCTURE_TYPE_KERNEL_PROPERTIES;
ze_scheduling_hint_exp_properties_t schedulingHintProperties = {};
schedulingHintProperties.stype = ZE_STRUCTURE_TYPE_SCHEDULING_HINT_EXP_PROPERTIES;
schedulingHintProperties.schedulingHintFlags = ZE_SCHEDULING_HINT_EXP_FLAG_FORCE_UINT32;
kernelProperties.pNext = &schedulingHintProperties;
ze_result_t res = device->getKernelProperties(&kernelProperties);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
EXPECT_NE(ZE_SCHEDULING_HINT_EXP_FLAG_FORCE_UINT32, schedulingHintProperties.schedulingHintFlags);
auto supportedThreadArbitrationPolicies = NEO::PreambleHelper<FamilyType>::getSupportedThreadArbitrationPolicies();
for (uint32_t &p : supportedThreadArbitrationPolicies) {
switch (p) {
case ThreadArbitrationPolicy::AgeBased:
EXPECT_NE(0u, (schedulingHintProperties.schedulingHintFlags &
ZE_SCHEDULING_HINT_EXP_FLAG_OLDEST_FIRST));
break;
case ThreadArbitrationPolicy::RoundRobin:
EXPECT_NE(0u, (schedulingHintProperties.schedulingHintFlags &
ZE_SCHEDULING_HINT_EXP_FLAG_ROUND_ROBIN));
break;
case ThreadArbitrationPolicy::RoundRobinAfterDependency:
EXPECT_NE(0u, (schedulingHintProperties.schedulingHintFlags &
ZE_SCHEDULING_HINT_EXP_FLAG_STALL_BASED_ROUND_ROBIN));
break;
default:
FAIL();
}
}
}
HWTEST_F(DeviceTest, givenAllThreadArbitrationPoliciesWhenPassingSchedulingHintExpStructToGetPropertiesThenPropertiesWithAllFlagsAreReturned) {
struct MockHwInfoConfig : NEO::HwInfoConfigHw<IGFX_SKYLAKE> {
std::vector<uint32_t> getKernelSupportedThreadArbitrationPolicies() override {
return threadArbPolicies;
}
std::vector<uint32_t> threadArbPolicies;
};
const uint32_t rootDeviceIndex = 0u;
auto hwInfo = *NEO::defaultHwInfo;
auto *neoMockDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo,
rootDeviceIndex);
Mock<L0::DeviceImp> deviceImp(neoMockDevice, neoMockDevice->getExecutionEnvironment());
MockHwInfoConfig hwInfoConfig{};
hwInfoConfig.threadArbPolicies = {ThreadArbitrationPolicy::AgeBased,
ThreadArbitrationPolicy::RoundRobin,
ThreadArbitrationPolicy::RoundRobinAfterDependency};
VariableBackup<HwInfoConfig *> hwInfoConfigFactoryBackup{&NEO::hwInfoConfigFactory[static_cast<size_t>(hwInfo.platform.eProductFamily)]};
hwInfoConfigFactoryBackup = &hwInfoConfig;
ze_device_module_properties_t kernelProperties = {};
kernelProperties.stype = ZE_STRUCTURE_TYPE_KERNEL_PROPERTIES;
ze_scheduling_hint_exp_properties_t schedulingHintProperties = {};
schedulingHintProperties.stype = ZE_STRUCTURE_TYPE_SCHEDULING_HINT_EXP_PROPERTIES;
schedulingHintProperties.schedulingHintFlags = ZE_SCHEDULING_HINT_EXP_FLAG_FORCE_UINT32;
kernelProperties.pNext = &schedulingHintProperties;
ze_result_t res = deviceImp.getKernelProperties(&kernelProperties);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
ze_scheduling_hint_exp_flags_t expected = (ZE_SCHEDULING_HINT_EXP_FLAG_OLDEST_FIRST |
ZE_SCHEDULING_HINT_EXP_FLAG_ROUND_ROBIN |
ZE_SCHEDULING_HINT_EXP_FLAG_STALL_BASED_ROUND_ROBIN);
EXPECT_EQ(expected, schedulingHintProperties.schedulingHintFlags);
}
HWTEST_F(DeviceTest, givenIncorrectThreadArbitrationPolicyWhenPassingSchedulingHintExpStructToGetPropertiesThenNoneIsReturned) {
struct MockHwInfoConfig : NEO::HwInfoConfigHw<IGFX_SKYLAKE> {
std::vector<uint32_t> getKernelSupportedThreadArbitrationPolicies() override {
return threadArbPolicies;
}
std::vector<uint32_t> threadArbPolicies;
};
const uint32_t rootDeviceIndex = 0u;
auto hwInfo = *NEO::defaultHwInfo;
auto *neoMockDevice = NEO::MockDevice::createWithNewExecutionEnvironment<NEO::MockDevice>(&hwInfo,
rootDeviceIndex);
Mock<L0::DeviceImp> deviceImp(neoMockDevice, neoMockDevice->getExecutionEnvironment());
MockHwInfoConfig hwInfoConfig{};
hwInfoConfig.threadArbPolicies = {ThreadArbitrationPolicy::NotPresent};
VariableBackup<HwInfoConfig *> hwInfoConfigFactoryBackup{&NEO::hwInfoConfigFactory[static_cast<size_t>(hwInfo.platform.eProductFamily)]};
hwInfoConfigFactoryBackup = &hwInfoConfig;
ze_device_module_properties_t kernelProperties = {};
kernelProperties.stype = ZE_STRUCTURE_TYPE_KERNEL_PROPERTIES;
ze_scheduling_hint_exp_properties_t schedulingHintProperties = {};
schedulingHintProperties.stype = ZE_STRUCTURE_TYPE_SCHEDULING_HINT_EXP_PROPERTIES;
schedulingHintProperties.schedulingHintFlags = ZE_SCHEDULING_HINT_EXP_FLAG_FORCE_UINT32;
kernelProperties.pNext = &schedulingHintProperties;
ze_result_t res = deviceImp.getKernelProperties(&kernelProperties);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
EXPECT_EQ(0u, schedulingHintProperties.schedulingHintFlags);
}
TEST_F(DeviceTest, givenKernelPropertiesStructureWhenKernelPropertiesCalledThenAllPropertiesAreAssigned) {
const auto &hardwareInfo = this->neoDevice->getHardwareInfo();

View File

@@ -184,6 +184,9 @@ HWTEST_F(HwInfoConfigTest, givenVariousValuesWhenGettingAubStreamSteppingFromHwR
uint32_t getSteppingFromHwRevId(const HardwareInfo &hwInfo) const override {
return returnedStepping;
}
std::vector<uint32_t> getKernelSupportedThreadArbitrationPolicies() override {
return std::vector<uint32_t>();
}
uint32_t returnedStepping = 0;
};
MockHwInfoConfig mockHwInfoConfig;

View File

@@ -38,6 +38,7 @@ class HwInfoConfig {
virtual uint64_t getSingleDeviceSharedMemCapabilities() = 0;
virtual uint64_t getCrossDeviceSharedMemCapabilities() = 0;
virtual void getKernelExtendedProperties(uint32_t *fp16, uint32_t *fp32, uint32_t *fp64) = 0;
virtual std::vector<uint32_t> getKernelSupportedThreadArbitrationPolicies() = 0;
virtual uint64_t getSharedSystemMemCapabilities() = 0;
virtual void convertTimestampsFromOaToCsDomain(uint64_t &timestampData) = 0;
virtual uint32_t getDeviceMemoryMaxClkRate(const HardwareInfo *hwInfo) = 0;
@@ -81,6 +82,7 @@ class HwInfoConfigHw : public HwInfoConfig {
uint64_t getSingleDeviceSharedMemCapabilities() override;
uint64_t getCrossDeviceSharedMemCapabilities() override;
void getKernelExtendedProperties(uint32_t *fp16, uint32_t *fp32, uint32_t *fp64) override;
std::vector<uint32_t> getKernelSupportedThreadArbitrationPolicies() override;
uint64_t getSharedSystemMemCapabilities() override;
void convertTimestampsFromOaToCsDomain(uint64_t &timestampData) override;
uint32_t getDeviceMemoryMaxClkRate(const HardwareInfo *hwInfo) override;

View File

@@ -8,6 +8,7 @@
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/helpers/api_specific_config.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/helpers/preamble.h"
#include "shared/source/os_interface/hw_info_config.h"
namespace NEO {
@@ -27,6 +28,12 @@ void HwInfoConfigHw<gfxProduct>::getKernelExtendedProperties(uint32_t *fp16, uin
*fp64 = 0u;
}
template <PRODUCT_FAMILY gfxProduct>
std::vector<uint32_t> HwInfoConfigHw<gfxProduct>::getKernelSupportedThreadArbitrationPolicies() {
using GfxFamily = typename HwMapper<gfxProduct>::GfxFamily;
return PreambleHelper<GfxFamily>::getSupportedThreadArbitrationPolicies();
}
template <PRODUCT_FAMILY gfxProduct>
uint64_t HwInfoConfigHw<gfxProduct>::getSharedSystemMemCapabilities() {
return 0;

View File

@@ -156,6 +156,11 @@ LocalMemoryAccessMode HwInfoConfigHw<IGFX_UNKNOWN>::getLocalMemoryAccessMode(con
return LocalMemoryAccessMode::Default;
}
template <>
std::vector<uint32_t> HwInfoConfigHw<IGFX_UNKNOWN>::getKernelSupportedThreadArbitrationPolicies() {
return std::vector<uint32_t>();
}
void OsAgnosticHwInfoConfigTest::SetUp() {
DeviceFixture::SetUp();
}