Add getComputeEngineIndexByOrdinal function

Related-To: NEO-4710

Change-Id: Idaf84e2b5df608582b32602a6fc987e889173eac
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2020-06-01 16:41:43 +02:00
committed by sys_ocldev
parent 4da9269d1b
commit 2b0114846e
6 changed files with 65 additions and 7 deletions

View File

@@ -128,13 +128,7 @@ ze_result_t DeviceImp::createCommandQueue(const ze_command_queue_desc_t *desc,
return ZE_RESULT_ERROR_INVALID_ARGUMENT;
}
if (desc->ordinal == 0) {
csr = neoDevice->getEngine(0).commandStreamReceiver;
} else {
// Skip low-priority and internal engines in engines vector
csr = neoDevice->getEngine(desc->ordinal + hwHelper.internalUsageEngineIndex).commandStreamReceiver;
}
csr = neoDevice->getEngine(hwHelper.getComputeEngineIndexByOrdinal(hardwareInfo, desc->ordinal)).commandStreamReceiver;
UNRECOVERABLE_IF(csr == nullptr);
}
*commandQueue = CommandQueue::create(productFamily, this, csr, desc, useBliter);

View File

@@ -91,6 +91,33 @@ TEST_F(CommandQueueCreate, givenOrdinalThenQueueIsCreatedOnlyIfOrdinalIsLessThan
}
}
TEST_F(CommandQueueCreate, givenOrdinalWhenQueueIsCreatedThenCorrectEngineIsSelected) {
ze_device_properties_t deviceProperties;
ze_result_t res = device->getProperties(&deviceProperties);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
auto numOfComputeEngines = NEO::HwHelper::getEnginesCount(device->getNEODevice()->getHardwareInfo());
ze_command_queue_desc_t desc = {};
desc.version = ZE_COMMAND_QUEUE_DESC_VERSION_CURRENT;
ze_command_queue_handle_t commandQueue = {};
auto &hwHelper = NEO::HwHelper::get(defaultHwInfo->platform.eRenderCoreFamily);
for (uint32_t i = 0; i < numOfComputeEngines; i++) {
desc.ordinal = i;
res = device->createCommandQueue(&desc, &commandQueue);
EXPECT_EQ(ZE_RESULT_SUCCESS, res);
ASSERT_NE(nullptr, commandQueue);
EXPECT_EQ(device->getNEODevice()->getEngine(hwHelper.getComputeEngineIndexByOrdinal(*defaultHwInfo, i)).commandStreamReceiver,
static_cast<CommandQueue *>(commandQueue)->getCsr());
L0::CommandQueue::fromHandle(commandQueue)->destroy();
}
}
using CommandQueueSBASupport = IsWithinProducts<IGFX_SKYLAKE, IGFX_TIGERLAKE_LP>;
struct MockMemoryManagerCommandQueueSBA : public MemoryManagerMock {

View File

@@ -194,6 +194,21 @@ GEN12LPTEST_F(HwHelperTestGen12Lp, givenTgllpWhenIsFusedEuDispatchEnabledIsCalle
}
}
GEN12LPTEST_F(HwHelperTestGen12Lp, whenGettingComputeEngineIndexByOrdinalThenCorrectIndexIsReturned) {
auto &helper = HwHelper::get(renderCoreFamily);
HardwareInfo hwInfo = *defaultHwInfo;
hwInfo.featureTable.ftrCCSNode = true;
EXPECT_EQ(helper.internalUsageEngineIndex + 1, helper.getComputeEngineIndexByOrdinal(hwInfo, 0));
EXPECT_EQ(0u, helper.getComputeEngineIndexByOrdinal(hwInfo, 1));
if (helper.getEnginesCount(hwInfo) > 1) {
auto engine0 = helper.getGpgpuEngineInstances(hwInfo)[helper.getComputeEngineIndexByOrdinal(hwInfo, 0)];
auto engine1 = helper.getGpgpuEngineInstances(hwInfo)[helper.getComputeEngineIndexByOrdinal(hwInfo, 1)];
EXPECT_NE(engine0, engine1);
}
}
class HwHelperTestsGen12LpBuffer : public ::testing::Test {
public:
void SetUp() override {

View File

@@ -885,6 +885,12 @@ HWTEST_F(HwHelperTest, givenDefaultHwHelperHwWhenMinimalSIMDSizeIsQueriedThen8Is
EXPECT_EQ(8u, helper.getMinimalSIMDSize());
}
using isAtMostGen11 = IsAtMostGfxCore<IGFX_GEN11LP_CORE>;
HWTEST2_F(HwHelperTest, givenSingleEnginePlatformWhenGettingComputeEngineIndexByOrdinalThenZeroIndexIsReturned, isAtMostGen11) {
auto &helper = HwHelper::get(renderCoreFamily);
EXPECT_EQ(0u, helper.getComputeEngineIndexByOrdinal(*defaultHwInfo, 0));
}
HWCMDTEST_F(IGFX_GEN8_CORE, HwHelperTest, WhenIsFusedEuDispatchEnabledIsCalledThenFalseIsReturned) {
if (hardwareInfo.platform.eRenderCoreFamily == IGFX_GEN12LP_CORE) {
GTEST_SKIP();

View File

@@ -41,6 +41,7 @@ class HwHelper {
virtual uint32_t getMaxNumSamplers() const = 0;
virtual void setCapabilityCoherencyFlag(const HardwareInfo *pHwInfo, bool &coherencyFlag) = 0;
virtual void adjustDefaultEngineType(HardwareInfo *pHwInfo) = 0;
virtual uint32_t getComputeEngineIndexByOrdinal(const HardwareInfo &hwInfo, uint32_t ordinal) const = 0;
virtual void setupHardwareCapabilities(HardwareCapabilities *caps, const HardwareInfo &hwInfo) = 0;
virtual bool isL3Configurable(const HardwareInfo &hwInfo) = 0;
virtual SipKernelType getSipKernelType(bool debuggingActive) = 0;
@@ -165,6 +166,13 @@ class HwHelperHw : public HwHelper {
void adjustDefaultEngineType(HardwareInfo *pHwInfo) override;
uint32_t getComputeEngineIndexByOrdinal(const HardwareInfo &hwInfo, uint32_t ordinal) const override {
if (hwInfo.featureTable.ftrCCSNode && ordinal < hwInfo.gtSystemInfo.CCSInfo.NumberOfCCSEnabled) {
return ordinal + internalUsageEngineIndex + 1;
}
return 0;
}
void setupHardwareCapabilities(HardwareCapabilities *caps, const HardwareInfo &hwInfo) override;
bool isL3Configurable(const HardwareInfo &hwInfo) override;

View File

@@ -987,6 +987,14 @@ struct IsGfxCore {
}
};
template <GFXCORE_FAMILY gfxCoreFamily>
struct IsAtMostGfxCore {
template <PRODUCT_FAMILY productFamily>
static constexpr bool isMatched() {
return NEO::ToGfxCoreFamily<productFamily>::get() <= gfxCoreFamily;
}
};
template <PRODUCT_FAMILY product>
struct IsProduct {
template <PRODUCT_FAMILY productFamily>