Add device callback for GMM library to notify AUB subcapture

This commit adds a new callback to be called by GMM library
when it allocates/deallocates compressed resources to collect data
about their addresses and sizes and handle their AUB residency.

Change-Id: I075d3ff4cb049cfe626da82892069c4460ea585c
This commit is contained in:
Milczarek, Slawomir 2018-08-17 13:38:09 +02:00
parent 044255e9bd
commit 393c2219c9
25 changed files with 245 additions and 34 deletions

View File

@ -37,6 +37,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverHw<GfxFamily> {
typedef CommandStreamReceiverHw<GfxFamily> BaseClass; typedef CommandStreamReceiverHw<GfxFamily> BaseClass;
typedef typename AUBFamilyMapper<GfxFamily>::AUB AUB; typedef typename AUBFamilyMapper<GfxFamily>::AUB AUB;
typedef typename AUB::MiContextDescriptorReg MiContextDescriptorReg; typedef typename AUB::MiContextDescriptorReg MiContextDescriptorReg;
using ExternalAllocationsContainer = std::vector<AllocationView>;
public: public:
FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer *allocationsForResidency) override; FlushStamp flush(BatchBuffer &batchBuffer, EngineType engineType, ResidencyContainer *allocationsForResidency) override;
@ -45,7 +46,11 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverHw<GfxFamily> {
void processResidency(ResidencyContainer *allocationsForResidency) override; void processResidency(ResidencyContainer *allocationsForResidency) override;
void makeResidentExternal(AllocationView &allocationView);
void makeNonResidentExternal(uint64_t gpuAddress);
MOCKABLE_VIRTUAL bool writeMemory(GraphicsAllocation &gfxAllocation); MOCKABLE_VIRTUAL bool writeMemory(GraphicsAllocation &gfxAllocation);
MOCKABLE_VIRTUAL bool writeMemory(AllocationView &allocationView);
void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override; void activateAubSubCapture(const MultiDispatchInfo &dispatchInfo) override;
@ -114,5 +119,6 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverHw<GfxFamily> {
protected: protected:
bool dumpAubNonWritable = false; bool dumpAubNonWritable = false;
ExternalAllocationsContainer externalAllocations;
}; };
} // namespace OCLRT } // namespace OCLRT

View File

