Skip to content

Commit ec48cce

Browse files
AUB CSRs to use a shared address mapper (CPU VA to GTT VA)
This commit moves address mapper from CSR to execution environment in order to generate unique GTT VA for LRCA, HWSP and ring buffer between different CSRs. Additionally, moved the rest of AUB file stream tests to separate module. Change-Id: I02ae44202c0255277a7ac17532485419e0c403ab
1 parent 5f11e68 commit ec48cce

File tree

8 files changed

+496
-437
lines changed

8 files changed

+496
-437
lines changed

runtime/command_stream/aub_center.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@
77

88
#pragma once
99
#include "runtime/command_stream/aub_stream_provider.h"
10+
#include "runtime/memory_manager/address_mapper.h"
1011
#include "runtime/memory_manager/physical_address_allocator.h"
1112

1213
namespace OCLRT {
1314

1415
class AubCenter {
1516
public:
1617
AubCenter() {
18+
addressMapper = std::make_unique<AddressMapper>();
1719
streamProvider = std::make_unique<AubFileStreamProvider>();
1820
}
1921
virtual ~AubCenter() = default;
@@ -26,12 +28,17 @@ class AubCenter {
2628
return physicalAddressAllocator.get();
2729
}
2830

31+
AddressMapper *getAddressMapper() const {
32+
return addressMapper.get();
33+
}
34+
2935
AubStreamProvider *getStreamProvider() const {
3036
return streamProvider.get();
3137
}
3238

3339
protected:
3440
std::unique_ptr<PhysicalAddressAllocator> physicalAddressAllocator;
41+
std::unique_ptr<AddressMapper> addressMapper;
3542
std::unique_ptr<AubStreamProvider> streamProvider;
3643
};
3744
} // namespace OCLRT

runtime/command_stream/aub_command_stream_receiver_hw.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
6262
MOCKABLE_VIRTUAL bool reopenFile(const std::string &fileName);
6363
MOCKABLE_VIRTUAL void initFile(const std::string &fileName);
6464
MOCKABLE_VIRTUAL void closeFile();
65-
MOCKABLE_VIRTUAL bool isFileOpen();
65+
MOCKABLE_VIRTUAL bool isFileOpen() const;
6666
MOCKABLE_VIRTUAL const std::string &getFileName();
6767

6868
void initializeEngine(EngineType engineType);
@@ -95,7 +95,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
9595
std::unique_ptr<TypeSelector<PML4, PDPE, sizeof(void *) == 8>::type> ppgtt;
9696
std::unique_ptr<PDPE> ggtt;
9797
// remap CPU VA -> GGTT VA
98-
AddressMapper gttRemap;
98+
AddressMapper *gttRemap;
9999

100100
MOCKABLE_VIRTUAL bool addPatchInfoComments();
101101
void addGUCStartMessage(uint64_t batchBufferAddress, EngineType engineType);

runtime/command_stream/aub_command_stream_receiver_hw.inl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ AUBCommandStreamReceiverHw<GfxFamily>::AUBCommandStreamReceiverHw(const Hardware
4646
ppgtt = std::make_unique<TypeSelector<PML4, PDPE, sizeof(void *) == 8>::type>(physicalAddressAllocator);
4747
ggtt = std::make_unique<PDPE>(physicalAddressAllocator);
4848

49+
gttRemap = aubCenter->getAddressMapper();
50+
UNRECOVERABLE_IF(nullptr == gttRemap);
51+
4952
auto streamProvider = aubCenter->getStreamProvider();
5053
UNRECOVERABLE_IF(nullptr == streamProvider);
5154

@@ -143,7 +146,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::closeFile() {
143146
}
144147

145148
template <typename GfxFamily>
146-
bool AUBCommandStreamReceiverHw<GfxFamily>::isFileOpen() {
149+
bool AUBCommandStreamReceiverHw<GfxFamily>::isFileOpen() const {
147150
return stream->isOpen();
148151
}
149152

@@ -165,7 +168,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine(EngineType engineTy
165168
const size_t sizeHWSP = 0x1000;
166169
const size_t alignHWSP = 0x1000;
167170
engineInfo.pGlobalHWStatusPage = alignedMalloc(sizeHWSP, alignHWSP);
168-
engineInfo.ggttHWSP = gttRemap.map(engineInfo.pGlobalHWStatusPage, sizeHWSP);
171+
engineInfo.ggttHWSP = gttRemap->map(engineInfo.pGlobalHWStatusPage, sizeHWSP);
169172

170173
auto physHWSP = ggtt->map(engineInfo.ggttHWSP, sizeHWSP, this->getGTTBits(), getMemoryBankForGtt());
171174

@@ -197,7 +200,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine(EngineType engineTy
197200
{
198201
const size_t alignRingBuffer = 0x1000;
199202
engineInfo.pRingBuffer = alignedMalloc(engineInfo.sizeRingBuffer, alignRingBuffer);
200-
engineInfo.ggttRingBuffer = gttRemap.map(engineInfo.pRingBuffer, engineInfo.sizeRingBuffer);
203+
engineInfo.ggttRingBuffer = gttRemap->map(engineInfo.pRingBuffer, engineInfo.sizeRingBuffer);
201204
auto physRingBuffer = ggtt->map(engineInfo.ggttRingBuffer, engineInfo.sizeRingBuffer, this->getGTTBits(), getMemoryBankForGtt());
202205

203206
{
@@ -225,7 +228,7 @@ void AUBCommandStreamReceiverHw<GfxFamily>::initializeEngine(EngineType engineTy
225228

226229
// Write our LRCA
227230
{
228-
engineInfo.ggttLRCA = gttRemap.map(engineInfo.pLRCA, sizeLRCA);
231+
engineInfo.ggttLRCA = gttRemap->map(engineInfo.pLRCA, sizeLRCA);
229232
auto lrcAddressPhys = ggtt->map(engineInfo.ggttLRCA, sizeLRCA, this->getGTTBits(), getMemoryBankForGtt());
230233

231234
{
@@ -254,15 +257,15 @@ template <typename GfxFamily>
254257
void AUBCommandStreamReceiverHw<GfxFamily>::freeEngineInfoTable() {
255258
for (auto &engineInfo : engineInfoTable) {
256259
alignedFree(engineInfo.pLRCA);
257-
gttRemap.unmap(engineInfo.pLRCA);
260+
gttRemap->unmap(engineInfo.pLRCA);
258261
engineInfo.pLRCA = nullptr;
259262

260263
alignedFree(engineInfo.pGlobalHWStatusPage);
261-
gttRemap.unmap(engineInfo.pGlobalHWStatusPage);
264+
gttRemap->unmap(engineInfo.pGlobalHWStatusPage);
262265
engineInfo.pGlobalHWStatusPage = nullptr;
263266

264267
alignedFree(engineInfo.pRingBuffer);
265-
gttRemap.unmap(engineInfo.pRingBuffer);
268+
gttRemap->unmap(engineInfo.pRingBuffer);
266269
engineInfo.pRingBuffer = nullptr;
267270
}
268271
}

0 commit comments

Comments
 (0)