Skip to content

Commit cd8f08b

Browse files
committed
AUB CSR functions to operate on engine instance
Change-Id: I928cf5f7c25980fdfb2da825cbe062b5497c328a
1 parent 0a7c13f commit cd8f08b

File tree

8 files changed

+53
-66
lines changed

8 files changed

+53
-66
lines changed

runtime/command_stream/aub_command_stream_receiver_hw.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
4444
void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override;
4545

4646
// Family specific version
47-
void submitLRCA(EngineType engineType, const MiContextDescriptorReg &contextDescriptor);
48-
MOCKABLE_VIRTUAL void pollForCompletion(EngineType engineType);
47+
void submitLRCA(EngineInstanceT engineInstance, const MiContextDescriptorReg &contextDescriptor);
48+
MOCKABLE_VIRTUAL void pollForCompletion(EngineInstanceT engineInstance);
4949
void initGlobalMMIO();
50-
void initEngineMMIO(EngineType engineType);
50+
void initEngineMMIO(EngineInstanceT engineInstance);
5151

5252
MOCKABLE_VIRTUAL void addContextToken(uint32_t dumpHandle);
5353

@@ -66,16 +66,15 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
6666
MOCKABLE_VIRTUAL bool isFileOpen() const;
6767
MOCKABLE_VIRTUAL const std::string &getFileName();
6868

69-
void initializeEngine(size_t engineInstance);
69+
void initializeEngine(size_t engineIndex);
7070
void freeEngineInfoTable();
7171

7272
MemoryManager *createMemoryManager(bool enable64kbPages, bool enableLocalMemory) override {
7373
return new OsAgnosticMemoryManager(enable64kbPages, enableLocalMemory, true, this->executionEnvironment);
7474
}
7575

76-
static const AubMemDump::LrcaHelper &getCsTraits(EngineType engineType);
77-
static void setCsTraits(EngineType engineType, const AubMemDump::LrcaHelper *lrca);
78-
size_t getEngineInstance(EngineType engineType);
76+
static const AubMemDump::LrcaHelper &getCsTraits(EngineInstanceT engineInstance);
77+
size_t getEngineIndex(EngineType engineType);
7978

8079
struct EngineInfo {
8180
void *pLRCA;
@@ -87,7 +86,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
8786
size_t sizeRingBuffer;
8887
uint32_t tailRingBuffer;
8988
} engineInfoTable[arrayCount(allEngineInstances)] = {};
90-
size_t gpgpuEngineInstance = arrayCount(gpgpuEngineInstances) - 1;
89+
size_t gpgpuEngineIndex = arrayCount(gpgpuEngineInstances) - 1;
9190

9291
AUBCommandStreamReceiver::AubFileStream *stream;
9392
std::unique_ptr<AubSubCaptureManager> subCaptureManager;

runtime/command_stream/aub_command_stream_receiver_hw.inl

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,12 @@ AUBCommandStreamReceiverHw<GfxFamily>::~AUBCommandStreamReceiverHw() {
8585
}
8686