@ -518,6 +518,21 @@ void AUBCommandStreamReceiverHw<GfxFamily>::makeResident(GraphicsAllocation &gfx
gfxAllocation.residencyTaskCount = submissionTaskCount; gfxAllocation.residencyTaskCount = submissionTaskCount;
} }
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::makeResidentExternal(AllocationView &allocationView) {
externalAllocations.push_back(allocationView);
}
template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::makeNonResidentExternal(uint64_t gpuAddress) {
for (auto it = externalAllocations.begin(); it != externalAllocations.end(); it++) {
if (it->first == gpuAddress) {
externalAllocations.erase(it);
break;
}
}
}
template <typename GfxFamily> template <typename GfxFamily>
bool AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxAllocation) { bool AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxAllocation) {
auto cpuAddress = gfxAllocation.getUnderlyingBuffer(); auto cpuAddress = gfxAllocation.getUnderlyingBuffer();
@ -555,6 +570,12 @@ bool AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(GraphicsAllocation &gfxA
return true; return true;
} }
template <typename GfxFamily>
bool AUBCommandStreamReceiverHw<GfxFamily>::writeMemory(AllocationView &allocationView) {
GraphicsAllocation gfxAllocation(reinterpret_cast<void *>(allocationView.first), allocationView.second);
return writeMemory(gfxAllocation);
}
template <typename GfxFamily> template <typename GfxFamily>
void AUBCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer *allocationsForResidency) { void AUBCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer *allocationsForResidency) {
if (subCaptureManager->isSubCaptureMode()) { if (subCaptureManager->isSubCaptureMode()) {
@ -563,6 +584,12 @@ void AUBCommandStreamReceiverHw<GfxFamily>::processResidency(ResidencyContainer
} }
} }
for (auto &externalAllocation : externalAllocations) {
if (!writeMemory(externalAllocation)) {
DEBUG_BREAK_IF(externalAllocation.second != 0);
}
}
auto &residencyAllocations = allocationsForResidency ? *allocationsForResidency : this->getMemoryManager()->getResidencyAllocations(); auto &residencyAllocations = allocationsForResidency ? *allocationsForResidency : this->getMemoryManager()->getResidencyAllocations();
for (auto &gfxAllocation : residencyAllocations) { for (auto &gfxAllocation : residencyAllocations) {

View File

@ -42,6 +42,7 @@ class GraphicsAllocation;
class IndirectHeap; class IndirectHeap;
class LinearStream; class LinearStream;
class MemoryManager; class MemoryManager;
class GmmPageTableMngr;
class OSInterface; class OSInterface;
class ExecutionEnvironment; class ExecutionEnvironment;
@ -87,6 +88,8 @@ class CommandStreamReceiver {
virtual MemoryManager *createMemoryManager(bool enable64kbPages) { return nullptr; } virtual MemoryManager *createMemoryManager(bool enable64kbPages) { return nullptr; }
void setMemoryManager(MemoryManager *mm); void setMemoryManager(MemoryManager *mm);
virtual GmmPageTableMngr *createPageTableManager() { return nullptr; }
GraphicsAllocation *createAllocationAndHandleResidency(const void *address, size_t size, bool addToDefferFreeList = true); GraphicsAllocation *createAllocationAndHandleResidency(const void *address, size_t size, bool addToDefferFreeList = true);
void waitForTaskCountAndCleanAllocationList(uint32_t requiredTaskCount, uint32_t allocationType); void waitForTaskCountAndCleanAllocationList(uint32_t requiredTaskCount, uint32_t allocationType);

View File

@ -20,7 +20,7 @@
set(RUNTIME_SRCS_GENX_CPP_WINDOWS set(RUNTIME_SRCS_GENX_CPP_WINDOWS
windows/command_stream_receiver windows/command_stream_receiver
windows/translationtable_callbacks windows/gmm_callbacks
windows/wddm windows/wddm
) )

View File

@ -47,6 +47,9 @@ bool ExecutionEnvironment::initializeCommandStreamReceiver(const HardwareInfo *p
if (!commandStreamReceiver) { if (!commandStreamReceiver) {
return false; return false;
} }
if (pHwInfo->capabilityTable.ftrRenderCompressedBuffers || pHwInfo->capabilityTable.ftrRenderCompressedImages) {
commandStreamReceiver->createPageTableManager();
}
this->commandStreamReceiver.reset(commandStreamReceiver); this->commandStreamReceiver.reset(commandStreamReceiver);
return true; return true;
} }

View File

@ -21,9 +21,10 @@
*/ */
#include "hw_cmds.h" #include "hw_cmds.h"
#include "runtime/helpers/translationtable_callbacks.h" #include "runtime/helpers/gmm_callbacks.h"
#include "runtime/helpers/translationtable_callbacks.inl" #include "runtime/helpers/gmm_callbacks.inl"
using namespace OCLRT; using namespace OCLRT;
template struct DeviceCallbacks<CNLFamily>;
template struct TTCallbacks<CNLFamily>; template struct TTCallbacks<CNLFamily>;

View File

@ -21,9 +21,10 @@
*/ */
#include "hw_cmds.h" #include "hw_cmds.h"
#include "runtime/helpers/translationtable_callbacks.h" #include "runtime/helpers/gmm_callbacks.h"
#include "runtime/helpers/translationtable_callbacks.inl" #include "runtime/helpers/gmm_callbacks.inl"
using namespace OCLRT; using namespace OCLRT;
template struct DeviceCallbacks<BDWFamily>;
template struct TTCallbacks<BDWFamily>; template struct TTCallbacks<BDWFamily>;

View File

@ -21,9 +21,10 @@
*/ */
#include "hw_cmds.h" #include "hw_cmds.h"
#include "runtime/helpers/translationtable_callbacks.h" #include "runtime/helpers/gmm_callbacks.h"
#include "runtime/helpers/translationtable_callbacks.inl" #include "runtime/helpers/gmm_callbacks.inl"
using namespace OCLRT; using namespace OCLRT;
template struct DeviceCallbacks<SKLFamily>;
template struct TTCallbacks<SKLFamily>; template struct TTCallbacks<SKLFamily>;

View File

@ -93,8 +93,8 @@ set(RUNTIME_SRCS_HELPERS_BASE
${CMAKE_CURRENT_SOURCE_DIR}/validators.h ${CMAKE_CURRENT_SOURCE_DIR}/validators.h
) )
set(RUNTIME_SRCS_HELPERS_WINDOWS set(RUNTIME_SRCS_HELPERS_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/translationtable_callbacks.h ${CMAKE_CURRENT_SOURCE_DIR}/gmm_callbacks.h
${CMAKE_CURRENT_SOURCE_DIR}/translationtable_callbacks.inl ${CMAKE_CURRENT_SOURCE_DIR}/gmm_callbacks.inl
${CMAKE_CURRENT_SOURCE_DIR}/windows/kmd_notify_properties_windows.cpp ${CMAKE_CURRENT_SOURCE_DIR}/windows/kmd_notify_properties_windows.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_helper.h ${CMAKE_CURRENT_SOURCE_DIR}/wddm_helper.h
) )

View File

@ -25,6 +25,11 @@
namespace OCLRT { namespace OCLRT {
template <typename GfxFamily>
struct DeviceCallbacks {
static long __stdcall notifyAubCapture(void *csrHandle, uint64_t gfxAddress, size_t gfxSize, bool allocate);
};
template <typename GfxFamily> template <typename GfxFamily>
struct TTCallbacks { struct TTCallbacks {
using MI_LOAD_REGISTER_IMM = typename GfxFamily::MI_LOAD_REGISTER_IMM; using MI_LOAD_REGISTER_IMM = typename GfxFamily::MI_LOAD_REGISTER_IMM;

View File

@ -20,15 +20,21 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include "runtime/helpers/translationtable_callbacks.h" #include "runtime/helpers/gmm_callbacks.h"
#include "runtime/command_stream/linear_stream.h" #include "runtime/command_stream/linear_stream.h"
#include "runtime/helpers/hw_helper.h" #include "runtime/helpers/hw_helper.h"
#include <cstdint> #include <cstdint>
namespace OCLRT { namespace OCLRT {
template <typename GfxFamily>
long __stdcall DeviceCallbacks<GfxFamily>::notifyAubCapture(void *csrHandle, uint64_t gfxAddress, size_t gfxSize, bool allocate) {
return 0;
}
template <typename GfxFamily> template <typename GfxFamily>
int __stdcall TTCallbacks<GfxFamily>::writeL3Address(void *queueHandle, uint64_t l3GfxAddress, uint64_t regOffset) { int __stdcall TTCallbacks<GfxFamily>::writeL3Address(void *queueHandle, uint64_t l3GfxAddress, uint64_t regOffset) {
return 0; return 0;
}; }
} // namespace OCLRT } // namespace OCLRT

View File

@ -22,9 +22,11 @@
#pragma once #pragma once
#include <vector> #include <vector>
#include <utility>
namespace OCLRT { namespace OCLRT {
class GraphicsAllocation; class GraphicsAllocation;
using ResidencyContainer = std::vector<GraphicsAllocation *>; using ResidencyContainer = std::vector<GraphicsAllocation *>;
using AllocationView = std::pair<uint64_t /*address*/, size_t /*size*/>;
} // namespace OCLRT } // namespace OCLRT

View File

@ -51,11 +51,11 @@ class WddmCommandStreamReceiver : public DeviceCommandStreamReceiver<GfxFamily>
Wddm *peekWddm() { Wddm *peekWddm() {
return wddm; return wddm;
} }
GmmPageTableMngr *createPageTableManager() override;
protected: protected:
void initPageTableManagerRegisters(LinearStream &csr) override; void initPageTableManagerRegisters(LinearStream &csr) override;
void kmDafLockAllocations(ResidencyContainer *allocationsForResidency); void kmDafLockAllocations(ResidencyContainer *allocationsForResidency);
GmmPageTableMngr *createPageTableManager();
Wddm *wddm; Wddm *wddm;
COMMAND_BUFFER_HEADER_REC *commandBufferHeader; COMMAND_BUFFER_HEADER_REC *commandBufferHeader;

View File

@ -29,8 +29,8 @@
#include "runtime/command_stream/preemption.h" #include "runtime/command_stream/preemption.h"
#include "runtime/device/device.h" #include "runtime/device/device.h"
#include "runtime/gmm_helper/page_table_mngr.h" #include "runtime/gmm_helper/page_table_mngr.h"
#include "runtime/helpers/gmm_callbacks.h"
#include "runtime/helpers/ptr_math.h" #include "runtime/helpers/ptr_math.h"
#include "runtime/helpers/translationtable_callbacks.h"
#include "runtime/mem_obj/mem_obj.h" #include "runtime/mem_obj/mem_obj.h"
#include "runtime/os_interface/windows/wddm/wddm.h" #include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/windows/wddm_device_command_stream.h" #include "runtime/os_interface/windows/wddm_device_command_stream.h"
@ -77,10 +77,6 @@ WddmCommandStreamReceiver<GfxFamily>::WddmCommandStreamReceiver(const HardwareIn
bool success = this->wddm->init<GfxFamily>(); bool success = this->wddm->init<GfxFamily>();
DEBUG_BREAK_IF(!success); DEBUG_BREAK_IF(!success);
if (hwInfoIn.capabilityTable.ftrRenderCompressedBuffers || hwInfoIn.capabilityTable.ftrRenderCompressedImages) {
this->wddm->resetPageTableManager(createPageTableManager());
}
} }
template <typename GfxFamily> template <typename GfxFamily>
@ -184,6 +180,7 @@ GmmPageTableMngr *WddmCommandStreamReceiver<GfxFamily>::createPageTableManager()
// clang-format off // clang-format off
deviceCallbacks.Adapter.KmtHandle = wddm->getAdapter(); deviceCallbacks.Adapter.KmtHandle = wddm->getAdapter();
deviceCallbacks.hDevice.KmtHandle = wddm->getDevice(); deviceCallbacks.hDevice.KmtHandle = wddm->getDevice();
deviceCallbacks.hCsr = static_cast<CommandStreamReceiverHw<GfxFamily> *>(this);
deviceCallbacks.PagingQueue = wddm->getPagingQueue(); deviceCallbacks.PagingQueue = wddm->getPagingQueue();
deviceCallbacks.PagingFence = wddm->getPagingQueueSyncObject(); deviceCallbacks.PagingFence = wddm->getPagingQueueSyncObject();
@ -198,11 +195,14 @@ GmmPageTableMngr *WddmCommandStreamReceiver<GfxFamily>::createPageTableManager()
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnLock = gdi->lock2; deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnLock = gdi->lock2;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnUnLock = gdi->unlock2; deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnUnLock = gdi->unlock2;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnEscape = gdi->escape; deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnEscape = gdi->escape;
deviceCallbacks.DevCbPtrs.KmtCbPtrs.pfnNotifyAubCapture = DeviceCallbacks<GfxFamily>::notifyAubCapture;
ttCallbacks.pfWriteL3Adr = TTCallbacks<GfxFamily>::writeL3Address; ttCallbacks.pfWriteL3Adr = TTCallbacks<GfxFamily>::writeL3Address;
// clang-format on // clang-format on
return GmmPageTableMngr::create(&deviceCallbacks, TT_TYPE::TRTT | TT_TYPE::AUXTT, &ttCallbacks); GmmPageTableMngr *gmmPageTableMngr = GmmPageTableMngr::create(&deviceCallbacks, TT_TYPE::TRTT | TT_TYPE::AUXTT, &ttCallbacks);
this->wddm->resetPageTableManager(gmmPageTableMngr);
return gmmPageTableMngr;
} }
template <typename GfxFamily> template <typename GfxFamily>

View File

@ -764,6 +764,23 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGraphic
EXPECT_FALSE(aubCsr->writeMemory(gfxAllocation)); EXPECT_FALSE(aubCsr->writeMemory(gfxAllocation));
} }
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAllocationDataIsPassedInAllocationViewThenWriteMemoryIsAllowed) {
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(*platformDevices[0], "", true, *pDevice->executionEnvironment);
size_t size = 100;
auto ptr = std::make_unique<char[]>(size);
auto addr = reinterpret_cast<uint64_t>(ptr.get());
AllocationView allocationView(addr, size);
EXPECT_TRUE(aubCsr->writeMemory(allocationView));
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAllocationSizeInAllocationViewIsZeroThenWriteMemoryIsNotAllowed) {
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(*platformDevices[0], "", true, *pDevice->executionEnvironment);
AllocationView allocationView(0x1234, 0);
EXPECT_FALSE(aubCsr->writeMemory(allocationView));
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenAubSubCaptureIsActivatedThenFileIsOpened) { HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverInSubCaptureModeWhenAubSubCaptureIsActivatedThenFileIsOpened) {
DebugManagerStateRestore stateRestore; DebugManagerStateRestore stateRestore;
std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", false, *pDevice->executionEnvironment)); std::unique_ptr<MockAubCsr<FamilyType>> aubCsr(new MockAubCsr<FamilyType>(*platformDevices[0], "", false, *pDevice->executionEnvironment));
@ -1776,6 +1793,97 @@ HWTEST_F(AubCommandStreamReceiverTests, givenPhysicalAddressWhenSetGttEntryIsCal
EXPECT_FALSE(entry.pageConfig.LocalMemory); EXPECT_FALSE(entry.pageConfig.LocalMemory);
} }
template <typename GfxFamily>
struct MockAubCsrToTestExternalAllocations : public AUBCommandStreamReceiverHw<GfxFamily> {
using AUBCommandStreamReceiverHw<GfxFamily>::AUBCommandStreamReceiverHw;
using AUBCommandStreamReceiverHw<GfxFamily>::externalAllocations;
bool writeMemory(AllocationView &allocationView) override {
writeMemoryParametrization.wasCalled = true;
writeMemoryParametrization.receivedAllocationView = allocationView;
writeMemoryParametrization.statusToReturn = (0 != allocationView.second) ? true : false;
return writeMemoryParametrization.statusToReturn;
}
struct WriteMemoryParametrization {
bool wasCalled = false;
AllocationView receivedAllocationView = {};
bool statusToReturn = false;
} writeMemoryParametrization;
};
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMakeResidentExternalIsCalledThenGivenAllocationViewShouldBeAddedToExternalAllocations) {
auto aubCsr = std::make_unique<MockAubCsrToTestExternalAllocations<FamilyType>>(*platformDevices[0], "", true, *pDevice->executionEnvironment);
size_t size = 100;
auto ptr = std::make_unique<char[]>(size);
auto addr = reinterpret_cast<uint64_t>(ptr.get());
AllocationView externalAllocation(addr, size);
ASSERT_EQ(0u, aubCsr->externalAllocations.size());
aubCsr->makeResidentExternal(externalAllocation);
EXPECT_EQ(1u, aubCsr->externalAllocations.size());
EXPECT_EQ(addr, aubCsr->externalAllocations[0].first);
EXPECT_EQ(size, aubCsr->externalAllocations[0].second);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMakeNonResidentExternalIsCalledThenMatchingAllocationViewShouldBeRemovedFromExternalAllocations) {
auto aubCsr = std::make_unique<MockAubCsrToTestExternalAllocations<FamilyType>>(*platformDevices[0], "", true, *pDevice->executionEnvironment);
size_t size = 100;
auto ptr = std::make_unique<char[]>(size);
auto addr = reinterpret_cast<uint64_t>(ptr.get());
AllocationView externalAllocation(addr, size);
aubCsr->makeResidentExternal(externalAllocation);
ASSERT_EQ(1u, aubCsr->externalAllocations.size());
aubCsr->makeNonResidentExternal(addr);
EXPECT_EQ(0u, aubCsr->externalAllocations.size());
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMakeNonResidentExternalIsCalledThenNonMatchingAllocationViewShouldNotBeRemovedFromExternalAllocations) {
auto aubCsr = std::make_unique<MockAubCsrToTestExternalAllocations<FamilyType>>(*platformDevices[0], "", true, *pDevice->executionEnvironment);
size_t size = 100;
auto ptr = std::make_unique<char[]>(size);
auto addr = reinterpret_cast<uint64_t>(ptr.get());
AllocationView externalAllocation(addr, size);
aubCsr->makeResidentExternal(externalAllocation);
ASSERT_EQ(1u, aubCsr->externalAllocations.size());
aubCsr->makeNonResidentExternal(0);
EXPECT_EQ(1u, aubCsr->externalAllocations.size());
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcessResidencyIsCalledThenExternalAllocationsShouldBeMadeResident) {
auto aubCsr = std::make_unique<MockAubCsrToTestExternalAllocations<FamilyType>>(*platformDevices[0], "", true, *pDevice->executionEnvironment);
size_t size = 100;
auto ptr = std::make_unique<char[]>(size);
auto addr = reinterpret_cast<uint64_t>(ptr.get());
AllocationView externalAllocation(addr, size);
aubCsr->makeResidentExternal(externalAllocation);
ASSERT_EQ(1u, aubCsr->externalAllocations.size());
ResidencyContainer allocationsForResidency;
aubCsr->processResidency(&allocationsForResidency);
EXPECT_TRUE(aubCsr->writeMemoryParametrization.wasCalled);
EXPECT_EQ(addr, aubCsr->writeMemoryParametrization.receivedAllocationView.first);
EXPECT_EQ(size, aubCsr->writeMemoryParametrization.receivedAllocationView.second);
EXPECT_TRUE(aubCsr->writeMemoryParametrization.statusToReturn);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenProcessResidencyIsCalledThenExternalAllocationWithZeroSizeShouldNotBeMadeResident) {
auto aubCsr = std::make_unique<MockAubCsrToTestExternalAllocations<FamilyType>>(*platformDevices[0], "", true, *pDevice->executionEnvironment);
AllocationView externalAllocation(0, 0);
aubCsr->makeResidentExternal(externalAllocation);
ASSERT_EQ(1u, aubCsr->externalAllocations.size());
ResidencyContainer allocationsForResidency;
aubCsr->processResidency(&allocationsForResidency);
EXPECT_TRUE(aubCsr->writeMemoryParametrization.wasCalled);
EXPECT_EQ(0u, aubCsr->writeMemoryParametrization.receivedAllocationView.first);
EXPECT_EQ(0u, aubCsr->writeMemoryParametrization.receivedAllocationView.second);
EXPECT_FALSE(aubCsr->writeMemoryParametrization.statusToReturn);
}
#if defined(__clang__) #if defined(__clang__)
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif

