Enable TBX mode in level zero

RelatedTo: NEO-4644

Change-Id: I76913d6b7c7d978a5a90a7a574778c67283497c1
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2020-05-06 11:52:48 +02:00
committed by sys_ocldev
parent 656468e42b
commit ef4fae3903
8 changed files with 57 additions and 26 deletions

View File

@ -68,9 +68,6 @@ ze_result_t CommandQueueImp::synchronizeByPollingForTaskCount(uint32_t timeout)
UNRECOVERABLE_IF(csr == nullptr);
auto taskCountToWait = this->taskCount;
waitForTaskCountWithKmdNotifyFallbackHelper(csr, this->taskCount, 0, false, false);
bool enableTimeout = (timeout != std::numeric_limits<uint32_t>::max());
csr->waitForCompletionWithTimeout(enableTimeout, timeout, this->taskCount);

View File

@ -92,8 +92,6 @@ ze_result_t FenceImp::hostSynchronize(uint32_t timeout) {
return ZE_RESULT_SUCCESS;
}
waitForTaskCountWithKmdNotifyFallbackHelper(cmdQueue->getCsr(), cmdQueue->getTaskCount(), 0, false, false);
if (timeout == 0) {
return queryStatus();
}

View File

@ -15,12 +15,4 @@ namespace L0 {
inline uint64_t getIntermediateCacheSize(const NEO::HardwareInfo &hwInfo) {
return 0u;
}
inline void waitForTaskCountWithKmdNotifyFallbackHelper(NEO::CommandStreamReceiver *csr,
uint32_t taskCountToWait,
NEO::FlushStamp flushStampToWait,
bool useQuickKmdSleep,
bool forcePowerSavingMode) {
}
} // namespace L0

View File

@ -31,6 +31,7 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
uint32_t getMaskAndValueForPollForCompletion() const;
bool getpollNotEqualValueForPollForCompletion() const;
void flushSubmissionsAndDownloadAllocations();
public:
using CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO;
@ -42,6 +43,7 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw<GfxFa
bool flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) override;
bool waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait) override;
void downloadAllocation(GraphicsAllocation &gfxAllocation) override;
void processEviction() override;

View File

