Add helper engines to EngineInstanced Device
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
parent
274fe055e9
commit
4fb5ceeb89
|
@ -1552,8 +1552,8 @@ struct CommandQueueOnSpecificEngineTests : ::testing::Test {
|
|||
template <typename GfxFamily, int rcsCount, int ccsCount, int bcsCount>
|
||||
class MockHwHelper : public HwHelperHw<GfxFamily> {
|
||||
public:
|
||||
const HwHelper::EngineInstancesContainer getGpgpuEngineInstances(const HardwareInfo &hwInfo) const override {
|
||||
HwHelper::EngineInstancesContainer result{};
|
||||
const EngineInstancesContainer getGpgpuEngineInstances(const HardwareInfo &hwInfo) const override {
|
||||
EngineInstancesContainer result{};
|
||||
for (int i = 0; i < rcsCount; i++) {
|
||||
result.push_back({aub_stream::ENGINE_RCS, EngineUsage::Regular});
|
||||
}
|
||||
|
|
|
@ -678,8 +678,8 @@ TEST(GetDeviceInfo, WhenQueryingGenericAddressSpaceSupportThenProperValueIsRetur
|
|||
template <typename GfxFamily, int ccsCount, int bcsCount>
|
||||
class MockHwHelper : public HwHelperHw<GfxFamily> {
|
||||
public:
|
||||
const HwHelper::EngineInstancesContainer getGpgpuEngineInstances(const HardwareInfo &hwInfo) const override {
|
||||
HwHelper::EngineInstancesContainer result{};
|
||||
const EngineInstancesContainer getGpgpuEngineInstances(const HardwareInfo &hwInfo) const override {
|
||||
EngineInstancesContainer result{};
|
||||
for (int i = 0; i < ccsCount; i++) {
|
||||
result.push_back({aub_stream::ENGINE_CCS, EngineUsage::Regular});
|
||||
}
|
||||
|
|
|
@ -366,7 +366,14 @@ struct EngineInstancedDeviceTests : public ::testing::Test {
|
|||
|
||||
template <typename MockDeviceT>
|
||||
bool hasEngineInstancedEngines(MockDeviceT *device, aub_stream::EngineType engineType) {
|
||||
bool ccsFound = false;
|
||||
bool regularCcsFound = false;
|
||||
bool internalCcsFound = false;
|
||||
bool lowPriorityCcsFound = false;
|
||||
|
||||
OsContext *defaultOsContext = device->getDefaultEngine().osContext;
|
||||
EXPECT_EQ(engineType, defaultOsContext->getEngineType());
|
||||
EXPECT_EQ(EngineUsage::Regular, defaultOsContext->getEngineUsage());
|
||||
EXPECT_TRUE(defaultOsContext->isDefaultContext());
|
||||
|
||||
for (auto &engine : device->engines) {
|
||||
if ((engine.getEngineType() != engineType) && !EngineHelpers::isBcs(engine.getEngineType())) {
|
||||
|
@ -377,17 +384,25 @@ struct EngineInstancedDeviceTests : public ::testing::Test {
|
|||
|
||||
auto osContext = engine.osContext;
|
||||
|
||||
if ((engine.getEngineType() == engineType) &&
|
||||
osContext->isDefaultContext() &&
|
||||
osContext->isRegular() &&
|
||||
!osContext->isLowPriority() &&
|
||||
!osContext->isInternalEngine()) {
|
||||
EXPECT_FALSE(ccsFound);
|
||||
ccsFound = true;
|
||||
if (engine.getEngineType() == engineType) {
|
||||
if (osContext->isRegular()) {
|
||||
EXPECT_FALSE(regularCcsFound);
|
||||
regularCcsFound = true;
|
||||
} else if (osContext->isLowPriority()) {
|
||||
EXPECT_FALSE(lowPriorityCcsFound);
|
||||
lowPriorityCcsFound = true;
|
||||
} else if (osContext->isInternalEngine()) {
|
||||
EXPECT_FALSE(internalCcsFound);
|
||||
internalCcsFound = true;
|
||||
} else {
|
||||
EXPECT_TRUE(false);
|
||||
}
|
||||
} else if (!EngineHelpers::isBcs(engine.getEngineType())) {
|
||||
EXPECT_TRUE(false);
|
||||
}
|
||||
}
|
||||
|
||||
return ccsFound;
|
||||
return (regularCcsFound && internalCcsFound && lowPriorityCcsFound);
|
||||
}
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
|
|
|
@ -261,21 +261,36 @@ bool Device::createDeviceImpl() {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Device::engineSupported(const EngineTypeUsage &engineTypeUsage) const {
|
||||
if (engineInstanced) {
|
||||
return (EngineHelpers::isBcs(engineTypeUsage.first) || (engineTypeUsage.first == this->engineInstancedType));
|
||||
void Device::translateToEngineInstanced(EngineInstancesContainer &engineInstancesContainer) {
|
||||
EngineInstancesContainer newEngines;
|
||||
|
||||
for (auto &engine : engineInstancesContainer) {
|
||||
if (EngineHelpers::isBcs(engine.first) || (engine.first == this->engineInstancedType) || (engine.second != EngineUsage::Regular)) {
|
||||
newEngines.push_back(engine);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Override non-Regular (internal, low priority, ..) to engineInstancedType
|
||||
if (newEngines.rbegin()->second != EngineUsage::Regular && !EngineHelpers::isBcs(newEngines.rbegin()->first)) {
|
||||
newEngines.rbegin()->first = this->engineInstancedType;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
std::swap(newEngines, engineInstancesContainer);
|
||||
}
|
||||
|
||||
bool Device::createEngines() {
|
||||
auto &hwInfo = getHardwareInfo();
|
||||
auto gpgpuEngines = HwHelper::get(hwInfo.platform.eRenderCoreFamily).getGpgpuEngineInstances(hwInfo);
|
||||
|
||||
if (engineInstanced) {
|
||||
translateToEngineInstanced(gpgpuEngines);
|
||||
}
|
||||
|
||||
uint32_t deviceCsrIndex = 0;
|
||||
for (auto &engine : gpgpuEngines) {
|
||||
if (engineSupported(engine) && !createEngine(deviceCsrIndex++, engine)) {
|
||||
if (!createEngine(deviceCsrIndex++, engine)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -307,7 +322,7 @@ bool Device::createEngine(uint32_t deviceCsrIndex, EngineTypeUsage engineTypeUsa
|
|||
const auto &hwInfo = getHardwareInfo();
|
||||
const auto engineType = engineTypeUsage.first;
|
||||
const auto engineUsage = engineTypeUsage.second;
|
||||
const auto defaultEngineType = getChosenEngineType(hwInfo);
|
||||
const auto defaultEngineType = engineInstanced ? this->engineInstancedType : getChosenEngineType(hwInfo);
|
||||
const bool isDefaultEngine = defaultEngineType == engineType && engineUsage == EngineUsage::Regular;
|
||||
const bool createAsEngineInstanced = engineInstanced && EngineHelpers::isCcs(engineType);
|
||||
|
||||
|
|
|
@ -143,7 +143,6 @@ class Device : public ReferenceTrackedObject<Device> {
|
|||
virtual bool createEngines();
|
||||
|
||||
void addEngineToEngineGroup(EngineControl &engine);
|
||||
bool engineSupported(const EngineTypeUsage &engineTypeUsage) const;
|
||||
MOCKABLE_VIRTUAL bool createEngine(uint32_t deviceCsrIndex, EngineTypeUsage engineTypeUsage);
|
||||
MOCKABLE_VIRTUAL std::unique_ptr<CommandStreamReceiver> createCommandStreamReceiver() const;
|
||||
MOCKABLE_VIRTUAL SubDevice *createSubDevice(uint32_t subDeviceIndex);
|
||||
|
@ -156,6 +155,7 @@ class Device : public ReferenceTrackedObject<Device> {
|
|||
virtual bool genericSubDevicesAllowed();
|
||||
bool engineInstancedSubDevicesAllowed();
|
||||
void setAsEngineInstanced();
|
||||
void translateToEngineInstanced(EngineInstancesContainer &engineInstancesContainer);
|
||||
|
||||
DeviceInfo deviceInfo = {};
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ uint32_t HwHelperHw<Family>::getMetricsLibraryGenId() const {
|
|||
}
|
||||
|
||||
template <>
|
||||
const HwHelper::EngineInstancesContainer HwHelperHw<Family>::getGpgpuEngineInstances(const HardwareInfo &hwInfo) const {
|
||||
const EngineInstancesContainer HwHelperHw<Family>::getGpgpuEngineInstances(const HardwareInfo &hwInfo) const {
|
||||
auto defaultEngine = getChosenEngineType(hwInfo);
|
||||
|
||||
EngineInstancesContainer engines = {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "shared/source/command_stream/preemption_mode.h"
|
||||
#include "shared/source/helpers/common_types.h"
|
||||
#include "shared/source/utilities/stackvec.h"
|
||||
|
||||
#include "engine_node.h"
|
||||
|
||||
|
@ -29,6 +30,7 @@ enum class EngineUsage : uint32_t {
|
|||
};
|
||||
|
||||
using EngineTypeUsage = std::pair<aub_stream::EngineType, EngineUsage>;
|
||||
using EngineInstancesContainer = StackVec<EngineTypeUsage, 32>;
|
||||
|
||||
struct EngineDescriptor {
|
||||
EngineDescriptor() = delete;
|
||||
|
|
|
@ -44,7 +44,6 @@ enum class LocalMemoryAccessMode {
|
|||
|
||||
class HwHelper {
|
||||
public:
|
||||
using EngineInstancesContainer = StackVec<EngineTypeUsage, 32>;
|
||||
static HwHelper &get(GFXCORE_FAMILY gfxCore);
|
||||
virtual uint32_t getBindingTableStateSurfaceStatePointer(const void *pBindingTable, uint32_t index) = 0;
|
||||
virtual size_t getBindingTableStateSize() const = 0;
|
||||
|
|
|
@ -51,7 +51,7 @@ bool HwHelperHw<GfxFamily>::timestampPacketWriteSupported() const {
|
|||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
const HwHelper::EngineInstancesContainer HwHelperHw<GfxFamily>::getGpgpuEngineInstances(const HardwareInfo &hwInfo) const {
|
||||
const EngineInstancesContainer HwHelperHw<GfxFamily>::getGpgpuEngineInstances(const HardwareInfo &hwInfo) const {
|
||||
return {
|
||||
{aub_stream::ENGINE_RCS, EngineUsage::Regular},
|
||||
{aub_stream::ENGINE_RCS, EngineUsage::LowPriority},
|
||||
|
|
|
@ -65,7 +65,7 @@ bool HwHelperHw<GfxFamily>::timestampPacketWriteSupported() const {
|
|||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
const HwHelper::EngineInstancesContainer HwHelperHw<GfxFamily>::getGpgpuEngineInstances(const HardwareInfo &hwInfo) const {
|
||||
const EngineInstancesContainer HwHelperHw<GfxFamily>::getGpgpuEngineInstances(const HardwareInfo &hwInfo) const {
|
||||
auto defaultEngine = getChosenEngineType(hwInfo);
|
||||
|
||||
EngineInstancesContainer engines;
|
||||
|
|
Loading…
Reference in New Issue