View File

@ -1366,6 +1366,8 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, CreateCommandStreamReceiverHw) {
MemoryManager *mm = csrHw->createMemoryManager(false); MemoryManager *mm = csrHw->createMemoryManager(false);
EXPECT_EQ(nullptr, mm); EXPECT_EQ(nullptr, mm);
GmmPageTableMngr *ptm = csrHw->createPageTableManager();
EXPECT_EQ(nullptr, ptm);
delete csrHw; delete csrHw;
DebugManager.flags.SetCommandStreamReceiver.set(0); DebugManager.flags.SetCommandStreamReceiver.set(0);

View File

@ -178,3 +178,26 @@ TEST(ExecutionEnvironment, givenMultipleDevicesWhenTheyAreCreatedTheyAllReuseThe
EXPECT_EQ(&commandStreamReceiver, &device->getCommandStreamReceiver()); EXPECT_EQ(&commandStreamReceiver, &device->getCommandStreamReceiver());
EXPECT_EQ(memoryManager, device2->getMemoryManager()); EXPECT_EQ(memoryManager, device2->getMemoryManager());
} }
typedef ::testing::Test ExecutionEnvironmentHw;
HWTEST_F(ExecutionEnvironmentHw, givenExecutionEnvironmentWhenCommandStreamReceiverIsInitializedForCompressedBuffersThenCreatePageTableManagerIsCalled) {
ExecutionEnvironment executionEnvironment;
HardwareInfo localHwInfo = *platformDevices[0];
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
executionEnvironment.initializeCommandStreamReceiver(&localHwInfo);
auto csr = static_cast<UltCommandStreamReceiver<FamilyType> *>(executionEnvironment.commandStreamReceiver.get());
ASSERT_NE(nullptr, csr);
EXPECT_TRUE(csr->createPageTableManagerCalled);
}
HWTEST_F(ExecutionEnvironmentHw, givenExecutionEnvironmentWhenCommandStreamReceiverIsInitializedForCompressedImagesThenCreatePageTableManagerIsCalled) {
ExecutionEnvironment executionEnvironment;
HardwareInfo localHwInfo = *platformDevices[0];
localHwInfo.capabilityTable.ftrRenderCompressedImages = true;
executionEnvironment.initializeCommandStreamReceiver(&localHwInfo);
EXPECT_NE(nullptr, executionEnvironment.commandStreamReceiver);
auto csr = static_cast<UltCommandStreamReceiver<FamilyType> *>(executionEnvironment.commandStreamReceiver.get());
ASSERT_NE(nullptr, csr);
EXPECT_TRUE(csr->createPageTableManagerCalled);
}