@ -451,7 +451,7 @@ bool TbxCommandStreamReceiverHw<GfxFamily>::expectMemory(const void *gfxAddress,
}
template <typename GfxFamily>
void TbxCommandStreamReceiverHw<GfxFamily>::waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) {
void TbxCommandStreamReceiverHw<GfxFamily>::flushSubmissionsAndDownloadAllocations() {
this->flushBatchedSubmissions();
while (*this->getTagAddress() < this->latestFlushedTaskCount) {
@ -462,10 +462,20 @@ void TbxCommandStreamReceiverHw<GfxFamily>::waitForTaskCountWithKmdNotifyFallbac
downloadAllocation(*graphicsAllocation);
}
this->allocationsForDownload.clear();
}
template <typename GfxFamily>
void TbxCommandStreamReceiverHw<GfxFamily>::waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) {
flushSubmissionsAndDownloadAllocations();
BaseClass::waitForTaskCountWithKmdNotifyFallback(taskCountToWait, flushStampToWait, useQuickKmdSleep, forcePowerSavingMode);
}
template <typename GfxFamily>
bool TbxCommandStreamReceiverHw<GfxFamily>::waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait) {
flushSubmissionsAndDownloadAllocations();
return BaseClass::waitForCompletionWithTimeout(enableTimeout, timeoutMicroseconds, taskCountToWait);
}
template <typename GfxFamily>
void TbxCommandStreamReceiverHw<GfxFamily>::processEviction() {
this->allocationsForDownload.insert(this->getEvictionAllocations().begin(), this->getEvictionAllocations().end());

View File

@ -396,17 +396,7 @@ HWTEST_F(TbxCommandSteamSimpleTest, givenTbxCsrWhenCallingMakeSurfacePackNonResi
}
HWTEST_F(TbxCommandSteamSimpleTest, givenTbxCsrWhenCallingWaitForTaskCountWithKmdNotifyFallbackThenTagAllocationAndScheduledAllocationsAreDownloaded) {
struct MockTbxCsr : TbxCommandStreamReceiverHw<FamilyType> {
using CommandStreamReceiver::latestFlushedTaskCount;
using TbxCommandStreamReceiverHw<FamilyType>::TbxCommandStreamReceiverHw;
void downloadAllocation(GraphicsAllocation &gfxAllocation) override {
*reinterpret_cast<uint32_t *>(CommandStreamReceiver::getTagAllocation()->getUnderlyingBuffer()) = this->latestFlushedTaskCount;
downloadedAllocations.insert(&gfxAllocation);
}
std::set<GraphicsAllocation *> downloadedAllocations;
};
MockTbxCsr tbxCsr{*pDevice->executionEnvironment, pDevice->getRootDeviceIndex()};
MockTbxCsrRegisterDownloadedAllocations<FamilyType> tbxCsr{*pDevice->executionEnvironment, pDevice->getRootDeviceIndex()};
MockOsContext osContext(0, 1, aub_stream::ENGINE_RCS, PreemptionMode::Disabled, false, false, false);
uint32_t tag = 0u;
tbxCsr.setupContext(osContext);
@ -430,6 +420,32 @@ HWTEST_F(TbxCommandSteamSimpleTest, givenTbxCsrWhenCallingWaitForTaskCountWithKm
EXPECT_EQ(0u, tbxCsr.allocationsForDownload.size());
}
HWTEST_F(TbxCommandSteamSimpleTest, givenTbxCsrWhenCallingWaitForCompletionWithTimeoutThenFlushIsCalledAndTagAllocationAndScheduledAllocationsAreDownloaded) {
MockTbxCsrRegisterDownloadedAllocations<FamilyType> tbxCsr{*pDevice->executionEnvironment, pDevice->getRootDeviceIndex()};
MockOsContext osContext(0, 1, aub_stream::ENGINE_RCS, PreemptionMode::Disabled, false, false, false);
uint32_t tag = 0u;
tbxCsr.setupContext(osContext);
tbxCsr.setTagAllocation(pDevice->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), false, sizeof(tag)}, &tag));
tbxCsr.latestFlushedTaskCount = 1u;
MockGraphicsAllocation allocation1, allocation2, allocation3;
allocation1.usageInfos[0].residencyTaskCount = 1;
allocation2.usageInfos[0].residencyTaskCount = 1;
allocation3.usageInfos[0].residencyTaskCount = 1;
ASSERT_TRUE(allocation1.isResident(0u));
ASSERT_TRUE(allocation2.isResident(0u));
ASSERT_TRUE(allocation3.isResident(0u));
tbxCsr.allocationsForDownload = {&allocation1, &allocation2, &allocation3};
tbxCsr.waitForCompletionWithTimeout(true, 0, 0);
std::set<GraphicsAllocation *> expectedDownloadedAllocations = {tbxCsr.getTagAllocation(), &allocation1, &allocation2, &allocation3};
EXPECT_EQ(expectedDownloadedAllocations, tbxCsr.downloadedAllocations);
EXPECT_EQ(0u, tbxCsr.allocationsForDownload.size());
EXPECT_TRUE(tbxCsr.flushBatchedSubmissionsCalled);
}
HWTEST_F(TbxCommandSteamSimpleTest, whenTbxCommandStreamReceiverIsCreatedThenPPGTTAndGGTTCreatedHavePhysicalAddressAllocatorSet) {
MockTbxCsr<FamilyType> tbxCsr(*pDevice->executionEnvironment);

View File

@ -70,4 +70,20 @@ class MockTbxCsr : public TbxCommandStreamReceiverHw<GfxFamily> {
bool makeCoherentCalled = false;
bool dumpAllocationCalled = false;
};
template <typename GfxFamily>
struct MockTbxCsrRegisterDownloadedAllocations : TbxCommandStreamReceiverHw<GfxFamily> {
using CommandStreamReceiver::latestFlushedTaskCount;
using TbxCommandStreamReceiverHw<GfxFamily>::TbxCommandStreamReceiverHw;
void downloadAllocation(GraphicsAllocation &gfxAllocation) override {
*reinterpret_cast<uint32_t *>(CommandStreamReceiver::getTagAllocation()->getUnderlyingBuffer()) = this->latestFlushedTaskCount;
downloadedAllocations.insert(&gfxAllocation);
}
bool flushBatchedSubmissions() override {
flushBatchedSubmissionsCalled = true;
return true;
}
std::set<GraphicsAllocation *> downloadedAllocations;
bool flushBatchedSubmissionsCalled = false;
};
} // namespace NEO

View File

@ -129,7 +129,7 @@ class CommandStreamReceiver {
bool isStallingPipeControlOnNextFlushRequired() const { return stallingPipeControlOnNextFlushRequired; }
virtual void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) = 0;
MOCKABLE_VIRTUAL bool waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait);
virtual bool waitForCompletionWithTimeout(bool enableTimeout, int64_t timeoutMicroseconds, uint32_t taskCountToWait);
virtual void downloadAllocation(GraphicsAllocation &gfxAllocation){};
void setSamplerCacheFlushRequired(SamplerCacheFlushState value) { this->samplerCacheFlushRequired = value; }