Refactor: pass root device environment to gmm client context

Related-To: NEO-6853
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2022-11-25 07:53:05 +00:00
committed by Compute-Runtime-Automation
parent ba9c50694d
commit 27cb39ef25
24 changed files with 150 additions and 156 deletions

View File

@@ -8,7 +8,6 @@
#include "level_zero/core/test/unit_tests/fixtures/module_fixture.h"
#include "shared/source/command_container/implicit_scaling.h"
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "gtest/gtest.h"
@@ -18,33 +17,7 @@ namespace ult {
ModuleImmutableDataFixture::MockImmutableMemoryManager::MockImmutableMemoryManager(NEO::ExecutionEnvironment &executionEnvironment) : NEO::MockMemoryManager(const_cast<NEO::ExecutionEnvironment &>(executionEnvironment)) {}
ModuleImmutableDataFixture::MockImmutableData::MockImmutableData(uint32_t perHwThreadPrivateMemorySize) {
mockKernelDescriptor = new NEO::KernelDescriptor;
mockKernelDescriptor->kernelAttributes.perHwThreadPrivateMemorySize = perHwThreadPrivateMemorySize;
kernelDescriptor = mockKernelDescriptor;
mockKernelInfo = new NEO::KernelInfo;
mockKernelInfo->heapInfo.pKernelHeap = kernelHeap;
mockKernelInfo->heapInfo.KernelHeapSize = MemoryConstants::pageSize;
kernelInfo = mockKernelInfo;
if (getIsaGraphicsAllocation() != nullptr) {
device->getNEODevice()->getMemoryManager()->freeGraphicsMemory(&*isaGraphicsAllocation);
isaGraphicsAllocation.release();
}
auto ptr = reinterpret_cast<void *>(0x1234);
auto gmmHelper = std::make_unique<GmmHelper>(nullptr, defaultHwInfo.get());
auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr));
isaGraphicsAllocation.reset(new NEO::MockGraphicsAllocation(0,
NEO::AllocationType::KERNEL_ISA,
ptr,
0x1000,
0u,
MemoryPool::System4KBPages,
MemoryManager::maxOsContextCount,
canonizedGpuAddress));
kernelInfo->kernelAllocation = isaGraphicsAllocation.get();
}
ModuleImmutableDataFixture::MockImmutableData::MockImmutableData(uint32_t perHwThreadPrivateMemorySize) : MockImmutableData(perHwThreadPrivateMemorySize, 0, 0) {}
ModuleImmutableDataFixture::MockImmutableData::MockImmutableData(uint32_t perHwThreadPrivateMemorySize, uint32_t perThreadScratchSize, uint32_t perThreaddPrivateScratchSize) {
mockKernelDescriptor = new NEO::KernelDescriptor;
mockKernelDescriptor->kernelAttributes.perHwThreadPrivateMemorySize = perHwThreadPrivateMemorySize;
@@ -57,13 +30,7 @@ ModuleImmutableDataFixture::MockImmutableData::MockImmutableData(uint32_t perHwT
mockKernelInfo->heapInfo.KernelHeapSize = MemoryConstants::pageSize;
kernelInfo = mockKernelInfo;
if (getIsaGraphicsAllocation() != nullptr) {
device->getNEODevice()->getMemoryManager()->freeGraphicsMemory(&*isaGraphicsAllocation);
isaGraphicsAllocation.release();
}
auto ptr = reinterpret_cast<void *>(0x1234);
auto gmmHelper = std::make_unique<GmmHelper>(nullptr, defaultHwInfo.get());
auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr));
isaGraphicsAllocation.reset(new NEO::MockGraphicsAllocation(0,
NEO::AllocationType::KERNEL_ISA,
ptr,
@@ -71,7 +38,7 @@ ModuleImmutableDataFixture::MockImmutableData::MockImmutableData(uint32_t perHwT
0u,
MemoryPool::System4KBPages,
MemoryManager::maxOsContextCount,
canonizedGpuAddress));
castToUint64(ptr)));
kernelInfo->kernelAllocation = isaGraphicsAllocation.get();
}
@@ -247,8 +214,6 @@ ModuleWithZebinFixture::MockImmutableData::MockImmutableData(L0::Device *device)
kernelDescriptor = mockKernelDescriptor;
this->device = device;
auto ptr = reinterpret_cast<void *>(0x1234);
auto gmmHelper = device->getNEODevice()->getGmmHelper();
auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr));
isaGraphicsAllocation.reset(new NEO::MockGraphicsAllocation(0,
NEO::AllocationType::KERNEL_ISA,
ptr,
@@ -256,7 +221,7 @@ ModuleWithZebinFixture::MockImmutableData::MockImmutableData(L0::Device *device)
0u,
MemoryPool::System4KBPages,
MemoryManager::maxOsContextCount,
canonizedGpuAddress));
castToUint64(ptr)));
}
ModuleWithZebinFixture::MockImmutableData::~MockImmutableData() {
@@ -269,8 +234,7 @@ ModuleWithZebinFixture::MockModuleWithZebin::MockModuleWithZebin(L0::Device *dev
void ModuleWithZebinFixture::MockModuleWithZebin::addSegments() {
kernelImmDatas.push_back(std::make_unique<MockImmutableData>(device));
auto ptr = reinterpret_cast<void *>(0x1234);
auto gmmHelper = device->getNEODevice()->getGmmHelper();
auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(ptr));
auto canonizedGpuAddress = castToUint64(ptr);
translationUnit->globalVarBuffer = new NEO::MockGraphicsAllocation(0,
NEO::AllocationType::GLOBAL_SURFACE,
ptr,

View File

@@ -283,7 +283,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe
DirectSubmissionControllerMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
};
struct GmmHelperMock : public DestructorCounted<GmmHelper, 6> {
GmmHelperMock(uint32_t &destructorId, const HardwareInfo *hwInfo) : DestructorCounted(destructorId, nullptr, hwInfo) {}
GmmHelperMock(uint32_t &destructorId, const RootDeviceEnvironment &rootDeviceEnvironment) : DestructorCounted(destructorId, rootDeviceEnvironment) {}
};
struct OsInterfaceMock : public DestructorCounted<OSInterface, 5> {
OsInterfaceMock(uint32_t &destructorId) : DestructorCounted(destructorId) {}
@@ -304,10 +304,8 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe
SourceLevelDebuggerMock(uint32_t &destructorId) : DestructorCounted(destructorId, nullptr) {}
};
auto gmmHelper = new GmmHelperMock(destructorId, defaultHwInfo.get());
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
executionEnvironment->rootDeviceEnvironments[0]->gmmHelper = std::unique_ptr<GmmHelperMock>(gmmHelper);
executionEnvironment->rootDeviceEnvironments[0]->gmmHelper = std::make_unique<GmmHelperMock>(destructorId, *executionEnvironment->rootDeviceEnvironments[0]);
executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique<OsInterfaceMock>(destructorId);
executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique<MemoryOperationsHandlerMock>(destructorId);
executionEnvironment->memoryManager = std::make_unique<MemoryMangerMock>(destructorId, *executionEnvironment);

View File

@@ -42,6 +42,7 @@ using namespace ::testing;
namespace NEO {
extern GMM_INIT_IN_ARGS passedInputArgs;
extern GT_SYSTEM_INFO passedGtSystemInfo;
extern SKU_FEATURE_TABLE passedFtrTable;
extern WA_TABLE passedWaTable;
extern bool copyInputArgs;
@@ -51,9 +52,11 @@ struct GmmTests : public MockExecutionEnvironmentGmmFixtureTest {
MockExecutionEnvironmentGmmFixture::setUp();
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
localPlatformDevice = rootDeviceEnvironment->getMutableHardwareInfo();
gmmHelper = rootDeviceEnvironment->getGmmHelper();
}
RootDeviceEnvironment *rootDeviceEnvironment = nullptr;
HardwareInfo *localPlatformDevice = nullptr;
GmmHelper *gmmHelper = nullptr;
};
TEST(GmmGlTests, givenGmmWhenAskedforCubeFaceIndexThenProperValueIsReturned) {
@@ -350,11 +353,13 @@ TEST_F(GmmTests, givenNonZeroRowPitchWhenQueryImgFromBufferParamsThenUseUserValu
using GmmCanonizeTests = GmmTests;
TEST_F(GmmCanonizeTests, WhenCanonizingThenCorrectAddressIsReturned) {
auto hwInfo = *defaultHwInfo;
auto &hwInfo = *rootDeviceEnvironment->getMutableHardwareInfo();
// 48 bit - canonize to 48 bit
hwInfo.capabilityTable.gpuAddressSpace = maxNBitValue(48); // 0x0000FFFFFFFFFFFF;
auto gmmHelper = std::make_unique<GmmHelper>(nullptr, &hwInfo);
rootDeviceEnvironment->gmmHelper.reset();
rootDeviceEnvironment->initGmm();
gmmHelper = rootDeviceEnvironment->getGmmHelper();
uint64_t testAddr1 = 0x7777777777777777;
uint64_t goodAddr1 = 0x0000777777777777;
@@ -366,18 +371,22 @@ TEST_F(GmmCanonizeTests, WhenCanonizingThenCorrectAddressIsReturned) {
// 36 bit - also canonize to 48 bit
hwInfo.capabilityTable.gpuAddressSpace = maxNBitValue(36); // 0x0000000FFFFFFFFF;
gmmHelper = std::make_unique<GmmHelper>(nullptr, &hwInfo);
rootDeviceEnvironment->gmmHelper.reset();
rootDeviceEnvironment->initGmm();
gmmHelper = rootDeviceEnvironment->getGmmHelper();
EXPECT_EQ(gmmHelper->canonize(testAddr1), goodAddr1);
EXPECT_EQ(gmmHelper->canonize(testAddr2), goodAddr2);
}
TEST_F(GmmCanonizeTests, WhenDecanonizingThenCorrectAddressIsReturned) {
auto hwInfo = *defaultHwInfo;
auto &hwInfo = *rootDeviceEnvironment->getMutableHardwareInfo();
// 48 bit - decanonize to 48 bit
hwInfo.capabilityTable.gpuAddressSpace = maxNBitValue(48); // 0x0000FFFFFFFFFFFF;
auto gmmHelper = std::make_unique<GmmHelper>(nullptr, &hwInfo);
rootDeviceEnvironment->gmmHelper.reset();
rootDeviceEnvironment->initGmm();
gmmHelper = rootDeviceEnvironment->getGmmHelper();
uint64_t testAddr1 = 0x7777777777777777;
uint64_t goodAddr1 = 0x0000777777777777;
@@ -389,18 +398,22 @@ TEST_F(GmmCanonizeTests, WhenDecanonizingThenCorrectAddressIsReturned) {
// 36 bit - also decanonize to 48 bit
hwInfo.capabilityTable.gpuAddressSpace = maxNBitValue(36); // 0x0000000FFFFFFFFF;
gmmHelper = std::make_unique<GmmHelper>(nullptr, &hwInfo);
rootDeviceEnvironment->gmmHelper.reset();
rootDeviceEnvironment->initGmm();
gmmHelper = rootDeviceEnvironment->getGmmHelper();
EXPECT_EQ(gmmHelper->decanonize(testAddr1), goodAddr1);
EXPECT_EQ(gmmHelper->decanonize(testAddr2), goodAddr2);
}
TEST_F(GmmCanonizeTests, WhenCheckingIsValidCanonicalGpuAddressThenOnlyValidAddressesReturnTrue) {
auto hwInfo = *defaultHwInfo;
auto &hwInfo = *rootDeviceEnvironment->getMutableHardwareInfo();
// 48 bit
hwInfo.capabilityTable.gpuAddressSpace = maxNBitValue(48); // 0x0000FFFFFFFFFFFF;
auto gmmHelper = std::make_unique<GmmHelper>(nullptr, &hwInfo);
rootDeviceEnvironment->gmmHelper.reset();
rootDeviceEnvironment->initGmm();
gmmHelper = rootDeviceEnvironment->getGmmHelper();
uint64_t testAddr1 = 0x0000400000000000;
EXPECT_TRUE(gmmHelper->isValidCanonicalGpuAddress(testAddr1));
@@ -416,7 +429,9 @@ TEST_F(GmmCanonizeTests, WhenCheckingIsValidCanonicalGpuAddressThenOnlyValidAddr
// 36 bit
hwInfo.capabilityTable.gpuAddressSpace = maxNBitValue(36); // 0x0000000FFFFFFFFF;
gmmHelper = std::make_unique<GmmHelper>(nullptr, &hwInfo);
rootDeviceEnvironment->gmmHelper.reset();
rootDeviceEnvironment->initGmm();
gmmHelper = rootDeviceEnvironment->getGmmHelper();
uint64_t testAddr5 = 0x0000000400000000;
EXPECT_TRUE(gmmHelper->isValidCanonicalGpuAddress(testAddr5));
@@ -432,7 +447,9 @@ TEST_F(GmmCanonizeTests, WhenCheckingIsValidCanonicalGpuAddressThenOnlyValidAddr
// 57 bit
hwInfo.capabilityTable.gpuAddressSpace = maxNBitValue(57); // 0x01FFFFFFFFFFFFFFF;
gmmHelper = std::make_unique<GmmHelper>(nullptr, &hwInfo);
rootDeviceEnvironment->gmmHelper.reset();
rootDeviceEnvironment->initGmm();
gmmHelper = rootDeviceEnvironment->getGmmHelper();
uint64_t testAddr9 = 0x0080000000000000;
EXPECT_TRUE(gmmHelper->isValidCanonicalGpuAddress(testAddr9));
@@ -1027,31 +1044,31 @@ struct GmmHelperTests : MockExecutionEnvironmentGmmFixtureTest {
};
TEST_F(GmmHelperTests, givenValidGmmFunctionsWhenCreateGmmHelperWithInitializedOsInterfaceThenProperParametersArePassed) {
std::unique_ptr<GmmHelper> gmmHelper;
DeviceFactory::prepareDeviceEnvironments(*executionEnvironment);
VariableBackup<decltype(passedInputArgs)> passedInputArgsBackup(&passedInputArgs);
VariableBackup<decltype(passedFtrTable)> passedFtrTableBackup(&passedFtrTable);
VariableBackup<decltype(passedGtSystemInfo)> passedGtSystemInfoBackup(&passedGtSystemInfo);
VariableBackup<decltype(passedWaTable)> passedWaTableBackup(&passedWaTable);
VariableBackup<decltype(copyInputArgs)> copyInputArgsBackup(&copyInputArgs, true);
auto hwInfo = defaultHwInfo.get();
auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
SKU_FEATURE_TABLE expectedFtrTable = {};
WA_TABLE expectedWaTable = {};
SkuInfoTransfer::transferFtrTableForGmm(&expectedFtrTable, &hwInfo->featureTable);
SkuInfoTransfer::transferWaTableForGmm(&expectedWaTable, &hwInfo->workaroundTable);
gmmHelper.reset(new GmmHelper(executionEnvironment->rootDeviceEnvironments[0]->osInterface.get(), hwInfo));
auto gmmHelper = std::make_unique<GmmHelper>(*executionEnvironment->rootDeviceEnvironments[0]);
EXPECT_EQ(0, memcmp(&hwInfo->platform, &passedInputArgs.Platform, sizeof(PLATFORM)));
EXPECT_EQ(&hwInfo->gtSystemInfo, passedInputArgs.pGtSysInfo);
EXPECT_EQ(0, memcmp(&hwInfo->gtSystemInfo, &passedGtSystemInfo, sizeof(GT_SYSTEM_INFO)));
EXPECT_EQ(0, memcmp(&expectedFtrTable, &passedFtrTable, sizeof(SKU_FEATURE_TABLE)));
EXPECT_EQ(0, memcmp(&expectedWaTable, &passedWaTable, sizeof(WA_TABLE)));
EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, passedInputArgs.ClientType);
}
TEST(GmmHelperTest, givenValidGmmFunctionsWhenCreateGmmHelperWithoutOsInterfaceThenInitializationDoesntCrashAndProperParametersArePassed) {
std::unique_ptr<GmmHelper> gmmHelper;
VariableBackup<decltype(passedInputArgs)> passedInputArgsBackup(&passedInputArgs);
VariableBackup<decltype(passedFtrTable)> passedFtrTableBackup(&passedFtrTable);
VariableBackup<decltype(passedGtSystemInfo)> passedGtSystemInfoBackup(&passedGtSystemInfo);
VariableBackup<decltype(passedWaTable)> passedWaTableBackup(&passedWaTable);
VariableBackup<decltype(copyInputArgs)> copyInputArgsBackup(&copyInputArgs, true);
@@ -1061,9 +1078,10 @@ TEST(GmmHelperTest, givenValidGmmFunctionsWhenCreateGmmHelperWithoutOsInterfaceT
SkuInfoTransfer::transferFtrTableForGmm(&expectedFtrTable, &hwInfo->featureTable);
SkuInfoTransfer::transferWaTableForGmm(&expectedWaTable, &hwInfo->workaroundTable);
gmmHelper.reset(new GmmHelper(nullptr, hwInfo));
MockExecutionEnvironment executionEnvironment{hwInfo};
EXPECT_EQ(nullptr, executionEnvironment.rootDeviceEnvironments[0]->osInterface.get());
EXPECT_EQ(0, memcmp(&hwInfo->platform, &passedInputArgs.Platform, sizeof(PLATFORM)));
EXPECT_EQ(&hwInfo->gtSystemInfo, passedInputArgs.pGtSysInfo);
EXPECT_EQ(0, memcmp(&hwInfo->gtSystemInfo, &passedGtSystemInfo, sizeof(GT_SYSTEM_INFO)));
EXPECT_EQ(0, memcmp(&expectedFtrTable, &passedFtrTable, sizeof(SKU_FEATURE_TABLE)));
EXPECT_EQ(0, memcmp(&expectedWaTable, &passedWaTable, sizeof(WA_TABLE)));
EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, passedInputArgs.ClientType);
@@ -1073,9 +1091,8 @@ TEST(GmmHelperTest, givenGmmHelperAndL3CacheDisabledForDebugThenCorrectMOCSIsRet
decltype(GmmHelper::createGmmContextWrapperFunc) createGmmContextSave = GmmHelper::createGmmContextWrapperFunc;
GmmHelper::createGmmContextWrapperFunc = GmmClientContext::create<MockGmmClientContext>;
std::unique_ptr<GmmHelper> gmmHelper;
auto hwInfo = defaultHwInfo.get();
gmmHelper.reset(new GmmHelper(nullptr, hwInfo));
MockExecutionEnvironment executionEnvironment{};
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper();
EXPECT_EQ(0u, gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED));
EXPECT_EQ(2u, gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER));
@@ -1101,9 +1118,8 @@ TEST(GmmHelperTest, givenGmmHelperAndForceAllResourcesUncachedDebugVariableSetTh
decltype(GmmHelper::createGmmContextWrapperFunc) createGmmContextSave = GmmHelper::createGmmContextWrapperFunc;
GmmHelper::createGmmContextWrapperFunc = GmmClientContext::create<MockGmmClientContext>;
std::unique_ptr<GmmHelper> gmmHelper;
auto hwInfo = defaultHwInfo.get();
gmmHelper.reset(new GmmHelper(nullptr, hwInfo));
MockExecutionEnvironment executionEnvironment{};
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper();
EXPECT_EQ(0u, gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED));
EXPECT_EQ(2u, gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER));

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -45,13 +45,13 @@ TEST(OsInterfaceTest, whenOsInterfaceSetupsGmmInputArgsThenFileDescriptorIsSetWi
}
TEST(GmmHelperTest, whenCreateGmmHelperWithoutOsInterfaceThenPassedFileDescriptorIsZeroed) {
std::unique_ptr<GmmHelper> gmmHelper;
MockExecutionEnvironment executionEnvironment{};
VariableBackup<decltype(passedInputArgs)> passedInputArgsBackup(&passedInputArgs);
VariableBackup<decltype(copyInputArgs)> copyInputArgsBackup(&copyInputArgs, true);
uint32_t expectedFileDescriptor = 0u;
gmmHelper.reset(new GmmHelper(nullptr, defaultHwInfo.get()));
auto gmmHelper = std::make_unique<GmmHelper>(*executionEnvironment.rootDeviceEnvironments[0]);
EXPECT_EQ(expectedFileDescriptor, passedInputArgs.FileDescriptor);
EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, passedInputArgs.ClientType);
}

View File

@@ -127,8 +127,9 @@ TEST(GraphicsAllocationTest, WhenAllocationIsCreatedThenItsAddressIsCorrect) {
TEST(GraphicsAllocationTest, GivenNonSharedResourceHandleWhenAllocationIsCreatedThenItsAddressIsCorrect) {
void *cpuPtr = (void *)0x30000;
size_t size = 0x1000;
GmmHelper gmmHelper(nullptr, defaultHwInfo.get());
auto canonizedGpuAddress = gmmHelper.canonize(castToUint64(cpuPtr));
MockExecutionEnvironment executionEnvironment{};
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper();
auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(cpuPtr));
osHandle sharedHandle = Sharing::nonSharedResource;
GraphicsAllocation gfxAllocation(0, AllocationType::UNKNOWN, cpuPtr, size, sharedHandle, MemoryPool::MemoryNull, 0u, canonizedGpuAddress);
uint64_t expectedGpuAddr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(gfxAllocation.getUnderlyingBuffer()));
@@ -150,7 +151,8 @@ TEST(GraphicsAllocationTest, WhenGettingAddressesThenAddressesAreCorrect) {
cpuPtr = (void *)65535;
gpuAddr = 1ULL;
auto gmmHelper = std::make_unique<GmmHelper>(nullptr, defaultHwInfo.get());
MockExecutionEnvironment executionEnvironment{};
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper();
auto canonizedGpuAddress = gmmHelper->canonize(gpuAddr);
gfxAllocation.setCpuPtrAndGpuAddress(cpuPtr, canonizedGpuAddress);
@@ -340,7 +342,6 @@ TEST_F(MemoryAllocatorTest, WhenPopulatingOsHandleThenOneFragmentIsReturned) {
TEST_F(MemoryAllocatorTest, givenOsHandleStorageWhenOsHandlesAreCleanedAndAubManagerIsNotAvailableThenFreeMemoryIsNotCalledOnAubManager) {
MockExecutionEnvironment mockExecutionEnvironment(defaultHwInfo.get());
MockMemoryManager mockMemoryManager(mockExecutionEnvironment);
GmmHelper gmmHelper(nullptr, defaultHwInfo.get());
auto mockAubCenter = new MockAubCenter(*mockExecutionEnvironment.rootDeviceEnvironments[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB);
mockAubCenter->aubManager.reset(nullptr);
mockExecutionEnvironment.rootDeviceEnvironments[0]->aubCenter.reset(mockAubCenter);
@@ -360,7 +361,6 @@ TEST_F(MemoryAllocatorTest, givenOsHandleStorageAndFreeMemoryEnabledWhenOsHandle
const uint32_t rootDeviceIndex = 1u;
MockExecutionEnvironment mockExecutionEnvironment(defaultHwInfo.get(), true, 3);
MockMemoryManager mockMemoryManager(mockExecutionEnvironment);
GmmHelper gmmHelper(nullptr, defaultHwInfo.get());
auto mockManager0 = new MockAubManager();
auto mockAubCenter0 = new MockAubCenter(*mockExecutionEnvironment.rootDeviceEnvironments[0], false, "aubfile", CommandStreamReceiverType::CSR_AUB);
mockAubCenter0->aubManager.reset(mockManager0);
@@ -1598,7 +1598,6 @@ TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerAndFreeMemoryEnabledWh
DebugManager.flags.EnableFreeMemory.set(true);
MockExecutionEnvironment executionEnvironment;
OsAgnosticMemoryManager memoryManager(executionEnvironment);
GmmHelper gmmHelper(nullptr, defaultHwInfo.get());
MockAubManager *mockManager = new MockAubManager();
MockAubCenter *mockAubCenter = new MockAubCenter(*executionEnvironment.rootDeviceEnvironments[0], false, "file_name.aub", CommandStreamReceiverType::CSR_AUB);
mockAubCenter->aubManager = std::unique_ptr<MockAubManager>(mockManager);
@@ -1615,7 +1614,6 @@ TEST(OsAgnosticMemoryManager, givenOsAgnosticMemoryManagerAndFreeMemoryDisabledW
DebugManager.flags.EnableFreeMemory.set(false);
MockExecutionEnvironment executionEnvironment;
OsAgnosticMemoryManager memoryManager(executionEnvironment);
GmmHelper gmmHelper(nullptr, defaultHwInfo.get());
MockAubManager *mockManager = new MockAubManager();
MockAubCenter *mockAubCenter = new MockAubCenter(*executionEnvironment.rootDeviceEnvironments[0], false, "file_name.aub", CommandStreamReceiverType::CSR_AUB);
mockAubCenter->aubManager = std::unique_ptr<MockAubManager>(mockManager);
@@ -2195,8 +2193,9 @@ TEST(GraphicsAllocation, givenSharedHandleBasedConstructorWhenGraphicsAllocation
void *addressWithTrailingBitSet = reinterpret_cast<void *>(address);
uint64_t expectedGpuAddress = 0xf0000000;
osHandle sharedHandle{};
GmmHelper gmmHelper(nullptr, defaultHwInfo.get());
auto canonizedGpuAddress = gmmHelper.canonize(castToUint64(addressWithTrailingBitSet));
MockExecutionEnvironment executionEnvironment{};
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper();
auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(addressWithTrailingBitSet));
GraphicsAllocation graphicsAllocation(0, AllocationType::UNKNOWN, addressWithTrailingBitSet, 1u, sharedHandle, MemoryPool::MemoryNull, 0u, canonizedGpuAddress);
EXPECT_EQ(expectedGpuAddress, graphicsAllocation.getGpuAddress());
}

View File

@@ -110,7 +110,7 @@ bool RootDeviceEnvironment::initAilConfiguration() {
void RootDeviceEnvironment::initGmm() {
if (!gmmHelper) {
gmmHelper.reset(new GmmHelper(osInterface.get(), getHardwareInfo()));
gmmHelper.reset(new GmmHelper(*this));
}
}

View File

@@ -7,6 +7,8 @@
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/gmm_helper/client_context/gmm_handle_allocator.h"
#include "shared/source/gmm_helper/gmm_interface.h"
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/helpers/hw_info.h"
@@ -14,21 +16,23 @@
#include "shared/source/sku_info/operations/sku_info_transfer.h"
namespace NEO {
GmmClientContext::GmmClientContext(OSInterface *osInterface, HardwareInfo *hwInfo) : hardwareInfo(hwInfo) {
GmmClientContext::GmmClientContext(const RootDeviceEnvironment &rootDeviceEnvironment) : hardwareInfo(rootDeviceEnvironment.getHardwareInfo()) {
_SKU_FEATURE_TABLE gmmFtrTable = {};
_WA_TABLE gmmWaTable = {};
SkuInfoTransfer::transferFtrTableForGmm(&gmmFtrTable, &hwInfo->featureTable);
SkuInfoTransfer::transferWaTableForGmm(&gmmWaTable, &hwInfo->workaroundTable);
SkuInfoTransfer::transferFtrTableForGmm(&gmmFtrTable, &hardwareInfo->featureTable);
SkuInfoTransfer::transferWaTableForGmm(&gmmWaTable, &hardwareInfo->workaroundTable);
GMM_INIT_IN_ARGS inArgs{};
GMM_INIT_OUT_ARGS outArgs{};
auto gtSystemInfo = hardwareInfo->gtSystemInfo;
inArgs.ClientType = GMM_CLIENT::GMM_OCL_VISTA;
inArgs.pGtSysInfo = &hwInfo->gtSystemInfo;
inArgs.pGtSysInfo = &gtSystemInfo;
inArgs.pSkuTable = &gmmFtrTable;
inArgs.pWaTable = &gmmWaTable;
inArgs.Platform = hwInfo->platform;
inArgs.Platform = hardwareInfo->platform;
auto osInterface = rootDeviceEnvironment.osInterface.get();
if (osInterface && osInterface->getDriverModel()) {
osInterface->getDriverModel()->setGmmInputArgs(&inArgs);
}
@@ -86,5 +90,8 @@ uint32_t GmmClientContext::cachePolicyGetPATIndex(GMM_RESOURCE_INFO *gmmResource
return patIndex;
}
void GmmClientContext::setHandleAllocator(std::unique_ptr<GmmHandleAllocator> allocator) {
this->handleAllocator = std::move(allocator);
}
} // namespace NEO

View File

@@ -6,19 +6,19 @@
*/
#pragma once
#include "shared/source/gmm_helper/client_context/gmm_handle_allocator.h"
#include "shared/source/gmm_helper/gmm_lib.h"
#include <memory>
namespace NEO {
class GmmClientContext;
class OSInterface;
struct RootDeviceEnvironment;
struct HardwareInfo;
class GmmHandleAllocator;
class GmmClientContext {
public:
GmmClientContext(OSInterface *osInterface, HardwareInfo *hwInfo);
GmmClientContext(const RootDeviceEnvironment &rootDeviceEnvironment);
MOCKABLE_VIRTUAL ~GmmClientContext();
MOCKABLE_VIRTUAL MEMORY_OBJECT_CONTROL_STATE cachePolicyGetMemoryObject(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE usage);
@@ -29,8 +29,8 @@ class GmmClientContext {
MOCKABLE_VIRTUAL void destroyResInfoObject(GMM_RESOURCE_INFO *pResInfo);
GMM_CLIENT_CONTEXT *getHandle() const;
template <typename T>
static std::unique_ptr<GmmClientContext> create(OSInterface *osInterface, HardwareInfo *hwInfo) {
return std::make_unique<T>(osInterface, hwInfo);
static std::unique_ptr<GmmClientContext> create(const RootDeviceEnvironment &rootDeviceEnvironment) {
return std::make_unique<T>(rootDeviceEnvironment);
}
const HardwareInfo *getHardwareInfo() {
@@ -40,9 +40,7 @@ class GmmClientContext {
MOCKABLE_VIRTUAL uint8_t getSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT format);
MOCKABLE_VIRTUAL uint8_t getMediaSurfaceStateCompressionFormat(GMM_RESOURCE_FORMAT format);
void setHandleAllocator(std::unique_ptr<GmmHandleAllocator> allocator) {
this->handleAllocator = std::move(allocator);
}
void setHandleAllocator(std::unique_ptr<GmmHandleAllocator> allocator);
MOCKABLE_VIRTUAL void setGmmDeviceInfo(GMM_DEVICE_INFO *deviceInfo);
@@ -51,7 +49,7 @@ class GmmClientContext {
}
protected:
HardwareInfo *hardwareInfo = nullptr;
const HardwareInfo *hardwareInfo = nullptr;
GMM_CLIENT_CONTEXT *clientContext;
std::unique_ptr<GmmHandleAllocator> handleAllocator;
};

View File

@@ -7,7 +7,7 @@
#pragma once
#include "shared/source/gmm_helper/gmm.h"
#include "shared/source/gmm_helper/gmm_lib.h"
#include <cstddef>

View File

@@ -8,6 +8,7 @@
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/helpers/hw_helper.h"
@@ -42,11 +43,11 @@ void GmmHelper::applyMocsEncryptionBit(uint32_t &index) {
}
}
GmmHelper::GmmHelper(OSInterface *osInterface, const HardwareInfo *pHwInfo) : hwInfo(pHwInfo) {
GmmHelper::GmmHelper(const RootDeviceEnvironment &rootDeviceEnvironment) : hwInfo(rootDeviceEnvironment.getHardwareInfo()) {
auto hwInfoAddressWidth = Math::log2(hwInfo->capabilityTable.gpuAddressSpace + 1);
addressWidth = std::max(hwInfoAddressWidth, 48u);
gmmClientContext = GmmHelper::createGmmContextWrapperFunc(osInterface, const_cast<HardwareInfo *>(pHwInfo));
gmmClientContext = GmmHelper::createGmmContextWrapperFunc(rootDeviceEnvironment);
UNRECOVERABLE_IF(!gmmClientContext);
}

View File

@@ -11,13 +11,13 @@
namespace NEO {
class GmmClientContext;
class OSInterface;
struct HardwareInfo;
struct RootDeviceEnvironment;
class GmmHelper {
public:
GmmHelper() = delete;
GmmHelper(OSInterface *osInterface, const HardwareInfo *hwInfo);
GmmHelper(const RootDeviceEnvironment &rootDeviceEnvironment);
MOCKABLE_VIRTUAL ~GmmHelper();
const HardwareInfo *getHardwareInfo();
@@ -37,7 +37,7 @@ class GmmHelper {
GmmClientContext *getClientContext() const;
static std::unique_ptr<GmmClientContext> (*createGmmContextWrapperFunc)(OSInterface *, HardwareInfo *);
static std::unique_ptr<GmmClientContext> (*createGmmContextWrapperFunc)(const RootDeviceEnvironment &);
protected:
uint32_t addressWidth;

View File

@@ -6,6 +6,7 @@
*/
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
#include "shared/source/gmm_helper/client_context/gmm_handle_allocator.h"
#include "shared/source/gmm_helper/resource_info.h"
#include "shared/source/helpers/debug_helpers.h"

View File

@@ -5,7 +5,7 @@
*
*/
#include "drm_neo.h"
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/source/command_stream/submission_status.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
@@ -13,6 +13,7 @@
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/gmm_helper/cache_settings_helper.h"
#include "shared/source/gmm_helper/client_context/gmm_client_context.h"
#include "shared/source/gmm_helper/gmm.h"
#include "shared/source/gmm_helper/resource_info.h"
#include "shared/source/helpers/constants.h"
#include "shared/source/helpers/debug_helpers.h"

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -9,6 +9,7 @@
namespace NEO {
GMM_INIT_IN_ARGS passedInputArgs = {};
GT_SYSTEM_INFO passedGtSystemInfo = {};
SKU_FEATURE_TABLE passedFtrTable = {};
WA_TABLE passedWaTable = {};
bool copyInputArgs = false;
@@ -23,6 +24,7 @@ GMM_STATUS initialize(GMM_INIT_IN_ARGS *pInArgs, GMM_INIT_OUT_ARGS *pOutArgs) {
}
if (copyInputArgs) {
passedInputArgs = *pInArgs;
passedGtSystemInfo = *reinterpret_cast<GT_SYSTEM_INFO *>(pInArgs->pGtSysInfo);
passedFtrTable = *reinterpret_cast<SKU_FEATURE_TABLE *>(pInArgs->pSkuTable);
passedWaTable = *reinterpret_cast<WA_TABLE *>(pInArgs->pWaTable);
}

View File

@@ -8,8 +8,6 @@
#include "mock_gmm_client_context.h"
namespace NEO {
MockGmmClientContext::MockGmmClientContext(OSInterface *osInterface, HardwareInfo *hwInfo) : MockGmmClientContextBase(osInterface, hwInfo) {
}
MEMORY_OBJECT_CONTROL_STATE MockGmmClientContextBase::cachePolicyGetMemoryObject(GMM_RESOURCE_INFO *pResInfo, GMM_RESOURCE_USAGE_TYPE usage) {
MEMORY_OBJECT_CONTROL_STATE retVal = {};

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -11,6 +11,6 @@
namespace NEO {
class MockGmmClientContext : public MockGmmClientContextBase {
public:
MockGmmClientContext(OSInterface *osInterface, HardwareInfo *hwInfo);
using MockGmmClientContextBase::MockGmmClientContextBase;
};
} // namespace NEO

View File

@@ -46,6 +46,7 @@ class DrmCommandStreamTest : public ::testing::Test {
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u);
executionEnvironment.rootDeviceEnvironments[0]->initGmm();
gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper();
mock->createVirtualMemoryAddressSpace(HwHelper::getSubDevicesCount(hwInfo));
osContext = std::make_unique<OsContextLinux>(*mock, 0, 0u,
@@ -95,6 +96,7 @@ class DrmCommandStreamTest : public ::testing::Test {
DebugManagerStateRestore dbgState;
MockExecutionEnvironment executionEnvironment;
std::unique_ptr<OsContextLinux> osContext;
GmmHelper *gmmHelper = nullptr;
};
template <typename DrmType>

View File

@@ -10,6 +10,7 @@
#include "shared/source/memory_manager/graphics_allocation.h"
#include "shared/test/common/fixtures/device_fixture.h"
#include "shared/test/common/fixtures/linear_stream_fixture.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
using namespace NEO;
@@ -42,7 +43,8 @@ TEST(LinearStreamSimpleTest, givenLinearStreamWithoutGraphicsAllocationWhenGetti
TEST(LinearStreamSimpleTest, givenLinearStreamWithGraphicsAllocationWhenGettingGpuBaseThenGpuAddressFromGraphicsAllocationIsReturned) {
MockGraphicsAllocation gfxAllocation;
auto gmmHelper = std::make_unique<GmmHelper>(nullptr, defaultHwInfo.get());
auto executionEnvironment = MockExecutionEnvironment{};
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper();
auto canonizedGpuAddress = gmmHelper->canonize(0x5555000);
gfxAllocation.setCpuPtrAndGpuAddress(nullptr, canonizedGpuAddress);

View File

@@ -10,11 +10,12 @@
#include "shared/source/gmm_helper/resource_info.h"
#include "shared/source/helpers/constants.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/mocks/mock_gmm_client_context.h"
#include "shared/test/common/mocks/mock_gmm_resource_info.h"
#include "shared/test/common/test_macros/hw_test.h"
extern PRODUCT_FAMILY productFamily;
using namespace NEO;
struct MockGmmHandleAllocator : NEO::GmmHandleAllocator {
void *createHandle(const GMM_RESOURCE_INFO *gmmResourceInfo) override {
@@ -40,9 +41,9 @@ struct MockGmmHandleAllocator : NEO::GmmHandleAllocator {
};
TEST(GmmResourceInfo, WhenGmmHandleAllocatorIsPresentThenItsBeingUsedForCreatingGmmResourceInfoHandles) {
NEO::HardwareInfo hwInfo;
hwInfo.platform.eProductFamily = productFamily;
NEO::MockGmmClientContext gmmClientCtx{nullptr, &hwInfo};
auto hwInfo = *defaultHwInfo;
MockExecutionEnvironment executionEnvironment{&hwInfo};
NEO::MockGmmClientContext gmmClientCtx{*executionEnvironment.rootDeviceEnvironments[0]};
gmmClientCtx.setHandleAllocator(std::make_unique<MockGmmHandleAllocator>());
auto handleAllocator = static_cast<MockGmmHandleAllocator *>(gmmClientCtx.getHandleAllocator());
@@ -73,9 +74,9 @@ TEST(GmmResourceInfo, WhenGmmHandleAllocatorIsPresentThenItsBeingUsedForCreating
}
TEST(GmmResourceInfo, GivenGmmResourceInfoAndHandleAllocatorInClientContextWhenDecodingResourceInfoThenExistingHandleIsOpened) {
NEO::HardwareInfo hwInfo;
hwInfo.platform.eProductFamily = productFamily;
NEO::MockGmmClientContext gmmClientCtx{nullptr, &hwInfo};
auto hwInfo = *defaultHwInfo;
MockExecutionEnvironment executionEnvironment{&hwInfo};
NEO::MockGmmClientContext gmmClientCtx{*executionEnvironment.rootDeviceEnvironments[0]};
gmmClientCtx.setHandleAllocator(std::make_unique<MockGmmHandleAllocator>());
auto handleAllocator = static_cast<MockGmmHandleAllocator *>(gmmClientCtx.getHandleAllocator());
@@ -131,9 +132,9 @@ TEST(GmmResourceInfo, GivenGmmResourceInfoAndHandleAllocatorInClientContextWhenD
}
TEST(GmmResourceInfo, GivenResourceInfoWhenRefreshIsCalledTiwceThenOpenHandleIsCalledTwice) {
NEO::HardwareInfo hwInfo;
hwInfo.platform.eProductFamily = productFamily;
NEO::MockGmmClientContext gmmClientCtx{nullptr, &hwInfo};
auto hwInfo = *defaultHwInfo;
MockExecutionEnvironment executionEnvironment{&hwInfo};
NEO::MockGmmClientContext gmmClientCtx{*executionEnvironment.rootDeviceEnvironments[0]};
gmmClientCtx.setHandleAllocator(std::make_unique<MockGmmHandleAllocator>());
auto handleAllocator = static_cast<MockGmmHandleAllocator *>(gmmClientCtx.getHandleAllocator());
@@ -206,23 +207,28 @@ TEST(GmmResourceInfo, GivenEmptyHandleWhenUsingBaseHandleAllocatorThenOpenHandle
}
TEST(GmmHelperTests, WhenInitializingGmmHelperThenCorrectAddressWidthIsSet) {
auto hwInfo = *NEO::defaultHwInfo;
auto hwInfo = *defaultHwInfo;
{
hwInfo.capabilityTable.gpuAddressSpace = maxNBitValue(48);
auto gmmHelper = std::make_unique<NEO::GmmHelper>(nullptr, &hwInfo);
MockExecutionEnvironment executionEnvironment{&hwInfo};
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper();
auto addressWidth = gmmHelper->getAddressWidth();
EXPECT_EQ(48u, addressWidth);
}
{
hwInfo.capabilityTable.gpuAddressSpace = maxNBitValue(36);
gmmHelper = std::make_unique<NEO::GmmHelper>(nullptr, &hwInfo);
MockExecutionEnvironment executionEnvironment{&hwInfo};
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper();
addressWidth = gmmHelper->getAddressWidth();
auto addressWidth = gmmHelper->getAddressWidth();
EXPECT_EQ(48u, addressWidth);
}
{
hwInfo.capabilityTable.gpuAddressSpace = maxNBitValue(57);
gmmHelper = std::make_unique<NEO::GmmHelper>(nullptr, &hwInfo);
addressWidth = gmmHelper->getAddressWidth();
MockExecutionEnvironment executionEnvironment{&hwInfo};
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper();
auto addressWidth = gmmHelper->getAddressWidth();
EXPECT_EQ(57u, addressWidth);
}
}

View File

@@ -11,6 +11,7 @@
#include "shared/source/indirect_heap/indirect_heap.h"
#include "shared/source/memory_manager/graphics_allocation.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "gtest/gtest.h"
@@ -66,7 +67,8 @@ TEST_F(HeapDirtyStateTests, givenNonDirtyObjectWhenAddressChangedThenReturnDirty
auto newBuffer = ptrOffset(buffer, MemoryConstants::pageSize + 1);
auto graphicsAllocation = stream->getGraphicsAllocation();
auto gmmHelper = std::make_unique<GmmHelper>(nullptr, defaultHwInfo.get());
MockExecutionEnvironment executionEnvironment{};
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper();
auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(newBuffer));
graphicsAllocation->setCpuPtrAndGpuAddress(newBuffer, canonizedGpuAddress);
@@ -106,7 +108,8 @@ TEST_F(HeapDirtyStateTests, givenNonDirtyObjectWhenSizeAndBufferChangedThenRetur
auto newBuffer = ptrOffset(buffer, 1);
auto newBufferSize = bufferSize + MemoryConstants::pageSize;
auto graphicsAllocation = stream->getGraphicsAllocation();
auto gmmHelper = std::make_unique<GmmHelper>(nullptr, defaultHwInfo.get());
MockExecutionEnvironment executionEnvironment{};
auto gmmHelper = executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper();
auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(newBuffer));
graphicsAllocation->setSize(newBufferSize);

View File

@@ -232,8 +232,7 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTest, GivenInvalidAddressWhenFlushingThenSucc
char *commandBuffer = new (std::nothrow) char[1024];
ASSERT_NE(nullptr, commandBuffer); // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks)
GmmHelper gmmHelper(nullptr, defaultHwInfo.get());
auto canonizedGpuAddress = gmmHelper.canonize(castToUint64(commandBuffer));
auto canonizedGpuAddress = gmmHelper->canonize(castToUint64(commandBuffer));
DrmAllocation commandBufferAllocation(0, AllocationType::COMMAND_BUFFER, nullptr, commandBuffer, 1024, static_cast<osHandle>(1u), MemoryPool::MemoryNull, canonizedGpuAddress);
LinearStream cs(&commandBufferAllocation);

View File

@@ -28,7 +28,7 @@ TEST(FileLogger, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) {
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
MockDrmAllocation allocation(AllocationType::BUFFER, MemoryPool::System64KBPages);
auto gmmHelper = std::make_unique<GmmHelper>(nullptr, defaultHwInfo.get());
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[0]->getGmmHelper();
auto canonizedGpuAddress = gmmHelper->canonize(0x12345);
allocation.setCpuPtrAndGpuAddress(&allocation, canonizedGpuAddress);
@@ -79,7 +79,7 @@ TEST(FileLogger, givenLogAllocationStdoutWhenLogAllocationThenLogToStdoutInstead
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
MockDrmAllocation allocation(AllocationType::BUFFER, MemoryPool::System64KBPages);
auto gmmHelper = std::make_unique<GmmHelper>(nullptr, defaultHwInfo.get());
auto gmmHelper = executionEnvironment->rootDeviceEnvironments[0]->getGmmHelper();
auto canonizedGpuAddress = gmmHelper->canonize(0x12345);
allocation.setCpuPtrAndGpuAddress(&allocation, canonizedGpuAddress);

View File

@@ -201,21 +201,20 @@ NTSTATUS __stdcall getDeviceStateMock(D3DKMT_GETDEVICESTATE *arg) {
struct WddmLinuxTest : public ::testing::Test {
void SetUp() override {
mockRootDeviceEnvironment = std::make_unique<NEO::MockRootDeviceEnvironment>(mockExecEnv);
osEnvironment = std::make_unique<NEO::OsEnvironmentWin>();
osEnvironment->gdi->closeAdapter = closeAdapterMock;
auto hwDeviceIdIn = std::make_unique<WddmLinuxMockHwDeviceIdWddm>(NULL_HANDLE, LUID{}, osEnvironment.get(), std::make_unique<NEO::UmKmDataTranslator>());
this->hwDeviceId = hwDeviceIdIn.get();
auto wddm = std::make_unique<MockWddmLinux>(std::move(hwDeviceIdIn), *mockRootDeviceEnvironment.get());
auto &rootDeviceEnvironment = *mockExecEnv.rootDeviceEnvironments[0];
auto wddm = std::make_unique<MockWddmLinux>(std::move(hwDeviceIdIn), rootDeviceEnvironment);
this->wddm = wddm.get();
mockGmmClientContext = NEO::GmmClientContext::create<NEO::MockGmmClientContext>(nullptr, NEO::defaultHwInfo.get());
wddm->gmmMemory = std::make_unique<MockGmmMemoryWddmLinux>(mockGmmClientContext.get());
auto gmmHelper = rootDeviceEnvironment.getGmmHelper();
wddm->gmmMemory = std::make_unique<MockGmmMemoryWddmLinux>(gmmHelper->getClientContext());
*wddm->gfxPlatform = NEO::defaultHwInfo->platform;
mockExecEnv.rootDeviceEnvironments[0]->osInterface.reset(new NEO::OSInterface);
mockExecEnv.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::move(wddm));
mockExecEnv.rootDeviceEnvironments[0]->gmmHelper.reset(new NEO::GmmHelper(mockExecEnv.rootDeviceEnvironments[0]->osInterface.get(), mockExecEnv.rootDeviceEnvironments[0]->getHardwareInfo()));
rootDeviceEnvironment.osInterface.reset(new NEO::OSInterface);
rootDeviceEnvironment.osInterface->setDriverModel(std::move(wddm));
}
size_t getMaxSvmSize() const {
@@ -231,10 +230,8 @@ struct WddmLinuxTest : public ::testing::Test {
std::unique_ptr<NEO::OsEnvironmentWin> osEnvironment;
NEO::MockExecutionEnvironment mockExecEnv;
std::unique_ptr<NEO::MockRootDeviceEnvironment> mockRootDeviceEnvironment;
MockWddmLinux *wddm = nullptr;
WddmLinuxMockHwDeviceIdWddm *hwDeviceId = nullptr;
std::unique_ptr<NEO::GmmClientContext> mockGmmClientContext;
};
using GmmTestsDG2 = WddmLinuxTest;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
* Copyright (C) 2020-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -9,6 +9,7 @@
#include "shared/source/gmm_helper/gmm_lib.h"
#include "shared/test/common/helpers/default_hw_info.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "gtest/gtest.h"
@@ -18,13 +19,12 @@ extern GMM_INIT_IN_ARGS passedInputArgs;
extern bool copyInputArgs;
TEST(GmmHelperTest, whenCreateGmmHelperWithoutOsInterfaceThenPassedAdapterBDFIsZeroed) {
std::unique_ptr<GmmHelper> gmmHelper;
VariableBackup<decltype(passedInputArgs)> passedInputArgsBackup(&passedInputArgs);
VariableBackup<decltype(copyInputArgs)> copyInputArgsBackup(&copyInputArgs, true);
ADAPTER_BDF expectedAdapterBDF{};
gmmHelper.reset(new GmmHelper(nullptr, defaultHwInfo.get()));
MockExecutionEnvironment executionEnvironment{};
EXPECT_EQ(0, memcmp(&expectedAdapterBDF, &passedInputArgs.stAdapterBDF, sizeof(ADAPTER_BDF)));
EXPECT_EQ(GMM_CLIENT::GMM_OCL_VISTA, passedInputArgs.ClientType);
}