View File

@ -20,10 +20,10 @@
set(IGDRCL_SRCS_tests_gen10_windows set(IGDRCL_SRCS_tests_gen10_windows
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/os_interface_tests_gen10.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gmm_callbacks_tests_gen10.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translationtable_callbacks_tests_gen10.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_mapper_tests_gen10.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_tests_gen10.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_tests_gen10.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_interface_tests_gen10.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_mapper_tests_gen10.cpp
) )
if(WIN32) if(WIN32)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen10_windows}) target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen10_windows})

View File

@ -20,13 +20,17 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include "runtime/helpers/translationtable_callbacks.h" #include "runtime/helpers/gmm_callbacks.h"
#include "test.h" #include "test.h"
using namespace OCLRT; using namespace OCLRT;
typedef ::testing::Test Gen10TTCallbacksTests; typedef ::testing::Test Gen10GmmCallbacksTests;
GEN10TEST_F(Gen10TTCallbacksTests, notSupported) { GEN10TEST_F(Gen10GmmCallbacksTests, notSupportedDeviceCallback) {
EXPECT_EQ(0, DeviceCallbacks<FamilyType>::notifyAubCapture(nullptr, 0, 0, false));
}
GEN10TEST_F(Gen10GmmCallbacksTests, notSupportedTTCallback) {
EXPECT_EQ(0, TTCallbacks<FamilyType>::writeL3Address(nullptr, 1, 2)); EXPECT_EQ(0, TTCallbacks<FamilyType>::writeL3Address(nullptr, 1, 2));
} }

