Remove engineIndex.

Change-Id: I58f7cf2c394686409dc45e315d1b5af33db2a28e
Signed-off-by: Piotr Fusik <piotr.fusik@intel.com>
This commit is contained in:
Piotr Fusik
2019-03-19 12:52:45 +01:00
committed by sys_ocldev
parent d27b5b59aa
commit 8c95b45e2f
11 changed files with 27 additions and 79 deletions

View File

@ -28,7 +28,6 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
typedef CommandStreamReceiverSimulatedHw<GfxFamily> BaseClass;
using AUB = typename AUBFamilyMapper<GfxFamily>::AUB;
using ExternalAllocationsContainer = std::vector<AllocationView>;
using BaseClass::engineIndex;
using BaseClass::getParametersForWriteMemory;
using BaseClass::osContext;

View File

@ -150,13 +150,12 @@ const std::string AUBCommandStreamReceiverHw<GfxFamily>::getFileName() {
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine() {
if (hardwareContextController) {
DEBUG_BREAK_IF(allEngineInstances[engineIndex].type != osContext->getEngineType().type);
hardwareContextController->initialize();
return;
}
auto csTraits = this->getCsTraits(osContext->getEngineType());
auto &engineInfo = engineInfoTable[engineIndex];
auto &engineInfo = engineInfoTable[osContext->getEngineType().type];
if (engineInfo.pLRCA) {
return;
@ -409,7 +408,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::submitBatchBuffer(uint64_t batchBuff
}
auto csTraits = this->getCsTraits(osContext->getEngineType());
auto &engineInfo = engineInfoTable[engineIndex];
auto &engineInfo = engineInfoTable[osContext->getEngineType().type];
{
{

View File

@ -30,7 +30,6 @@ class CommandStreamReceiverSimulatedCommonHw : public CommandStreamReceiverHw<Gf
using AUB = typename AUBFamilyMapper<GfxFamily>::AUB;
using MiContextDescriptorReg = typename AUB::MiContextDescriptorReg;
uint32_t engineIndex = 0;
bool getParametersForWriteMemory(GraphicsAllocation &graphicsAllocation, uint64_t &gpuAddress, void *&cpuAddress, size_t &size) const;
public:
@ -42,7 +41,6 @@ class CommandStreamReceiverSimulatedCommonHw : public CommandStreamReceiverHw<Gf
uint64_t getPPGTTAdditionalBits(GraphicsAllocation *gfxAllocation);
void getGTTData(void *memory, AubGTTData &data);
uint32_t getMemoryBankForGtt() const;
uint32_t getEngineIndex(EngineInstanceT engineInstance);
static const AubMemDump::LrcaHelper &getCsTraits(EngineInstanceT engineInstance);
void initEngineMMIO();
void submitLRCA(const MiContextDescriptorReg &contextDescriptor);
@ -67,7 +65,7 @@ class CommandStreamReceiverSimulatedCommonHw : public CommandStreamReceiverHw<Gf
uint32_t ggttRingBuffer;
size_t sizeRingBuffer;
uint32_t tailRingBuffer;
} engineInfoTable[EngineInstanceConstants::numAllEngineInstances] = {};
} engineInfoTable[EngineType::NUM_ENGINES] = {};
AubMemDump::AubStream *stream;
};

View File

@ -54,14 +54,6 @@ uint32_t CommandStreamReceiverSimulatedCommonHw<GfxFamily>::getMemoryBankForGtt(
return MemoryBanks::getBank(this->deviceIndex);
}
template <typename GfxFamily>
uint32_t CommandStreamReceiverSimulatedCommonHw<GfxFamily>::getEngineIndex(EngineInstanceT engineInstance) {
auto findCriteria = [&](const auto &it) { return it.type == engineInstance.type && it.id == engineInstance.id; };
auto findResult = std::find_if(allEngineInstances.begin(), allEngineInstances.end(), findCriteria);
UNRECOVERABLE_IF(findResult == allEngineInstances.end());
return static_cast<uint32_t>(findResult - allEngineInstances.begin());
}
template <typename GfxFamily>
const AubMemDump::LrcaHelper &CommandStreamReceiverSimulatedCommonHw<GfxFamily>::getCsTraits(EngineInstanceT engineInstance) {
return *AUBFamilyMapper<GfxFamily>::csTraits[engineInstance.type];
@ -91,12 +83,11 @@ void CommandStreamReceiverSimulatedCommonHw<GfxFamily>::setupContext(OsContext &
CommandStreamReceiverHw<GfxFamily>::setupContext(osContext);
auto engineType = osContext.getEngineType();
engineIndex = getEngineIndex(engineType);
uint32_t flags = 0;
getCsTraits(engineType).setContextSaveRestoreFlags(flags);
if (aubManager && !osContext.isLowPriority()) {
hardwareContextController = std::make_unique<HardwareContextController>(*aubManager, osContext, engineIndex, flags);
hardwareContextController = std::make_unique<HardwareContextController>(*aubManager, osContext, flags);
}
}

View File

@ -6,7 +6,6 @@
*/
#pragma once
#include <array>
#include <cstdint>
namespace OCLRT {
@ -21,7 +20,6 @@ enum EngineType : uint32_t {
namespace EngineInstanceConstants {
constexpr uint32_t lowPriorityGpgpuEngineIndex = 1;
constexpr size_t numAllEngineInstances = 5;
constexpr uint32_t numGpgpuEngineInstances = 2;
} // namespace EngineInstanceConstants
@ -34,13 +32,6 @@ struct EngineInstanceT {
};
constexpr EngineInstanceT lowPriorityGpgpuEngine{ENGINE_RCS, 1};
static constexpr std::array<EngineInstanceT, EngineInstanceConstants::numAllEngineInstances> allEngineInstances = {{
{ENGINE_RCS, 0},
lowPriorityGpgpuEngine,
{ENGINE_BCS},
{ENGINE_VCS},
{ENGINE_VECS},
}};
constexpr uint32_t maxOsContextCount = EngineInstanceConstants::numGpgpuEngineInstances;
constexpr uint32_t maxHandleCount = 1u;

View File

@ -31,7 +31,6 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
protected:
typedef CommandStreamReceiverSimulatedHw<GfxFamily> BaseClass;
using AUB = typename AUBFamilyMapper<GfxFamily>::AUB;
using BaseClass::engineIndex;
using BaseClass::getParametersForWriteMemory;
using BaseClass::osContext;

View File

@ -90,7 +90,7 @@ void TbxCommandStreamReceiverHw<GfxFamily>::initializeEngine() {
}
auto csTraits = this->getCsTraits(osContext->getEngineType());
auto &engineInfo = engineInfoTable[engineIndex];
auto &engineInfo = engineInfoTable[osContext->getEngineType().type];
if (engineInfo.pLRCA) {
return;
@ -231,7 +231,7 @@ void TbxCommandStreamReceiverHw<GfxFamily>::submitBatchBuffer(uint64_t batchBuff
}
auto csTraits = this->getCsTraits(osContext->getEngineType());
auto &engineInfo = engineInfoTable[engineIndex];
auto &engineInfo = engineInfoTable[osContext->getEngineType().type];
{
auto physBatchBuffer = ppgtt->map(static_cast<uintptr_t>(batchBufferGpuAddress), batchBufferSize, entryBits, memoryBank);

View File

@ -12,11 +12,11 @@
using namespace OCLRT;
HardwareContextController::HardwareContextController(aub_stream::AubManager &aubManager, OsContext &osContext, uint32_t engineIndex, uint32_t flags) {
HardwareContextController::HardwareContextController(aub_stream::AubManager &aubManager, OsContext &osContext, uint32_t flags) {
auto deviceBitfield = osContext.getDeviceBitfield();
for (uint32_t deviceIndex = 0; deviceIndex < deviceBitfield.size(); deviceIndex++) {
if (deviceBitfield.test(deviceIndex)) {
hardwareContexts.emplace_back(aubManager.createHardwareContext(deviceIndex, engineIndex, flags));
hardwareContexts.emplace_back(aubManager.createHardwareContext(deviceIndex, osContext.getEngineType().type, flags));
}
}
}

View File

@ -18,7 +18,7 @@ class OsContext;
class HardwareContextController {
public:
HardwareContextController() = delete;
HardwareContextController(aub_stream::AubManager &aubManager, OsContext &osContext, uint32_t engineIndex, uint32_t flags);
HardwareContextController(aub_stream::AubManager &aubManager, OsContext &osContext, uint32_t flags);
void initialize();
void pollForCompletion();

View File

@ -88,31 +88,6 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenItIsCre
EXPECT_EQ(nullptr, aubCsr->hardwareContextController);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGetEngineIndexFromInstanceIsCalledForGivenEngineInstanceThenEngineIndexForThatInstanceIsReturned) {
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
EXPECT_NE(nullptr, aubCsr);
EXPECT_TRUE(aubCsr->getEngineIndex(EngineInstanceT(EngineType::ENGINE_RCS, 0)) < allEngineInstances.size());
EXPECT_TRUE(aubCsr->getEngineIndex(EngineInstanceT(EngineType::ENGINE_RCS, 1)) < allEngineInstances.size());
EXPECT_TRUE(aubCsr->getEngineIndex(EngineInstanceT(EngineType::ENGINE_BCS, 0)) < allEngineInstances.size());
EXPECT_TRUE(aubCsr->getEngineIndex(EngineInstanceT(EngineType::ENGINE_VCS, 0)) < allEngineInstances.size());
EXPECT_TRUE(aubCsr->getEngineIndex(EngineInstanceT(EngineType::ENGINE_VECS, 0)) < allEngineInstances.size());
EXPECT_THROW(aubCsr->getEngineIndex(EngineInstanceT(EngineType::ENGINE_RCS, 2)), std::exception);
EXPECT_THROW(aubCsr->getEngineIndex(EngineInstanceT(EngineType::ENGINE_BCS, 1)), std::exception);
EXPECT_THROW(aubCsr->getEngineIndex(EngineInstanceT(EngineType::ENGINE_VCS, 1)), std::exception);
EXPECT_THROW(aubCsr->getEngineIndex(EngineInstanceT(EngineType::ENGINE_VECS, 1)), std::exception);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGetEngineIndexIsCalledForGivenEngineTypeThenEngineIndexForThatTypeIsReturned) {
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
EXPECT_NE(nullptr, aubCsr);
auto engineIndex = aubCsr->getEngineIndex(EngineInstanceT(EngineType::ENGINE_RCS, 1));
EXPECT_EQ(EngineType::ENGINE_RCS, allEngineInstances[engineIndex].type);
EXPECT_EQ(1, allEngineInstances[engineIndex].id);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenItIsCreatedWithDefaultSettingsThenItHasBatchedDispatchModeEnabled) {
DebugManagerStateRestore stateRestore;
DebugManager.flags.CsrDispatchMode.set(0);
@ -188,17 +163,16 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWithAubMana
ExecutionEnvironment executionEnvironment;
executionEnvironment.aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(reinterpret_cast<AUBCommandStreamReceiverHw<FamilyType> *>(AUBCommandStreamReceiver::create(hwInfo, fileName, true, executionEnvironment)));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(static_cast<AUBCommandStreamReceiverHw<FamilyType> *>(AUBCommandStreamReceiver::create(hwInfo, fileName, true, executionEnvironment)));
ASSERT_NE(nullptr, aubCsr);
EXPECT_TRUE(aubCsr->isFileOpen());
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenOsContextIsSetThenCreateHardwareContext) {
uint32_t engineIndex = 2;
uint32_t deviceIndex = 3;
MockOsContext osContext(0, 8, allEngineInstances[engineIndex], PreemptionMode::Disabled, false);
MockOsContext osContext(0, 8, {EngineType::ENGINE_BCS}, PreemptionMode::Disabled, false);
std::string fileName = "file_name.aub";
MockAubManager *mockManager = new MockAubManager();
MockAubCenter *mockAubCenter = new MockAubCenter(platformDevices[0], false, fileName, CommandStreamReceiverType::CSR_AUB);
@ -206,7 +180,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenOsContextIsSetThenCreateH
ExecutionEnvironment executionEnvironment;
executionEnvironment.aubCenter = std::unique_ptr<MockAubCenter>(mockAubCenter);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(reinterpret_cast<AUBCommandStreamReceiverHw<FamilyType> *>(AUBCommandStreamReceiver::create(*platformDevices[0], fileName, true, executionEnvironment)));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(static_cast<AUBCommandStreamReceiverHw<FamilyType> *>(AUBCommandStreamReceiver::create(*platformDevices[0], fileName, true, executionEnvironment)));
aubCsr->setDeviceIndex(deviceIndex);
EXPECT_EQ(nullptr, aubCsr->hardwareContextController.get());
@ -214,7 +188,6 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenOsContextIsSetThenCreateH
EXPECT_NE(nullptr, aubCsr->hardwareContextController.get());
auto mockHardwareContext = static_cast<MockHardwareContext *>(aubCsr->hardwareContextController->hardwareContexts[0].get());
EXPECT_EQ(deviceIndex, mockHardwareContext->deviceIndex);
EXPECT_EQ(engineIndex, mockHardwareContext->engineIndex);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenLowPriorityOsContextIsSetThenDontCreateHardwareContext) {
@ -238,7 +211,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptur
DebugManager.flags.AUBDumpSubCaptureMode.set(static_cast<int32_t>(AubSubCaptureManager::SubCaptureMode::Filter));
HardwareInfo hwInfo = *platformDevices[0];
std::string fileName = "file_name.aub";
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(reinterpret_cast<AUBCommandStreamReceiverHw<FamilyType> *>(AUBCommandStreamReceiver::create(hwInfo, fileName, true, *pDevice->executionEnvironment)));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(static_cast<AUBCommandStreamReceiverHw<FamilyType> *>(AUBCommandStreamReceiver::create(hwInfo, fileName, true, *pDevice->executionEnvironment)));
EXPECT_NE(nullptr, aubCsr);
EXPECT_FALSE(aubCsr->isFileOpen());
}
@ -311,11 +284,11 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenFlushIs
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
ResidencyContainer allocationsForResidency = {};
auto engineIndex = aubCsr->getEngineIndex(aubCsr->getOsContext().getEngineType());
const auto &engineInfo = aubCsr->engineInfoTable[aubCsr->getOsContext().getEngineType().type];
aubCsr->flush(batchBuffer, allocationsForResidency);
EXPECT_NE(nullptr, aubCsr->engineInfoTable[engineIndex].pLRCA);
EXPECT_NE(nullptr, aubCsr->engineInfoTable[engineIndex].pGlobalHWStatusPage);
EXPECT_NE(nullptr, aubCsr->engineInfoTable[engineIndex].pRingBuffer);
EXPECT_NE(nullptr, engineInfo.pLRCA);
EXPECT_NE(nullptr, engineInfo.pGlobalHWStatusPage);
EXPECT_NE(nullptr, engineInfo.pRingBuffer);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenProcessResidencyIsCalledButSubCaptureIsDisabledThenItShouldntWriteMemory) {
@ -1102,7 +1075,7 @@ TEST_F(HardwareContextContainerTests, givenOsContextWithMultipleDevicesSupported
deviceBitfield.set(1);
MockOsContext osContext(1, deviceBitfield, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled, false);
HardwareContextController hwContextControler(aubManager, osContext, 0, 0);
HardwareContextController hwContextControler(aubManager, osContext, 0);
EXPECT_EQ(2u, hwContextControler.hardwareContexts.size());
EXPECT_EQ(2u, osContext.getNumSupportedDevices());
auto mockHwContext0 = static_cast<MockHardwareContext *>(hwContextControler.hardwareContexts[0].get());
@ -1117,7 +1090,7 @@ TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCa
deviceBitfield.set(0);
deviceBitfield.set(1);
MockOsContext osContext(1, deviceBitfield, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled, false);
HardwareContextController hwContextContainer(aubManager, osContext, 3, 0);
HardwareContextController hwContextContainer(aubManager, osContext, 0);
EXPECT_EQ(2u, hwContextContainer.hardwareContexts.size());
auto mockHwContext0 = static_cast<MockHardwareContext *>(hwContextContainer.hardwareContexts[0].get());
@ -1158,7 +1131,7 @@ TEST_F(HardwareContextContainerTests, givenMultipleHwContextWhenSingleMethodIsCa
deviceBitfield.set(0);
deviceBitfield.set(1);
MockOsContext osContext(1, deviceBitfield, {EngineType::ENGINE_RCS, 0}, PreemptionMode::Disabled, false);
HardwareContextController hwContextContainer(aubManager, osContext, 2, 0);
HardwareContextController hwContextContainer(aubManager, osContext, 0);
EXPECT_EQ(2u, hwContextContainer.hardwareContexts.size());
auto mockHwContext0 = static_cast<MockHardwareContext *>(hwContextContainer.hardwareContexts[0].get());

View File

@ -9,18 +9,17 @@
#include "third_party/aub_stream/headers/hardware_context.h"
struct MockHardwareContext : public aub_stream::HardwareContext {
MockHardwareContext(uint32_t deviceIndex, uint32_t engineIndex)
: deviceIndex(deviceIndex), engineIndex(engineIndex){};
~MockHardwareContext() override{};
MockHardwareContext(uint32_t deviceIndex) : deviceIndex(deviceIndex) {}
~MockHardwareContext() override {}
void initialize() override { initializeCalled = true; }
void pollForCompletion() override { pollForCompletionCalled = true; };
void pollForCompletion() override { pollForCompletionCalled = true; }
void submit(uint64_t gfxAddress, const void *batchBuffer, size_t size, uint32_t memoryBank, size_t pageSize = 65536) override { submitCalled = true; }
void writeMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t memoryBanks, int hint, size_t pageSize = 65536) override { writeMemoryCalled = true; }
void freeMemory(uint64_t gfxAddress, size_t size) override { freeMemoryCalled = true; }
void expectMemory(uint64_t gfxAddress, const void *memory, size_t size, uint32_t compareOperation) override { expectMemoryCalled = true; }
void readMemory(uint64_t gfxAddress, void *memory, size_t size, uint32_t memoryBank, size_t pageSize) override { readMemoryCalled = true; };
void dumpBufferBIN(uint64_t gfxAddress, size_t size) override { dumpBufferBINCalled = true; };
void readMemory(uint64_t gfxAddress, void *memory, size_t size, uint32_t memoryBank, size_t pageSize) override { readMemoryCalled = true; }
void dumpBufferBIN(uint64_t gfxAddress, size_t size) override { dumpBufferBINCalled = true; }
bool initializeCalled = false;
bool pollForCompletionCalled = false;
@ -31,8 +30,7 @@ struct MockHardwareContext : public aub_stream::HardwareContext {
bool readMemoryCalled = false;
bool dumpBufferBINCalled = false;
uint32_t deviceIndex = 0;
uint32_t engineIndex = 0;
const uint32_t deviceIndex;
};
class MockAubManager : public aub_stream::AubManager {
@ -52,7 +50,7 @@ class MockAubManager : public aub_stream::AubManager {
HardwareContext *createHardwareContext(uint32_t device, uint32_t engine) { return createHardwareContext(device, engine, 0); }
HardwareContext *createHardwareContext(uint32_t device, uint32_t engine, uint32_t flags) override {
contextFlags = flags;
return new MockHardwareContext(device, engine);
return new MockHardwareContext(device);
}
void open(const std::string &aubFileName) override {