[1/n] Move Hardware Info to Execution Environment

- remove gmm_environment_fixture
- remove hwInfo parameter from ExecutionEnvironment methods

Change-Id: Ieb0f9b5b89191fbbaf7676685c77644d42d69c26
Signed-off-by: Adam Stefanowski <adam.stefanowski@intel.com>
This commit is contained in:
Stefanowski, Adam
2019-01-23 11:59:54 +01:00
committed by sys_ocldev
parent a1bfbcf293
commit 341fcfc091
61 changed files with 480 additions and 507 deletions

View File

@@ -13,6 +13,7 @@
#include "runtime/command_stream/tbx_command_stream_receiver_hw.h"
#include "runtime/helpers/hw_helper.h"
#include "runtime/os_interface/os_interface.h"
#include "runtime/platform/platform.h"
#include "unit_tests/command_queue/command_queue_fixture.h"
#include "unit_tests/mocks/mock_device.h"
#include "unit_tests/tests_configuration.h"
@@ -34,7 +35,7 @@ class AUBFixture : public CommandQueueHwFixture {
std::stringstream strfilename;
strfilename << testInfo->test_case_name() << "_" << testInfo->name() << "_" << hwHelper.getCsTraits(engineType).name;
executionEnvironment = new ExecutionEnvironment;
executionEnvironment = platformImpl->peekExecutionEnvironment();
if (testMode == TestMode::AubTestsWithTbx) {
this->csr = TbxCommandStreamReceiver::create(hwInfo, strfilename.str(), true, *executionEnvironment);
} else {

View File

@@ -81,7 +81,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenItIsCre
DebugManager.flags.UseAubStream.set(false);
HardwareInfo hwInfo = *platformDevices[0];
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(hwInfo, "", true, executionEnvironment);
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(hwInfo, "", true, *pDevice->executionEnvironment);
ASSERT_NE(nullptr, aubCsr);
EXPECT_EQ(nullptr, aubCsr->aubManager);
@@ -89,7 +89,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenItIsCre
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGetEngineIndexFromInstanceIsCalledForGivenEngineInstanceThenEngineIndexForThatInstanceIsReturned) {
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
EXPECT_NE(nullptr, aubCsr);
EXPECT_TRUE(aubCsr->getEngineIndex(EngineInstanceT(EngineType::ENGINE_RCS, 0)) < allEngineInstances.size());
@@ -105,7 +105,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGetEngi
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenGetEngineIndexIsCalledForGivenEngineTypeThenEngineIndexForThatTypeIsReturned) {
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto aubCsr = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
EXPECT_NE(nullptr, aubCsr);
auto engineIndex = aubCsr->getEngineIndex(EngineInstanceT(EngineType::ENGINE_RCS, 1));
@@ -134,52 +134,47 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenItIsCre
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesAreCreatedThenTheyOperateOnSingleFileStream) {
ExecutionEnvironment executionEnvironment;
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
EXPECT_EQ(aubCsr1->stream, aubCsr2->stream);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesAreCreatedThenTheyUseTheSameFileStream) {
ExecutionEnvironment executionEnvironment;
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto streamProvider1 = executionEnvironment.aubCenter->getStreamProvider();
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
auto streamProvider1 = pDevice->executionEnvironment->aubCenter->getStreamProvider();
EXPECT_NE(nullptr, streamProvider1);
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto streamProvider2 = executionEnvironment.aubCenter->getStreamProvider();
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
auto streamProvider2 = pDevice->executionEnvironment->aubCenter->getStreamProvider();
EXPECT_NE(nullptr, streamProvider2);
EXPECT_EQ(streamProvider1, streamProvider2);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesAreCreatedThenTheyUseTheSamePhysicalAddressAllocator) {
ExecutionEnvironment executionEnvironment;
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto physicalAddressAlocator1 = executionEnvironment.aubCenter->getPhysicalAddressAllocator();
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
auto physicalAddressAlocator1 = pDevice->executionEnvironment->aubCenter->getPhysicalAddressAllocator();
EXPECT_NE(nullptr, physicalAddressAlocator1);
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto physicalAddressAlocator2 = executionEnvironment.aubCenter->getPhysicalAddressAllocator();
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
auto physicalAddressAlocator2 = pDevice->executionEnvironment->aubCenter->getPhysicalAddressAllocator();
EXPECT_NE(nullptr, physicalAddressAlocator2);
EXPECT_EQ(physicalAddressAlocator1, physicalAddressAlocator2);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesAreCreatedThenTheyUseTheSameAddressMapper) {
ExecutionEnvironment executionEnvironment;
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto addressMapper1 = executionEnvironment.aubCenter->getAddressMapper();
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
auto addressMapper1 = pDevice->executionEnvironment->aubCenter->getAddressMapper();
EXPECT_NE(nullptr, addressMapper1);
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto addressMapper2 = executionEnvironment.aubCenter->getAddressMapper();
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
auto addressMapper2 = pDevice->executionEnvironment->aubCenter->getAddressMapper();
EXPECT_NE(nullptr, addressMapper2);
EXPECT_EQ(addressMapper1, addressMapper2);
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenMultipleInstancesAreCreatedThenTheyUseTheSameSubCaptureManager) {
ExecutionEnvironment executionEnvironment;
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto subCaptureManager1 = executionEnvironment.aubCenter->getSubCaptureManager();
auto aubCsr1 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
auto subCaptureManager1 = pDevice->executionEnvironment->aubCenter->getSubCaptureManager();
EXPECT_NE(nullptr, subCaptureManager1);
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto subCaptureManager2 = executionEnvironment.aubCenter->getSubCaptureManager();
auto aubCsr2 = std::make_unique<AUBCommandStreamReceiverHw<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
auto subCaptureManager2 = pDevice->executionEnvironment->aubCenter->getSubCaptureManager();
EXPECT_NE(nullptr, subCaptureManager2);
EXPECT_EQ(subCaptureManager1, subCaptureManager2);
}

View File

@@ -10,6 +10,7 @@
#include "runtime/helpers/hardware_context_controller.h"
#include "runtime/helpers/hw_helper.h"
#include "runtime/mem_obj/mem_obj_helper.h"
#include "runtime/platform/platform.h"
#include "test.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
@@ -468,13 +469,13 @@ class OsAgnosticMemoryManagerForImagesWithNoHostPtr : public OsAgnosticMemoryMan
using AubCommandStreamReceiverNoHostPtrTests = ::testing::Test;
HWTEST_F(AubCommandStreamReceiverNoHostPtrTests, givenAubCommandStreamReceiverWhenWriteMemoryIsCalledOnImageWithNoHostPtrThenResourceShouldBeLockedToGetCpuAddress) {
ExecutionEnvironment executionEnvironment;
auto memoryManager = new OsAgnosticMemoryManagerForImagesWithNoHostPtr(executionEnvironment);
executionEnvironment.memoryManager.reset(memoryManager);
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
auto memoryManager = new OsAgnosticMemoryManagerForImagesWithNoHostPtr(*executionEnvironment);
executionEnvironment->memoryManager.reset(memoryManager);
auto engineInstance = HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0];
MockOsContext osContext(nullptr, 0, 1, engineInstance, PreemptionMode::Disabled);
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, executionEnvironment));
std::unique_ptr<AUBCommandStreamReceiverHw<FamilyType>> aubCsr(new AUBCommandStreamReceiverHw<FamilyType>(*platformDevices[0], "", true, *executionEnvironment));
aubCsr->setupContext(osContext);
cl_image_desc imgDesc = {};
@@ -703,11 +704,11 @@ HWTEST_F(AubCommandStreamReceiverTests, whenAubCommandStreamReceiverIsCreatedThe
}
HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenEngineIsInitializedThenDumpHandleIsGenerated) {
executionEnvironment.aubCenter.reset(new AubCenter());
pDevice->executionEnvironment->aubCenter.reset(new AubCenter());
auto engineInstance = HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0];
MockOsContext osContext(nullptr, 0, 1, engineInstance, PreemptionMode::Disabled);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
EXPECT_NE(nullptr, aubCsr);
aubCsr->setupContext(osContext);
@@ -721,7 +722,7 @@ HWTEST_F(InjectMmmioTest, givenAddMmioKeySetToZeroWhenInitAdditionalMmioCalledTh
DebugManagerStateRestore stateRestore;
DebugManager.flags.AubDumpAddMmioRegistersList.set("");
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
EXPECT_NE(nullptr, aubCsr);
auto stream = std::make_unique<MockAubFileStreamMockMmioWrite>();
@@ -738,7 +739,7 @@ HWTEST_F(InjectMmmioTest, givenAddMmioRegistersListSetWhenInitAdditionalMmioCall
DebugManagerStateRestore stateRestore;
DebugManager.flags.AubDumpAddMmioRegistersList.set(registers);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
EXPECT_NE(nullptr, aubCsr);
auto stream = std::make_unique<MockAubFileStreamMockMmioWrite>();
@@ -755,7 +756,7 @@ HWTEST_F(InjectMmmioTest, givenLongSequenceOfAddMmioRegistersListSetWhenInitAddi
DebugManagerStateRestore stateRestore;
DebugManager.flags.AubDumpAddMmioRegistersList.set(registers);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
EXPECT_NE(nullptr, aubCsr);
auto stream = std::make_unique<MockAubFileStreamMockMmioWrite>();
@@ -773,7 +774,7 @@ HWTEST_F(InjectMmmioTest, givenSequenceWithIncompletePairOfAddMmioRegistersListS
DebugManagerStateRestore stateRestore;
DebugManager.flags.AubDumpAddMmioRegistersList.set(registers);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
EXPECT_NE(nullptr, aubCsr);
auto stream = std::make_unique<MockAubFileStreamMockMmioWrite>();
@@ -792,7 +793,7 @@ HWTEST_F(InjectMmmioTest, givenAddMmioRegistersListSetWithSemicolonAtTheEndWhenI
DebugManagerStateRestore stateRestore;
DebugManager.flags.AubDumpAddMmioRegistersList.set(registers);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
EXPECT_NE(nullptr, aubCsr);
auto stream = std::make_unique<MockAubFileStreamMockMmioWrite>();
@@ -809,7 +810,7 @@ HWTEST_F(InjectMmmioTest, givenAddMmioRegistersListSetWithInvalidValueWhenInitAd
DebugManagerStateRestore stateRestore;
DebugManager.flags.AubDumpAddMmioRegistersList.set(registers);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>(**platformDevices, "", true, executionEnvironment);
auto aubCsr = std::make_unique<MockAubCsrToTestDumpContext<FamilyType>>(**platformDevices, "", true, *pDevice->executionEnvironment);
EXPECT_NE(nullptr, aubCsr);
auto stream = std::make_unique<MockAubFileStreamMockMmioWrite>();

View File

@@ -385,7 +385,7 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, GivenKernelWithSlmWhenPreviousSLML
HWTEST_F(CommandStreamReceiverFlushTaskTests, CreateCommandStreamReceiverHw) {
const HardwareInfo hwInfo = *platformDevices[0];
auto csrHw = CommandStreamReceiverHw<FamilyType>::create(hwInfo, executionEnvironment);
auto csrHw = CommandStreamReceiverHw<FamilyType>::create(hwInfo, *pDevice->executionEnvironment);
EXPECT_NE(nullptr, csrHw);
GmmPageTableMngr *ptm = csrHw->createPageTableManager();

View File

@@ -15,6 +15,7 @@
#include "runtime/memory_manager/internal_allocation_storage.h"
#include "runtime/memory_manager/memory_manager.h"
#include "runtime/memory_manager/surface.h"
#include "runtime/platform/platform.h"
#include "runtime/utilities/tag_allocator.h"
#include "test.h"
#include "unit_tests/fixtures/device_fixture.h"
@@ -287,7 +288,7 @@ HWTEST_F(CommandStreamReceiverTest, givenDebugVariableEnabledWhenCreatingCsrThen
}
HWTEST_F(CommandStreamReceiverTest, whenCsrIsCreatedThenUseTimestampPacketWriteIfPossible) {
CommandStreamReceiverHw<FamilyType> csr(*platformDevices[0], executionEnvironment);
CommandStreamReceiverHw<FamilyType> csr(*platformDevices[0], *pDevice->executionEnvironment);
EXPECT_EQ(UnitTestHelper<FamilyType>::isTimestampPacketWriteSupported(), csr.peekTimestampPacketWriteEnabled());
}
@@ -396,7 +397,7 @@ TEST(CommandStreamReceiverSimpleTest, givenCSRWhenWaitBeforeMakingNonResidentWhe
}
TEST(CommandStreamReceiverMultiContextTests, givenMultipleCsrsWhenSameResourcesAreUsedThenResidencyIsProperlyHandled) {
auto executionEnvironment = new ExecutionEnvironment;
auto executionEnvironment = platformImpl->peekExecutionEnvironment();
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(nullptr, executionEnvironment, 0u));
@@ -433,7 +434,7 @@ TEST(CommandStreamReceiverMultiContextTests, givenMultipleCsrsWhenSameResourcesA
struct CreateAllocationForHostSurfaceTest : public ::testing::Test {
void SetUp() override {
executionEnvironment = new ExecutionEnvironment;
executionEnvironment = platformImpl->peekExecutionEnvironment();
gmockMemoryManager = new ::testing::NiceMock<GMockMemoryManager>(*executionEnvironment);
executionEnvironment->memoryManager.reset(gmockMemoryManager);
device.reset(MockDevice::create<MockDevice>(&hwInfo, executionEnvironment, 0u));

View File

@@ -13,6 +13,7 @@
#include "runtime/helpers/dispatch_info.h"
#include "runtime/helpers/hw_helper.h"
#include "runtime/os_interface/os_context.h"
#include "runtime/platform/platform.h"
#include "test.h"
#include "unit_tests/libult/ult_command_stream_receiver.h"
#include "unit_tests/mocks/mock_allocation_properties.h"
@@ -102,23 +103,24 @@ struct MyMockCsrWithAubDump : CommandStreamReceiverWithAUBDump<BaseCSR> {
struct CommandStreamReceiverWithAubDumpTest : public ::testing::TestWithParam<bool /*createAubCSR*/> {
void SetUp() override {
executionEnvironment = platformImpl->peekExecutionEnvironment();
createAubCSR = GetParam();
csrWithAubDump = new MyMockCsrWithAubDump<MyMockCsr>(DEFAULT_TEST_PLATFORM::hwInfo, createAubCSR, executionEnvironment);
csrWithAubDump = new MyMockCsrWithAubDump<MyMockCsr>(DEFAULT_TEST_PLATFORM::hwInfo, createAubCSR, *executionEnvironment);
ASSERT_NE(nullptr, csrWithAubDump);
executionEnvironment.initializeMemoryManager(false, false);
memoryManager = executionEnvironment.memoryManager.get();
executionEnvironment->initializeMemoryManager(false, false);
memoryManager = executionEnvironment->memoryManager.get();
ASSERT_NE(nullptr, memoryManager);
auto osContext = executionEnvironment.memoryManager->createAndRegisterOsContext(csrWithAubDump,
getChosenEngineType(DEFAULT_TEST_PLATFORM::hwInfo),
1, PreemptionHelper::getDefaultPreemptionMode(DEFAULT_TEST_PLATFORM::hwInfo));
auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(csrWithAubDump,
getChosenEngineType(DEFAULT_TEST_PLATFORM::hwInfo),
1, PreemptionHelper::getDefaultPreemptionMode(DEFAULT_TEST_PLATFORM::hwInfo));
csrWithAubDump->setupContext(*osContext);
}
void TearDown() override {
delete csrWithAubDump;
}
ExecutionEnvironment executionEnvironment;
ExecutionEnvironment *executionEnvironment;
MyMockCsrWithAubDump<MyMockCsr> *csrWithAubDump;
MemoryManager *memoryManager;
bool createAubCSR;
@@ -127,9 +129,9 @@ struct CommandStreamReceiverWithAubDumpTest : public ::testing::TestWithParam<bo
using CommandStreamReceiverWithAubDumpSimpleTest = ::testing::Test;
HWTEST_F(CommandStreamReceiverWithAubDumpSimpleTest, givenCsrWithAubDumpWhenSettingOsContextThenReplicateItToAubCsr) {
ExecutionEnvironment executionEnvironment;
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
CommandStreamReceiverWithAUBDump<UltCommandStreamReceiver<FamilyType>> csrWithAubDump(*platformDevices[0], "aubfile", executionEnvironment);
CommandStreamReceiverWithAUBDump<UltCommandStreamReceiver<FamilyType>> csrWithAubDump(*platformDevices[0], "aubfile", *executionEnvironment);
MockOsContext osContext(nullptr, 0, 1, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
csrWithAubDump.setupContext(osContext);

View File

@@ -11,7 +11,6 @@
#include "runtime/helpers/options.h"
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
#include "test.h"
#include "unit_tests/fixtures/gmm_environment_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/helpers/execution_environment_helper.h"
#include "unit_tests/helpers/variable_backup.h"
@@ -19,25 +18,12 @@
using namespace OCLRT;
struct CreateCommandStreamReceiverTest : public GmmEnvironmentFixture, public ::testing::TestWithParam<CommandStreamReceiverType> {
void SetUp() override {
GmmEnvironmentFixture::SetUp();
storeInitHWTag = initialHardwareTag;
}
void TearDown() override {
initialHardwareTag = storeInitHWTag;
GmmEnvironmentFixture::TearDown();
}
protected:
int storeInitHWTag;
};
struct CreateCommandStreamReceiverTest : public ::testing::TestWithParam<CommandStreamReceiverType> {};
HWTEST_P(CreateCommandStreamReceiverTest, givenCreateCommandStreamWhenCsrIsSetToValidTypeThenTheFuntionReturnsCommandStreamReceiver) {
DebugManagerStateRestore stateRestorer;
HardwareInfo *hwInfo = nullptr;
std::unique_ptr<ExecutionEnvironment> executionEnvironment = std::unique_ptr<ExecutionEnvironment>(getExecutionEnvironmentImpl(hwInfo));
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
CommandStreamReceiverType csrType = GetParam();

View File

@@ -10,6 +10,7 @@
#include "runtime/helpers/options.h"
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
#include "runtime/os_interface/device_factory.h"
#include "runtime/platform/platform.h"
#include "test.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/libult/create_command_stream.h"
@@ -58,9 +59,9 @@ HWTEST_F(GetDevicesTest, givenGetDevicesWhenCsrIsSetToVariousTypesThenTheFunctio
}
DebugManager.flags.ProductFamilyOverride.set(productFamily);
ExecutionEnvironment exeEnv;
ExecutionEnvironment *exeEnv = platformImpl->peekExecutionEnvironment();
const auto ret = getDevices(&hwInfo, numDevices, exeEnv);
const auto ret = getDevices(&hwInfo, numDevices, *exeEnv);
switch (csrType) {
case CSR_HW:
@@ -89,6 +90,7 @@ HWTEST_F(GetDevicesTest, givenGetDevicesWhenCsrIsSetToVariousTypesThenTheFunctio
EXPECT_EQ(0, memcmp(&hardwareInfoTable[i]->capabilityTable, &hwInfo->capabilityTable, sizeof(RuntimeCapabilityTable)));
EXPECT_EQ(0, memcmp(hardwareInfoTable[i]->pWaTable, hwInfo->pWaTable, sizeof(WorkaroundTable)));
EXPECT_STREQ(hardwarePrefix[i], productFamily.c_str());
DeviceFactory::releaseDevices();
break;
default:
break;
@@ -104,9 +106,9 @@ HWTEST_F(GetDevicesTest, givenGetDevicesAndUnknownProductFamilyWhenCsrIsSetToVal
DebugManager.flags.SetCommandStreamReceiver.set(csrType);
DebugManager.flags.ProductFamilyOverride.set(productFamily);
ExecutionEnvironment exeEnv;
ExecutionEnvironment *exeEnv = platformImpl->peekExecutionEnvironment();
auto ret = getDevices(&hwInfo, numDevices, exeEnv);
auto ret = getDevices(&hwInfo, numDevices, *exeEnv);
switch (csrType) {
case CSR_HW:
@@ -135,6 +137,7 @@ HWTEST_F(GetDevicesTest, givenGetDevicesAndUnknownProductFamilyWhenCsrIsSetToVal
EXPECT_EQ(0, memcmp(defaultHwInfo->pPlatform, hwInfo->pPlatform, sizeof(PLATFORM)));
EXPECT_EQ(0, memcmp(&defaultHwInfo->capabilityTable, &hwInfo->capabilityTable, sizeof(RuntimeCapabilityTable)));
EXPECT_EQ(0, memcmp(defaultHwInfo->pWaTable, hwInfo->pWaTable, sizeof(WorkaroundTable)));
DeviceFactory::releaseDevices();
break;
}
default:

View File

@@ -15,6 +15,7 @@
#include "runtime/memory_manager/memory_banks.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/os_interface/os_context.h"
#include "runtime/platform/platform.h"
#include "test.h"
#include "unit_tests/command_queue/command_queue_fixture.h"
#include "unit_tests/fixtures/device_fixture.h"
@@ -148,8 +149,8 @@ TEST(TbxCommandStreamReceiverTest, givenTbxCommandStreamReceiverWhenItIsCreatedW
TEST(TbxCommandStreamReceiverTest, givenTbxCommandStreamReceiverWhenTypeIsCheckedThenTbxCsrIsReturned) {
HardwareInfo hwInfo = *platformDevices[0];
ExecutionEnvironment executionEnvironment;
std::unique_ptr<CommandStreamReceiver> csr(TbxCommandStreamReceiver::create(hwInfo, "", false, executionEnvironment));
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
std::unique_ptr<CommandStreamReceiver> csr(TbxCommandStreamReceiver::create(hwInfo, "", false, *executionEnvironment));
EXPECT_NE(nullptr, csr);
EXPECT_EQ(CommandStreamReceiverType::CSR_TBX, csr->getType());
}
@@ -293,8 +294,7 @@ HWTEST_F(TbxCommandStreamTests, givenDbgDeviceIdFlagIsSetWhenTbxCsrIsCreatedThen
DebugManagerStateRestore stateRestore;
DebugManager.flags.OverrideAubDeviceId.set(9); //this is Hsw, not used
const HardwareInfo &hwInfoIn = *platformDevices[0];
ExecutionEnvironment executionEnvironment;
std::unique_ptr<TbxCommandStreamReceiverHw<FamilyType>> tbxCsr(reinterpret_cast<TbxCommandStreamReceiverHw<FamilyType> *>(TbxCommandStreamReceiver::create(hwInfoIn, "", false, executionEnvironment)));
std::unique_ptr<TbxCommandStreamReceiverHw<FamilyType>> tbxCsr(reinterpret_cast<TbxCommandStreamReceiverHw<FamilyType> *>(TbxCommandStreamReceiver::create(hwInfoIn, "", false, *pDevice->executionEnvironment)));
EXPECT_EQ(9u, tbxCsr->aubDeviceId);
}
@@ -482,14 +482,13 @@ HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenOsContextIsSetThenCreateHardwareC
}
HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenPollForCompletionImplIsCalledThenSimulatedCsrMethodIsCalled) {
ExecutionEnvironment executionEnvironment;
std::unique_ptr<TbxCommandStreamReceiverHw<FamilyType>> tbxCsr(reinterpret_cast<TbxCommandStreamReceiverHw<FamilyType> *>(TbxCommandStreamReceiver::create(*platformDevices[0], "", false, executionEnvironment)));
std::unique_ptr<TbxCommandStreamReceiverHw<FamilyType>> tbxCsr(reinterpret_cast<TbxCommandStreamReceiverHw<FamilyType> *>(TbxCommandStreamReceiver::create(*platformDevices[0], "", false, *pDevice->executionEnvironment)));
tbxCsr->pollForCompletionImpl();
}
HWTEST_F(TbxCommandStreamTests, givenTbxCsrWhenCreatedWithAubDumpThenFileNameIsExtendedWithSystemInfo) {
MockExecutionEnvironment executionEnvironment;
executionEnvironment.setHwInfo(*platformDevices);
auto fullName = AUBCommandStreamReceiver::createFullFilePath(*platformDevices[0], "aubfile");

View File

@@ -10,6 +10,7 @@
#include "runtime/helpers/options.h"
#include "runtime/indirect_heap/indirect_heap.h"
#include "runtime/os_interface/os_context.h"
#include "runtime/platform/platform.h"
#include "test.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
@@ -154,15 +155,14 @@ TEST(DeviceCreation, givenDeviceWhenItIsCreatedThenOsContextIsRegistredInMemoryM
}
TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachOsContextHasUniqueId) {
ExecutionEnvironment executionEnvironment;
executionEnvironment.incRefInternal();
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
const size_t numDevices = 2;
const auto &numGpgpuEngines = static_cast<uint32_t>(HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances().size());
auto device1 = std::unique_ptr<Device>(Device::create<MockDevice>(nullptr, &executionEnvironment, 0u));
auto device2 = std::unique_ptr<Device>(Device::create<MockDevice>(nullptr, &executionEnvironment, 1u));
auto device1 = std::unique_ptr<Device>(Device::create<MockDevice>(nullptr, executionEnvironment, 0u));
auto device2 = std::unique_ptr<Device>(Device::create<MockDevice>(nullptr, executionEnvironment, 1u));
auto &registeredEngines = executionEnvironment.memoryManager->getRegisteredEngines();
auto &registeredEngines = executionEnvironment->memoryManager->getRegisteredEngines();
EXPECT_EQ(numGpgpuEngines * numDevices, registeredEngines.size());
for (uint32_t i = 0; i < numGpgpuEngines; i++) {
@@ -176,43 +176,40 @@ TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachOsContextHasUniqu
EXPECT_EQ(registeredEngines[i + numGpgpuEngines].commandStreamReceiver,
device2->getEngine(i).commandStreamReceiver);
}
EXPECT_EQ(numGpgpuEngines * numDevices, executionEnvironment.memoryManager->getRegisteredEnginesCount());
EXPECT_EQ(numGpgpuEngines * numDevices, executionEnvironment->memoryManager->getRegisteredEnginesCount());
}
TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachDeviceHasSeperateDeviceIndex) {
ExecutionEnvironment executionEnvironment;
executionEnvironment.incRefInternal();
auto device = std::unique_ptr<Device>(Device::create<MockDevice>(nullptr, &executionEnvironment, 0u));
auto device2 = std::unique_ptr<Device>(Device::create<MockDevice>(nullptr, &executionEnvironment, 1u));
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
auto device = std::unique_ptr<Device>(Device::create<MockDevice>(nullptr, executionEnvironment, 0u));
auto device2 = std::unique_ptr<Device>(Device::create<MockDevice>(nullptr, executionEnvironment, 1u));
EXPECT_EQ(0u, device->getDeviceIndex());
EXPECT_EQ(1u, device2->getDeviceIndex());
}
TEST(DeviceCreation, givenMultiDeviceWhenTheyAreCreatedThenEachDeviceHasSeperateCommandStreamReceiver) {
ExecutionEnvironment executionEnvironment;
executionEnvironment.incRefInternal();
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
const size_t numDevices = 2;
const auto &numGpgpuEngines = HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances().size();
auto device1 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, &executionEnvironment, 0u));
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, &executionEnvironment, 1u));
auto device1 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, executionEnvironment, 0u));
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, executionEnvironment, 1u));
EXPECT_EQ(numDevices, executionEnvironment.commandStreamReceivers.size());
EXPECT_EQ(numGpgpuEngines, executionEnvironment.commandStreamReceivers[0].size());
EXPECT_EQ(numGpgpuEngines, executionEnvironment.commandStreamReceivers[1].size());
EXPECT_EQ(numDevices, executionEnvironment->commandStreamReceivers.size());
EXPECT_EQ(numGpgpuEngines, executionEnvironment->commandStreamReceivers[0].size());
EXPECT_EQ(numGpgpuEngines, executionEnvironment->commandStreamReceivers[1].size());
for (uint32_t i = 0; i < static_cast<uint32_t>(numGpgpuEngines); i++) {
EXPECT_NE(nullptr, executionEnvironment.commandStreamReceivers[0][i]);
EXPECT_NE(nullptr, executionEnvironment.commandStreamReceivers[1][i]);
EXPECT_EQ(executionEnvironment.commandStreamReceivers[0][i].get(), device1->getEngine(i).commandStreamReceiver);
EXPECT_EQ(executionEnvironment.commandStreamReceivers[1][i].get(), device2->getEngine(i).commandStreamReceiver);
EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0][i]);
EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[1][i]);
EXPECT_EQ(executionEnvironment->commandStreamReceivers[0][i].get(), device1->getEngine(i).commandStreamReceiver);
EXPECT_EQ(executionEnvironment->commandStreamReceivers[1][i].get(), device2->getEngine(i).commandStreamReceiver);
}
}
TEST(DeviceCreation, givenDeviceWhenAskingForDefaultEngineThenReturnValidValue) {
ExecutionEnvironment executionEnvironment;
executionEnvironment.incRefInternal();
auto device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(platformDevices[0], &executionEnvironment, 0));
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
auto device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(platformDevices[0], executionEnvironment, 0));
auto &defaultEngine = device->getDefaultEngine().osContext->getEngineType();

View File

@@ -391,7 +391,7 @@ TEST_F(EventTest, Event_Wait_NonBlocking) {
struct UpdateEventTest : public ::testing::Test {
void SetUp() override {
executionEnvironment = new ExecutionEnvironment;
executionEnvironment = platformImpl->peekExecutionEnvironment();
memoryManager = new MockMemoryManager(*executionEnvironment);
hostPtrManager = static_cast<MockHostPtrManager *>(memoryManager->getHostPtrManager());
executionEnvironment->memoryManager.reset(memoryManager);

View File

@@ -102,39 +102,37 @@ TEST(ExecutionEnvironment, givenPlatformWhenItIsCreatedThenItCreatesMemoryManage
}
TEST(ExecutionEnvironment, givenDeviceWhenItIsDestroyedThenMemoryManagerIsStillAvailable) {
std::unique_ptr<ExecutionEnvironment> executionEnvironment(new ExecutionEnvironment);
executionEnvironment->incRefInternal();
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
executionEnvironment->initializeMemoryManager(false, false);
std::unique_ptr<Device> device(Device::create<OCLRT::Device>(nullptr, executionEnvironment.get(), 0u));
std::unique_ptr<Device> device(Device::create<OCLRT::Device>(nullptr, executionEnvironment, 0u));
device.reset(nullptr);
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
}
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeCommandStreamReceiverIsCalledThenItIsInitalized) {
std::unique_ptr<ExecutionEnvironment> executionEnvironment(new ExecutionEnvironment);
executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0, 0);
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
executionEnvironment->initializeCommandStreamReceiver(0, 0);
EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0][0]);
}
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeIsCalledWithDifferentDeviceIndexesThenInternalStorageIsResized) {
std::unique_ptr<ExecutionEnvironment> executionEnvironment(new ExecutionEnvironment);
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
EXPECT_EQ(0u, executionEnvironment->commandStreamReceivers.size());
executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0, 0);
executionEnvironment->initializeCommandStreamReceiver(0, 0);
EXPECT_EQ(1u, executionEnvironment->commandStreamReceivers.size());
EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[0][0]);
executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 1, 0);
executionEnvironment->initializeCommandStreamReceiver(1, 0);
EXPECT_EQ(2u, executionEnvironment->commandStreamReceivers.size());
EXPECT_NE(nullptr, executionEnvironment->commandStreamReceivers[1][0]);
}
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeIsCalledMultipleTimesForTheSameIndexThenCommandStreamReceiverIsReused) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
EXPECT_EQ(0u, executionEnvironment->commandStreamReceivers.size());
executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0, 1);
executionEnvironment->initializeCommandStreamReceiver(0, 1);
auto currentCommandStreamReceiver = executionEnvironment->commandStreamReceivers[0][1].get();
executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0, 1);
executionEnvironment->initializeCommandStreamReceiver(0, 1);
EXPECT_EQ(currentCommandStreamReceiver, executionEnvironment->commandStreamReceivers[0][1].get());
EXPECT_EQ(2u, executionEnvironment->commandStreamReceivers[0].size());
@@ -143,7 +141,8 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeIsCalledMultip
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeAubCenterIsCalledThenItIsReceivesCorrectInputParams) {
MockExecutionEnvironment executionEnvironment;
executionEnvironment.initAubCenter(platformDevices[0], true, "test.aub", CommandStreamReceiverType::CSR_AUB);
executionEnvironment.setHwInfo(*platformDevices);
executionEnvironment.initAubCenter(true, "test.aub", CommandStreamReceiverType::CSR_AUB);
EXPECT_TRUE(executionEnvironment.initAubCenterCalled);
EXPECT_TRUE(executionEnvironment.localMemoryEnabledReceived);
EXPECT_STREQ(executionEnvironment.aubFileNameReceived.c_str(), "test.aub");
@@ -153,46 +152,47 @@ TEST(ExecutionEnvironment, givenUseAubStreamFalseWhenGetAubManagerIsCalledThenRe
DebugManagerStateRestore dbgRestore;
DebugManager.flags.UseAubStream.set(false);
ExecutionEnvironment executionEnvironment;
executionEnvironment.initAubCenter(platformDevices[0], false, "", CommandStreamReceiverType::CSR_AUB);
auto aubManager = executionEnvironment.aubCenter->getAubManager();
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
executionEnvironment->initAubCenter(false, "", CommandStreamReceiverType::CSR_AUB);
auto aubManager = executionEnvironment->aubCenter->getAubManager();
EXPECT_EQ(nullptr, aubManager);
}
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeAubCenterIsCalledThenItIsInitalizedOnce) {
ExecutionEnvironment executionEnvironment;
executionEnvironment.initAubCenter(platformDevices[0], false, "", CommandStreamReceiverType::CSR_AUB);
auto currentAubCenter = executionEnvironment.aubCenter.get();
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
executionEnvironment->initAubCenter(false, "", CommandStreamReceiverType::CSR_AUB);
auto currentAubCenter = executionEnvironment->aubCenter.get();
EXPECT_NE(nullptr, currentAubCenter);
auto currentAubStreamProvider = currentAubCenter->getStreamProvider();
EXPECT_NE(nullptr, currentAubStreamProvider);
auto currentAubFileStream = currentAubStreamProvider->getStream();
EXPECT_NE(nullptr, currentAubFileStream);
executionEnvironment.initAubCenter(platformDevices[0], false, "", CommandStreamReceiverType::CSR_AUB);
EXPECT_EQ(currentAubCenter, executionEnvironment.aubCenter.get());
EXPECT_EQ(currentAubStreamProvider, executionEnvironment.aubCenter->getStreamProvider());
EXPECT_EQ(currentAubFileStream, executionEnvironment.aubCenter->getStreamProvider()->getStream());
executionEnvironment->initAubCenter(false, "", CommandStreamReceiverType::CSR_AUB);
EXPECT_EQ(currentAubCenter, executionEnvironment->aubCenter.get());
EXPECT_EQ(currentAubStreamProvider, executionEnvironment->aubCenter->getStreamProvider());
EXPECT_EQ(currentAubFileStream, executionEnvironment->aubCenter->getStreamProvider()->getStream());
}
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerIsCalledThenLocalMemorySupportedInMemoryManagerHasCorrectValue) {
const HardwareInfo *hwInfo = platformDevices[0];
auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(hwInfo));
auto executionEnvironment = device->getExecutionEnvironment();
executionEnvironment->initializeCommandStreamReceiver(hwInfo, 0, 0);
executionEnvironment->initializeCommandStreamReceiver(0, 0);
auto enableLocalMemory = HwHelper::get(hwInfo->pPlatform->eRenderCoreFamily).getEnableLocalMemory(*hwInfo);
executionEnvironment->initializeMemoryManager(false, enableLocalMemory);
EXPECT_EQ(enableLocalMemory, executionEnvironment->memoryManager->isLocalMemorySupported());
}
TEST(ExecutionEnvironment, givenExecutionEnvironmentWhenInitializeMemoryManagerIsCalledThenItIsInitalized) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0, 0);
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
executionEnvironment->initializeCommandStreamReceiver(0, 0);
executionEnvironment->initializeMemoryManager(false, false);
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
}
static_assert(sizeof(ExecutionEnvironment) == sizeof(std::vector<std::unique_ptr<CommandStreamReceiver>>) +
sizeof(std::unique_ptr<CommandStreamReceiver>) +
sizeof(std::mutex) +
sizeof(HardwareInfo *) +
(is64bit ? 80 : 44),
"New members detected in ExecutionEnvironment, please ensure that destruction sequence of objects is correct");
@@ -247,7 +247,7 @@ TEST(ExecutionEnvironment, givenExecutionEnvironmentWithVariousMembersWhenItIsDe
}
TEST(ExecutionEnvironment, givenMultipleDevicesWhenTheyAreCreatedTheyAllReuseTheSameMemoryManagerAndCommandStreamReceiver) {
auto executionEnvironment = new ExecutionEnvironment;
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
std::unique_ptr<MockDevice> device(Device::create<OCLRT::MockDevice>(nullptr, executionEnvironment, 0u));
auto &commandStreamReceiver = device->getCommandStreamReceiver();
auto memoryManager = device->getMemoryManager();
@@ -265,26 +265,27 @@ HWTEST_F(ExecutionEnvironmentHw, givenHwHelperInputWhenInitializingCsrThenCreate
localHwInfo.capabilityTable.ftrRenderCompressedImages = false;
ExecutionEnvironment executionEnvironment;
executionEnvironment.initializeCommandStreamReceiver(&localHwInfo, 0, 0);
executionEnvironment.setHwInfo(&localHwInfo);
executionEnvironment.initializeCommandStreamReceiver(0, 0);
auto csr0 = static_cast<UltCommandStreamReceiver<FamilyType> *>(executionEnvironment.commandStreamReceivers[0][0].get());
EXPECT_FALSE(csr0->createPageTableManagerCalled);
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
localHwInfo.capabilityTable.ftrRenderCompressedImages = false;
executionEnvironment.initializeCommandStreamReceiver(&localHwInfo, 1, 0);
executionEnvironment.initializeCommandStreamReceiver(1, 0);
auto csr1 = static_cast<UltCommandStreamReceiver<FamilyType> *>(executionEnvironment.commandStreamReceivers[1][0].get());
EXPECT_EQ(UnitTestHelper<FamilyType>::isPageTableManagerSupported(localHwInfo), csr1->createPageTableManagerCalled);
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = false;
localHwInfo.capabilityTable.ftrRenderCompressedImages = true;
executionEnvironment.initializeCommandStreamReceiver(&localHwInfo, 2, 0);
executionEnvironment.initializeCommandStreamReceiver(2, 0);
auto csr2 = static_cast<UltCommandStreamReceiver<FamilyType> *>(executionEnvironment.commandStreamReceivers[2][0].get());
EXPECT_EQ(UnitTestHelper<FamilyType>::isPageTableManagerSupported(localHwInfo), csr2->createPageTableManagerCalled);
}
TEST(ExecutionEnvironment, whenSpecialCsrNotExistThenReturnNullSpecialEngineControl) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0, 0);
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
executionEnvironment->initializeCommandStreamReceiver(0, 0);
executionEnvironment->initializeMemoryManager(false, false);
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
auto engineControl = executionEnvironment->getEngineControlForSpecialCsr();
@@ -292,8 +293,8 @@ TEST(ExecutionEnvironment, whenSpecialCsrNotExistThenReturnNullSpecialEngineCont
}
TEST(ExecutionEnvironment, whenSpecialCsrExistsThenReturnSpecialEngineControl) {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->initializeCommandStreamReceiver(platformDevices[0], 0, 0);
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
executionEnvironment->initializeCommandStreamReceiver(0, 0);
executionEnvironment->initializeMemoryManager(false, false);
EXPECT_NE(nullptr, executionEnvironment->memoryManager);

View File

@@ -1,5 +1,5 @@
#
# Copyright (C) 2018 Intel Corporation
# Copyright (C) 2018-2019 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@@ -15,7 +15,6 @@ set(IGDRCL_SRCS_tests_fixtures
${CMAKE_CURRENT_SOURCE_DIR}/enqueue_handler_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/execution_model_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/execution_model_kernel_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/gmm_environment_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/hello_world_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/hello_world_kernel_fixture.h
${CMAKE_CURRENT_SOURCE_DIR}/image_fixture.cpp

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -22,6 +22,5 @@ struct DeviceFixture {
volatile uint32_t *pTagMemory = nullptr;
HardwareInfo hwInfoHelper = {};
PLATFORM platformHelper = {};
ExecutionEnvironment executionEnvironment;
};
} // namespace OCLRT