View File

@ -20,8 +20,8 @@
set(IGDRCL_SRCS_tests_gen8_windows set(IGDRCL_SRCS_tests_gen8_windows
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/gmm_callbacks_tests_gen8.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_mapper_tests_gen8.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_mapper_tests_gen8.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translationtable_callbacks_tests_gen8.cpp
) )
if(WIN32) if(WIN32)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen8_windows}) target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen8_windows})

View File

@ -20,13 +20,17 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include "runtime/helpers/translationtable_callbacks.h" #include "runtime/helpers/gmm_callbacks.h"
#include "test.h" #include "test.h"
using namespace OCLRT; using namespace OCLRT;
typedef ::testing::Test Gen9TTCallbacksTests; typedef ::testing::Test Gen8GmmCallbacksTests;
GEN9TEST_F(Gen9TTCallbacksTests, notSupported) { GEN8TEST_F(Gen8GmmCallbacksTests, notSupportedDeviceCallback) {
EXPECT_EQ(0, DeviceCallbacks<FamilyType>::notifyAubCapture(nullptr, 0, 0, false));
}
GEN8TEST_F(Gen8GmmCallbacksTests, notSupportedTTCallback) {
EXPECT_EQ(0, TTCallbacks<FamilyType>::writeL3Address(nullptr, 1, 2)); EXPECT_EQ(0, TTCallbacks<FamilyType>::writeL3Address(nullptr, 1, 2));
} }

