Skip to content

Commit

Permalink
refactor: Allow for grouping BCS1+ copy engines in more engine group …
Browse files Browse the repository at this point in the history
…types

Do not group copy engines from BCS1+ in linked copy group by default.

Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
  • Loading branch information
km-nowak authored and Compute-Runtime-Automation committed Jan 23, 2024
1 parent f9f9035 commit 6cf71cc
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2023 Intel Corporation
* Copyright (C) 2021-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -206,7 +206,12 @@ HWTEST2_F(CommandQueuePvcAndLaterTests, givenAdditionalBcsWhenCreatingCommandQue
MockClDevice clDevice{device};
MockContext context{&clDevice};

const auto familyIndex = device->getEngineGroupIndexFromEngineGroupType(EngineGroupType::linkedCopy);
const auto &productHelper = device->getExecutionEnvironment()->rootDeviceEnvironments[0]->getProductHelper();
auto engineGroupType = EngineGroupType::linkedCopy;
if (aub_stream::EngineType::ENGINE_BCS != productHelper.getDefaultCopyEngine()) {
engineGroupType = EngineGroupType::copy;
}
const auto familyIndex = device->getEngineGroupIndexFromEngineGroupType(engineGroupType);
cl_command_queue_properties queueProperties[5] = {
CL_QUEUE_FAMILY_INTEL,
familyIndex,
Expand Down Expand Up @@ -574,9 +579,14 @@ struct BcsCsrSelectionCommandQueueTests : ::testing::Test {
}

std::unique_ptr<MockCommandQueue> createQueueWithLinkBcsSelectedWithQueueFamilies(size_t linkBcsIndex) {
const auto &productHelper = device->getRootDeviceEnvironment().getProductHelper();
auto engineGroupType = EngineGroupType::linkedCopy;
if (aub_stream::EngineType::ENGINE_BCS != productHelper.getDefaultCopyEngine()) {
engineGroupType = EngineGroupType::copy;
}
cl_command_queue_properties queueProperties[5] = {};
queueProperties[0] = CL_QUEUE_FAMILY_INTEL;
queueProperties[1] = device->getEngineGroupIndexFromEngineGroupType(EngineGroupType::linkedCopy);
queueProperties[1] = device->getEngineGroupIndexFromEngineGroupType(engineGroupType);
queueProperties[2] = CL_QUEUE_INDEX_INTEL;
queueProperties[3] = linkBcsIndex;
auto queue = createQueue(queueProperties);
Expand Down
4 changes: 3 additions & 1 deletion shared/source/device/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,11 @@ bool Device::createEngines() {
void Device::addEngineToEngineGroup(EngineControl &engine) {
auto &hardwareInfo = this->getHardwareInfo();
auto &gfxCoreHelper = getGfxCoreHelper();
auto &productHelper = getProductHelper();
auto &rootDeviceEnvironment = this->getRootDeviceEnvironment();

const EngineGroupType engineGroupType = gfxCoreHelper.getEngineGroupType(engine.getEngineType(), engine.getEngineUsage(), hardwareInfo);
EngineGroupType engineGroupType = gfxCoreHelper.getEngineGroupType(engine.getEngineType(), engine.getEngineUsage(), hardwareInfo);
productHelper.adjustEngineGroupType(engineGroupType);

if (!gfxCoreHelper.isSubDeviceEngineSupported(rootDeviceEnvironment, getDeviceBitfield(), engine.getEngineType())) {
return;
Expand Down
2 changes: 2 additions & 0 deletions shared/source/os_interface/product_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ struct RootDeviceEnvironment;
class OSInterface;
class DriverModel;
enum class DriverModelType;
enum class EngineGroupType : uint32_t;

using ProductHelperCreateFunctionType = std::unique_ptr<ProductHelper> (*)();
extern ProductHelperCreateFunctionType productHelperFactory[IGFX_MAX_PRODUCT];
Expand Down Expand Up @@ -213,6 +214,7 @@ class ProductHelper {
virtual uint64_t overridePatIndex(bool isUncachedType, uint64_t patIndex) const = 0;
virtual std::vector<uint32_t> getSupportedNumGrfs(const ReleaseHelper *releaseHelper) const = 0;
virtual aub_stream::EngineType getDefaultCopyEngine() const = 0;
virtual void adjustEngineGroupType(EngineGroupType &engineGroupType) const = 0;

virtual ~ProductHelper() = default;

Expand Down
3 changes: 3 additions & 0 deletions shared/source/os_interface/product_helper.inl
Original file line number Diff line number Diff line change
Expand Up @@ -836,4 +836,7 @@ aub_stream::EngineType ProductHelperHw<gfxProduct>::getDefaultCopyEngine() const
return aub_stream::EngineType::ENGINE_BCS;
}

template <PRODUCT_FAMILY gfxProduct>
void ProductHelperHw<gfxProduct>::adjustEngineGroupType(EngineGroupType &engineGroupType) const {}

} // namespace NEO
1 change: 1 addition & 0 deletions shared/source/os_interface/product_helper_hw.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class ProductHelperHw : public ProductHelper {
uint64_t overridePatIndex(bool isUncachedType, uint64_t patIndex) const override;
std::vector<uint32_t> getSupportedNumGrfs(const ReleaseHelper *releaseHelper) const override;
aub_stream::EngineType getDefaultCopyEngine() const override;
void adjustEngineGroupType(EngineGroupType &engineGroupType) const override;

~ProductHelperHw() override = default;

Expand Down
9 changes: 9 additions & 0 deletions shared/test/unit_test/os_interface/product_helper_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,3 +859,12 @@ HWTEST_F(ProductHelperTest, givenProductHelperWhenGettingSupportedNumGrfsThenCor
HWTEST_F(ProductHelperTest, givenProductHelperWhenGettingDefaultCopyEngineThenEngineBCSIsReturned) {
EXPECT_EQ(aub_stream::EngineType::ENGINE_BCS, productHelper->getDefaultCopyEngine());
}

HWTEST_F(ProductHelperTest, givenProductHelperWhenAdjustingEnginesGroupThenDoNotChangeEngineGroups) {
for (uint32_t engineGroupIt = static_cast<uint32_t>(EngineGroupType::compute); engineGroupIt < static_cast<uint32_t>(EngineGroupType::maxEngineGroups); engineGroupIt++) {
auto engineGroupType = static_cast<EngineGroupType>(engineGroupIt);
auto engineGroupTypeUnchanged = engineGroupType;
productHelper->adjustEngineGroupType(engineGroupType);
EXPECT_EQ(engineGroupTypeUnchanged, engineGroupType);
}
}

0 comments on commit 6cf71cc

Please sign in to comment.