View File

@@ -1,22 +0,0 @@
/*
* Copyright (C) 2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/helpers/options.h"
namespace OCLRT {
struct GmmEnvironmentFixture {
virtual void SetUp() {
executionEnvironment.initGmm(*platformDevices);
}
virtual void TearDown(){};
ExecutionEnvironment executionEnvironment;
};
} // namespace OCLRT

View File

@@ -120,7 +120,8 @@ class ImageClearColorFixture {
hwInfoHelper.hwInfo.capabilityTable.ftrRenderCompressedImages = true;
OCLRT::platformImpl.reset();
OCLRT::constructPlatform()->peekExecutionEnvironment()->initGmm(&hwInfoHelper.hwInfo);
OCLRT::constructPlatform()->peekExecutionEnvironment()->setHwInfo(&hwInfoHelper.hwInfo);
OCLRT::platform()->peekExecutionEnvironment()->initGmm();
surfaceState = FamilyType::cmdInitRenderSurfaceState;
surfaceState.setAuxiliarySurfaceMode(AUXILIARY_SURFACE_MODE::AUXILIARY_SURFACE_MODE_AUX_CCS_E);

View File

@@ -22,7 +22,8 @@ class MemoryAllocatorFixture : public MemoryManagementFixture {
void SetUp() override {
MemoryManagementFixture::SetUp();
executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->initializeCommandStreamReceiver(*platformDevices, 0, 0);
executionEnvironment->setHwInfo(*platformDevices);
executionEnvironment->initializeCommandStreamReceiver(0, 0);
memoryManager = new MockMemoryManager(false, false, *executionEnvironment);
executionEnvironment->memoryManager.reset(memoryManager);
csr = memoryManager->getDefaultCommandStreamReceiver(0);

View File

@@ -6,6 +6,7 @@
*/
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/platform/platform.h"
#include "test.h"
#include "unit_tests/os_interface/windows/os_interface_win_tests.h"
@@ -15,8 +16,8 @@ GEN9TEST_F(OsInterfaceTestSkl, askKmdIfPreemptionRegisterWhitelisted) {
HardwareInfo *hwInfo = nullptr;
size_t numDevices = 0;
ExecutionEnvironment executionEnvironment;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, *executionEnvironment);
EXPECT_TRUE(success);
for (size_t i = 0u; i < numDevices; i++) {

View File

@@ -30,9 +30,9 @@ using namespace ::testing;
namespace OCLRT {
struct GmmTests : public ::testing::Test {
void SetUp() override {
executionEnvironment.initGmm(*platformDevices);
executionEnvironment = platformImpl->peekExecutionEnvironment();
}
ExecutionEnvironment executionEnvironment;
ExecutionEnvironment *executionEnvironment;
};
TEST(GmmGlTests, givenGmmWhenAskedforCubeFaceIndexThenProperValueIsReturned) {
@@ -53,7 +53,7 @@ TEST(GmmGlTests, givenGmmWhenAskedforCubeFaceIndexThenProperValueIsReturned) {
}
TEST_F(GmmTests, resourceCreation) {
std::unique_ptr<MemoryManager> mm(new OsAgnosticMemoryManager(false, false, executionEnvironment));
std::unique_ptr<MemoryManager> mm(new OsAgnosticMemoryManager(false, false, *executionEnvironment));
void *pSysMem = mm->allocateSystemMemory(4096, 4096);
std::unique_ptr<Gmm> gmm(new Gmm(pSysMem, 4096, false));
@@ -67,7 +67,7 @@ TEST_F(GmmTests, resourceCreation) {
}
TEST_F(GmmTests, resourceCreationUncacheable) {
std::unique_ptr<MemoryManager> mm(new OsAgnosticMemoryManager(false, false, executionEnvironment));
std::unique_ptr<MemoryManager> mm(new OsAgnosticMemoryManager(false, false, *executionEnvironment));
void *pSysMem = mm->allocateSystemMemory(4096, 4096);
std::unique_ptr<Gmm> gmm(new Gmm(pSysMem, 4096, true));
@@ -83,7 +83,7 @@ TEST_F(GmmTests, resourceCreationUncacheable) {
}
TEST_F(GmmTests, resourceCleanupOnDelete) {
std::unique_ptr<MemoryManager> mm(new OsAgnosticMemoryManager(false, false, executionEnvironment));
std::unique_ptr<MemoryManager> mm(new OsAgnosticMemoryManager(false, false, *executionEnvironment));
void *pSysMem = mm->allocateSystemMemory(4096, 4096);
std::unique_ptr<Gmm> gmm(new Gmm(pSysMem, 4096, false));
@@ -96,7 +96,7 @@ TEST_F(GmmTests, resourceCleanupOnDelete) {
TEST_F(GmmTests, GivenBufferSizeLargerThenMaxPitchWhenAskedForGmmCreationThenGMMResourceIsCreatedWithNoRestrictionsFlag) {
auto maxSize = static_cast<size_t>(GmmHelper::maxPossiblePitch);
MemoryManager *mm = new OsAgnosticMemoryManager(false, false, executionEnvironment);
MemoryManager *mm = new OsAgnosticMemoryManager(false, false, *executionEnvironment);
void *pSysMem = mm->allocateSystemMemory(4096, 4096);
auto gmmRes = new Gmm(pSysMem, maxSize, false);

View File

@@ -10,11 +10,12 @@
#include "runtime/device/device.h"
#include "runtime/helpers/hw_helper.h"
#include "runtime/os_interface/device_factory.h"
#include "runtime/platform/platform.h"
namespace OCLRT {
ExecutionEnvironment *getExecutionEnvironmentImpl(HardwareInfo *&hwInfo) {
ExecutionEnvironment *executionEnvironment = new ExecutionEnvironment;
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
size_t numDevicesReturned = 0;
hwInfo = nullptr;
DeviceFactory::getDevices(&hwInfo, numDevicesReturned, *executionEnvironment);

View File

@@ -10,6 +10,7 @@
#include "runtime/event/user_event.h"
#include "runtime/helpers/options.h"
#include "runtime/helpers/timestamp_packet.h"
#include "runtime/platform/platform.h"
#include "runtime/utilities/tag_allocator.h"
#include "test.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
@@ -86,8 +87,8 @@ struct TimestampPacketSimpleTests : public ::testing::Test {
struct TimestampPacketTests : public TimestampPacketSimpleTests {
void SetUp() override {
executionEnvironment.incRefInternal();
device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, &executionEnvironment, 0u));
executionEnvironment = platformImpl->peekExecutionEnvironment();
device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, executionEnvironment, 0u));
context = new MockContext(device.get());
kernel = std::make_unique<MockKernelWithInternals>(*device, context);
mockCmdQ = new MockCommandQueue(context, device.get(), nullptr);
@@ -129,7 +130,7 @@ struct TimestampPacketTests : public TimestampPacketSimpleTests {
}
}
ExecutionEnvironment executionEnvironment;
ExecutionEnvironment *executionEnvironment;
std::unique_ptr<MockDevice> device;
MockContext *context;
std::unique_ptr<MockKernelWithInternals> kernel;
@@ -252,7 +253,7 @@ TEST_F(TimestampPacketSimpleTests, whenAskedForStampAddressThenReturnWithValidOf
}
HWTEST_F(TimestampPacketTests, givenCommandStreamReceiverHwWhenObtainingPreferredTagPoolSizeThenReturnCorrectValue) {
CommandStreamReceiverHw<FamilyType> csr(*platformDevices[0], executionEnvironment);
CommandStreamReceiverHw<FamilyType> csr(*platformDevices[0], *executionEnvironment);
EXPECT_EQ(512u, csr.getPreferredTagPoolSize());
}
@@ -488,7 +489,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenEnqueueingThe
auto &csr = device->getUltCommandStreamReceiver<FamilyType>();
csr.timestampPacketWriteEnabled = true;
auto mockTagAllocator = new MockTagAllocator<>(executionEnvironment.memoryManager.get());
auto mockTagAllocator = new MockTagAllocator<>(executionEnvironment->memoryManager.get());
csr.timestampPacketAllocator.reset(mockTagAllocator);
auto cmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, device.get(), nullptr);
@@ -557,7 +558,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenEnqueueingThe
}
HWTEST_F(TimestampPacketTests, givenEventsRequestWhenEstimatingStreamSizeForCsrThenAddSizeForSemaphores) {
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, &executionEnvironment, 1u));
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, executionEnvironment, 1u));
MockContext context2(device2.get());
auto cmdQ2 = std::make_unique<MockCommandQueueHw<FamilyType>>(&context2, device2.get(), nullptr);
@@ -644,7 +645,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenEnqueueingThe
using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
using MI_ATOMIC = typename FamilyType::MI_ATOMIC;
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, &executionEnvironment, 1u));
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, executionEnvironment, 1u));
device->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
device2->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
@@ -755,7 +756,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledOnDifferentCSRsFr
HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenEnqueueingBlockedThenProgramSemaphoresOnCsrStreamOnFlush) {
using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, &executionEnvironment, 1u));
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, executionEnvironment, 1u));
device->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
device2->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
@@ -800,7 +801,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenEnqueueingBlo
HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledOnDifferentCSRsFromOneDeviceWhenEnqueueingBlockedThenProgramSemaphoresOnCsrStreamOnFlush) {
using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, &executionEnvironment, 1u));
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, executionEnvironment, 1u));
device->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
@@ -847,7 +848,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledWhenDispatchingTh
using MI_SEMAPHORE_WAIT = typename FamilyType::MI_SEMAPHORE_WAIT;
using WALKER = WALKER_TYPE<FamilyType>;
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, &executionEnvironment, 1u));
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, executionEnvironment, 1u));
device->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
device2->getUltCommandStreamReceiver<FamilyType>().timestampPacketWriteEnabled = true;
MockContext context2(device2.get());
@@ -1011,7 +1012,7 @@ HWTEST_F(TimestampPacketTests, givenTimestampPacketWriteEnabledOnDifferentCSRsFr
}
HWTEST_F(TimestampPacketTests, givenAlreadyAssignedNodeWhenEnqueueingNonBlockedThenMakeItResident) {
auto mockTagAllocator = new MockTagAllocator<>(executionEnvironment.memoryManager.get(), 1);
auto mockTagAllocator = new MockTagAllocator<>(executionEnvironment->memoryManager.get(), 1);
auto &csr = device->getUltCommandStreamReceiver<FamilyType>();
csr.timestampPacketAllocator.reset(mockTagAllocator);
@@ -1033,7 +1034,7 @@ HWTEST_F(TimestampPacketTests, givenAlreadyAssignedNodeWhenEnqueueingNonBlockedT
}
HWTEST_F(TimestampPacketTests, givenAlreadyAssignedNodeWhenEnqueueingBlockedThenMakeItResident) {
auto mockTagAllocator = new MockTagAllocator<>(executionEnvironment.memoryManager.get(), 1);
auto mockTagAllocator = new MockTagAllocator<>(executionEnvironment->memoryManager.get(), 1);
auto &csr = device->getUltCommandStreamReceiver<FamilyType>();
csr.timestampPacketAllocator.reset(mockTagAllocator);
@@ -1150,8 +1151,8 @@ HWTEST_F(TimestampPacketTests, givenAlreadyAssignedNodeWhenEnqueueingToOoqThenDo
}
HWTEST_F(TimestampPacketTests, givenEventsWaitlistFromDifferentDevicesWhenEnqueueingThenMakeAllTimestampsResident) {
TagAllocator<TimestampPacket> tagAllocator(executionEnvironment.memoryManager.get(), 1, 1);
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, &executionEnvironment, 1u));
TagAllocator<TimestampPacket> tagAllocator(executionEnvironment->memoryManager.get(), 1, 1);
auto device2 = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr, executionEnvironment, 1u));
auto &ultCsr = device->getUltCommandStreamReceiver<FamilyType>();
ultCsr.timestampPacketWriteEnabled = true;
@@ -1185,7 +1186,7 @@ HWTEST_F(TimestampPacketTests, givenEventsWaitlistFromDifferentDevicesWhenEnqueu
}
HWTEST_F(TimestampPacketTests, givenEventsWaitlistFromDifferentCSRsWhenEnqueueingThenMakeAllTimestampsResident) {
TagAllocator<TimestampPacket> tagAllocator(executionEnvironment.memoryManager.get(), 1, 1);
TagAllocator<TimestampPacket> tagAllocator(executionEnvironment->memoryManager.get(), 1, 1);
auto &ultCsr = device->getUltCommandStreamReceiver<FamilyType>();
ultCsr.timestampPacketWriteEnabled = true;
@@ -1436,7 +1437,7 @@ HWTEST_F(TimestampPacketTests, givenKernelWhichDoesntRequiersFlushWhenEnquingKer
auto &csr = device->getUltCommandStreamReceiver<FamilyType>();
csr.timestampPacketWriteEnabled = true;
auto mockTagAllocator = new MockTagAllocator<>(executionEnvironment.memoryManager.get());
auto mockTagAllocator = new MockTagAllocator<>(executionEnvironment->memoryManager.get());
csr.timestampPacketAllocator.reset(mockTagAllocator);
auto cmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, device.get(), nullptr);
// obtain first node for cmdQ and event1
@@ -1453,7 +1454,7 @@ HWTEST_F(TimestampPacketTests, givenKernelWhichRequiersFlushWhenEnquingKernelThe
auto &csr = device->getUltCommandStreamReceiver<FamilyType>();
csr.timestampPacketWriteEnabled = true;
auto mockTagAllocator = new MockTagAllocator<>(executionEnvironment.memoryManager.get());
auto mockTagAllocator = new MockTagAllocator<>(executionEnvironment->memoryManager.get());
csr.timestampPacketAllocator.reset(mockTagAllocator);
auto cmdQ = std::make_unique<MockCommandQueueHw<FamilyType>>(context, device.get(), nullptr);
kernel->mockKernel->svmAllocationsRequireCacheFlush = true;

View File

@@ -40,6 +40,7 @@ CommandStreamReceiver *createCommandStream(const HardwareInfo *pHwInfo, Executio
bool getDevices(HardwareInfo **hwInfo, size_t &numDevicesReturned, ExecutionEnvironment &executionEnvironment) {
if (overrideDeviceWithDefaultHardwareInfo) {
*hwInfo = const_cast<HardwareInfo *>(*platformDevices);
executionEnvironment.setHwInfo(*hwInfo);
numDevicesReturned = numPlatformDevices;
return getDevicesResult;
}

View File

@@ -15,6 +15,7 @@
#include "runtime/mem_obj/buffer.h"
#include "runtime/memory_manager/svm_memory_manager.h"
#include "runtime/os_interface/os_context.h"
#include "runtime/platform/platform.h"
#include "test.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/fixtures/memory_management_fixture.h"
@@ -399,15 +400,14 @@ TEST(Buffer, givenZeroFlagsNoSharedContextAndRenderCompressedBuffersDisabledWhen
}
TEST(Buffer, givenClMemCopyHostPointerPassedToBufferCreateWhenAllocationIsNotInSystemMemoryPoolThenAllocationIsWrittenByEnqueueWriteBuffer) {
ExecutionEnvironment executionEnvironment;
executionEnvironment.incRefInternal();
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
auto *memoryManager = new ::testing::NiceMock<GMockMemoryManagerFailFirstAllocation>(executionEnvironment);
executionEnvironment.memoryManager.reset(memoryManager);
auto *memoryManager = new ::testing::NiceMock<GMockMemoryManagerFailFirstAllocation>(*executionEnvironment);
executionEnvironment->memoryManager.reset(memoryManager);
EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInDevicePool(::testing::_, ::testing::_))
.WillRepeatedly(::testing::Invoke(memoryManager, &GMockMemoryManagerFailFirstAllocation::baseAllocateGraphicsMemoryInDevicePool));
std::unique_ptr<MockDevice> device(MockDevice::create<MockDevice>(*platformDevices, &executionEnvironment, 0));
std::unique_ptr<MockDevice> device(MockDevice::create<MockDevice>(*platformDevices, executionEnvironment, 0));
MockContext ctx(device.get());
EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInDevicePool(::testing::_, ::testing::_))
@@ -427,7 +427,8 @@ TEST(Buffer, givenClMemCopyHostPointerPassedToBufferCreateWhenAllocationIsNotInS
struct RenderCompressedBuffersTests : public ::testing::Test {
void SetUp() override {
localHwInfo = *platformDevices[0];
device.reset(Device::create<MockDevice>(&localHwInfo, new ExecutionEnvironment(), 0u));
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
device.reset(Device::create<MockDevice>(&localHwInfo, executionEnvironment, 0u));
context = std::make_unique<MockContext>(device.get(), true);
context->setContextType(ContextType::CONTEXT_TYPE_UNRESTRICTIVE);
}

View File

@@ -634,7 +634,7 @@ TEST_P(CreateImageHostPtr, failedAllocationInjection) {
}
TEST_P(CreateImageHostPtr, checkWritingOutsideAllocatedMemoryWhileCreatingImage) {
auto mockMemoryManager = new MockMemoryManager(executionEnvironment);
auto mockMemoryManager = new MockMemoryManager(*pDevice->executionEnvironment);
pDevice->injectMemoryManager(mockMemoryManager);
context->setMemoryManager(mockMemoryManager);
mockMemoryManager->redundancyRatio = 2;
@@ -1294,15 +1294,13 @@ TEST(ImageTest, givenForcedLinearImages3DImageAndProperDescriptorValuesWhenIsCop
}
TEST(ImageTest, givenClMemCopyHostPointerPassedToImageCreateWhenAllocationIsNotInSystemMemoryPoolThenAllocationIsWrittenByEnqueueWriteImage) {
ExecutionEnvironment executionEnvironment;
executionEnvironment.incRefInternal();
auto *memoryManager = new ::testing::NiceMock<GMockMemoryManagerFailFirstAllocation>(executionEnvironment);
executionEnvironment.memoryManager.reset(memoryManager);
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
auto *memoryManager = new ::testing::NiceMock<GMockMemoryManagerFailFirstAllocation>(*executionEnvironment);
executionEnvironment->memoryManager.reset(memoryManager);
EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInDevicePool(::testing::_, ::testing::_))
.WillRepeatedly(::testing::Invoke(memoryManager, &GMockMemoryManagerFailFirstAllocation::baseAllocateGraphicsMemoryInDevicePool));
std::unique_ptr<MockDevice> device(MockDevice::create<MockDevice>(*platformDevices, &executionEnvironment, 0));
std::unique_ptr<MockDevice> device(MockDevice::create<MockDevice>(*platformDevices, executionEnvironment, 0));
MockContext ctx(device.get());
EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInDevicePool(::testing::_, ::testing::_))

View File

@@ -8,6 +8,7 @@
#include "runtime/mem_obj/mem_obj.h"
#include "runtime/memory_manager/allocations_list.h"
#include "runtime/os_interface/os_context.h"
#include "runtime/platform/platform.h"
#include "test.h"
#include "unit_tests/libult/ult_command_stream_receiver.h"
#include "unit_tests/mocks/mock_context.h"
@@ -29,11 +30,10 @@ void CL_CALLBACK emptyDestructorCallback(cl_mem memObj, void *userData) {
class MemObjDestructionTest : public ::testing::TestWithParam<bool> {
public:
void SetUp() override {
executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->incRefInternal();
executionEnvironment = platformImpl->peekExecutionEnvironment();
memoryManager = new MockMemoryManager(*executionEnvironment);
executionEnvironment->memoryManager.reset(memoryManager);
device.reset(MockDevice::create<MockDevice>(*platformDevices, executionEnvironment.get(), 0));
device.reset(MockDevice::create<MockDevice>(*platformDevices, executionEnvironment, 0));
context.reset(new MockContext(device.get()));
allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{size});
@@ -64,7 +64,7 @@ class MemObjDestructionTest : public ::testing::TestWithParam<bool> {
}
constexpr static uint32_t taskCountReady = 3u;
std::unique_ptr<ExecutionEnvironment> executionEnvironment;
ExecutionEnvironment *executionEnvironment;
std::unique_ptr<MockDevice> device;
uint32_t contextId = 0;
MockMemoryManager *memoryManager;

View File

@@ -12,6 +12,7 @@
#include "runtime/mem_obj/mem_obj.h"
#include "runtime/memory_manager/allocations_list.h"
#include "runtime/os_interface/os_context.h"
#include "runtime/platform/platform.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_deferred_deleter.h"
#include "unit_tests/mocks/mock_device.h"
@@ -161,11 +162,10 @@ TEST(MemObj, givenNotReadyGraphicsAllocationWhenMemObjDestroysAllocationAsyncThe
}
TEST(MemObj, givenReadyGraphicsAllocationWhenMemObjDestroysAllocationAsyncThenAllocationIsNotAddedToMemoryManagerAllocationList) {
ExecutionEnvironment executionEnvironment;
executionEnvironment.incRefInternal();
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(*platformDevices, &executionEnvironment, 0));
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(*platformDevices, executionEnvironment, 0));
MockContext context(device.get());
auto memoryManager = executionEnvironment.memoryManager.get();
auto memoryManager = executionEnvironment->memoryManager.get();
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
allocation->updateTaskCount(1, device->getDefaultEngine().osContext->getContextId());

View File

@@ -10,6 +10,7 @@
#include "runtime/memory_manager/deferrable_allocation_deletion.h"
#include "runtime/memory_manager/deferred_deleter.h"
#include "runtime/os_interface/os_context.h"
#include "runtime/platform/platform.h"
#include "test.h"
#include "unit_tests/libult/ult_command_stream_receiver.h"
#include "unit_tests/mocks/mock_allocation_properties.h"
@@ -36,10 +37,10 @@ struct DeferredDeleterPublic : DeferredDeleter {
struct DeferrableAllocationDeletionTest : ::testing::Test {
void SetUp() override {
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
memoryManager = new MockMemoryManager(*executionEnvironment);
executionEnvironment->memoryManager.reset(memoryManager);
device.reset(Device::create<MockDevice>(nullptr, executionEnvironment.release(), 0u));
device.reset(Device::create<MockDevice>(nullptr, executionEnvironment, 0u));
hwTag = device->getDefaultEngine().commandStreamReceiver->getTagAddress();
defaultOsContextId = device->getDefaultEngine().osContext->getContextId();
asyncDeleter = std::make_unique<DeferredDeleterPublic>();

View File

@@ -16,6 +16,7 @@
#include "runtime/memory_manager/memory_constants.h"
#include "runtime/os_interface/os_context.h"
#include "runtime/os_interface/os_interface.h"
#include "runtime/platform/platform.h"
#include "runtime/program/printf_handler.h"
#include "runtime/program/program.h"
#include "test.h"
@@ -550,16 +551,14 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenForce32bitallocationI
}
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenAllocateGraphicsMemoryForImageIsCalledThenGraphicsAllocationIsReturned) {
ExecutionEnvironment executionEnvironment;
MockMemoryManager memoryManager(false, false, executionEnvironment);
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
MockMemoryManager memoryManager(false, false, *executionEnvironment);
cl_image_desc imgDesc = {};
imgDesc.image_width = 512;
imgDesc.image_height = 1;
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
executionEnvironment.initGmm(*platformDevices);
MockMemoryManager::AllocationData allocationData;
allocationData.imgInfo = &imgInfo;
@@ -571,16 +570,14 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenAllocateGraphicsMemor
}
TEST(OsAgnosticMemoryManager, givenEnabledLocalMemoryWhenAllocateGraphicsMemoryForImageIsCalledThenUseLocalMemoryIsNotSet) {
ExecutionEnvironment executionEnvironment;
MockMemoryManager memoryManager(false, true, executionEnvironment);
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
MockMemoryManager memoryManager(false, true, *executionEnvironment);
cl_image_desc imgDesc = {};
imgDesc.image_width = 1;
imgDesc.image_height = 1;
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
executionEnvironment.initGmm(*platformDevices);
MockMemoryManager::AllocationData allocationData;
allocationData.imgInfo = &imgInfo;
@@ -591,9 +588,8 @@ TEST(OsAgnosticMemoryManager, givenEnabledLocalMemoryWhenAllocateGraphicsMemoryF
}
TEST(OsAgnosticMemoryManager, givenHostPointerNotRequiringCopyWhenAllocateGraphicsMemoryForImageFromHostPtrIsCalledThenGraphicsAllocationIsReturned) {
ExecutionEnvironment executionEnvironment;
MockMemoryManager memoryManager(false, false, executionEnvironment);
executionEnvironment.initGmm(*platformDevices);
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
MockMemoryManager memoryManager(false, false, *executionEnvironment);
cl_image_desc imgDesc = {};
imgDesc.image_width = 4;
@@ -631,9 +627,8 @@ TEST(OsAgnosticMemoryManager, givenHostPointerNotRequiringCopyWhenAllocateGraphi
}
TEST(OsAgnosticMemoryManager, givenHostPointerRequiringCopyWhenAllocateGraphicsMemoryForImageFromHostPtrIsCalledThenNullptrIsReturned) {
ExecutionEnvironment executionEnvironment;
MockMemoryManager memoryManager(false, false, executionEnvironment);
executionEnvironment.initGmm(*platformDevices);
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
MockMemoryManager memoryManager(false, false, *executionEnvironment);
cl_image_desc imgDesc = {};
imgDesc.image_width = 4;
@@ -1168,16 +1163,14 @@ TEST(OsAgnosticMemoryManager, givenLocalMemorySupportedAndAubUsageWhenMemoryMana
}
TEST(MemoryManager, givenSharedResourceCopyWhenAllocatingGraphicsMemoryThenAllocateGraphicsMemoryForImageIsCalled) {
ExecutionEnvironment executionEnvironment;
MockMemoryManager memoryManager(false, true, executionEnvironment);
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
MockMemoryManager memoryManager(false, true, *executionEnvironment);
cl_image_desc imgDesc = {};
imgDesc.image_width = 1;
imgDesc.image_height = 1;
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
executionEnvironment.initGmm(*platformDevices);
MockMemoryManager::AllocationData allocationData;
allocationData.imgInfo = &imgInfo;
allocationData.type = GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY;
@@ -1479,12 +1472,11 @@ HWTEST_F(GraphicsAllocationTests, givenAllocationUsedOnlyByNonDefaultCsrWhenChec
}
HWTEST_F(GraphicsAllocationTests, givenAllocationUsedOnlyByNonDefaultDeviceWhenCheckingUsageBeforeDestroyThenStoreItAsTemporaryAllocation) {
ExecutionEnvironment executionEnvironment;
executionEnvironment.incRefInternal();
auto device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(platformDevices[0], &executionEnvironment, 0u));
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
auto device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(platformDevices[0], executionEnvironment, 0u));
auto &defaultCommandStreamReceiver = device->getCommandStreamReceiver();
auto &nonDefaultCommandStreamReceiver = static_cast<UltCommandStreamReceiver<FamilyType> &>(*executionEnvironment.commandStreamReceivers[0][1]);
auto memoryManager = executionEnvironment.memoryManager.get();
auto &nonDefaultCommandStreamReceiver = static_cast<UltCommandStreamReceiver<FamilyType> &>(*executionEnvironment->commandStreamReceivers[0][1]);
auto memoryManager = executionEnvironment->memoryManager.get();
auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
auto notReadyTaskCount = *nonDefaultCommandStreamReceiver.getTagAddress() + 1;
@@ -1502,15 +1494,14 @@ HWTEST_F(GraphicsAllocationTests, givenAllocationUsedOnlyByNonDefaultDeviceWhenC
}
HWTEST_F(GraphicsAllocationTests, givenAllocationUsedByManyOsContextsWhenCheckingUsageBeforeDestroyThenMultiContextDestructorIsUsedForWaitingForAllOsContexts) {
ExecutionEnvironment executionEnvironment;
executionEnvironment.incRefInternal();
auto memoryManager = new MockMemoryManager(false, false, executionEnvironment);
executionEnvironment.memoryManager.reset(memoryManager);
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
auto memoryManager = new MockMemoryManager(false, false, *executionEnvironment);
executionEnvironment->memoryManager.reset(memoryManager);
auto multiContextDestructor = new MockDeferredDeleter();
multiContextDestructor->expectDrainBlockingValue(false);
memoryManager->multiContextResourceDestructor.reset(multiContextDestructor);
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(platformDevices[0], &executionEnvironment, 0u));
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(platformDevices[0], executionEnvironment, 0u));
auto nonDefaultOsContext = device->getEngine(EngineInstanceConstants::lowPriorityGpgpuEngineIndex).osContext;
auto nonDefaultCsr = reinterpret_cast<UltCommandStreamReceiver<FamilyType> *>(device->getEngine(EngineInstanceConstants::lowPriorityGpgpuEngineIndex).commandStreamReceiver);
auto defaultCsr = reinterpret_cast<UltCommandStreamReceiver<FamilyType> *>(device->getDefaultEngine().commandStreamReceiver);

View File

@@ -9,6 +9,7 @@
#include "runtime/device/driver_info.h"
#include "runtime/os_interface/os_context.h"
#include "unit_tests/mocks/mock_execution_environment.h"
#include "unit_tests/mocks/mock_memory_manager.h"
#include "unit_tests/mocks/mock_ostime.h"
#include "unit_tests/tests_configuration.h"
@@ -16,7 +17,7 @@
using namespace OCLRT;
MockDevice::MockDevice(const HardwareInfo &hwInfo)
: MockDevice(hwInfo, new ExecutionEnvironment, 0u) {
: MockDevice(hwInfo, new MockExecutionEnvironment(&hwInfo), 0u) {
CommandStreamReceiver *commandStreamReceiver = createCommandStream(&hwInfo, *this->executionEnvironment);
executionEnvironment->commandStreamReceivers.resize(getDeviceIndex() + 1);
executionEnvironment->commandStreamReceivers[getDeviceIndex()].resize(defaultEngineIndex + 1);
@@ -73,4 +74,4 @@ FailDevice::FailDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executi
FailDeviceAfterOne::FailDeviceAfterOne(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex)
: MockDevice(hwInfo, executionEnvironment, deviceIndex) {
this->mockMemoryManager.reset(new FailMemoryManager(1));
}
}

View File

@@ -83,6 +83,7 @@ class MockDevice : public Device {
template <typename T>
static T *createWithExecutionEnvironment(const HardwareInfo *pHwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex) {
pHwInfo = getDeviceInitHwInfo(pHwInfo);
executionEnvironment->setHwInfo(pHwInfo);
T *device = new T(*pHwInfo, executionEnvironment, deviceIndex);
executionEnvironment->memoryManager = std::move(device->mockMemoryManager);
return createDeviceInternals(pHwInfo, device);
@@ -90,7 +91,9 @@ class MockDevice : public Device {
template <typename T>
static T *createWithNewExecutionEnvironment(const HardwareInfo *pHwInfo) {
return createWithExecutionEnvironment<T>(pHwInfo, new ExecutionEnvironment(), 0u);
ExecutionEnvironment *executionEnvironment = new ExecutionEnvironment();
executionEnvironment->setHwInfo(pHwInfo);
return createWithExecutionEnvironment<T>(pHwInfo, executionEnvironment, 0u);
}
void allocatePreemptionAllocationIfNotPresent() {
@@ -122,8 +125,8 @@ inline Device *MockDevice::createWithNewExecutionEnvironment<Device>(const Hardw
enableLocalMemory = HwHelper::get(pHwInfo->pPlatform->eRenderCoreFamily).getEnableLocalMemory(*pHwInfo);
enable64kbPages = getEnabled64kbPages(*pHwInfo);
}
executionEnvironment->setHwInfo(*platformDevices);
executionEnvironment->initializeMemoryManager(enable64kbPages, enableLocalMemory);
return Device::create<Device>(pHwInfo, executionEnvironment, 0u);
}
@@ -141,5 +144,4 @@ class MockAlignedMallocManagerDevice : public MockDevice {
public:
MockAlignedMallocManagerDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment, uint32_t deviceIndex);
};
} // namespace OCLRT

View File

@@ -13,13 +13,16 @@
namespace OCLRT {
struct MockExecutionEnvironment : ExecutionEnvironment {
MockExecutionEnvironment() = default;
void initAubCenter(const HardwareInfo *hwInfo, bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType) override {
MockExecutionEnvironment(const HardwareInfo *hwInfo) {
setHwInfo(hwInfo);
}
void initAubCenter(bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType) override {
if (!initAubCenterCalled) {
initAubCenterCalled = true;
localMemoryEnabledReceived = localMemoryEnabled;
aubFileNameReceived = aubFileName;
}
ExecutionEnvironment::initAubCenter(hwInfo, localMemoryEnabled, aubFileName, csrType);
ExecutionEnvironment::initAubCenter(localMemoryEnabled, aubFileName, csrType);
}
bool initAubCenterCalled = false;
bool localMemoryEnabledReceived = false;

View File

@@ -11,6 +11,7 @@
#include "runtime/memory_manager/memory_constants.h"
#include "runtime/os_interface/device_factory.h"
#include "runtime/os_interface/os_library.h"
#include "runtime/platform/platform.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "gtest/gtest.h"
@@ -23,6 +24,7 @@ struct DeviceFactoryTest : public ::testing::Test {
public:
void SetUp() override {
const HardwareInfo hwInfo = *platformDevices[0];
executionEnvironment = platformImpl->peekExecutionEnvironment();
mockGdiDll = setAdapterInfo(hwInfo.pPlatform, hwInfo.pSysInfo);
}
@@ -32,14 +34,14 @@ struct DeviceFactoryTest : public ::testing::Test {
protected:
OsLibrary *mockGdiDll;
ExecutionEnvironment executionEnvironment;
ExecutionEnvironment *executionEnvironment;
};
TEST_F(DeviceFactoryTest, GetDevices_Expect_True_If_Returned) {
DeviceFactoryCleaner cleaner;
HardwareInfo *hwInfo = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, *executionEnvironment);
EXPECT_TRUE((numDevices > 0) ? success : !success);
}
@@ -48,7 +50,7 @@ TEST_F(DeviceFactoryTest, GetDevices_Check_HwInfo_Null) {
DeviceFactoryCleaner cleaner;
HardwareInfo *hwInfo = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, *executionEnvironment);
EXPECT_TRUE((numDevices > 0) ? success : !success);
if (numDevices > 0) {
@@ -66,7 +68,7 @@ TEST_F(DeviceFactoryTest, GetDevices_Check_HwInfo_Platform) {
const HardwareInfo *refHwinfo = *platformDevices;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, *executionEnvironment);
EXPECT_TRUE((numDevices > 0) ? success : !success);
if (numDevices > 0) {
@@ -85,7 +87,7 @@ TEST_F(DeviceFactoryTest, overrideKmdNotifySettings) {
HardwareInfo *hwInfoOverriden = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfoReference, numDevices, executionEnvironment);
bool success = DeviceFactory::getDevices(&hwInfoReference, numDevices, *executionEnvironment);
ASSERT_TRUE(success);
auto refEnableKmdNotify = hwInfoReference->capabilityTable.kmdNotifyProperties.enableKmdNotify;
auto refDelayKmdNotifyMicroseconds = hwInfoReference->capabilityTable.kmdNotifyProperties.delayKmdNotifyMicroseconds;
@@ -104,7 +106,7 @@ TEST_F(DeviceFactoryTest, overrideKmdNotifySettings) {
DebugManager.flags.OverrideEnableQuickKmdSleepForSporadicWaits.set(!refEnableQuickKmdSleepForSporadicWaits);
DebugManager.flags.OverrideDelayQuickKmdSleepForSporadicWaitsMicroseconds.set(static_cast<int32_t>(refDelayQuickKmdSleepForSporadicWaitsMicroseconds) + 12);
success = DeviceFactory::getDevices(&hwInfoOverriden, numDevices, executionEnvironment);
success = DeviceFactory::getDevices(&hwInfoOverriden, numDevices, *executionEnvironment);
ASSERT_TRUE(success);
EXPECT_EQ(!refEnableKmdNotify, hwInfoOverriden->capabilityTable.kmdNotifyProperties.enableKmdNotify);
@@ -127,7 +129,7 @@ TEST_F(DeviceFactoryTest, getEngineTypeDebugOverride) {
HardwareInfo *hwInfoOverriden = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfoOverriden, numDevices, executionEnvironment);
bool success = DeviceFactory::getDevices(&hwInfoOverriden, numDevices, *executionEnvironment);
ASSERT_TRUE(success);
ASSERT_NE(nullptr, hwInfoOverriden);
int32_t actualEngineType = static_cast<int32_t>(hwInfoOverriden->capabilityTable.defaultEngineType);
@@ -138,7 +140,7 @@ TEST_F(DeviceFactoryTest, givenPointerToHwInfoWhenGetDevicedCalledThenRequiedSur
DeviceFactoryCleaner cleaner;
HardwareInfo *hwInfo = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, *executionEnvironment);
ASSERT_TRUE(success);
EXPECT_EQ(hwInfo->pSysInfo->CsrSizeInMb * MemoryConstants::megaByte, hwInfo->capabilityTable.requiredPreemptionSurfaceSize);
@@ -151,7 +153,7 @@ TEST_F(DeviceFactoryTest, givenCreateMultipleDevicesDebugFlagWhenGetDevicesIsCal
DebugManager.flags.CreateMultipleDevices.set(requiredDeviceCount);
HardwareInfo *hwInfo = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, *executionEnvironment);
ASSERT_NE(nullptr, hwInfo);
for (auto deviceIndex = 0u; deviceIndex < requiredDeviceCount; deviceIndex++) {
@@ -174,7 +176,7 @@ TEST_F(DeviceFactoryTest, givenCreateMultipleDevicesDebugFlagWhenGetDevicesForPr
DebugManager.flags.CreateMultipleDevices.set(requiredDeviceCount);
HardwareInfo *hwInfo = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevicesForProductFamilyOverride(&hwInfo, numDevices, executionEnvironment);
bool success = DeviceFactory::getDevicesForProductFamilyOverride(&hwInfo, numDevices, *executionEnvironment);
ASSERT_NE(nullptr, hwInfo);
for (auto deviceIndex = 0u; deviceIndex < requiredDeviceCount; deviceIndex++) {
@@ -194,7 +196,7 @@ TEST_F(DeviceFactoryTest, givenGetDevicesCallWhenItIsDoneThenOsInterfaceIsAlloca
DeviceFactoryCleaner cleaner;
HardwareInfo *hwInfo = nullptr;
size_t numDevices = 0;
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, executionEnvironment);
bool success = DeviceFactory::getDevices(&hwInfo, numDevices, *executionEnvironment);
EXPECT_TRUE(success);
EXPECT_NE(nullptr, executionEnvironment.osInterface);
EXPECT_NE(nullptr, executionEnvironment->osInterface);
}

View File

@@ -27,10 +27,10 @@ using namespace OCLRT;
struct DeviceCommandStreamLeaksTest : ::testing::Test {
void SetUp() override {
HardwareInfo *hwInfo = nullptr;
executionEnvironment = std::unique_ptr<ExecutionEnvironment>(getExecutionEnvironmentImpl(hwInfo));
executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
}
std::unique_ptr<ExecutionEnvironment> executionEnvironment;
ExecutionEnvironment *executionEnvironment;
};
HWTEST_F(DeviceCommandStreamLeaksTest, Create) {

View File

@@ -39,6 +39,7 @@ class DrmCommandStreamFixture {
mock = std::make_unique<::testing::NiceMock<DrmMockImpl>>(mockFd);
executionEnvironment.setHwInfo(*platformDevices);
executionEnvironment.osInterface = std::make_unique<OSInterface>();
executionEnvironment.osInterface->get()->setDrm(mock.get());
@@ -565,7 +566,8 @@ class DrmCommandStreamEnhancedFixture
virtual void SetUp() {
executionEnvironment = new ExecutionEnvironment;
executionEnvironment->incRefInternal();
executionEnvironment->initGmm(*platformDevices);
executionEnvironment->setHwInfo(*platformDevices);
executionEnvironment->initGmm();
this->dbgState = std::make_unique<DebugManagerStateRestore>();
//make sure this is disabled, we don't want test this now
DebugManager.flags.EnableForcePin.set(false);

View File

@@ -107,6 +107,7 @@ class DrmMemoryManagerFixtureWithoutQuietIoctlExpectation : public MemoryManagem
void SetUp() override {
MemoryManagementFixture::SetUp();
executionEnvironment = new ExecutionEnvironment;
executionEnvironment->setHwInfo(*platformDevices);
this->mock = new DrmMockCustom;
memoryManager = new (std::nothrow) TestedDrmMemoryManager(this->mock, *executionEnvironment);
ASSERT_NE(nullptr, memoryManager);
@@ -1222,8 +1223,6 @@ TEST_F(DrmMemoryManagerTest, GivenMemoryManagerWhenAllocateGraphicsMemoryForImag
imgInfo.size = 4096u;
imgInfo.rowPitch = 512u;
ExecutionEnvironment executionEnvironment;
executionEnvironment.initGmm(*platformDevices);
TestedDrmMemoryManager::AllocationData allocationData;
allocationData.imgInfo = &imgInfo;
@@ -1945,9 +1944,6 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAlloca
imgInfo.size = 4096u;
imgInfo.rowPitch = 512u;
ExecutionEnvironment executionEnvironment;
executionEnvironment.initGmm(*platformDevices);
TestedDrmMemoryManager::AllocationData allocationData;
allocationData.imgInfo = &imgInfo;

View File

@@ -24,9 +24,9 @@
#include "runtime/os_interface/windows/wddm_device_command_stream.h"
#include "runtime/os_interface/windows/wddm_memory_manager.h"
#include "runtime/os_interface/windows/wddm_residency_controller.h"
#include "runtime/platform/platform.h"
#include "test.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/fixtures/gmm_environment_fixture.h"
#include "unit_tests/fixtures/memory_management_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/helpers/execution_environment_helper.h"
@@ -117,7 +117,6 @@ class WddmCommandStreamWithMockGdiFixture {
virtual void SetUp() {
HardwareInfo *hwInfo = nullptr;
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
executionEnvironment->initGmm(*platformDevices);
wddm = static_cast<WddmMock *>(executionEnvironment->osInterface->get()->getWddm());
gdi = new MockGdi();
wddm->gdi.reset(gdi);
@@ -147,23 +146,24 @@ class WddmCommandStreamWithMockGdiFixture {
using WddmCommandStreamTest = ::Test<WddmCommandStreamFixture>;
using WddmCommandStreamMockGdiTest = ::Test<WddmCommandStreamWithMockGdiFixture>;
using WddmDefaultTest = ::Test<DeviceFixture>;
using DeviceCommandStreamTest = ::Test<GmmEnvironmentFixture>;
TEST_F(DeviceCommandStreamTest, CreateWddmCSR) {
TEST(DeviceCommandStreamTest, CreateWddmCSR) {
auto wddm = Wddm::createWddm();
this->executionEnvironment.osInterface = std::make_unique<OSInterface>();
this->executionEnvironment.osInterface->get()->setWddm(static_cast<WddmMock *>(wddm));
std::unique_ptr<WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>> csr(static_cast<WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *>(WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>::create(DEFAULT_TEST_PLATFORM::hwInfo, false, this->executionEnvironment)));
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
executionEnvironment->osInterface = std::make_unique<OSInterface>();
executionEnvironment->osInterface->get()->setWddm(static_cast<WddmMock *>(wddm));
std::unique_ptr<WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>> csr(static_cast<WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *>(WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>::create(DEFAULT_TEST_PLATFORM::hwInfo, false, *executionEnvironment)));
EXPECT_NE(nullptr, csr);
auto wddmFromCsr = csr->peekWddm();
EXPECT_NE(nullptr, wddmFromCsr);
}
TEST_F(DeviceCommandStreamTest, CreateWddmCSRWithAubDump) {
TEST(DeviceCommandStreamTest, CreateWddmCSRWithAubDump) {
auto wddm = Wddm::createWddm();
this->executionEnvironment.osInterface = std::make_unique<OSInterface>();
this->executionEnvironment.osInterface->get()->setWddm(static_cast<WddmMock *>(wddm));
std::unique_ptr<WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>> csr(static_cast<WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *>(WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>::create(DEFAULT_TEST_PLATFORM::hwInfo, true, this->executionEnvironment)));
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
executionEnvironment->osInterface = std::make_unique<OSInterface>();
executionEnvironment->osInterface->get()->setWddm(static_cast<WddmMock *>(wddm));
std::unique_ptr<WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>> csr(static_cast<WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME> *>(WddmCommandStreamReceiver<DEFAULT_TEST_FAMILY_NAME>::create(DEFAULT_TEST_PLATFORM::hwInfo, true, *executionEnvironment)));
EXPECT_NE(nullptr, csr);
auto wddmFromCsr = csr->peekWddm();
EXPECT_NE(nullptr, wddmFromCsr);
@@ -240,7 +240,7 @@ TEST_F(WddmCommandStreamTest, givenWdmmWhenSubmitIsCalledThenCoherencyRequiredFl
TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOffWhenWorkloadIsSubmittedThenHeaderDoesntHavePreemptionFieldSet) {
HardwareInfo *hwInfo = nullptr;
std::unique_ptr<ExecutionEnvironment> executionEnvironment = std::unique_ptr<ExecutionEnvironment>(getExecutionEnvironmentImpl(hwInfo));
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::Disabled;
auto wddm = static_cast<WddmMock *>(executionEnvironment->osInterface->get()->getWddm());
executionEnvironment->commandStreamReceivers.resize(1);
@@ -265,7 +265,7 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOf
TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOnWhenWorkloadIsSubmittedThenHeaderDoesHavePreemptionFieldSet) {
HardwareInfo *hwInfo = nullptr;
std::unique_ptr<ExecutionEnvironment> executionEnvironment = std::unique_ptr<ExecutionEnvironment>(getExecutionEnvironmentImpl(hwInfo));
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread;
auto wddm = static_cast<WddmMock *>(executionEnvironment->osInterface->get()->getWddm());
executionEnvironment->commandStreamReceivers.resize(1);
@@ -291,7 +291,7 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOn
TEST(WddmPreemptionHeaderTests, givenDeviceSupportingPreemptionWhenCommandStreamReceiverIsCreatedThenHeaderContainsPreemptionFieldSet) {
HardwareInfo *hwInfo = nullptr;
std::unique_ptr<ExecutionEnvironment> executionEnvironment = std::unique_ptr<ExecutionEnvironment>(getExecutionEnvironmentImpl(hwInfo));
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::MidThread;
auto commandStreamReceiver = std::make_unique<MockWddmCsr<DEFAULT_TEST_FAMILY_NAME>>(hwInfo[0], *executionEnvironment);
auto commandHeader = commandStreamReceiver->commandBufferHeader;
@@ -301,7 +301,7 @@ TEST(WddmPreemptionHeaderTests, givenDeviceSupportingPreemptionWhenCommandStream
TEST(WddmPreemptionHeaderTests, givenDevicenotSupportingPreemptionWhenCommandStreamReceiverIsCreatedThenHeaderPreemptionFieldIsNotSet) {
HardwareInfo *hwInfo = nullptr;
std::unique_ptr<ExecutionEnvironment> executionEnvironment = std::unique_ptr<ExecutionEnvironment>(getExecutionEnvironmentImpl(hwInfo));
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
hwInfo->capabilityTable.defaultPreemptionMode = PreemptionMode::Disabled;
auto commandStreamReceiver = std::make_unique<MockWddmCsr<DEFAULT_TEST_FAMILY_NAME>>(hwInfo[0], *executionEnvironment);
auto commandHeader = commandStreamReceiver->commandBufferHeader;
@@ -785,6 +785,7 @@ using WddmSimpleTest = ::testing::Test;
HWTEST_F(WddmSimpleTest, givenDefaultWddmCsrWhenItIsCreatedThenBatchingIsTurnedOn) {
DebugManager.flags.CsrDispatchMode.set(0);
ExecutionEnvironment *executionEnvironment = new ExecutionEnvironment;
executionEnvironment->setHwInfo(*platformDevices);
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(platformDevices[0], executionEnvironment, 0u));
auto wddm = Wddm::createWddm();
executionEnvironment->osInterface = std::make_unique<OSInterface>();
@@ -818,55 +819,60 @@ struct WddmCsrCompressionTests : ::testing::Test {
WddmMock *myMockWddm;
};
HWTEST_F(WddmCsrCompressionTests, givenEnabledCompressionWhenInitializedThenCreatePagetableMngr) {
bool compressionEnabled[2][2] = {{true, false}, {false, true}};
for (size_t i = 0; i < 2; i++) {
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(hwInfo, executionEnvironment, 0u));
setCompressionEnabled(compressionEnabled[i][0], compressionEnabled[i][1]);
myMockWddm = static_cast<WddmMock *>(executionEnvironment->osInterface->get()->getWddm());
EXPECT_EQ(nullptr, myMockWddm->getPageTableManager());
MockWddmCsr<FamilyType> mockWddmCsr(hwInfo[0], *executionEnvironment);
mockWddmCsr.createPageTableManager();
ASSERT_NE(nullptr, myMockWddm->getPageTableManager());
auto mockMngr = reinterpret_cast<MockGmmPageTableMngr *>(myMockWddm->getPageTableManager());
GMM_DEVICE_CALLBACKS_INT expectedDeviceCb = {};
GMM_TRANSLATIONTABLE_CALLBACKS expectedTTCallbacks = {};
unsigned int expectedFlags = (TT_TYPE::TRTT | TT_TYPE::AUXTT);
auto myGdi = myMockWddm->getGdi();
// clang-format off
expectedDeviceCb.Adapter.KmtHandle = myMockWddm->getAdapter();
expectedDeviceCb.hDevice.KmtHandle = myMockWddm->getDevice();
expectedDeviceCb.hCsr = &mockWddmCsr;
expectedDeviceCb.PagingQueue = myMockWddm->getPagingQueue();
expectedDeviceCb.PagingFence = myMockWddm->getPagingQueueSyncObject();
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnAllocate = myGdi->createAllocation;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnDeallocate = myGdi->destroyAllocation;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnMapGPUVA = myGdi->mapGpuVirtualAddress;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnMakeResident = myGdi->makeResident;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnEvict = myGdi->evict;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnReserveGPUVA = myGdi->reserveGpuVirtualAddress;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnUpdateGPUVA = myGdi->updateGpuVirtualAddress;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnWaitFromCpu = myGdi->waitForSynchronizationObjectFromCpu;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnLock = myGdi->lock2;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnUnLock = myGdi->unlock2;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnEscape = myGdi->escape;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnNotifyAubCapture = DeviceCallbacks<FamilyType>::notifyAubCapture;
expectedTTCallbacks.pfWriteL3Adr = TTCallbacks<FamilyType>::writeL3Address;
// clang-format on
EXPECT_TRUE(memcmp(&expectedDeviceCb, &mockMngr->deviceCb, sizeof(GMM_DEVICE_CALLBACKS_INT)) == 0);
EXPECT_TRUE(memcmp(&expectedDeviceCb.Adapter, &mockMngr->deviceCb.Adapter, sizeof(GMM_HANDLE_EXT)) == 0);
EXPECT_TRUE(memcmp(&expectedDeviceCb.hDevice, &mockMngr->deviceCb.hDevice, sizeof(GMM_HANDLE_EXT)) == 0);
EXPECT_TRUE(memcmp(&expectedDeviceCb.DevCbPtrs.KmtCbPtrs, &mockMngr->deviceCb.DevCbPtrs.KmtCbPtrs, sizeof(GMM_DEVICE_CB_PTRS::KmtCbPtrs)) == 0);
EXPECT_TRUE(memcmp(&expectedTTCallbacks, &mockMngr->translationTableCb, sizeof(GMM_TRANSLATIONTABLE_CALLBACKS)) == 0);
EXPECT_TRUE(memcmp(&expectedFlags, &mockMngr->translationTableFlags, sizeof(unsigned int)) == 0);
struct WddmCsrCompressionParameterizedTest : WddmCsrCompressionTests, ::testing::WithParamInterface<bool /*compressionEnabled*/> {
void SetUp() override {
compressionEnabled = GetParam();
}
bool compressionEnabled;
};
HWTEST_P(WddmCsrCompressionParameterizedTest, givenEnabledCompressionWhenInitializedThenCreatePagetableMngr) {
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(hwInfo, executionEnvironment, 0u));
setCompressionEnabled(compressionEnabled, !compressionEnabled);
myMockWddm = static_cast<WddmMock *>(executionEnvironment->osInterface->get()->getWddm());
EXPECT_EQ(nullptr, myMockWddm->getPageTableManager());
MockWddmCsr<FamilyType> mockWddmCsr(hwInfo[0], *executionEnvironment);
mockWddmCsr.createPageTableManager();
ASSERT_NE(nullptr, myMockWddm->getPageTableManager());
auto mockMngr = reinterpret_cast<MockGmmPageTableMngr *>(myMockWddm->getPageTableManager());
GMM_DEVICE_CALLBACKS_INT expectedDeviceCb = {};
GMM_TRANSLATIONTABLE_CALLBACKS expectedTTCallbacks = {};
unsigned int expectedFlags = (TT_TYPE::TRTT | TT_TYPE::AUXTT);
auto myGdi = myMockWddm->getGdi();
// clang-format off
expectedDeviceCb.Adapter.KmtHandle = myMockWddm->getAdapter();
expectedDeviceCb.hDevice.KmtHandle = myMockWddm->getDevice();
expectedDeviceCb.hCsr = &mockWddmCsr;
expectedDeviceCb.PagingQueue = myMockWddm->getPagingQueue();
expectedDeviceCb.PagingFence = myMockWddm->getPagingQueueSyncObject();
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnAllocate = myGdi->createAllocation;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnDeallocate = myGdi->destroyAllocation;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnMapGPUVA = myGdi->mapGpuVirtualAddress;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnMakeResident = myGdi->makeResident;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnEvict = myGdi->evict;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnReserveGPUVA = myGdi->reserveGpuVirtualAddress;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnUpdateGPUVA = myGdi->updateGpuVirtualAddress;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnWaitFromCpu = myGdi->waitForSynchronizationObjectFromCpu;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnLock = myGdi->lock2;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnUnLock = myGdi->unlock2;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnEscape = myGdi->escape;
expectedDeviceCb.DevCbPtrs.KmtCbPtrs.pfnNotifyAubCapture = DeviceCallbacks<FamilyType>::notifyAubCapture;
expectedTTCallbacks.pfWriteL3Adr = TTCallbacks<FamilyType>::writeL3Address;
// clang-format on
EXPECT_TRUE(memcmp(&expectedDeviceCb, &mockMngr->deviceCb, sizeof(GMM_DEVICE_CALLBACKS_INT)) == 0);
EXPECT_TRUE(memcmp(&expectedDeviceCb.Adapter, &mockMngr->deviceCb.Adapter, sizeof(GMM_HANDLE_EXT)) == 0);
EXPECT_TRUE(memcmp(&expectedDeviceCb.hDevice, &mockMngr->deviceCb.hDevice, sizeof(GMM_HANDLE_EXT)) == 0);
EXPECT_TRUE(memcmp(&expectedDeviceCb.DevCbPtrs.KmtCbPtrs, &mockMngr->deviceCb.DevCbPtrs.KmtCbPtrs, sizeof(GMM_DEVICE_CB_PTRS::KmtCbPtrs)) == 0);
EXPECT_TRUE(memcmp(&expectedTTCallbacks, &mockMngr->translationTableCb, sizeof(GMM_TRANSLATIONTABLE_CALLBACKS)) == 0);
EXPECT_TRUE(memcmp(&expectedFlags, &mockMngr->translationTableFlags, sizeof(unsigned int)) == 0);
}
HWTEST_F(WddmCsrCompressionTests, givenDisabledCompressionWhenInitializedThenDontCreatePagetableMngr) {
@@ -878,50 +884,52 @@ HWTEST_F(WddmCsrCompressionTests, givenDisabledCompressionWhenInitializedThenDon
EXPECT_EQ(nullptr, myMockWddm->getPageTableManager());
}
HWTEST_F(WddmCsrCompressionTests, givenEnabledCompressionWhenFlushingThenInitTranslationTableOnce) {
bool compressionEnabled[2][2] = {{true, false}, {false, true}};
for (size_t i = 0; i < 2; i++) {
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
setCompressionEnabled(compressionEnabled[i][0], compressionEnabled[i][1]);
myMockWddm = static_cast<WddmMock *>(executionEnvironment->osInterface->get()->getWddm());
auto mockWddmCsr = new MockWddmCsr<FamilyType>(hwInfo[0], *executionEnvironment);
mockWddmCsr->createPageTableManager();
mockWddmCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch);
executionEnvironment->memoryManager.reset(new WddmMemoryManager(false, false, executionEnvironment->osInterface->get()->getWddm(), *executionEnvironment));
HWTEST_P(WddmCsrCompressionParameterizedTest, givenEnabledCompressionWhenFlushingThenInitTranslationTableOnce) {
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
setCompressionEnabled(compressionEnabled, !compressionEnabled);
myMockWddm = static_cast<WddmMock *>(executionEnvironment->osInterface->get()->getWddm());
auto mockWddmCsr = new MockWddmCsr<FamilyType>(hwInfo[0], *executionEnvironment);
mockWddmCsr->createPageTableManager();
mockWddmCsr->overrideDispatchPolicy(DispatchMode::BatchedDispatch);
executionEnvironment->memoryManager.reset(new WddmMemoryManager(false, false, executionEnvironment->osInterface->get()->getWddm(), *executionEnvironment));
auto mockMngr = reinterpret_cast<MockGmmPageTableMngr *>(myMockWddm->getPageTableManager());
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(hwInfo, executionEnvironment, 0u));
device->resetCommandStreamReceiver(mockWddmCsr);
auto mockMngr = reinterpret_cast<MockGmmPageTableMngr *>(myMockWddm->getPageTableManager());
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(hwInfo, executionEnvironment, 0u));
device->resetCommandStreamReceiver(mockWddmCsr);
auto memoryManager = executionEnvironment->memoryManager.get();
auto memoryManager = executionEnvironment->memoryManager.get();
mockWddmCsr->getCS();
mockWddmCsr->getCS();
auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
IndirectHeap cs(graphicsAllocation);
auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
IndirectHeap cs(graphicsAllocation);
EXPECT_FALSE(mockWddmCsr->pageTableManagerInitialized);
EXPECT_FALSE(mockWddmCsr->pageTableManagerInitialized);
EXPECT_CALL(*mockMngr, initContextAuxTableRegister(mockWddmCsr, GMM_ENGINE_TYPE::ENGINE_TYPE_RCS))
.Times(1)
.WillOnce(Return(GMM_SUCCESS));
EXPECT_CALL(*mockMngr, initContextTRTableRegister(mockWddmCsr, GMM_ENGINE_TYPE::ENGINE_TYPE_RCS))
.Times(1)
.WillOnce(Return(GMM_SUCCESS));
EXPECT_CALL(*mockMngr, initContextAuxTableRegister(mockWddmCsr, GMM_ENGINE_TYPE::ENGINE_TYPE_RCS))
.Times(1)
.WillOnce(Return(GMM_SUCCESS));
EXPECT_CALL(*mockMngr, initContextTRTableRegister(mockWddmCsr, GMM_ENGINE_TYPE::ENGINE_TYPE_RCS))
.Times(1)
.WillOnce(Return(GMM_SUCCESS));
DispatchFlags dispatchFlags;
mockWddmCsr->flushTask(cs, 0u, cs, cs, cs, 0u, dispatchFlags, *device);
DispatchFlags dispatchFlags;
mockWddmCsr->flushTask(cs, 0u, cs, cs, cs, 0u, dispatchFlags, *device);
EXPECT_TRUE(mockWddmCsr->pageTableManagerInitialized);
EXPECT_TRUE(mockWddmCsr->pageTableManagerInitialized);
// flush again to check if PT manager was initialized once
mockWddmCsr->flushTask(cs, 0u, cs, cs, cs, 0u, dispatchFlags, *device);
// flush again to check if PT manager was initialized once
mockWddmCsr->flushTask(cs, 0u, cs, cs, cs, 0u, dispatchFlags, *device);
mockWddmCsr->flushBatchedSubmissions();
memoryManager->freeGraphicsMemory(graphicsAllocation);
}
mockWddmCsr->flushBatchedSubmissions();
memoryManager->freeGraphicsMemory(graphicsAllocation);
}
INSTANTIATE_TEST_CASE_P(
WddmCsrCompressionParameterizedTestCreate,
WddmCsrCompressionParameterizedTest,
::testing::Bool());
HWTEST_F(WddmCsrCompressionTests, givenDisabledCompressionWhenFlushingThenDontInitTranslationTable) {
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo);
setCompressionEnabled(false, false);

View File

@@ -170,7 +170,7 @@ TEST_F(Wddm20Tests, whenInitializeWddmThenContextIsCreated) {
}
TEST_F(Wddm20Tests, allocation) {
OsAgnosticMemoryManager mm(false, false, executionEnvironment);
OsAgnosticMemoryManager mm(false, false, *executionEnvironment);
WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, mm.allocateSystemMemory(100, 0), 100, nullptr, MemoryPool::MemoryNull, false);
Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize());
@@ -334,7 +334,7 @@ TEST_F(Wddm20WithMockGdiDllTests, GivenThreeOsHandlesWhenAskedForDestroyAllocati
}
TEST_F(Wddm20Tests, mapAndFreeGpuVa) {
OsAgnosticMemoryManager mm(false, false, executionEnvironment);
OsAgnosticMemoryManager mm(false, false, *executionEnvironment);
WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, mm.allocateSystemMemory(100, 0), 100, nullptr, MemoryPool::MemoryNull, false);
Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize());
@@ -359,7 +359,7 @@ TEST_F(Wddm20Tests, mapAndFreeGpuVa) {
}
TEST_F(Wddm20Tests, givenNullAllocationWhenCreateThenAllocateAndMap) {
OsAgnosticMemoryManager mm(false, false, executionEnvironment);
OsAgnosticMemoryManager mm(false, false, *executionEnvironment);
WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, nullptr, 100, nullptr, MemoryPool::MemoryNull, false);
Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize());
@@ -379,7 +379,7 @@ TEST_F(Wddm20Tests, givenNullAllocationWhenCreateThenAllocateAndMap) {
}
TEST_F(Wddm20Tests, makeResidentNonResident) {
OsAgnosticMemoryManager mm(false, false, executionEnvironment);
OsAgnosticMemoryManager mm(false, false, *executionEnvironment);
WddmAllocation allocation(GraphicsAllocation::AllocationType::UNDECIDED, mm.allocateSystemMemory(100, 0), 100, nullptr, MemoryPool::MemoryNull, false);
Gmm *gmm = GmmHelperFunctions::getGmm(allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize());
@@ -418,7 +418,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationF
auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
EXPECT_EQ(0u, status);
WddmMemoryManager mm(false, false, wddm, executionEnvironment);
WddmMemoryManager mm(false, false, wddm, *executionEnvironment);
auto graphicsAllocation = mm.createGraphicsAllocationFromSharedHandle(ALLOCATION_HANDLE, false);
auto wddmAllocation = (WddmAllocation *)graphicsAllocation;
@@ -454,7 +454,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationF
auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u);
EXPECT_EQ(0u, status);
WddmMemoryManager mm(false, false, wddm, executionEnvironment);
WddmMemoryManager mm(false, false, wddm, *executionEnvironment);
auto graphicsAllocation = mm.createGraphicsAllocationFromSharedHandle(ALLOCATION_HANDLE, false);
auto wddmAllocation = (WddmAllocation *)graphicsAllocation;
@@ -482,8 +482,6 @@ HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceOnInit) {
D3DKMT_HANDLE adapterHandle = ADAPTER_HANDLE;
D3DKMT_HANDLE deviceHandle = DEVICE_HANDLE;
const HardwareInfo hwInfo = *platformDevices[0];
ExecutionEnvironment executionEnvironment;
executionEnvironment.initGmm(&hwInfo);
BOOLEAN FtrL3IACoherency = hwInfo.pSkuTable->ftrL3IACoherency ? 1 : 0;
uintptr_t maxAddr = hwInfo.capabilityTable.gpuAddressSpace == MemoryConstants::max48BitAddress
? reinterpret_cast<uintptr_t>(sysInfo.lpMaximumApplicationAddress) + 1
@@ -502,8 +500,6 @@ HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceOnInit) {
TEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoAdapter) {
wddm->adapter = static_cast<D3DKMT_HANDLE>(0);
ExecutionEnvironment executionEnvironment;
executionEnvironment.initGmm(*platformDevices);
EXPECT_CALL(*gmmMem,
configureDeviceAddressSpace(static_cast<D3DKMT_HANDLE>(0), ::testing::_, ::testing::_, ::testing::_, ::testing::_))
.Times(0);
@@ -514,8 +510,6 @@ TEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoAdapter) {
TEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoDevice) {
wddm->device = static_cast<D3DKMT_HANDLE>(0);
ExecutionEnvironment executionEnvironment;
executionEnvironment.initGmm(*platformDevices);
EXPECT_CALL(*gmmMem,
configureDeviceAddressSpace(::testing::_, static_cast<D3DKMT_HANDLE>(0), ::testing::_, ::testing::_, ::testing::_))
.Times(0);
@@ -526,8 +520,6 @@ TEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoDevice) {
TEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoEscFunc) {
wddm->gdi->escape = static_cast<PFND3DKMT_ESCAPE>(nullptr);
ExecutionEnvironment executionEnvironment;
executionEnvironment.initGmm(*platformDevices);
EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(::testing::_, ::testing::_, static_cast<PFND3DKMT_ESCAPE>(nullptr), ::testing::_,
::testing::_))
.Times(0);
@@ -590,7 +582,6 @@ TEST(DebugFlagTest, givenDebugManagerWhenGetForUseNoRingFlushesKmdModeIsCalledTh
}
TEST_F(Wddm20Tests, makeResidentMultipleHandles) {
D3DKMT_HANDLE handles[2] = {ALLOCATION_HANDLE, ALLOCATION_HANDLE};
gdi->getMakeResidentArg().NumAllocations = 0;
gdi->getMakeResidentArg().AllocationList = nullptr;
@@ -979,7 +970,7 @@ TEST_F(WddmLockWithMakeResidentTests, whenEvictingTemporaryResourceThenOtherReso
}
TEST_F(WddmLockWithMakeResidentTests, whenAlllocationNeedsBlockingMakeResidentBeforeLockThenLockWithBlockingMakeResident) {
WddmMemoryManager memoryManager(false, false, wddm, executionEnvironment);
WddmMemoryManager memoryManager(false, false, wddm, *executionEnvironment);
MockWddmAllocation allocation;
allocation.needsMakeResidentBeforeLock = false;
memoryManager.lockResource(&allocation);

View File

@@ -11,8 +11,8 @@
#include "runtime/os_interface/windows/gdi_interface.h"
#include "runtime/os_interface/windows/os_context_win.h"
#include "runtime/os_interface/windows/os_interface.h"
#include "runtime/platform/platform.h"
#include "test.h"
#include "unit_tests/fixtures/gmm_environment_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "unit_tests/mocks/mock_wddm.h"
#include "unit_tests/mocks/mock_wddm_interface23.h"
@@ -20,11 +20,11 @@
using namespace OCLRT;
struct Wddm23TestsWithoutWddmInit : public ::testing::Test, GdiDllFixture, public GmmEnvironmentFixture {
struct Wddm23TestsWithoutWddmInit : public ::testing::Test, GdiDllFixture {
void SetUp() override {
GmmEnvironmentFixture::SetUp();
GdiDllFixture::SetUp();
executionEnvironment = platformImpl->peekExecutionEnvironment();
wddm = static_cast<WddmMock *>(Wddm::createWddm());
osInterface = std::make_unique<OSInterface>();
osInterface->get()->setWddm(wddm);
@@ -43,13 +43,13 @@ struct Wddm23TestsWithoutWddmInit : public ::testing::Test, GdiDllFixture, publi
void TearDown() override {
GdiDllFixture::TearDown();
GmmEnvironmentFixture::TearDown();
}
std::unique_ptr<OSInterface> osInterface;
std::unique_ptr<OsContextWin> osContext;
WddmMock *wddm = nullptr;
WddmMockInterface23 *wddmMockInterface = nullptr;
ExecutionEnvironment *executionEnvironment;
};
struct Wddm23Tests : public Wddm23TestsWithoutWddmInit {

View File

@@ -6,8 +6,8 @@
*/
#include "runtime/command_stream/preemption.h"
#include "runtime/helpers/options.h"
#include "test.h"
#include "unit_tests/fixtures/gmm_environment_fixture.h"
#include "unit_tests/mocks/mock_wddm.h"
using namespace OCLRT;
@@ -54,9 +54,7 @@ class WddmMockReserveAddress : public WddmMock {
uint32_t returnNullIter = 0;
};
using WddmReserveAddressTest = Test<GmmEnvironmentFixture>;
TEST_F(WddmReserveAddressTest, givenWddmWhenFirstIsSuccessfulThenReturnReserveAddress) {
TEST(WddmReserveAddressTest, givenWddmWhenFirstIsSuccessfulThenReturnReserveAddress) {
std::unique_ptr<WddmMockReserveAddress> wddm(new WddmMockReserveAddress());
size_t size = 0x1000;
void *reserve = nullptr;
@@ -73,7 +71,7 @@ TEST_F(WddmReserveAddressTest, givenWddmWhenFirstIsSuccessfulThenReturnReserveAd
wddm->releaseReservedAddress(reserve);
}
TEST_F(WddmReserveAddressTest, givenWddmWhenFirstIsNullThenReturnNull) {
TEST(WddmReserveAddressTest, givenWddmWhenFirstIsNullThenReturnNull) {
std::unique_ptr<WddmMockReserveAddress> wddm(new WddmMockReserveAddress());
size_t size = 0x1000;
void *reserve = nullptr;
@@ -86,7 +84,7 @@ TEST_F(WddmReserveAddressTest, givenWddmWhenFirstIsNullThenReturnNull) {
EXPECT_EQ(expectedReserve, reinterpret_cast<uintptr_t>(reserve));
}
TEST_F(WddmReserveAddressTest, givenWddmWhenFirstIsInvalidSecondSuccessfulThenReturnSecond) {
TEST(WddmReserveAddressTest, givenWddmWhenFirstIsInvalidSecondSuccessfulThenReturnSecond) {
std::unique_ptr<WddmMockReserveAddress> wddm(new WddmMockReserveAddress());
size_t size = 0x1000;
void *reserve = nullptr;
@@ -103,7 +101,7 @@ TEST_F(WddmReserveAddressTest, givenWddmWhenFirstIsInvalidSecondSuccessfulThenRe
wddm->releaseReservedAddress(reserve);
}
TEST_F(WddmReserveAddressTest, givenWddmWhenSecondIsInvalidThirdSuccessfulThenReturnThird) {
TEST(WddmReserveAddressTest, givenWddmWhenSecondIsInvalidThirdSuccessfulThenReturnThird) {
std::unique_ptr<WddmMockReserveAddress> wddm(new WddmMockReserveAddress());
size_t size = 0x1000;
void *reserve = nullptr;
@@ -120,7 +118,7 @@ TEST_F(WddmReserveAddressTest, givenWddmWhenSecondIsInvalidThirdSuccessfulThenRe
wddm->releaseReservedAddress(reserve);
}
TEST_F(WddmReserveAddressTest, givenWddmWhenFirstIsInvalidSecondNullThenReturnSecondNull) {
TEST(WddmReserveAddressTest, givenWddmWhenFirstIsInvalidSecondNullThenReturnSecondNull) {
std::unique_ptr<WddmMockReserveAddress> wddm(new WddmMockReserveAddress());
size_t size = 0x1000;
void *reserve = nullptr;

View File

@@ -12,8 +12,8 @@
#include "runtime/os_interface/windows/gdi_interface.h"
#include "runtime/os_interface/windows/os_context_win.h"
#include "runtime/os_interface/windows/os_interface.h"
#include "runtime/platform/platform.h"
#include "test.h"
#include "unit_tests/fixtures/gmm_environment_fixture.h"
#include "unit_tests/mocks/mock_wddm.h"
#include "unit_tests/os_interface/windows/gdi_dll_fixture.h"
#include "unit_tests/os_interface/windows/mock_gdi_interface.h"
@@ -21,9 +21,9 @@
#include "mock_gmm_memory.h"
namespace OCLRT {
struct WddmFixture : public GmmEnvironmentFixture {
void SetUp() override {
GmmEnvironmentFixture::SetUp();
struct WddmFixture : ::testing::Test {
void SetUp() {
executionEnvironment = platformImpl->peekExecutionEnvironment();
wddm = static_cast<WddmMock *>(Wddm::createWddm());
osInterface = std::make_unique<OSInterface>();
osInterface->get()->setWddm(wddm);
@@ -35,20 +35,17 @@ struct WddmFixture : public GmmEnvironmentFixture {
ASSERT_TRUE(wddm->isInitialized());
}
void TearDown() override {
GmmEnvironmentFixture::TearDown();
};
WddmMock *wddm = nullptr;
std::unique_ptr<OSInterface> osInterface;
std::unique_ptr<OsContextWin> osContext;
ExecutionEnvironment *executionEnvironment;
MockGdi *gdi = nullptr;
};
struct WddmFixtureWithMockGdiDll : public GmmEnvironmentFixture, public GdiDllFixture {
struct WddmFixtureWithMockGdiDll : public GdiDllFixture {
void SetUp() override {
GmmEnvironmentFixture::SetUp();
executionEnvironment = platformImpl->peekExecutionEnvironment();
GdiDllFixture::SetUp();
wddm = static_cast<WddmMock *>(Wddm::createWddm());
osInterface = std::make_unique<OSInterface>();
@@ -64,30 +61,30 @@ struct WddmFixtureWithMockGdiDll : public GmmEnvironmentFixture, public GdiDllFi
void TearDown() override {
GdiDllFixture::TearDown();
GmmEnvironmentFixture::TearDown();
}
WddmMock *wddm = nullptr;
std::unique_ptr<OSInterface> osInterface;
std::unique_ptr<OsContextWin> osContext;
ExecutionEnvironment *executionEnvironment;
};
struct WddmInstrumentationGmmFixture : public GmmEnvironmentFixture {
void SetUp() override {
GmmEnvironmentFixture::SetUp();
struct WddmInstrumentationGmmFixture {
void SetUp() {
executionEnvironment = platformImpl->peekExecutionEnvironment();
wddm.reset(static_cast<WddmMock *>(Wddm::createWddm()));
gmmMem = new ::testing::NiceMock<GmockGmmMemory>();
wddm->gmmMemory.reset(gmmMem);
}
void TearDown() override {
GmmEnvironmentFixture::TearDown();
void TearDown() {
}
std::unique_ptr<WddmMock> wddm;
GmockGmmMemory *gmmMem = nullptr;
ExecutionEnvironment *executionEnvironment;
};
using WddmTest = Test<WddmFixture>;
using WddmTest = WddmFixture;
using WddmTestWithMockGdiDll = Test<WddmFixtureWithMockGdiDll>;
using WddmInstrumentationTest = Test<WddmInstrumentationGmmFixture>;
using WddmTestSingle = ::testing::Test;

View File

@@ -11,8 +11,8 @@
#include "runtime/memory_manager/memory_manager.h"
#include "runtime/os_interface/windows/wddm/wddm.h"
#include "runtime/os_interface/windows/wddm_allocation.h"
#include "runtime/platform/platform.h"
#include "test.h"
#include "unit_tests/fixtures/gmm_environment_fixture.h"
#include "unit_tests/mock_gdi/mock_gdi.h"
#include "unit_tests/os_interface/windows/mock_gdi_interface.h"
#include "unit_tests/os_interface/windows/mock_kmdaf_listener.h"
@@ -35,20 +35,20 @@ class WddmWithKmDafMock : public Wddm {
}
};
class WddmKmDafListenerTest : public GmmEnvironmentFixture, public ::testing::Test {
class WddmKmDafListenerTest : public ::testing::Test {
public:
void SetUp() {
GmmEnvironmentFixture::SetUp();
executionEnvironment = platformImpl->peekExecutionEnvironment();
wddmWithKmDafMock.reset(new WddmWithKmDafMock());
wddmWithKmDafMock->gdi.reset(new MockGdi());
wddmWithKmDafMock->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
wddmWithKmDafMock->featureTable->ftrKmdDaf = true;
}
void TearDown() {
GmmEnvironmentFixture::TearDown();
}
std::unique_ptr<WddmWithKmDafMock> wddmWithKmDafMock;
ExecutionEnvironment *executionEnvironment;
};
TEST_F(WddmKmDafListenerTest, givenWddmWhenLockResourceIsCalledThenKmDafListenerNotifyLockIsFedWithCorrectParams) {

View File

@@ -14,7 +14,7 @@ using namespace OCLRT;
using namespace ::testing;
TEST_F(WddmMemoryManagerSimpleTest, givenUseSystemMemorySetToTrueWhenAllocateInDevicePoolIsCalledThenNullptrIsReturned) {
memoryManager.reset(new MockWddmMemoryManager(false, false, wddm, executionEnvironment));
memoryManager.reset(new MockWddmMemoryManager(false, false, wddm, *executionEnvironment));
MemoryManager::AllocationStatus status = MemoryManager::AllocationStatus::Success;
AllocationData allocData;
allocData.size = MemoryConstants::pageSize;

View File

@@ -30,7 +30,6 @@ using namespace OCLRT;
using namespace ::testing;
void WddmMemoryManagerFixture::SetUp() {
GmmEnvironmentFixture::SetUp();
GdiDllFixture::SetUp();
wddm = static_cast<WddmMock *>(Wddm::createWddm());
@@ -43,10 +42,11 @@ void WddmMemoryManagerFixture::SetUp() {
constexpr uint64_t heap32Base = (is32bit) ? 0x1000 : 0x800000000000;
wddm->setHeap32(heap32Base, 1000 * MemoryConstants::pageSize - 1);
executionEnvironment.osInterface = std::make_unique<OSInterface>();
executionEnvironment.osInterface->get()->setWddm(wddm);
executionEnvironment = platformImpl->peekExecutionEnvironment();
executionEnvironment->osInterface = std::make_unique<OSInterface>();
executionEnvironment->osInterface->get()->setWddm(wddm);
memoryManager = std::make_unique<MockWddmMemoryManager>(wddm, executionEnvironment);
memoryManager = std::make_unique<MockWddmMemoryManager>(wddm, *executionEnvironment);
}
TEST(ResidencyData, givenNewlyConstructedResidencyDataThenItIsNotResidentOnAnyOsContext) {
@@ -132,7 +132,7 @@ TEST(WddmMemoryManagerWithDeferredDeleterTest, givenWMMWhenAsyncDeleterIsEnabled
}
TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenAllocateGraphicsMemoryIsCalledThenMemoryPoolIsSystem4KBPages) {
memoryManager.reset(new MockWddmMemoryManager(false, false, wddm, executionEnvironment));
memoryManager.reset(new MockWddmMemoryManager(false, false, wddm, *executionEnvironment));
auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
EXPECT_NE(nullptr, allocation);
@@ -142,7 +142,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenAllocateGraphicsMemory
}
TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWith64KBPagesEnabledWhenAllocateGraphicsMemory64kbIsCalledThenMemoryPoolIsSystem64KBPages) {
memoryManager.reset(new MockWddmMemoryManager(false, false, wddm, executionEnvironment));
memoryManager.reset(new MockWddmMemoryManager(false, false, wddm, *executionEnvironment));
AllocationData allocationData;
allocationData.size = 4096u;
auto allocation = memoryManager->allocateGraphicsMemory64kb(allocationData);
@@ -153,7 +153,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWith64KBPagesEnabledWhenAl
}
TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenAllocateGraphicsMemoryWithPtrIsCalledThenMemoryPoolIsSystem4KBPages) {
memoryManager.reset(new MockWddmMemoryManager(false, false, wddm, executionEnvironment));
memoryManager.reset(new MockWddmMemoryManager(false, false, wddm, *executionEnvironment));
void *ptr = reinterpret_cast<void *>(0x1001);
auto size = 4096u;
auto allocation = memoryManager->allocateGraphicsMemory(MockAllocationProperties{false, size}, ptr);
@@ -166,7 +166,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenAllocateGraphicsMemory
}
TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenAllocate32BitGraphicsMemoryWithPtrIsCalledThenMemoryPoolIsSystem4KBPagesWith32BitGpuAddressing) {
memoryManager.reset(new MockWddmMemoryManager(false, false, wddm, executionEnvironment));
memoryManager.reset(new MockWddmMemoryManager(false, false, wddm, *executionEnvironment));
void *ptr = reinterpret_cast<void *>(0x1001);
auto size = MemoryConstants::pageSize;
@@ -180,7 +180,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenAllocate32BitGraphicsM
}
TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWith64KBPagesDisabledWhenAllocateGraphicsMemoryForSVMThen4KBGraphicsAllocationIsReturned) {
memoryManager.reset(new MockWddmMemoryManager(false, false, wddm, executionEnvironment));
memoryManager.reset(new MockWddmMemoryManager(false, false, wddm, *executionEnvironment));
auto size = MemoryConstants::pageSize;
auto svmAllocation = memoryManager->allocateGraphicsMemoryWithProperties({size, GraphicsAllocation::AllocationType::SVM});
@@ -191,7 +191,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWith64KBPagesDisabledWhenA
}
TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWith64KBPagesEnabledWhenAllocateGraphicsMemoryForSVMThenMemoryPoolIsSystem64KBPages) {
memoryManager.reset(new MockWddmMemoryManager(true, false, wddm, executionEnvironment));
memoryManager.reset(new MockWddmMemoryManager(true, false, wddm, *executionEnvironment));
auto size = MemoryConstants::pageSize;
auto svmAllocation = memoryManager->allocateGraphicsMemoryWithProperties({size, GraphicsAllocation::AllocationType::SVM});
@@ -201,7 +201,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWith64KBPagesEnabledWhenAl
}
TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenCreateAllocationFromHandleIsCalledThenMemoryPoolIsSystemCpuInaccessible) {
memoryManager.reset(new MockWddmMemoryManager(false, false, wddm, executionEnvironment));
memoryManager.reset(new MockWddmMemoryManager(false, false, wddm, *executionEnvironment));
auto osHandle = 1u;
gdi->getQueryResourceInfoArgOut().NumAllocations = 1;
std::unique_ptr<Gmm> gmm(new Gmm(nullptr, 0, false));
@@ -221,7 +221,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenCreateAllocationFromHa
TEST_F(WddmMemoryManagerSimpleTest,
givenAllocateGraphicsMemoryForNonSvmHostPtrIsCalledWhenNotAlignedPtrIsPassedThenAlignedGraphicsAllocationIsCreated) {
memoryManager.reset(new MockWddmMemoryManager(false, false, wddm, executionEnvironment));
memoryManager.reset(new MockWddmMemoryManager(false, false, wddm, *executionEnvironment));
void *hostPtr = reinterpret_cast<void *>(0x5001);
auto allocation = memoryManager->allocateGraphicsMemoryForNonSvmHostPtr(13, hostPtr);
@@ -584,8 +584,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenTiledImageWithMipCountNo
}
TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenTiledImageIsBeingCreatedFromHostPtrThenallocateGraphicsMemoryForImageIsUsed) {
executionEnvironment.incRefInternal(); // to prevent destrorying execution environment by destructor of device
std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(*platformDevices, &executionEnvironment, 0u));
std::unique_ptr<Device> device(MockDevice::createWithExecutionEnvironment<MockDevice>(*platformDevices, executionEnvironment, 0u));
MockContext context(device.get());
context.setMemoryManager(memoryManager.get());
@@ -1252,7 +1251,7 @@ TEST_F(MockWddmMemoryManagerTest, givenEnabled64kbpagesWhenCreatingGraphicsMemor
auto wddm = std::make_unique<WddmMock>();
EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
DebugManager.flags.Enable64kbpages.set(true);
WddmMemoryManager memoryManager64k(true, false, wddm.get(), executionEnvironment);
WddmMemoryManager memoryManager64k(true, false, wddm.get(), *executionEnvironment);
EXPECT_EQ(0, wddm->createAllocationResult.called);
GraphicsAllocation *galloc = memoryManager64k.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize64k, GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY});
@@ -1270,7 +1269,7 @@ TEST_F(OsAgnosticMemoryManagerUsingWddmTest, givenEnabled64kbPagesWhenAllocation
auto wddm = std::make_unique<WddmMock>();
EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
DebugManager.flags.Enable64kbpages.set(true);
MockWddmMemoryManager memoryManager(true, false, wddm.get(), executionEnvironment);
MockWddmMemoryManager memoryManager(true, false, wddm.get(), *executionEnvironment);
AllocationData allocationData;
allocationData.size = 1u;
auto graphicsAllocation = memoryManager.allocateGraphicsMemory64kb(allocationData);
@@ -1304,7 +1303,7 @@ TEST_F(MockWddmMemoryManagerTest, givenWddmWhenallocateGraphicsMemory64kbThenLoc
TEST_F(MockWddmMemoryManagerTest, givenDefaultMemoryManagerWhenItIsCreatedThenAsyncDeleterEnabledIsTrue) {
auto wddm = std::make_unique<WddmMock>();
WddmMemoryManager memoryManager(false, false, wddm.get(), executionEnvironment);
WddmMemoryManager memoryManager(false, false, wddm.get(), *executionEnvironment);
EXPECT_TRUE(memoryManager.isAsyncDeleterEnabled());
EXPECT_NE(nullptr, memoryManager.getDeferredDeleter());
}
@@ -1333,7 +1332,7 @@ TEST_F(MockWddmMemoryManagerTest, givenEnabledAsyncDeleterFlagWhenMemoryManagerI
bool defaultEnableDeferredDeleterFlag = DebugManager.flags.EnableDeferredDeleter.get();
DebugManager.flags.EnableDeferredDeleter.set(true);
auto wddm = std::make_unique<WddmMock>();
WddmMemoryManager memoryManager(false, false, wddm.get(), executionEnvironment);
WddmMemoryManager memoryManager(false, false, wddm.get(), *executionEnvironment);
EXPECT_TRUE(memoryManager.isAsyncDeleterEnabled());
EXPECT_NE(nullptr, memoryManager.getDeferredDeleter());
DebugManager.flags.EnableDeferredDeleter.set(defaultEnableDeferredDeleterFlag);
@@ -1343,7 +1342,7 @@ TEST_F(MockWddmMemoryManagerTest, givenDisabledAsyncDeleterFlagWhenMemoryManager
bool defaultEnableDeferredDeleterFlag = DebugManager.flags.EnableDeferredDeleter.get();
DebugManager.flags.EnableDeferredDeleter.set(false);
auto wddm = std::make_unique<WddmMock>();
WddmMemoryManager memoryManager(false, false, wddm.get(), executionEnvironment);
WddmMemoryManager memoryManager(false, false, wddm.get(), *executionEnvironment);
EXPECT_FALSE(memoryManager.isAsyncDeleterEnabled());
EXPECT_EQ(nullptr, memoryManager.getDeferredDeleter());
DebugManager.flags.EnableDeferredDeleter.set(defaultEnableDeferredDeleterFlag);
@@ -1352,7 +1351,7 @@ TEST_F(MockWddmMemoryManagerTest, givenDisabledAsyncDeleterFlagWhenMemoryManager
TEST_F(MockWddmMemoryManagerTest, givenPageTableManagerWhenMapAuxGpuVaCalledThenUseWddmToMap) {
auto myWddm = std::make_unique<WddmMock>();
EXPECT_TRUE(myWddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
WddmMemoryManager memoryManager(false, false, myWddm.get(), executionEnvironment);
WddmMemoryManager memoryManager(false, false, myWddm.get(), *executionEnvironment);
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
myWddm->resetPageTableManager(mockMngr);
@@ -1412,7 +1411,7 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenMappedGpuVa
TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenReleaseingThenUnmapAuxVa) {
auto wddm = std::make_unique<WddmMock>();
EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
WddmMemoryManager memoryManager(false, false, wddm.get(), executionEnvironment);
WddmMemoryManager memoryManager(false, false, wddm.get(), *executionEnvironment);
D3DGPU_VIRTUAL_ADDRESS gpuVa = 123;
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
@@ -1438,7 +1437,7 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenReleaseingT
TEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenReleaseingThenDontUnmapAuxVa) {
auto wddm = std::make_unique<WddmMock>();
EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
WddmMemoryManager memoryManager(false, false, wddm.get(), executionEnvironment);
WddmMemoryManager memoryManager(false, false, wddm.get(), *executionEnvironment);
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
wddm->resetPageTableManager(mockMngr);
@@ -1484,7 +1483,7 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedFlagSetWhenInternalIsUnse
D3DGPU_VIRTUAL_ADDRESS gpuVa = 0;
auto wddm = std::make_unique<WddmMock>();
EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
WddmMemoryManager memoryManager(false, false, wddm.get(), executionEnvironment);
WddmMemoryManager memoryManager(false, false, wddm.get(), *executionEnvironment);
auto mockMngr = new NiceMock<MockGmmPageTableMngr>();
wddm->resetPageTableManager(mockMngr);

View File

@@ -9,7 +9,6 @@
#include "runtime/os_interface/windows/os_interface.h"
#include "test.h"
#include "unit_tests/fixtures/gmm_environment_fixture.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_gmm.h"
#include "unit_tests/mocks/mock_gmm_page_table_mngr.h"
@@ -25,26 +24,25 @@
using namespace OCLRT;
using namespace ::testing;
class WddmMemoryManagerFixture : public GmmEnvironmentFixture, public GdiDllFixture {
class WddmMemoryManagerFixture : public GdiDllFixture {
public:
void SetUp() override;
void TearDown() override {
GdiDllFixture::TearDown();
GmmEnvironmentFixture::TearDown();
}
ExecutionEnvironment *executionEnvironment;
std::unique_ptr<MockWddmMemoryManager> memoryManager;
WddmMock *wddm;
};
typedef ::Test<WddmMemoryManagerFixture> WddmMemoryManagerTest;
class MockWddmMemoryManagerFixture : public GmmEnvironmentFixture {
class MockWddmMemoryManagerFixture {
public:
void SetUp() {
GmmEnvironmentFixture::SetUp();
executionEnvironment = platformImpl->peekExecutionEnvironment();
gdi = new MockGdi();
wddm = static_cast<WddmMock *>(Wddm::createWddm());
@@ -53,10 +51,10 @@ class MockWddmMemoryManagerFixture : public GmmEnvironmentFixture {
wddm->setHeap32(heap32Base, 1000 * MemoryConstants::pageSize - 1);
EXPECT_TRUE(wddm->init(PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0])));
executionEnvironment.osInterface.reset(new OSInterface());
executionEnvironment.osInterface->get()->setWddm(wddm);
executionEnvironment->osInterface.reset(new OSInterface());
executionEnvironment->osInterface->get()->setWddm(wddm);
memoryManager = std::make_unique<MockWddmMemoryManager>(wddm, executionEnvironment);
memoryManager = std::make_unique<MockWddmMemoryManager>(wddm, *executionEnvironment);
osContext = memoryManager->createAndRegisterOsContext(nullptr, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], 1, PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]));
osContext->incRefInternal();
@@ -64,9 +62,9 @@ class MockWddmMemoryManagerFixture : public GmmEnvironmentFixture {
void TearDown() {
osContext->decRefInternal();
GmmEnvironmentFixture::TearDown();
}
ExecutionEnvironment *executionEnvironment;
std::unique_ptr<MockWddmMemoryManager> memoryManager;
WddmMock *wddm = nullptr;
OsContext *osContext = nullptr;
@@ -75,12 +73,20 @@ class MockWddmMemoryManagerFixture : public GmmEnvironmentFixture {
typedef ::Test<MockWddmMemoryManagerFixture> WddmMemoryManagerResidencyTest;
class WddmMemoryManagerFixtureWithGmockWddm : public GmmEnvironmentFixture {
class ExecutionEnvironmentFixture : public ::testing::Test {
public:
ExecutionEnvironmentFixture() {
executionEnvironment = platformImpl->peekExecutionEnvironment();
}
ExecutionEnvironment *executionEnvironment;
};
class WddmMemoryManagerFixtureWithGmockWddm : public ExecutionEnvironmentFixture {
public:
MockWddmMemoryManager *memoryManager = nullptr;
void SetUp() {
GmmEnvironmentFixture::SetUp();
void SetUp() override {
// wddm is deleted by memory manager
wddm = new NiceMock<GmockWddm>;
osInterface = std::make_unique<OSInterface>();
@@ -89,7 +95,7 @@ class WddmMemoryManagerFixtureWithGmockWddm : public GmmEnvironmentFixture {
EXPECT_TRUE(wddm->init(preemptionMode));
osInterface->get()->setWddm(wddm);
wddm->init(preemptionMode);
memoryManager = new (std::nothrow) MockWddmMemoryManager(wddm, executionEnvironment);
memoryManager = new (std::nothrow) MockWddmMemoryManager(wddm, *executionEnvironment);
//assert we have memory manager
ASSERT_NE(nullptr, memoryManager);
osContext = memoryManager->createAndRegisterOsContext(nullptr, HwHelper::get(platformDevices[0]->pPlatform->eRenderCoreFamily).getGpgpuEngineInstances()[0], 1, preemptionMode);
@@ -99,10 +105,9 @@ class WddmMemoryManagerFixtureWithGmockWddm : public GmmEnvironmentFixture {
ON_CALL(*wddm, createAllocationsAndMapGpuVa(::testing::_)).WillByDefault(::testing::Invoke(wddm, &GmockWddm::baseCreateAllocationAndMapGpuVa));
}
void TearDown() {
void TearDown() override {
osContext->decRefInternal();
delete memoryManager;
GmmEnvironmentFixture::TearDown();
}
NiceMock<GmockWddm> *wddm = nullptr;
@@ -110,7 +115,7 @@ class WddmMemoryManagerFixtureWithGmockWddm : public GmmEnvironmentFixture {
OsContext *osContext;
};
typedef ::Test<WddmMemoryManagerFixtureWithGmockWddm> WddmMemoryManagerTest2;
using WddmMemoryManagerTest2 = WddmMemoryManagerFixtureWithGmockWddm;
class BufferWithWddmMemory : public ::testing::Test,
public WddmMemoryManagerFixture {
@@ -145,5 +150,5 @@ class WddmMemoryManagerSimpleTest : public MockWddmMemoryManagerFixture, public
}
};
using MockWddmMemoryManagerTest = ::Test<GmmEnvironmentFixture>;
using MockWddmMemoryManagerTest = ExecutionEnvironmentFixture;
using OsAgnosticMemoryManagerUsingWddmTest = MockWddmMemoryManagerTest;

View File

@@ -14,6 +14,7 @@
#include "runtime/os_interface/windows/os_interface.h"
#include "runtime/os_interface/windows/wddm/wddm_interface.h"
#include "runtime/os_interface/windows/wddm_residency_controller.h"
#include "runtime/platform/platform.h"
#include "test.h"
#include "unit_tests/mocks/mock_allocation_properties.h"
#include "unit_tests/mocks/mock_wddm.h"
@@ -80,8 +81,7 @@ struct WddmResidencyControllerWithGdiTest : ::testing::Test {
struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerTest {
void SetUp() {
executionEnvironment = std::make_unique<ExecutionEnvironment>();
executionEnvironment->initGmm(*platformDevices);
executionEnvironment = platformImpl->peekExecutionEnvironment();
wddm = new ::testing::NiceMock<GmockWddm>();
wddm->gdi = std::make_unique<MockGdi>();
@@ -102,7 +102,7 @@ struct WddmResidencyControllerWithMockWddmTest : public WddmResidencyControllerT
osContext->decRefInternal();
}
std::unique_ptr<ExecutionEnvironment> executionEnvironment;
ExecutionEnvironment *executionEnvironment;
std::unique_ptr<MockWddmMemoryManager> memoryManager;
::testing::NiceMock<GmockWddm> *wddm = nullptr;
OsContext *osContext;

View File

@@ -478,11 +478,10 @@ HWTEST_F(MidThreadPreemptionTests, givenMidThreadPreemptionWhenFailingOnCsrSurfa
uint32_t allocateGraphicsMemoryCount = 0;
};
ExecutionEnvironment executionEnvironment;
executionEnvironment.incRefInternal();
executionEnvironment.memoryManager = std::make_unique<FailingMemoryManager>(executionEnvironment);
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
executionEnvironment->memoryManager = std::make_unique<FailingMemoryManager>(*executionEnvironment);
std::unique_ptr<MockDevice> mockDevice(MockDevice::create<MockDevice>(platformDevices[0], &executionEnvironment, 0));
std::unique_ptr<MockDevice> mockDevice(MockDevice::create<MockDevice>(platformDevices[0], executionEnvironment, 0));
EXPECT_EQ(nullptr, mockDevice.get());
}

View File

@@ -9,6 +9,7 @@
#include "runtime/event/user_event.h"
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/os_interface/os_interface.h"
#include "runtime/platform/platform.h"
#include "runtime/sharings/gl/gl_arb_sync_event.h"
#include "runtime/sharings/sharing.h"
#include "test.h"
@@ -63,7 +64,7 @@ struct GlArbSyncEventTest : public ::testing::Test {
}
void SetUp() override {
executionEnvironment = new ExecutionEnvironment;
executionEnvironment = platformImpl->peekExecutionEnvironment();
auto mockCsr = new MockCommandStreamReceiver(*executionEnvironment);
executionEnvironment->memoryManager = std::make_unique<OsAgnosticMemoryManager>(false, false, *executionEnvironment);
device.reset(MockDevice::create<MockDevice>(nullptr, executionEnvironment, 0u));

View File

@@ -6,6 +6,7 @@
*/
#include "runtime/mem_obj/image.h"
#include "runtime/platform/platform.h"
#include "runtime/sharings/gl/gl_texture.h"
#include "unit_tests/libult/create_command_stream.h"
#include "unit_tests/libult/ult_command_stream_receiver.h"
@@ -48,15 +49,15 @@ class GlSharingTextureTests : public ::testing::Test {
};
void SetUp() override {
executionEnvironment.incRefInternal();
executionEnvironment = platformImpl->peekExecutionEnvironment();
imgDesc = {};
imgDesc.image_type = CL_MEM_OBJECT_IMAGE1D;
imgDesc.image_width = 10;
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
tempMM = new TempMM(executionEnvironment);
executionEnvironment.memoryManager.reset(tempMM);
device.reset(MockDevice::create<MockDevice>(*platformDevices, &executionEnvironment, 0));
tempMM = new TempMM(*executionEnvironment);
executionEnvironment->memoryManager.reset(tempMM);
device.reset(MockDevice::create<MockDevice>(*platformDevices, executionEnvironment, 0));
clContext = std::make_unique<MockContext>(device.get());
mockGlSharingFunctions = glSharing->sharingFunctions.release();
@@ -75,7 +76,7 @@ class GlSharingTextureTests : public ::testing::Test {
mockGmmResInfo->setUnifiedAuxTranslationCapable();
}
ExecutionEnvironment executionEnvironment;
ExecutionEnvironment *executionEnvironment;
cl_image_desc imgDesc;
TempMM *tempMM;
std::unique_ptr<MockDevice> device;

View File

@@ -5,6 +5,7 @@
*
*/
#include "runtime/platform/platform.h"
#include "runtime/source_level_debugger/source_level_debugger.h"
#include "test.h"
#include "unit_tests/fixtures/device_fixture.h"
@@ -36,18 +37,18 @@ class MockDeviceWithDebuggerActive : public MockDevice {
};
TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsDestructedThenSourceLevelDebuggerIsNotified) {
auto exeEnv = new ExecutionEnvironment;
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
auto gmock = new ::testing::NiceMock<GMockSourceLevelDebugger>(new MockOsLibrary);
exeEnv->sourceLevelDebugger.reset(gmock);
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDeviceWithDebuggerActive>(nullptr, exeEnv, 0u));
executionEnvironment->sourceLevelDebugger.reset(gmock);
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDeviceWithDebuggerActive>(nullptr, executionEnvironment, 0u));
EXPECT_CALL(*gmock, notifyDeviceDestruction()).Times(1);
}
TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsCreatedThenPreemptionIsDisabled) {
auto exeEnv = new ExecutionEnvironment;
exeEnv->sourceLevelDebugger.reset(new MockActiveSourceLevelDebugger(new MockOsLibrary));
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDeviceWithDebuggerActive>(nullptr, exeEnv, 0u));
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
executionEnvironment->sourceLevelDebugger.reset(new MockActiveSourceLevelDebugger(new MockOsLibrary));
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDeviceWithDebuggerActive>(nullptr, executionEnvironment, 0u));
EXPECT_EQ(PreemptionMode::Disabled, device->getPreemptionMode());
}

View File

@@ -528,15 +528,14 @@ TEST(SourceLevelDebugger, givenTwoDevicesWhenSecondIsCreatedThenNotCreatingNewSo
DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
std::unique_ptr<ExecutionEnvironment> executionEnvironment(new ExecutionEnvironment);
executionEnvironment->incRefInternal();
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
std::unique_ptr<Device> device1(Device::create<OCLRT::MockDevice>(nullptr, executionEnvironment.get(), 0u));
std::unique_ptr<Device> device1(Device::create<OCLRT::MockDevice>(nullptr, executionEnvironment, 0u));
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
EXPECT_TRUE(interceptor.initCalled);
interceptor.initCalled = false;
std::unique_ptr<Device> device2(Device::create<OCLRT::MockDevice>(nullptr, executionEnvironment.get(), 1u));
std::unique_ptr<Device> device2(Device::create<OCLRT::MockDevice>(nullptr, executionEnvironment, 1u));
EXPECT_NE(nullptr, executionEnvironment->memoryManager);
EXPECT_FALSE(interceptor.initCalled);
}
@@ -549,7 +548,7 @@ TEST(SourceLevelDebugger, givenMultipleDevicesWhenTheyAreCreatedTheyAllReuseTheS
DebuggerLibrary::setLibraryAvailable(true);
DebuggerLibrary::setDebuggerActive(true);
auto executionEnvironment = new ExecutionEnvironment;
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
std::unique_ptr<Device> device1(Device::create<OCLRT::MockDevice>(nullptr, executionEnvironment, 0u));
auto sourceLevelDebugger = device1->getSourceLevelDebugger();
std::unique_ptr<Device> device2(Device::create<OCLRT::MockDevice>(nullptr, executionEnvironment, 1u));

View File

@@ -12,8 +12,9 @@
#include "runtime/platform/platform.h"
void OCLRT::UltConfigListener::OnTestStart(const ::testing::TestInfo &testInfo) {
constructPlatform()->peekExecutionEnvironment()->setHwInfo(*platformDevices);
// Create platform and initialize gmm that dont want to create Platform and test gmm initialization path
constructPlatform()->peekExecutionEnvironment()->initGmm(*platformDevices);
platform()->peekExecutionEnvironment()->initGmm();
}
void OCLRT::UltConfigListener::OnTestEnd(const ::testing::TestInfo &testInfo) {
// Clear global platform that it shouldn't be reused between tests