View File

@ -20,9 +20,9 @@
set(IGDRCL_SRCS_tests_gen9_windows set(IGDRCL_SRCS_tests_gen9_windows
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/gmm_callbacks_tests_gen9.cpp
${CMAKE_CURRENT_SOURCE_DIR}/os_interface_tests_gen9.cpp ${CMAKE_CURRENT_SOURCE_DIR}/os_interface_tests_gen9.cpp
${CMAKE_CURRENT_SOURCE_DIR}/wddm_mapper_tests_gen9.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_mapper_tests_gen9.cpp
${CMAKE_CURRENT_SOURCE_DIR}/translationtable_callbacks_tests_gen9.cpp
) )
if(WIN32) if(WIN32)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen9_windows}) target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen9_windows})

View File

@ -20,13 +20,17 @@
* OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*/ */
#include "runtime/helpers/translationtable_callbacks.h" #include "runtime/helpers/gmm_callbacks.h"
#include "test.h" #include "test.h"
using namespace OCLRT; using namespace OCLRT;
typedef ::testing::Test Gen8TTCallbacksTests; typedef ::testing::Test Gen9GmmCallbacksTests;
GEN8TEST_F(Gen8TTCallbacksTests, notSupported) { GEN9TEST_F(Gen9GmmCallbacksTests, notSupportedDeviceCallback) {
EXPECT_EQ(0, DeviceCallbacks<FamilyType>::notifyAubCapture(nullptr, 0, 0, false));
}
GEN9TEST_F(Gen9GmmCallbacksTests, notSupportedTTCallback) {
EXPECT_EQ(0, TTCallbacks<FamilyType>::writeL3Address(nullptr, 1, 2)); EXPECT_EQ(0, TTCallbacks<FamilyType>::writeL3Address(nullptr, 1, 2));
} }