8787
template <typename GfxFamily>
88-
const AubMemDump::LrcaHelper &AUBCommandStreamReceiverHw<GfxFamily>::getCsTraits(EngineType engineType) {
89-
return *AUBFamilyMapper<GfxFamily>::csTraits[engineType];
88+
const AubMemDump::LrcaHelper &AUBCommandStreamReceiverHw<GfxFamily>::getCsTraits(EngineInstanceT engineInstance) {
89+
return *AUBFamilyMapper<GfxFamily>::csTraits[engineInstance.type];
9090
}
9191

9292
template <typename GfxFamily>
93-
void AUBCommandStreamReceiverHw<GfxFamily>::setCsTraits(EngineType engineType, const AubMemDump::LrcaHelper *lrca) {
94-
AUBFamilyMapper<GfxFamily>::csTraits[engineType] = lrca;
95-
}
96-
97-
template <typename GfxFamily>
98-
size_t AUBCommandStreamReceiverHw<GfxFamily>::getEngineInstance(EngineType engineType) {
93+
size_t AUBCommandStreamReceiverHw<GfxFamily>::getEngineIndex(EngineType engineType) {
9994
constexpr auto numAllEngines = arrayCount(allEngineInstances);
10095
constexpr auto findBegin = allEngineInstances;
10196
constexpr auto findEnd = findBegin + numAllEngines;
@@ -113,8 +108,8 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initGlobalMMIO() {
113108
}
114109

115110
template <typename GfxFamily>
116-
void AUBCommandStreamReceiverHw<GfxFamily>::initEngineMMIO(EngineType engineType) {
117-
auto mmioList = AUBFamilyMapper<GfxFamily>::perEngineMMIO[engineType];
111+
void AUBCommandStreamReceiverHw<GfxFamily>::initEngineMMIO(EngineInstanceT engineInstance) {
112+
auto mmioList = AUBFamilyMapper<GfxFamily>::perEngineMMIO[engineInstance.type];
118113

119114
DEBUG_BREAK_IF(!mmioList);
120115
for (auto &mmioPair : *mmioList) {
@@ -176,13 +171,13 @@ const std::string &AUBCommandStreamReceiverHw<GfxFamily>::getFileName() {
176171
}
177172

178173
template <typename GfxFamily>
179-
void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine(size_t engineInstance) {
180-
auto engineType = allEngineInstances[engineInstance].type;
181-
auto mmioBase = getCsTraits(engineType).mmioBase;
182-
auto &engineInfo = engineInfoTable[engineInstance];
174+
void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine(size_t engineIndex) {
175+
auto engineInstance = allEngineInstances[engineIndex];
176+
auto mmioBase = getCsTraits(engineInstance).mmioBase;
177+
auto &engineInfo = engineInfoTable[engineIndex];
183178

184179
initGlobalMMIO();
185-
initEngineMMIO(engineType);
180+
initEngineMMIO(engineInstance);
186181

187182
// Global HW Status Page
188183
{
@@ -207,7 +202,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine(size_t engineInstan
207202
}
208203

209204
// Allocate the LRCA
210-
auto csTraits = getCsTraits(engineType);
205+
auto csTraits = getCsTraits(engineInstance);
211206
const size_t sizeLRCA = csTraits.sizeLRCA;
212207
const size_t alignLRCA = csTraits.alignLRCA;
213208
auto pLRCABase = alignedMalloc(sizeLRCA, alignLRCA);
@@ -315,13 +310,14 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
315310
}
316311

317312
auto streamLocked = stream->lockStream();
318-
auto engineInstance = getEngineInstance(engineType);
319-
engineType = allEngineInstances[engineInstance].type;
320-
uint32_t mmioBase = getCsTraits(engineType).mmioBase;
321-
auto &engineInfo = engineInfoTable[engineInstance];
313+
auto engineIndex = getEngineIndex(engineType);
314+
auto engineInstance = allEngineInstances[engineIndex];
315+
engineType = engineInstance.type;
316+
uint32_t mmioBase = getCsTraits(engineInstance).mmioBase;
317+
auto &engineInfo = engineInfoTable[engineIndex];
322318

323319
if (!engineInfo.pLRCA) {
324-
initializeEngine(engineInstance);
320+
initializeEngine(engineIndex);
325321
DEBUG_BREAK_IF(!engineInfo.pLRCA);
326322
}
327323

@@ -478,7 +474,7 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
478474
physLRCA + 0x101c,
479475
&engineInfo.tailRingBuffer,
480476
sizeof(engineInfo.tailRingBuffer),
481-
this->getAddressSpace(getCsTraits(engineType).aubHintLRCA));
477+
this->getAddressSpace(getCsTraits(engineInstance).aubHintLRCA));
482478

483479
DEBUG_BREAK_IF(engineInfo.tailRingBuffer >= engineInfo.sizeRingBuffer);
484480
}
@@ -499,10 +495,10 @@ FlushStamp AUBCommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer
499495
contextDescriptor.sData.LogicalRingCtxAddress = ggttLRCA / 4096;
500496
contextDescriptor.sData.ContextID = 0;
501497

502-
submitLRCA(engineType, contextDescriptor);
498+
submitLRCA(engineInstance, contextDescriptor);
503499
}
504500

505-
pollForCompletion(engineType);
501+
pollForCompletion(engineInstance);
506502
if (this->standalone) {
507503
*this->tagAddress = this->peekLatestSentTaskCount();
508504
}
@@ -559,19 +555,19 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::addPatchInfoComments() {
559555
}
560556

561557
template <typename GfxFamily>
562-
void AUBCommandStreamReceiverHw<GfxFamily>::submitLRCA(EngineType engineType, const typename AUBCommandStreamReceiverHw<GfxFamily>::MiContextDescriptorReg &contextDescriptor) {
563-
auto mmioBase = getCsTraits(engineType).mmioBase;
558+
void AUBCommandStreamReceiverHw<GfxFamily>::submitLRCA(EngineInstanceT engineInstance, const typename AUBCommandStreamReceiverHw<GfxFamily>::MiContextDescriptorReg &contextDescriptor) {
559+
auto mmioBase = getCsTraits(engineInstance).mmioBase;
564560
stream->writeMMIO(mmioBase + 0x2230, 0);
565561
stream->writeMMIO(mmioBase + 0x2230, 0);
566562
stream->writeMMIO(mmioBase + 0x2230, contextDescriptor.ulData[1]);
567563
stream->writeMMIO(mmioBase + 0x2230, contextDescriptor.ulData[0]);
568564
}
569565

570566
template <typename GfxFamily>
571-
void AUBCommandStreamReceiverHw<GfxFamily>::pollForCompletion(EngineType engineType) {
567+
void AUBCommandStreamReceiverHw<GfxFamily>::pollForCompletion(EngineInstanceT engineInstance) {
572568
typedef typename AubMemDump::CmdServicesMemTraceRegisterPoll CmdServicesMemTraceRegisterPoll;
573569

574-
auto mmioBase = getCsTraits(engineType).mmioBase;
570+
auto mmioBase = getCsTraits(engineInstance).mmioBase;
575571
bool pollNotEqual = false;
576572
this->stream->registerPoll(
577573
mmioBase + 0x2234, //EXECLIST_STATUS

runtime/helpers/engine_node.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ enum EngineType : uint32_t {
1818
};
1919

2020
struct EngineInstanceT {
21+
constexpr EngineInstanceT(EngineType type) : type(type), id(0) {}
22+
constexpr EngineInstanceT(EngineType type, int id) : type(type), id(id) {}
23+
2124
EngineType type;
2225
int id;
2326
};

runtime/helpers/hw_helper.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class HwHelper {
3434
virtual uint32_t getConfigureAddressSpaceMode() = 0;
3535
virtual bool isLocalMemoryEnabled(const HardwareInfo &hwInfo) = 0;
3636
virtual bool isPageTableManagerSupported(const HardwareInfo &hwInfo) const = 0;
37-
virtual const AubMemDump::LrcaHelper &getCsTraits(EngineType engineType) const = 0;
37+
virtual const AubMemDump::LrcaHelper &getCsTraits(EngineInstanceT engineInstance) const = 0;
3838
virtual bool supportsYTiling() const = 0;
3939
virtual bool timestampPacketWriteSupported() const = 0;
4040

@@ -72,7 +72,7 @@ class HwHelperHw : public HwHelper {
7272
return sizeof(INTERFACE_DESCRIPTOR_DATA);
7373
}
7474

75-
const AubMemDump::LrcaHelper &getCsTraits(EngineType engineType) const override;
75+
const AubMemDump::LrcaHelper &getCsTraits(EngineInstanceT engineInstance) const override;
7676

7777
size_t getMaxBarrierRegisterPerSlice() const override;
7878

runtime/helpers/hw_helper_common.inl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ size_t HwHelperHw<Family>::getMaxBarrierRegisterPerSlice() const {
6666
}
6767

6868
template <typename Family>
69-
const AubMemDump::LrcaHelper &HwHelperHw<Family>::getCsTraits(EngineType engineType) const {
70-
return *AUBFamilyMapper<Family>::csTraits[engineType];
69+
const AubMemDump::LrcaHelper &HwHelperHw<Family>::getCsTraits(EngineInstanceT engineInstance) const {
70+
return *AUBFamilyMapper<Family>::csTraits[engineInstance.type];
7171
}
7272

7373
template <typename Family>

unit_tests/command_stream/aub_command_stream_receiver_tests.cpp

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,33 +85,21 @@ TEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenTypeIsChe
8585
EXPECT_EQ(CommandStreamReceiverType::CSR_AUB, aubCsr->getType());
8686
}
8787

88-
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGetInstanceIsCalledForAGivenEngineTypeThenEngineInstanceForThatTypeIsReturned) {
88+
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGetEngineIndexIsCalledForGivenEngineTypeThenEngineIndexForThatTypeIsReturned) {
8989
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment);
9090
EXPECT_NE(nullptr, aubCsr);
9191

92-
auto engineId = aubCsr->getEngineInstance(EngineType::ENGINE_RCS);
93-
EXPECT_EQ(EngineType::ENGINE_RCS, allEngineInstances[engineId].type);
92+
auto engineIndex = aubCsr->getEngineIndex(EngineType::ENGINE_RCS);
93+
EXPECT_EQ(EngineType::ENGINE_RCS, allEngineInstances[engineIndex].type);
9494

95-
engineId = aubCsr->getEngineInstance(EngineType::ENGINE_BCS);
96-
EXPECT_EQ(EngineType::ENGINE_BCS, allEngineInstances[engineId].type);
95+
engineIndex = aubCsr->getEngineIndex(EngineType::ENGINE_BCS);
96+
EXPECT_EQ(EngineType::ENGINE_BCS, allEngineInstances[engineIndex].type);
9797

98-
engineId = aubCsr->getEngineInstance(EngineType::ENGINE_VCS);
99-
EXPECT_EQ(EngineType::ENGINE_VCS, allEngineInstances[engineId].type);
98+
engineIndex = aubCsr->getEngineIndex(EngineType::ENGINE_VCS);
99+
EXPECT_EQ(EngineType::ENGINE_VCS, allEngineInstances[engineIndex].type);
100100

101-
engineId = aubCsr->getEngineInstance(EngineType::ENGINE_VECS);
102-
EXPECT_EQ(EngineType::ENGINE_VECS, allEngineInstances[engineId].type);
103-
}
104-
105-
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenSetCsTraitsIsCalledThenLRCAIsSetForAGivenEngine) {
106-
const auto &csTraits = AUBCommandStreamReceiverHw<FamilyType>::getCsTraits(EngineType::ENGINE_RCS);
107-
108-
auto mmioBase = 0x12345679u;
109-
const AubMemDump::LrcaHelper lrca(mmioBase);
110-
AUBCommandStreamReceiverHw<FamilyType>::setCsTraits(EngineType::ENGINE_RCS, &lrca);
111-
const auto &traits = AUBCommandStreamReceiverHw<FamilyType>::getCsTraits(EngineType::ENGINE_RCS);
112-
EXPECT_EQ(mmioBase, traits.mmioBase);
113-
114-
AUBCommandStreamReceiverHw<FamilyType>::setCsTraits(EngineType::ENGINE_RCS, &csTraits);
101+
engineIndex = aubCsr->getEngineIndex(EngineType::ENGINE_VECS);
102+
EXPECT_EQ(EngineType::ENGINE_VECS, allEngineInstances[engineIndex].type);
115103
}
116104

117105
HWTEST_F(AubCommandStreamReceiverTests, givenAubCsrWhenItIsCreatedWithDefaultSettingsThenItHasBatchedDispatchModeEnabled) {
@@ -243,13 +231,14 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipl
243231
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment);
244232
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment);
245233
auto engineType = OCLRT::ENGINE_RCS;
234+
auto engineIndex = aubCsr1->getEngineIndex(engineType);
246235

247-
aubCsr1->initializeEngine(engineType);
236+
aubCsr1->initializeEngine(engineIndex);
248237
EXPECT_NE(0u, aubCsr1->engineInfoTable[engineType].ggttLRCA);
249238
EXPECT_NE(0u, aubCsr1->engineInfoTable[engineType].ggttHWSP);
250239
EXPECT_NE(0u, aubCsr1->engineInfoTable[engineType].ggttRingBuffer);
251240

252-
aubCsr2->initializeEngine(engineType);
241+
aubCsr2->initializeEngine(engineIndex);
253242
EXPECT_NE(aubCsr1->engineInfoTable[engineType].ggttLRCA, aubCsr2->engineInfoTable[engineType].ggttLRCA);
254243
EXPECT_NE(aubCsr1->engineInfoTable[engineType].ggttHWSP, aubCsr2->engineInfoTable[engineType].ggttHWSP);
255244
EXPECT_NE(aubCsr1->engineInfoTable[engineType].ggttRingBuffer, aubCsr2->engineInfoTable[engineType].ggttRingBuffer);

unit_tests/libult/mock_gfx_family.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ bool HwHelperHw<GENX>::setupPreemptionRegisters(HardwareInfo *pHwInfo, bool enab
6161
return enable;
6262
}
6363
template <>
64-
const AubMemDump::LrcaHelper &HwHelperHw<GENX>::getCsTraits(EngineType engineType) const {
65-
return *AUBFamilyMapper<GENX>::csTraits[engineType];
64+
const AubMemDump::LrcaHelper &HwHelperHw<GENX>::getCsTraits(EngineInstanceT engineInstance) const {
65+
return *AUBFamilyMapper<GENX>::csTraits[engineInstance.type];
6666
}
6767

6868
struct hw_helper_static_init {

unit_tests/mocks/mock_aub_csr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw<GfxFamily> {
6161
void initProgrammingFlags() override {
6262
initProgrammingFlagsCalled = true;
6363
}
64-
void pollForCompletion(EngineType engineType) override {
64+
void pollForCompletion(EngineInstanceT engineInstance) override {
6565
pollForCompletionCalled = true;
6666
}
6767
bool flushBatchedSubmissionsCalled = false;

0 commit comments

Comments
 (0)