View File

@ -28,6 +28,8 @@
namespace OCLRT { namespace OCLRT {
class GmmPageTableMngr;
template <typename GfxFamily> template <typename GfxFamily>
class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily> { class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily> {
using BaseClass = CommandStreamReceiverHw<GfxFamily>; using BaseClass = CommandStreamReceiverHw<GfxFamily>;
@ -80,6 +82,11 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily> {
return memoryManager; return memoryManager;
} }
virtual GmmPageTableMngr *createPageTableManager() override {
createPageTableManagerCalled = true;
return nullptr;
}
void overrideCsrSizeReqFlags(CsrSizeRequestFlags &flags) { this->csrSizeRequestFlags = flags; } void overrideCsrSizeReqFlags(CsrSizeRequestFlags &flags) { this->csrSizeRequestFlags = flags; }
bool isPreambleProgrammed() const { return this->isPreambleSent; } bool isPreambleProgrammed() const { return this->isPreambleSent; }
bool isGSBAFor32BitProgrammed() const { return this->GSBAFor32BitProgrammed; } bool isGSBAFor32BitProgrammed() const { return this->GSBAFor32BitProgrammed; }
@ -133,6 +140,7 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily> {
initProgrammingFlagsCalled = true; initProgrammingFlagsCalled = true;
} }
bool createPageTableManagerCalled = false;
bool activateAubSubCaptureCalled = false; bool activateAubSubCaptureCalled = false;
bool flushBatchedSubmissionsCalled = false; bool flushBatchedSubmissionsCalled = false;
bool initProgrammingFlagsCalled = false; bool initProgrammingFlagsCalled = false;

View File

@ -28,8 +28,8 @@
#include "runtime/command_stream/preemption.h" #include "runtime/command_stream/preemption.h"
#include "runtime/gen_common/hw_cmds.h" #include "runtime/gen_common/hw_cmds.h"
#include "runtime/helpers/built_ins_helper.h" #include "runtime/helpers/built_ins_helper.h"
#include "runtime/helpers/gmm_callbacks.h"
#include "runtime/helpers/options.h" #include "runtime/helpers/options.h"
#include "runtime/helpers/translationtable_callbacks.h"
#include "runtime/mem_obj/buffer.h" #include "runtime/mem_obj/buffer.h"
#include "runtime/memory_manager/memory_manager.h" #include "runtime/memory_manager/memory_manager.h"
#include "runtime/os_interface/windows/wddm_device_command_stream.h" #include "runtime/os_interface/windows/wddm_device_command_stream.h"
@ -830,6 +830,7 @@ HWTEST_F(WddmCsrCompressionTests, givenEnabledCompressionWhenInitializedThenCrea
createMockWddm(); createMockWddm();
EXPECT_EQ(nullptr, myMockWddm->getPageTableManager()); EXPECT_EQ(nullptr, myMockWddm->getPageTableManager());
MockWddmCsr<FamilyType> mockWddmCsr(hwInfo, myMockWddm, *executionEnvironment); MockWddmCsr<FamilyType> mockWddmCsr(hwInfo, myMockWddm, *executionEnvironment);
mockWddmCsr.createPageTableManager();
ASSERT_NE(nullptr, myMockWddm->getPageTableManager()); ASSERT_NE(nullptr, myMockWddm->getPageTableManager());
auto mockMngr = reinterpret_cast<MockGmmPageTableMngr *>(myMockWddm->getPageTableManager()); auto mockMngr = reinterpret_cast<MockGmmPageTableMngr *>(myMockWddm->getPageTableManager());
@ -841,6 +842,7 @@ HWTEST_F(WddmCsrCompressionTests, givenEnabledCompressionWhenInitializedThenCrea
// clang-format off // clang-format off
expectedDeviceCb.Adapter.KmtHandle = myMockWddm->getAdapter(); expectedDeviceCb.Adapter.KmtHandle = myMockWddm->getAdapter();
expectedDeviceCb.hDevice.KmtHandle = myMockWddm->getDevice(); expectedDeviceCb.hDevice.KmtHandle = myMockWddm->getDevice();
expectedDeviceCb.hCsr = &mockWddmCsr;
expectedDeviceCb.PagingQueue = myMockWddm->getPagingQueue(); expectedDeviceCb.PagingQueue = myMockWddm->getPagingQueue();
expectedDeviceCb.PagingFence = myMockWddm->getPagingQueueSyncObject(); expectedDeviceCb.PagingFence = myMockWddm->getPagingQueueSyncObject();
@ -855,6 +857,7 @@ HWTEST_F(WddmCsrCompressionTests, givenEnabledCompressionWhenInitializedThenCrea
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnLock = myGdi->lock2; expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnLock = myGdi->lock2;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnUnLock = myGdi->unlock2; expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnUnLock = myGdi->unlock2;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnEscape = myGdi->escape; expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnEscape = myGdi->escape;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnNotifyAubCapture = DeviceCallbacks<FamilyType>::notifyAubCapture;
expectedTTCallbacks.pfWriteL3Adr = TTCallbacks<FamilyType>::writeL3Address; expectedTTCallbacks.pfWriteL3Adr = TTCallbacks<FamilyType>::writeL3Address;
// clang-format on // clang-format on
@ -883,8 +886,8 @@ HWTEST_F(WddmCsrCompressionTests, givenEnabledCompressionWhenFlushingThenInitTra
ExecutionEnvironment *executionEnvironment = new ExecutionEnvironment; ExecutionEnvironment *executionEnvironment = new ExecutionEnvironment;
setCompressionEnabled(compressionEnabled[i][0], compressionEnabled[i][1]); setCompressionEnabled(compressionEnabled[i][0], compressionEnabled[i][1]);
createMockWddm(); createMockWddm();
auto mockWddmCsr = new MockWddmCsr<FamilyType>(hwInfo, myMockWddm, *executionEnvironment); auto mockWddmCsr = new MockWddmCsr<FamilyType>(hwInfo, myMockWddm, *executionEnvironment);
mockWddmCsr->createPageTableManager();
mockWddmCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch); mockWddmCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch);
executionEnvironment->commandStreamReceiver.reset(mockWddmCsr); executionEnvironment->commandStreamReceiver.reset(mockWddmCsr);