diff --git a/Jenkinsfile b/Jenkinsfile index 64d607d55a..422520175c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,4 @@ #!groovy neoDependenciesRev='775910-972' strategy='EQUAL' -allowedCD=297 +allowedCD=298 diff --git a/runtime/command_stream/create_command_stream_impl.cpp b/runtime/command_stream/create_command_stream_impl.cpp index 0d49fb6da3..9f880476aa 100644 --- a/runtime/command_stream/create_command_stream_impl.cpp +++ b/runtime/command_stream/create_command_stream_impl.cpp @@ -41,27 +41,15 @@ CommandStreamReceiver *createCommandStreamImpl(const HardwareInfo *pHwInfo) { if (csr) { switch (csr) { case CSR_AUB: - GmmHelper::initContext(pHwInfo->pPlatform, - pHwInfo->pSkuTable, - pHwInfo->pWaTable, - pHwInfo->pSysInfo); commandStreamReceiver = AUBCommandStreamReceiver::create(*pHwInfo, "aubfile", true); break; case CSR_TBX: - GmmHelper::initContext(pHwInfo->pPlatform, - pHwInfo->pSkuTable, - pHwInfo->pWaTable, - pHwInfo->pSysInfo); commandStreamReceiver = TbxCommandStreamReceiver::create(*pHwInfo, false); break; case CSR_HW_WITH_AUB: commandStreamReceiver = funcCreate(*pHwInfo, true); break; case CSR_TBX_WITH_AUB: - GmmHelper::initContext(pHwInfo->pPlatform, - pHwInfo->pSkuTable, - pHwInfo->pWaTable, - pHwInfo->pSysInfo); commandStreamReceiver = TbxCommandStreamReceiver::create(*pHwInfo, true); break; default: diff --git a/runtime/device/device.cpp b/runtime/device/device.cpp index bc3cc16124..de6a41975c 100644 --- a/runtime/device/device.cpp +++ b/runtime/device/device.cpp @@ -134,6 +134,7 @@ Device::~Device() { } bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) { + outDevice.executionEnvironment->initGmm(pHwInfo); CommandStreamReceiver *commandStreamReceiver = createCommandStream(pHwInfo); if (!commandStreamReceiver) { return false; diff --git a/runtime/device/device.h b/runtime/device/device.h index f969f6b8d4..8fc047eef9 100644 --- a/runtime/device/device.h +++ b/runtime/device/device.h @@ -53,9 +53,10 @@ class Device : public BaseObject<_cl_device_id> { static const cl_ulong objectMagic = 0x8055832341AC8D08LL; template - static T *create(const HardwareInfo *pHwInfo) { + static T *create(const HardwareInfo *pHwInfo, ExecutionEnvironment *execEnv) { pHwInfo = getDeviceInitHwInfo(pHwInfo); T *device = new T(*pHwInfo); + device->connectToExecutionEnvironment(execEnv); if (false == createDeviceImpl(pHwInfo, *device)) { delete device; return nullptr; diff --git a/runtime/execution_environment/execution_environment.cpp b/runtime/execution_environment/execution_environment.cpp index 4c92027f6e..6838a38965 100644 --- a/runtime/execution_environment/execution_environment.cpp +++ b/runtime/execution_environment/execution_environment.cpp @@ -21,8 +21,15 @@ */ #include "runtime/execution_environment/execution_environment.h" +#include "runtime/gmm_helper/gmm_helper.h" #include "runtime/os_interface/device_factory.h" -OCLRT::ExecutionEnvironment::~ExecutionEnvironment() { +namespace OCLRT { +ExecutionEnvironment::ExecutionEnvironment() = default; +ExecutionEnvironment::~ExecutionEnvironment() { DeviceFactory::releaseDevices(); } +void ExecutionEnvironment::initGmm(const HardwareInfo *hwInfo) { + gmmHelper.reset(new GmmHelper(hwInfo)); +} +} // namespace OCLRT diff --git a/runtime/execution_environment/execution_environment.h b/runtime/execution_environment/execution_environment.h index f25cad3c3b..363bfe4f85 100644 --- a/runtime/execution_environment/execution_environment.h +++ b/runtime/execution_environment/execution_environment.h @@ -23,8 +23,15 @@ #include "runtime/utilities/reference_tracked_object.h" namespace OCLRT { +class GmmHelper; +struct HardwareInfo; class ExecutionEnvironment : public ReferenceTrackedObject { public: + ExecutionEnvironment(); ~ExecutionEnvironment() override; + void initGmm(const HardwareInfo *hwInfo); + + protected: + std::unique_ptr gmmHelper; }; } // namespace OCLRT diff --git a/runtime/gmm_helper/gmm_helper.cpp b/runtime/gmm_helper/gmm_helper.cpp index e022633a3d..6c7230dea7 100644 --- a/runtime/gmm_helper/gmm_helper.cpp +++ b/runtime/gmm_helper/gmm_helper.cpp @@ -30,9 +30,10 @@ #include "runtime/helpers/surface_formats.h" #include "runtime/helpers/hw_info.h" #include "runtime/sku_info/operations/sku_info_transfer.h" +#include "runtime/os_interface/os_library.h" namespace OCLRT { -bool GmmHelper::initContext(const PLATFORM *pPlatform, +void GmmHelper::initContext(const PLATFORM *pPlatform, const FeatureTable *pSkuTable, const WorkaroundTable *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo) { @@ -41,14 +42,12 @@ bool GmmHelper::initContext(const PLATFORM *pPlatform, _WA_TABLE gmmWaTable = {}; SkuInfoTransfer::transferFtrTableForGmm(&gmmFtrTable, pSkuTable); SkuInfoTransfer::transferWaTableForGmm(&gmmWaTable, pWaTable); - if (!isLoaded) { - loadLib(); - } + loadLib(); bool success = GMM_SUCCESS == initGlobalContextFunc(*pPlatform, &gmmFtrTable, &gmmWaTable, pGtSysInfo, GMM_CLIENT::GMM_OCL_VISTA); UNRECOVERABLE_IF(!success); GmmHelper::gmmClientContext = GmmHelper::createClientContextFunc(GMM_CLIENT::GMM_OCL_VISTA); } - return GmmHelper::gmmClientContext != nullptr; + UNRECOVERABLE_IF(!GmmHelper::gmmClientContext); } void GmmHelper::destroyContext() { @@ -56,6 +55,10 @@ void GmmHelper::destroyContext() { deleteClientContextFunc(GmmHelper::gmmClientContext); GmmHelper::gmmClientContext = nullptr; destroyGlobalContextFunc(); + if (gmmLib) { + delete gmmLib; + gmmLib = nullptr; + } } } @@ -67,7 +70,6 @@ uint32_t GmmHelper::getMOCS(uint32_t type) { return cacheEnabledIndex; } } - MEMORY_OBJECT_CONTROL_STATE mocs = GmmHelper::gmmClientContext->CachePolicyGetMemoryObject(nullptr, static_cast(type)); return static_cast(mocs.DwordValue); @@ -159,10 +161,17 @@ GMM_YUV_PLANE GmmHelper::convertPlane(OCLPlane oclPlane) { return GMM_NO_PLANE; } - +GmmHelper::GmmHelper(const HardwareInfo *pHwInfo) { + GmmHelper::hwInfo = pHwInfo; + initContext(pHwInfo->pPlatform, pHwInfo->pSkuTable, pHwInfo->pWaTable, pHwInfo->pSysInfo); +} +GmmHelper::~GmmHelper() { + if (isLoaded) { + destroyContext(); + } +} bool GmmHelper::useSimplifiedMocsTable = false; GMM_CLIENT_CONTEXT *GmmHelper::gmmClientContext = nullptr; const HardwareInfo *GmmHelper::hwInfo = nullptr; -bool GmmHelper::isLoaded = false; - +OsLibrary *GmmHelper::gmmLib = nullptr; } // namespace OCLRT diff --git a/runtime/gmm_helper/gmm_helper.h b/runtime/gmm_helper/gmm_helper.h index 1ae2d993d4..e6fa6f8343 100644 --- a/runtime/gmm_helper/gmm_helper.h +++ b/runtime/gmm_helper/gmm_helper.h @@ -35,18 +35,17 @@ struct WorkaroundTable; struct ImageInfo; class GraphicsAllocation; class Gmm; +class OsLibrary; class GmmHelper { public: GmmHelper() = delete; + GmmHelper(const HardwareInfo *hwInfo); + ~GmmHelper(); static constexpr uint32_t cacheDisabledIndex = 0; static constexpr uint32_t cacheEnabledIndex = 4; static constexpr uint32_t maxPossiblePitch = 2147483648; - static void loadLib(); - static bool initContext(const PLATFORM *pPlatform, const FeatureTable *pSkuTable, const WorkaroundTable *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo); - static void destroyContext(); - static uint64_t canonize(uint64_t address); static uint64_t decanonize(uint64_t address); @@ -67,6 +66,13 @@ class GmmHelper { static bool useSimplifiedMocsTable; static GMM_CLIENT_CONTEXT *gmmClientContext; static const HardwareInfo *hwInfo; - static bool isLoaded; + static OsLibrary *gmmLib; + + protected: + void loadLib(); + void initContext(const PLATFORM *pPlatform, const FeatureTable *pSkuTable, const WorkaroundTable *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo); + void destroyContext(); + + bool isLoaded = false; }; } // namespace OCLRT diff --git a/runtime/gmm_helper/gmm_memory_base.cpp b/runtime/gmm_helper/gmm_memory_base.cpp index c2335e6553..533c9b3cd4 100644 --- a/runtime/gmm_helper/gmm_memory_base.cpp +++ b/runtime/gmm_helper/gmm_memory_base.cpp @@ -24,6 +24,9 @@ #include "runtime/gmm_helper/gmm_helper.h" namespace OCLRT { +GmmMemoryBase::GmmMemoryBase() { + clientContext = GmmHelper::gmmClientContext; +} bool GmmMemoryBase::configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter, GMM_ESCAPE_HANDLE hDevice, GMM_ESCAPE_FUNC_TYPE pfnEscape, @@ -33,7 +36,7 @@ bool GmmMemoryBase::configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter, BOOLEAN BDWL3Coherency, GMM_GFX_SIZE_T SizeOverride, GMM_GFX_SIZE_T SlmGfxSpaceReserve) { - return GmmHelper::gmmClientContext->ConfigureDeviceAddressSpace( + return clientContext->ConfigureDeviceAddressSpace( {hAdapter}, {hDevice}, {pfnEscape}, @@ -46,7 +49,7 @@ bool GmmMemoryBase::configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter, } uintptr_t GmmMemoryBase::getInternalGpuVaRangeLimit() { - return static_cast(GmmHelper::gmmClientContext->GetInternalGpuVaRangeLimit()); + return static_cast(clientContext->GetInternalGpuVaRangeLimit()); } }; // namespace OCLRT diff --git a/runtime/gmm_helper/gmm_memory_base.h b/runtime/gmm_helper/gmm_memory_base.h index dac1603863..100c3f31ce 100644 --- a/runtime/gmm_helper/gmm_memory_base.h +++ b/runtime/gmm_helper/gmm_memory_base.h @@ -42,6 +42,7 @@ class GmmMemoryBase { MOCKABLE_VIRTUAL uintptr_t getInternalGpuVaRangeLimit(); protected: - GmmMemoryBase() = default; + GmmMemoryBase(); + GMM_CLIENT_CONTEXT *clientContext; }; } // namespace OCLRT diff --git a/runtime/gmm_helper/page_table_mngr.h b/runtime/gmm_helper/page_table_mngr.h index 28822da01c..a52f706184 100644 --- a/runtime/gmm_helper/page_table_mngr.h +++ b/runtime/gmm_helper/page_table_mngr.h @@ -28,7 +28,7 @@ namespace OCLRT { class GmmPageTableMngr { public: - MOCKABLE_VIRTUAL ~GmmPageTableMngr() = default; + MOCKABLE_VIRTUAL ~GmmPageTableMngr(); static GmmPageTableMngr *create(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb); @@ -45,13 +45,10 @@ class GmmPageTableMngr { } protected: - static void customDeleter(GMM_PAGETABLE_MGR *gmmPageTableManager); - using UniquePtrType = std::unique_ptr>; - GmmPageTableMngr() = default; GmmPageTableMngr(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb); - - UniquePtrType pageTableManager; + GMM_CLIENT_CONTEXT *clientContext = nullptr; + GMM_PAGETABLE_MGR *pageTableManager = nullptr; }; } // namespace OCLRT diff --git a/runtime/gmm_helper/page_table_mngr_impl.cpp b/runtime/gmm_helper/page_table_mngr_impl.cpp index e104e1bb05..6b506153d8 100644 --- a/runtime/gmm_helper/page_table_mngr_impl.cpp +++ b/runtime/gmm_helper/page_table_mngr_impl.cpp @@ -24,13 +24,15 @@ #include "runtime/gmm_helper/page_table_mngr.h" namespace OCLRT { -void GmmPageTableMngr::customDeleter(GMM_PAGETABLE_MGR *gmmPageTableManager) { - GmmHelper::gmmClientContext->DestroyPageTblMgrObject(gmmPageTableManager); +GmmPageTableMngr::~GmmPageTableMngr() { + if (clientContext) { + clientContext->DestroyPageTblMgrObject(pageTableManager); + } } GmmPageTableMngr::GmmPageTableMngr(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb) { - auto pageTableMngrPtr = GmmHelper::gmmClientContext->CreatePageTblMgrObject(deviceCb, translationTableCb, translationTableFlags); - this->pageTableManager = UniquePtrType(pageTableMngrPtr, GmmPageTableMngr::customDeleter); + this->clientContext = GmmHelper::gmmClientContext; + pageTableManager = clientContext->CreatePageTblMgrObject(deviceCb, translationTableCb, translationTableFlags); } } // namespace OCLRT diff --git a/runtime/os_interface/linux/device_factory.cpp b/runtime/os_interface/linux/device_factory.cpp index fb00f67008..7c8cbfaad0 100644 --- a/runtime/os_interface/linux/device_factory.cpp +++ b/runtime/os_interface/linux/device_factory.cpp @@ -75,8 +75,7 @@ bool DeviceFactory::getDevices(HardwareInfo **pHWInfos, size_t &numDevices) { DeviceFactory::numDevices = devNum; DeviceFactory::hwInfos = ptr; - return GmmHelper::initContext(hwInfos->pPlatform, hwInfos->pSkuTable, - hwInfos->pWaTable, hwInfos->pSysInfo); + return true; } void DeviceFactory::releaseDevices() { diff --git a/runtime/os_interface/windows/gmm_interface_dynamic_win.cpp b/runtime/os_interface/windows/gmm_interface_dynamic_win.cpp index 321c4cb721..87dbaf5dc9 100644 --- a/runtime/os_interface/windows/gmm_interface_dynamic_win.cpp +++ b/runtime/os_interface/windows/gmm_interface_dynamic_win.cpp @@ -39,9 +39,8 @@ decltype(GmmHelper::destroyGlobalContextFunc) GmmHelper::destroyGlobalContextFun decltype(GmmHelper::createClientContextFunc) GmmHelper::createClientContextFunc = nullptr; decltype(GmmHelper::deleteClientContextFunc) GmmHelper::deleteClientContextFunc = nullptr; -std::unique_ptr gmmLib; void GmmHelper::loadLib() { - gmmLib.reset(OsLibrary::load(Os::gmmDllName)); + gmmLib = OsLibrary::load(Os::gmmDllName); UNRECOVERABLE_IF(!gmmLib); if (gmmLib->isLoaded()) { diff --git a/runtime/os_interface/windows/wddm/wddm.cpp b/runtime/os_interface/windows/wddm/wddm.cpp index b231768169..87a36c64bd 100644 --- a/runtime/os_interface/windows/wddm/wddm.cpp +++ b/runtime/os_interface/windows/wddm/wddm.cpp @@ -85,8 +85,6 @@ Wddm::Wddm() : initialized(false), Wddm::~Wddm() { resetPageTableManager(nullptr); - if (initialized) - destroyGmmContext(); destroyContext(context); destroyPagingQueue(); destroyDevice(); diff --git a/runtime/os_interface/windows/wddm/wddm.h b/runtime/os_interface/windows/wddm/wddm.h index cea29eabd6..637b160ad8 100644 --- a/runtime/os_interface/windows/wddm/wddm.h +++ b/runtime/os_interface/windows/wddm/wddm.h @@ -211,8 +211,6 @@ class Wddm { void getDeviceState(); void handleCompletion(); unsigned int readEnablePreemptionRegKey(); - bool initGmmContext(); - void destroyGmmContext(); void resetMonitoredFenceParams(D3DKMT_HANDLE &handle, uint64_t *cpuAddress, D3DGPU_VIRTUAL_ADDRESS &gpuAddress); virtual const bool hwQueuesSupported() const { return false; } diff --git a/runtime/os_interface/windows/wddm/wddm.inl b/runtime/os_interface/windows/wddm/wddm.inl index d84716a934..1df1b905f0 100644 --- a/runtime/os_interface/windows/wddm/wddm.inl +++ b/runtime/os_interface/windows/wddm/wddm.inl @@ -52,9 +52,6 @@ bool Wddm::init() { if (!createPagingQueue()) { return false; } - if (!initGmmContext()) { - return false; - } if (!configureDeviceAddressSpace()) { return false; } diff --git a/runtime/os_interface/windows/wddm/wddm_calls.cpp b/runtime/os_interface/windows/wddm/wddm_calls.cpp index 10a4f50a5f..9149670d11 100644 --- a/runtime/os_interface/windows/wddm/wddm_calls.cpp +++ b/runtime/os_interface/windows/wddm/wddm_calls.cpp @@ -40,15 +40,4 @@ Wddm::VirtualFreeFcn getVirtualFree() { Wddm::VirtualAllocFcn getVirtualAlloc() { return VirtualAlloc; } - -bool Wddm::initGmmContext() { - return GmmHelper::initContext(gfxPlatform.get(), - featureTable.get(), - waTable.get(), - gtSystemInfo.get()); -} - -void Wddm::destroyGmmContext() { - GmmHelper::destroyContext(); -} } // namespace OCLRT diff --git a/runtime/platform/platform.cpp b/runtime/platform/platform.cpp index 2b1e513f38..373f916064 100644 --- a/runtime/platform/platform.cpp +++ b/runtime/platform/platform.cpp @@ -148,7 +148,7 @@ bool Platform::initialize() { this->devices.resize(numDevicesReturned); for (size_t deviceOrdinal = 0; deviceOrdinal < numDevicesReturned; ++deviceOrdinal) { - auto pDevice = Device::create(&hwInfo[deviceOrdinal]); + auto pDevice = Device::create(&hwInfo[deviceOrdinal], executionEnvironment); DEBUG_BREAK_IF(!pDevice); if (pDevice) { this->devices[deviceOrdinal] = pDevice; @@ -168,7 +168,6 @@ bool Platform::initialize() { } compilerExtensions = convertEnabledExtensionsToCompilerInternalOptions(pDevice->getDeviceInfo().deviceExtensions); - pDevice->connectToExecutionEnvironment(this->executionEnvironment); } else { return false; } diff --git a/unit_tests/api/cl_api_tests.cpp b/unit_tests/api/cl_api_tests.cpp index 0a423e1ed4..bf3203678e 100644 --- a/unit_tests/api/cl_api_tests.cpp +++ b/unit_tests/api/cl_api_tests.cpp @@ -66,7 +66,7 @@ void api_fixture_using_aligned_memory_manager::SetUp() { retVal = CL_SUCCESS; retSize = 0; - device = Device::create(*platformDevices); + device = MockDevice::createWithNewExecutionEnvironment(*platformDevices); Device *devPtr = reinterpret_cast(device); cl_device_id clDevice = devPtr; diff --git a/unit_tests/api/cl_get_device_and_host_timer.cpp b/unit_tests/api/cl_get_device_and_host_timer.cpp index e2d353a317..d4d30a7db7 100644 --- a/unit_tests/api/cl_get_device_and_host_timer.cpp +++ b/unit_tests/api/cl_get_device_and_host_timer.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017, Intel Corporation +* Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -80,7 +80,7 @@ TEST_F(clGetDeviceAndHostTimerTest, OsCallPass) { cl_ulong host_timestamp = 0; cl_ulong zero_timestamp = 0; - auto mDev = Device::create(nullptr); + auto mDev = MockDevice::createWithNewExecutionEnvironment(nullptr); mDev->setOSTime(new MockOSTime()); retVal = clGetDeviceAndHostTimer( @@ -100,7 +100,7 @@ TEST_F(clGetDeviceAndHostTimerTest, OsCallFail) { cl_ulong host_timestamp = 0; cl_ulong zero_timestamp = 0; - auto mDev = Device::create(nullptr); + auto mDev = MockDevice::createWithNewExecutionEnvironment(nullptr); mDev->setOSTime(new FailOSTime()); retVal = clGetDeviceAndHostTimer( @@ -149,7 +149,7 @@ TEST_F(clGetHostTimerTest, OsCallPass) { cl_ulong host_timestamp = 0; cl_ulong zero_timestamp = 0; - auto mDev = Device::create(nullptr); + auto mDev = MockDevice::createWithNewExecutionEnvironment(nullptr); mDev->setOSTime(new MockOSTime()); retVal = clGetHostTimer( @@ -166,7 +166,7 @@ TEST_F(clGetHostTimerTest, OsCallFail) { cl_ulong host_timestamp = 0; cl_ulong zero_timestamp = 0; - auto mDev = Device::create(nullptr); + auto mDev = MockDevice::createWithNewExecutionEnvironment(nullptr); mDev->setOSTime(new FailOSTime()); retVal = clGetHostTimer( diff --git a/unit_tests/built_ins/sip_tests.cpp b/unit_tests/built_ins/sip_tests.cpp index 4656829d2a..bbb5af3a0e 100644 --- a/unit_tests/built_ins/sip_tests.cpp +++ b/unit_tests/built_ins/sip_tests.cpp @@ -61,7 +61,7 @@ TEST(Sip, WhenRequestingCsrSipKernelThenProperCompilerInternalOptionsAreReturned } TEST(Sip, When32BitAddressesAreNotBeingForcedThenSipLlHasSameBitnessAsHostApplication) { - auto mockDevice = std::unique_ptr(Device::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); EXPECT_NE(nullptr, mockDevice); mockDevice->setForce32BitAddressing(false); const char *src = getSipLlSrc(*mockDevice); @@ -77,7 +77,7 @@ TEST(Sip, When32BitAddressesAreNotBeingForcedThenSipLlHasSameBitnessAsHostApplic } TEST(Sip, When32BitAddressesAreBeingForcedThenSipLlHas32BitAddresses) { - auto mockDevice = std::unique_ptr(Device::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); EXPECT_NE(nullptr, mockDevice); mockDevice->setForce32BitAddressing(true); const char *src = getSipLlSrc(*mockDevice); @@ -88,7 +88,7 @@ TEST(Sip, When32BitAddressesAreBeingForcedThenSipLlHas32BitAddresses) { } TEST(Sip, SipLlContainsMetadataRequiredByCompiler) { - auto mockDevice = std::unique_ptr(Device::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); EXPECT_NE(nullptr, mockDevice); const char *src = getSipLlSrc(*mockDevice); ASSERT_NE(nullptr, src); @@ -138,7 +138,7 @@ TEST(DebugSip, WhenRequestingDbgCsrWithLocalMemorySipKernelThenProperCompilerInt } TEST(DebugSip, DISABLED_givenBuiltInsWhenDbgCsrSipIsRequestedThanCorrectSipKernelIsReturned) { - auto mockDevice = std::unique_ptr(Device::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); EXPECT_NE(nullptr, mockDevice); MockCompilerDebugVars igcDebugVars; diff --git a/unit_tests/command_queue/command_queue_tests.cpp b/unit_tests/command_queue/command_queue_tests.cpp index 41dbc656d1..92eccc9fb5 100644 --- a/unit_tests/command_queue/command_queue_tests.cpp +++ b/unit_tests/command_queue/command_queue_tests.cpp @@ -236,7 +236,7 @@ TEST(CommandQueue, givenCmdQueueBlockedByReadyVirtualEventWhenUnblockingThenUpda TEST(CommandQueue, givenCmdQueueBlockedByAbortedVirtualEventWhenUnblockingThenUpdateFlushTaskFromEvent) { auto context = new MockContext; - std::unique_ptr mockDevice(Device::create(nullptr)); + std::unique_ptr mockDevice(MockDevice::createWithNewExecutionEnvironment(nullptr)); auto cmdQ = new CommandQueue(context, mockDevice.get(), 0); auto userEvent = new Event(cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0); @@ -272,7 +272,7 @@ struct CommandQueueCommandStreamTest : public CommandQueueMemoryDevice, HWTEST_F(CommandQueueCommandStreamTest, givenCommandQueueThatWaitsOnAbortedUserEventWhenIsQueueBlockedIsCalledThenTaskLevelAlignsToCsr) { MockContext context; - std::unique_ptr mockDevice(Device::create(nullptr)); + std::unique_ptr mockDevice(MockDevice::createWithNewExecutionEnvironment(nullptr)); CommandQueue cmdQ(&context, mockDevice.get(), 0); auto &commandStreamReceiver = mockDevice->getUltCommandStreamReceiver(); @@ -679,7 +679,7 @@ INSTANTIATE_TEST_CASE_P( using CommandQueueTests = ::testing::Test; HWTEST_F(CommandQueueTests, givenMultipleCommandQueuesWhenMarkerIsEmittedThenGraphicsAllocationIsReused) { - std::unique_ptr device(Device::create(*platformDevices)); + std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(*platformDevices)); MockContext context(device.get()); std::unique_ptr commandQ(new CommandQueue(&context, device.get(), 0)); *device->getTagAddress() = 0; @@ -710,7 +710,7 @@ struct WaitForQueueCompletionTests : public ::testing::Test { }; void SetUp() override { - device.reset(Device::create(*platformDevices)); + device.reset(MockDevice::createWithNewExecutionEnvironment(*platformDevices)); context.reset(new MockContext(device.get())); } diff --git a/unit_tests/command_stream/submissions_aggregator_tests.cpp b/unit_tests/command_stream/submissions_aggregator_tests.cpp index c6e4e19df2..0ca03cd3f4 100644 --- a/unit_tests/command_stream/submissions_aggregator_tests.cpp +++ b/unit_tests/command_stream/submissions_aggregator_tests.cpp @@ -477,7 +477,7 @@ TEST(SubmissionsAggregator, dontAllocateFlushStamp) { struct SubmissionsAggregatorTests : public ::testing::Test { void SetUp() override { - device.reset(Device::create(platformDevices[0])); + device.reset(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); context.reset(new MockContext(device.get())); } diff --git a/unit_tests/device/device_caps_tests.cpp b/unit_tests/device/device_caps_tests.cpp index 564168b9ba..2f4c33120c 100644 --- a/unit_tests/device/device_caps_tests.cpp +++ b/unit_tests/device/device_caps_tests.cpp @@ -704,7 +704,7 @@ const std::string DriverInfoMock::testDeviceName = "testDeviceName"; const std::string DriverInfoMock::testVersion = "testVersion"; TEST(Device_GetCaps, givenSystemWithDriverInfoWhenGettingNameAndVersionThenReturnValuesFromDriverInfo) { - auto device = Device::create(platformDevices[0]); + auto device = MockDevice::createWithNewExecutionEnvironment(platformDevices[0]); DriverInfoMock *driverInfoMock = new DriverInfoMock(); device->setDriverInfo(driverInfoMock); @@ -718,7 +718,7 @@ TEST(Device_GetCaps, givenSystemWithDriverInfoWhenGettingNameAndVersionThenRetur } TEST(Device_GetCaps, givenSystemWithNoDriverInfoWhenGettingNameAndVersionThenReturnDefaultValues) { - auto device = Device::create(platformDevices[0]); + auto device = MockDevice::createWithNewExecutionEnvironment(platformDevices[0]); device->setDriverInfo(nullptr); device->name.clear(); @@ -777,7 +777,7 @@ TEST(Device_GetCaps, GivenFlagEnabled64kbPagesWhenSetThenReturnCorrectValue) { } TEST(Device_GetCaps, givenDeviceWithNullSourceLevelDebuggerWhenCapsAreInitializedThenSourceLevelDebuggerActiveIsSetToFalse) { - std::unique_ptr device(Device::create(platformDevices[0])); + std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); const auto &caps = device->getDeviceInfo(); EXPECT_EQ(nullptr, device->getSourceLevelDebugger()); @@ -790,7 +790,7 @@ TEST_F(DeviceCapsWithModifiedHwInfoTest, givenPlatformWithSourceLevelDebuggerNot hwInfo.capabilityTable.sourceLevelDebuggerSupported = false; - std::unique_ptr> device(Device::create>(&hwInfo)); + std::unique_ptr> device(MockDevice::createWithNewExecutionEnvironment>(&hwInfo)); const auto &caps = device->getDeviceInfo(); EXPECT_NE(nullptr, device->getSourceLevelDebugger()); diff --git a/unit_tests/device/device_tests.cpp b/unit_tests/device/device_tests.cpp index 92cbd0fde7..5e050b90ec 100644 --- a/unit_tests/device/device_tests.cpp +++ b/unit_tests/device/device_tests.cpp @@ -134,13 +134,13 @@ struct SmallMockDevice : public Device { TEST(DeviceCreation, givenDeviceWithUsedTagAllocationWhenItIsDestroyedThenThereAreNoCrashesAndLeaks) { overrideCommandStreamReceiverCreation = 1; - std::unique_ptr device(Device::create(platformDevices[0])); + std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); auto tagAllocation = device->peekTagAllocation(); tagAllocation->taskCount = 1; } TEST(DeviceCleanup, givenDeviceWhenItIsDestroyedThenFlushBatchedSubmissionsIsCalled) { - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); MockCommandStreamReceiver *csr = new MockCommandStreamReceiver; mockDevice->resetCommandStreamReceiver(csr); int flushedBatchedSubmissionsCalledCount = 0; @@ -155,7 +155,7 @@ TEST(DeviceCreation, givenSelectedAubCsrInDebugVarsWhenDeviceIsCreatedThenIsSimu DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_AUB); overrideCommandStreamReceiverCreation = true; - auto mockDevice = std::unique_ptr(Device::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); EXPECT_TRUE(mockDevice->isSimulation()); } @@ -164,7 +164,7 @@ TEST(DeviceCreation, givenSelectedTbxCsrInDebugVarsWhenDeviceIsCreatedThenIsSimu DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_TBX); overrideCommandStreamReceiverCreation = true; - auto device = std::unique_ptr(Device::create(nullptr)); + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); EXPECT_TRUE(device->isSimulation()); } @@ -173,7 +173,7 @@ TEST(DeviceCreation, givenSelectedTbxWithAubCsrInDebugVarsWhenDeviceIsCreatedThe DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_TBX_WITH_AUB); overrideCommandStreamReceiverCreation = true; - auto device = std::unique_ptr(Device::create(nullptr)); + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); EXPECT_TRUE(device->isSimulation()); } @@ -181,7 +181,7 @@ TEST(DeviceCreation, givenHwWithAubCsrInDebugVarsWhenDeviceIsCreatedThenIsSimula DebugManagerStateRestore dbgRestorer; DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_HW_WITH_AUB); - auto device = std::unique_ptr(Device::create(nullptr)); + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); EXPECT_FALSE(device->isSimulation()); } @@ -189,6 +189,6 @@ TEST(DeviceCreation, givenDefaultHwCsrInDebugVarsWhenDeviceIsCreatedThenIsSimula int32_t defaultHwCsr = CommandStreamReceiverType::CSR_HW; EXPECT_EQ(defaultHwCsr, DebugManager.flags.SetCommandStreamReceiver.get()); - auto device = std::unique_ptr(Device::create(nullptr)); + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); EXPECT_FALSE(device->isSimulation()); } diff --git a/unit_tests/device/device_timers_tests.cpp b/unit_tests/device/device_timers_tests.cpp index 94a11cb498..8ccba651df 100644 --- a/unit_tests/device/device_timers_tests.cpp +++ b/unit_tests/device/device_timers_tests.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017, Intel Corporation +* Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -31,7 +31,7 @@ TEST(MockOSTime, DeviceHostIncreaseCheck) { cl_ulong deviceTimestamp[2] = {0, 0}; cl_ulong hostTimestamp[2] = {0, 0}; - auto mDev = Device::create(nullptr); + auto mDev = MockDevice::createWithNewExecutionEnvironment(nullptr); mDev->setOSTime(new MockOSTime()); mDev->getDeviceAndHostTimer( @@ -97,7 +97,7 @@ TEST(MockOSTime, DeviceHostDeltaCheck) { TEST(MockOSTime, HostIncreaseCheck) { cl_ulong hostTimestamp[2] = {0, 0}; - auto mDev = Device::create(nullptr); + auto mDev = MockDevice::createWithNewExecutionEnvironment(nullptr); mDev->setOSTime(new MockOSTime()); mDev->getHostTimer( @@ -114,7 +114,7 @@ TEST(MockOSTime, HostIncreaseCheck) { } TEST(MockOSTime, NegativeTest) { - auto mDev = Device::create(nullptr); + auto mDev = MockDevice::createWithNewExecutionEnvironment(nullptr); mDev->setOSTime(nullptr); double zeroRes; diff --git a/unit_tests/device_queue/device_queue_hw_tests.cpp b/unit_tests/device_queue/device_queue_hw_tests.cpp index b3cc29c031..b4a8462d63 100644 --- a/unit_tests/device_queue/device_queue_hw_tests.cpp +++ b/unit_tests/device_queue/device_queue_hw_tests.cpp @@ -494,7 +494,7 @@ class DeviceQueueHwWithKernel : public ExecutionModelKernelFixture { 0, 0, 0}; cl_int errcodeRet = 0; - device = Device::create(platformDevices[0]); + device = MockDevice::createWithNewExecutionEnvironment(platformDevices[0]); context = new MockContext(); ASSERT_NE(nullptr, context); @@ -625,7 +625,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, TheSimplestDeviceQueueFixture, resetDeviceQueueSetEa DebugManager.flags.SchedulerSimulationReturnInstance.set(3); - std::unique_ptr device(Device::create(platformDevices[0])); + std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); MockContext context; std::unique_ptr> mockDeviceQueueHw(new MockDeviceQueueHw(&context, device.get(), deviceQueueProperties::minimumProperties[0])); @@ -639,7 +639,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, TheSimplestDeviceQueueFixture, addMediaStateClearCmd using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE; - std::unique_ptr device(Device::create(platformDevices[0])); + std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); MockContext context; std::unique_ptr> mockDeviceQueueHw(new MockDeviceQueueHw(&context, device.get(), deviceQueueProperties::minimumProperties[0])); @@ -683,7 +683,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, TheSimplestDeviceQueueFixture, addExecutionModelClea addMediaStateClearCmdsCalled = true; } }; - std::unique_ptr device(Device::create(platformDevices[0])); + std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); MockContext context; std::unique_ptr mockDeviceQueueHw(new MockDeviceQueueWithMediaStateClearRegistering(&context, device.get(), deviceQueueProperties::minimumProperties[0])); @@ -700,7 +700,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, TheSimplestDeviceQueueFixture, getMediaStateClearCmd using PIPE_CONTROL = typename FamilyType::PIPE_CONTROL; using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE; - std::unique_ptr device(Device::create(platformDevices[0])); + std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); MockContext context; std::unique_ptr> mockDeviceQueueHw(new MockDeviceQueueHw(&context, device.get(), deviceQueueProperties::minimumProperties[0])); @@ -716,7 +716,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, TheSimplestDeviceQueueFixture, getExecutionModelClea using MI_MATH = typename FamilyType::MI_MATH; using MI_BATCH_BUFFER_END = typename FamilyType::MI_BATCH_BUFFER_END; - std::unique_ptr device(Device::create(platformDevices[0])); + std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); MockContext context; std::unique_ptr> mockDeviceQueueHw(new MockDeviceQueueHw(&context, device.get(), deviceQueueProperties::minimumProperties[0])); @@ -741,7 +741,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, TheSimplestDeviceQueueFixture, getProfilingEndCmdsSi using MI_STORE_REGISTER_MEM = typename FamilyType::MI_STORE_REGISTER_MEM; using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM; - std::unique_ptr device(Device::create(platformDevices[0])); + std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); MockContext context; std::unique_ptr> mockDeviceQueueHw(new MockDeviceQueueHw(&context, device.get(), deviceQueueProperties::minimumProperties[0])); diff --git a/unit_tests/fixtures/device_fixture.h b/unit_tests/fixtures/device_fixture.h index c44aedd454..262515d931 100644 --- a/unit_tests/fixtures/device_fixture.h +++ b/unit_tests/fixtures/device_fixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Intel Corporation + * Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -35,7 +35,7 @@ struct DeviceDefaults { template struct DeviceHelper { static OCLRT::MockDevice *create(const OCLRT::HardwareInfo *hardwareInfo = nullptr) { - OCLRT::MockDevice *device = OCLRT::Device::create(hardwareInfo); + OCLRT::MockDevice *device = OCLRT::MockDevice::createWithNewExecutionEnvironment(hardwareInfo); assert(device != nullptr); return device; } diff --git a/unit_tests/fixtures/kernel_data_fixture.h b/unit_tests/fixtures/kernel_data_fixture.h index 86f5dab279..2b4a51f047 100644 --- a/unit_tests/fixtures/kernel_data_fixture.h +++ b/unit_tests/fixtures/kernel_data_fixture.h @@ -63,7 +63,7 @@ class KernelDataTest : public testing::Test { protected: void SetUp() override { kernelBinaryHeader.KernelNameSize = kernelNameSize; - pDevice = Device::create(nullptr); + pDevice = MockDevice::createWithNewExecutionEnvironment(nullptr); } void TearDown() override { diff --git a/unit_tests/fixtures/preemption_fixture.cpp b/unit_tests/fixtures/preemption_fixture.cpp index 6686ef9ae5..92893e4083 100644 --- a/unit_tests/fixtures/preemption_fixture.cpp +++ b/unit_tests/fixtures/preemption_fixture.cpp @@ -50,7 +50,7 @@ void DevicePreemptionTests::SetUp() { } const cl_queue_properties properties[3] = {CL_QUEUE_PROPERTIES, 0, 0}; kernelInfo.reset(KernelInfo::create()); - device.reset(MockDevice::create(nullptr)); + device.reset(MockDevice::createWithNewExecutionEnvironment(nullptr)); context.reset(new MockContext(device.get())); cmdQ.reset(new MockCommandQueue(context.get(), device.get(), properties)); executionEnvironment.reset(new SPatchExecutionEnvironment); diff --git a/unit_tests/gen10/coherency_tests_gen10.cpp b/unit_tests/gen10/coherency_tests_gen10.cpp index 9c2a7626dd..21ab0d8c3c 100644 --- a/unit_tests/gen10/coherency_tests_gen10.cpp +++ b/unit_tests/gen10/coherency_tests_gen10.cpp @@ -45,7 +45,7 @@ struct Gen10CoherencyRequirements : public ::testing::Test { void SetUp() override { csr = new myCsr(); - device.reset(Device::create(platformDevices[0])); + device.reset(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); device->resetCommandStreamReceiver(csr); } diff --git a/unit_tests/gen10/preamble_tests_gen10.cpp b/unit_tests/gen10/preamble_tests_gen10.cpp index 8c8405ab72..04b0736920 100644 --- a/unit_tests/gen10/preamble_tests_gen10.cpp +++ b/unit_tests/gen10/preamble_tests_gen10.cpp @@ -62,7 +62,7 @@ GEN10TEST_F(PreambleTestGen10, givenDisabledPreemptionAndDisabledDebuggingWhenPr GEN10TEST_F(PreambleTestGen10, givenKernelDebuggingActiveAndDisabledPreemptionWhenGetAdditionalCommandsSizeIsCalledThen2MiLoadRegisterImmCmdsAndStateSipAreInlcuded) { DebugManagerStateRestore dbgRestore; DebugManager.flags.ForcePreemptionMode.set(static_cast(PreemptionMode::Disabled)); - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); mockDevice->setSourceLevelDebuggerActive(false); size_t withoutDebugging = PreambleHelper::getAdditionalCommandsSize(*mockDevice); diff --git a/unit_tests/gen10/test_preamble_gen10.cpp b/unit_tests/gen10/test_preamble_gen10.cpp index 6de91b87b3..25702a24c8 100644 --- a/unit_tests/gen10/test_preamble_gen10.cpp +++ b/unit_tests/gen10/test_preamble_gen10.cpp @@ -201,7 +201,7 @@ using PreambleTestGen10 = ::testing::Test; GEN10TEST_F(PreambleTestGen10, givenProgrammingPreambleWhenPreemptionIsTakenIntoAccountThenCSRBaseAddressIsEqualCSRGpuAddress) { using GPGPU_CSR_BASE_ADDRESS = typename FamilyType::GPGPU_CSR_BASE_ADDRESS; - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); mockDevice->setPreemptionMode(PreemptionMode::MidThread); auto cmdSizePreemptionMidThread = PreemptionHelper::getRequiredPreambleSize(*mockDevice); diff --git a/unit_tests/gen8/bdw/device_tests_bdw.cpp b/unit_tests/gen8/bdw/device_tests_bdw.cpp index 08112fa247..af527e32e6 100644 --- a/unit_tests/gen8/bdw/device_tests_bdw.cpp +++ b/unit_tests/gen8/bdw/device_tests_bdw.cpp @@ -43,7 +43,7 @@ BDWTEST_F(BdwDeviceTest, givenBdwDeviceWhenAskedForClVersionThenReport21) { } BDWTEST_F(BdwDeviceTest, givenSourceLevelDebuggerAvailableWhenDeviceIsCreatedThenSourceLevelDebuggerIsDisabled) { - auto device = std::unique_ptr>(Device::create>(nullptr)); + auto device = std::unique_ptr>(MockDevice::createWithNewExecutionEnvironment>(nullptr)); const auto &caps = device->getDeviceInfo(); EXPECT_NE(nullptr, device->getSourceLevelDebugger()); EXPECT_FALSE(caps.sourceLevelDebuggerActive); diff --git a/unit_tests/gen9/preamble_tests_gen9.cpp b/unit_tests/gen9/preamble_tests_gen9.cpp index a4ce734ecd..8e9fe2b946 100644 --- a/unit_tests/gen9/preamble_tests_gen9.cpp +++ b/unit_tests/gen9/preamble_tests_gen9.cpp @@ -62,7 +62,7 @@ GEN9TEST_F(PreambleTestGen9, givenDisabledPreemptionAndDisabledDebuggingWhenPrea GEN9TEST_F(PreambleTestGen9, givenKernelDebuggingActiveAndDisabledPreemptionWhenGetAdditionalCommandsSizeIsCalledThen2MiLoadRegisterImmCmdsAndStateSipAreInlcuded) { DebugManagerStateRestore dbgRestore; DebugManager.flags.ForcePreemptionMode.set(static_cast(PreemptionMode::Disabled)); - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); mockDevice->setSourceLevelDebuggerActive(false); size_t withoutDebugging = PreambleHelper::getAdditionalCommandsSize(*mockDevice); @@ -77,7 +77,7 @@ GEN9TEST_F(PreambleTestGen9, givenKernelDebuggingActiveAndDisabledPreemptionWhen GEN9TEST_F(PreambleTestGen9, givenProgrammingPreambleWhenPreemptionIsTakenIntoAccountThenCSRBaseAddressIsEqualCSRGpuAddress) { using GPGPU_CSR_BASE_ADDRESS = typename FamilyType::GPGPU_CSR_BASE_ADDRESS; - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); mockDevice->setPreemptionMode(PreemptionMode::MidThread); auto cmdSizePreemptionMidThread = PreemptionHelper::getRequiredPreambleSize(*mockDevice); diff --git a/unit_tests/gen9/sip_tests_gen9.cpp b/unit_tests/gen9/sip_tests_gen9.cpp index b49fd2fcbc..e9bb15380b 100644 --- a/unit_tests/gen9/sip_tests_gen9.cpp +++ b/unit_tests/gen9/sip_tests_gen9.cpp @@ -37,7 +37,7 @@ extern std::string getDebugSipKernelNameWithBitnessAndProductSuffix(std::string typedef ::testing::Test gen9SipTests; GEN9TEST_F(gen9SipTests, DISABLED_givenDebugCsrSipKernelWithLocalMemoryWhenAskedForDebugSurfaceBtiAndSizeThenBtiIsZeroAndSizeGreaterThanZero) { - auto mockDevice = std::unique_ptr(Device::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); EXPECT_NE(nullptr, mockDevice); MockCompilerDebugVars igcDebugVars; diff --git a/unit_tests/gmm_helper/gmm_helper_tests.cpp b/unit_tests/gmm_helper/gmm_helper_tests.cpp index 148f974c89..447a35730b 100644 --- a/unit_tests/gmm_helper/gmm_helper_tests.cpp +++ b/unit_tests/gmm_helper/gmm_helper_tests.cpp @@ -35,6 +35,10 @@ using namespace ::testing; namespace OCLRT { class GmmTests : public ::testing::Test { + void SetUp() override { + execEnv.initGmm(*platformDevices); + } + ExecutionEnvironment execEnv; }; TEST_F(GmmTests, resourceCreation) { @@ -599,31 +603,31 @@ TEST(GmmTest, givenInvalidFlagsSetWhenAskedForUnifiedAuxTranslationCapabilityThe EXPECT_FALSE(gmm->unifiedAuxTranslationCapable()); // RenderCompressed == 0 } +class MockGmmHelper : public GmmHelper { + public: + using GmmHelper::destroyContext; + using GmmHelper::initContext; + MockGmmHelper(const HardwareInfo *hwInfo) : GmmHelper(hwInfo) {} +}; + TEST(GmmTest, whenContextIsInitializedMultipleTimesThenDontOverride) { const HardwareInfo *hwinfo = *platformDevices; - EXPECT_TRUE(GmmHelper::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo)); + auto gmmHelper = MockGmmHelper(hwinfo); auto currentClientContext = GmmHelper::gmmClientContext; - - EXPECT_TRUE(GmmHelper::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo)); - + gmmHelper.initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo); EXPECT_EQ(currentClientContext, GmmHelper::gmmClientContext); } TEST(GmmTest, whenContextIsDestroyedMultimpleTimesThenDontCrash) { const HardwareInfo *hwinfo = *platformDevices; - EXPECT_TRUE(GmmHelper::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo)); - - GmmHelper::destroyContext(); - EXPECT_EQ(nullptr, GmmHelper::gmmClientContext); - GmmHelper::destroyContext(); - - EXPECT_TRUE(GmmHelper::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo)); + auto gmmHelper = MockGmmHelper(hwinfo); + gmmHelper.destroyContext(); } TEST(GmmTest, givenHwInfoWhenDeviceIsCreatedTheSetThisHwInfoToGmmHelper) { HardwareInfo localHwInfo = **platformDevices; - std::unique_ptr device(Device::create(&localHwInfo)); + std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(&localHwInfo)); EXPECT_EQ(&localHwInfo, GmmHelper::hwInfo); } @@ -645,7 +649,8 @@ TEST(GmmTest, whenResourceIsCreatedThenHandleItsOwnership) { gmmParams.Flags.Info.Cacheable = 1; gmmParams.Flags.Gpu.Texture = 1; gmmParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER; - + ExecutionEnvironment execEnv; + execEnv.initGmm(*platformDevices); MyMockResourecInfo myMockResourceInfo1(&gmmParams); EXPECT_NE(nullptr, myMockResourceInfo1.resourceInfo.get()); diff --git a/unit_tests/helpers/kmd_notify_tests.cpp b/unit_tests/helpers/kmd_notify_tests.cpp index 216ce173a8..963d78bbf1 100644 --- a/unit_tests/helpers/kmd_notify_tests.cpp +++ b/unit_tests/helpers/kmd_notify_tests.cpp @@ -35,7 +35,7 @@ using namespace OCLRT; struct KmdNotifyTests : public ::testing::Test { void SetUp() override { - device.reset(Device::create(&localHwInfo)); + device.reset(MockDevice::createWithNewExecutionEnvironment(&localHwInfo)); cmdQ.reset(new CommandQueue(&context, device.get(), nullptr)); *device->getTagAddress() = taskCountToWait; device->getCommandStreamReceiver().waitForFlushStamp(flushStampToWait); diff --git a/unit_tests/kernel/kernel_arg_svm_tests.cpp b/unit_tests/kernel/kernel_arg_svm_tests.cpp index 1be0c69422..84c2ac69ea 100644 --- a/unit_tests/kernel/kernel_arg_svm_tests.cpp +++ b/unit_tests/kernel/kernel_arg_svm_tests.cpp @@ -369,7 +369,7 @@ HWTEST_TYPED_TEST(KernelArgSvmTestTyped, GivenBufferKernelArgWhenBufferOffsetIsN using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; constexpr size_t rendSurfSize = sizeof(RENDER_SURFACE_STATE); - std::unique_ptr device(Device::create(*platformDevices)); + std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(*platformDevices)); uint32_t svmSize = MemoryConstants::pageSize; char *svmPtr = reinterpret_cast(alignedMalloc(svmSize, MemoryConstants::pageSize)); diff --git a/unit_tests/kernel/kernel_is_patched_tests.cpp b/unit_tests/kernel/kernel_is_patched_tests.cpp index 4db9543dd8..034a87764b 100644 --- a/unit_tests/kernel/kernel_is_patched_tests.cpp +++ b/unit_tests/kernel/kernel_is_patched_tests.cpp @@ -32,7 +32,7 @@ class PatchedKernelTest : public ::testing::Test { public: void SetUp() override { constructPlatform(); - device.reset(MockDevice::create(nullptr)); + device.reset(MockDevice::createWithNewExecutionEnvironment(nullptr)); context.reset(new MockContext(device.get())); program.reset(Program::create("FillBufferBytes", context.get(), *device.get(), true, &retVal)); EXPECT_EQ(CL_SUCCESS, retVal); diff --git a/unit_tests/kernel/kernel_reflection_surface_tests.cpp b/unit_tests/kernel/kernel_reflection_surface_tests.cpp index c5766b78f7..d2b4dc1904 100644 --- a/unit_tests/kernel/kernel_reflection_surface_tests.cpp +++ b/unit_tests/kernel/kernel_reflection_surface_tests.cpp @@ -655,7 +655,7 @@ TEST(KernelReflectionSurfaceTestSingle, CreateKernelReflectionSurfaceCalledOnNon TEST(KernelReflectionSurfaceTestSingle, ObtainKernelReflectionSurfaceWithoutKernelArgs) { MockProgram program; MockContext context; - std::unique_ptr device(Device::create(platformDevices[0])); + std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); KernelInfo *blockInfo = new KernelInfo; KernelInfo &info = *blockInfo; cl_queue_properties properties[1] = {0}; @@ -706,7 +706,7 @@ TEST(KernelReflectionSurfaceTestSingle, ObtainKernelReflectionSurfaceWithoutKern TEST(KernelReflectionSurfaceTestSingle, ObtainKernelReflectionSurfaceWithDeviceQueueKernelArg) { MockProgram program; MockContext context; - std::unique_ptr device(Device::create(platformDevices[0])); + std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); KernelInfo *blockInfo = new KernelInfo; KernelInfo &info = *blockInfo; diff --git a/unit_tests/kernel/kernel_tests.cpp b/unit_tests/kernel/kernel_tests.cpp index ef9bdc8c11..e25dd682d9 100644 --- a/unit_tests/kernel/kernel_tests.cpp +++ b/unit_tests/kernel/kernel_tests.cpp @@ -2194,7 +2194,7 @@ TEST(KernelTest, givenKernelWithKernelInfoWith32bitPointerSizeThenReport32bit) { MockContext context; MockProgram program(&context, false); - std::unique_ptr device(Device::create(nullptr)); + std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(nullptr)); std::unique_ptr kernel(new MockKernel(&program, info, *device.get())); EXPECT_TRUE(kernel->is32Bit()); @@ -2206,7 +2206,7 @@ TEST(KernelTest, givenKernelWithKernelInfoWith64bitPointerSizeThenReport64bit) { MockContext context; MockProgram program(&context, false); - std::unique_ptr device(Device::create(nullptr)); + std::unique_ptr device(MockDevice::createWithNewExecutionEnvironment(nullptr)); std::unique_ptr kernel(new MockKernel(&program, info, *device.get())); EXPECT_FALSE(kernel->is32Bit()); diff --git a/unit_tests/main.cpp b/unit_tests/main.cpp index db94a3480c..ba7961ac88 100644 --- a/unit_tests/main.cpp +++ b/unit_tests/main.cpp @@ -142,16 +142,11 @@ LONG WINAPI UltExceptionFilter( #endif void initializeTestHelpers() { - const HardwareInfo *hwinfo = *platformDevices; - auto initialized = GmmHelper::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, - hwinfo->pWaTable, hwinfo->pSysInfo); - ASSERT_TRUE(initialized); GlobalMockSipProgram::initSipProgram(); } void cleanTestHelpers() { GlobalMockSipProgram::shutDownSipProgram(); - GmmHelper::destroyContext(); } std::string getHardwarePrefix() { diff --git a/unit_tests/mem_obj/buffer_tests.cpp b/unit_tests/mem_obj/buffer_tests.cpp index ec4d7e393a..a1047989f9 100644 --- a/unit_tests/mem_obj/buffer_tests.cpp +++ b/unit_tests/mem_obj/buffer_tests.cpp @@ -765,7 +765,7 @@ TEST(SharedBuffersTest, whenBuffersIsCreatedWithSharingHandlerThenItIsSharedBuff class BufferTests : public ::testing::Test { protected: void SetUp() override { - device.reset(Device::create(*platformDevices)); + device.reset(MockDevice::createWithNewExecutionEnvironment(*platformDevices)); } void TearDown() override { } diff --git a/unit_tests/mem_obj/image_tests.cpp b/unit_tests/mem_obj/image_tests.cpp index ac8efd6c73..62e2d4ad9e 100644 --- a/unit_tests/mem_obj/image_tests.cpp +++ b/unit_tests/mem_obj/image_tests.cpp @@ -955,7 +955,7 @@ class ImageCompressionTests : public ::testing::Test { void SetUp() override { myMemoryManager = new MyMemoryManager(); - mockDevice.reset(Device::create(*platformDevices)); + mockDevice.reset(MockDevice::createWithNewExecutionEnvironment(*platformDevices)); mockDevice->injectMemoryManager(myMemoryManager); mockContext.reset(new MockContext(mockDevice.get())); } diff --git a/unit_tests/mem_obj/image_transfer_tests.cpp b/unit_tests/mem_obj/image_transfer_tests.cpp index 5880ac032b..108e70c67f 100644 --- a/unit_tests/mem_obj/image_transfer_tests.cpp +++ b/unit_tests/mem_obj/image_transfer_tests.cpp @@ -31,7 +31,7 @@ class ImageHostPtrTransferTests : public testing::Test { public: void SetUp() override { - device.reset(Device::create(*platformDevices)); + device.reset(MockDevice::createWithNewExecutionEnvironment(*platformDevices)); context.reset(new MockContext(device.get())); } diff --git a/unit_tests/memory_manager/memory_manager_tests.cpp b/unit_tests/memory_manager/memory_manager_tests.cpp index 73014f2784..46fcc3d5c1 100644 --- a/unit_tests/memory_manager/memory_manager_tests.cpp +++ b/unit_tests/memory_manager/memory_manager_tests.cpp @@ -822,6 +822,8 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenAllocateGraphicsMemor imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); + ExecutionEnvironment execEnv; + execEnv.initGmm(*platformDevices); auto queryGmm = MockGmm::queryImgParams(imgInfo); auto imageAllocation = memoryManager.allocateGraphicsMemoryForImage(imgInfo, queryGmm.get()); diff --git a/unit_tests/mocks/mock_buffer.h b/unit_tests/mocks/mock_buffer.h index b854c20f35..c6576f6046 100644 --- a/unit_tests/mocks/mock_buffer.h +++ b/unit_tests/mocks/mock_buffer.h @@ -37,11 +37,13 @@ class MockBufferStorage { } char data[128]; MockGraphicsAllocation mockGfxAllocation; + std::unique_ptr device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); }; class MockBuffer : public MockBufferStorage, public Buffer { public: using Buffer::magic; + using MockBufferStorage::device; MockBuffer(GraphicsAllocation &alloc) : MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, alloc.getUnderlyingBufferSize(), alloc.getUnderlyingBuffer(), alloc.getUnderlyingBuffer(), &alloc, true, false, false), @@ -59,12 +61,12 @@ class MockBuffer : public MockBufferStorage, public Buffer { void setArgStateful(void *memory) override { Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), (externalAlloc != nullptr) ? externalAlloc : &mockGfxAllocation); } - std::unique_ptr device = std::unique_ptr(OCLRT::Device::create(nullptr)); GraphicsAllocation *externalAlloc = nullptr; }; class AlignedBuffer : public MockBufferStorage, public Buffer { public: + using MockBufferStorage::device; AlignedBuffer() : MockBufferStorage(false), Buffer(nullptr, CL_MEM_USE_HOST_PTR, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64), &mockGfxAllocation, true, false, false) { } AlignedBuffer(GraphicsAllocation *gfxAllocation) : MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64), gfxAllocation, true, false, false) { @@ -72,11 +74,11 @@ class AlignedBuffer : public MockBufferStorage, public Buffer { void setArgStateful(void *memory) override { Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), &mockGfxAllocation); } - std::unique_ptr device = std::unique_ptr(OCLRT::Device::create(nullptr)); }; class UnalignedBuffer : public MockBufferStorage, public Buffer { public: + using MockBufferStorage::device; UnalignedBuffer() : MockBufferStorage(true), Buffer(nullptr, CL_MEM_USE_HOST_PTR, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4), &mockGfxAllocation, false, false, false) { } UnalignedBuffer(GraphicsAllocation *gfxAllocation) : MockBufferStorage(true), Buffer(nullptr, CL_MEM_USE_HOST_PTR, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4), gfxAllocation, false, false, false) { @@ -84,5 +86,4 @@ class UnalignedBuffer : public MockBufferStorage, public Buffer { void setArgStateful(void *memory) override { Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), &mockGfxAllocation); } - std::unique_ptr device = std::unique_ptr(OCLRT::Device::create(nullptr)); }; diff --git a/unit_tests/mocks/mock_device.h b/unit_tests/mocks/mock_device.h index d0343b368c..85c99ed6b0 100644 --- a/unit_tests/mocks/mock_device.h +++ b/unit_tests/mocks/mock_device.h @@ -23,6 +23,7 @@ #pragma once #include "runtime/memory_manager/memory_manager.h" #include "runtime/device/device.h" +#include "runtime/execution_environment/execution_environment.h" #include "runtime/helpers/hw_info.h" #include "runtime/memory_manager/os_agnostic_memory_manager.h" #include "unit_tests/libult/ult_command_stream_receiver.h" @@ -102,6 +103,7 @@ class MockDevice : public Device { MemoryManager *memManager) { pHwInfo = getDeviceInitHwInfo(pHwInfo); T *device = new T(*pHwInfo); + device->connectToExecutionEnvironment(new ExecutionEnvironment); if (memManager) { device->setMemoryManager(memManager); } @@ -111,6 +113,10 @@ class MockDevice : public Device { } return device; } + template + static T *createWithNewExecutionEnvironment(const HardwareInfo *pHwInfo) { + return Device::create(pHwInfo, new ExecutionEnvironment); + } void allocatePreemptionAllocationIfNotPresent() { if (this->preemptionAllocation == nullptr) { diff --git a/unit_tests/mt_tests/device_queue/device_queue_mt_tests.cpp b/unit_tests/mt_tests/device_queue/device_queue_mt_tests.cpp index 8885cb40d0..b100118bd3 100644 --- a/unit_tests/mt_tests/device_queue/device_queue_mt_tests.cpp +++ b/unit_tests/mt_tests/device_queue/device_queue_mt_tests.cpp @@ -30,7 +30,7 @@ using namespace OCLRT; typedef ::testing::Test DeviceQueueHwMtTest; HWCMDTEST_F(IGFX_GEN8_CORE, DeviceQueueHwMtTest, givenTakenIgilCriticalSectionWhenSecondThreadIsWaitingThenDontHang) { - auto device = std::unique_ptr(Device::create(nullptr)); + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); auto context = std::unique_ptr(new MockContext()); cl_queue_properties properties[3] = {0}; diff --git a/unit_tests/os_interface/debug_settings_manager_tests.cpp b/unit_tests/os_interface/debug_settings_manager_tests.cpp index 4e2ea10c3b..df246485fc 100644 --- a/unit_tests/os_interface/debug_settings_manager_tests.cpp +++ b/unit_tests/os_interface/debug_settings_manager_tests.cpp @@ -399,7 +399,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDontDumpKernelArgsForNullMdi) { TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsForMdi) { MockProgram program; auto kernelInfo = unique_ptr(KernelInfo::create()); - auto device = unique_ptr(Device::create(nullptr)); + auto device = unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); auto kernel = unique_ptr(new MockKernel(&program, *kernelInfo, *device)); auto multiDispatchInfo = unique_ptr(new MockMultiDispatchInfo(kernel.get())); @@ -441,7 +441,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelNullKernel) { TEST(DebugSettingsManager, WithDebugFunctionalityAndEmptyKernelDontDumpKernelArgs) { MockProgram program; auto kernelInfo = unique_ptr(KernelInfo::create()); - auto device = unique_ptr(Device::create(nullptr)); + auto device = unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); auto kernel = unique_ptr(new MockKernel(&program, *kernelInfo, *device)); FullyEnabledTestDebugManager debugManager; @@ -455,7 +455,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityAndEmptyKernelDontDumpKernelArg TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsImmediate) { MockProgram program; auto kernelInfo = unique_ptr(KernelInfo::create()); - auto device = unique_ptr(Device::create(nullptr)); + auto device = unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); auto kernel = unique_ptr(new MockKernel(&program, *kernelInfo, *device)); KernelArgPatchInfo kernelArgPatchInfo; @@ -486,7 +486,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsImmediate) { TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsImmediateZeroSize) { MockProgram program; auto kernelInfo = unique_ptr(KernelInfo::create()); - auto device = unique_ptr(Device::create(nullptr)); + auto device = unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); auto kernel = unique_ptr(new MockKernel(&program, *kernelInfo, *device)); KernelArgPatchInfo kernelArgPatchInfo; @@ -514,7 +514,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsImmediateZeroSize TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsLocalBuffer) { MockProgram program; auto kernelInfo = unique_ptr(KernelInfo::create()); - auto device = unique_ptr(Device::create(nullptr)); + auto device = unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); auto kernel = unique_ptr(new MockKernel(&program, *kernelInfo, *device)); KernelArgPatchInfo kernelArgPatchInfo; @@ -535,7 +535,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsLocalBuffer) { TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsBufferNotSet) { MockProgram program; auto kernelInfo = unique_ptr(KernelInfo::create()); - auto device = unique_ptr(Device::create(nullptr)); + auto device = unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); auto kernel = unique_ptr(new MockKernel(&program, *kernelInfo, *device)); KernelArgPatchInfo kernelArgPatchInfo; @@ -566,7 +566,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsBuffer) { MockProgram program(&context, false); auto kernelInfo = unique_ptr(KernelInfo::create()); - auto device = unique_ptr(Device::create(nullptr)); + auto device = unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); auto kernel = unique_ptr(new MockKernel(&program, *kernelInfo, *device)); KernelArgPatchInfo kernelArgPatchInfo; @@ -600,7 +600,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsBuffer) { TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsSampler) { MockProgram program; auto kernelInfo = unique_ptr(KernelInfo::create()); - auto device = unique_ptr(Device::create(nullptr)); + auto device = unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); auto kernel = unique_ptr(new MockKernel(&program, *kernelInfo, *device)); KernelArgPatchInfo kernelArgPatchInfo; @@ -623,7 +623,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsSampler) { TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsImageNotSet) { MockProgram program; auto kernelInfo = unique_ptr(KernelInfo::create()); - auto device = unique_ptr(Device::create(nullptr)); + auto device = unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); auto kernel = unique_ptr(new MockKernel(&program, *kernelInfo, *device)); SKernelBinaryHeaderCommon kernelHeader; @@ -900,4 +900,3 @@ TEST(DebugSettingsManager, whenOnlyRegKeysAreEnabledThenAllOtherDebugFunctionali static_assert(false == debugManager.kernelArgDumpingAvailable(), ""); static_assert(debugManager.registryReadAvailable(), ""); } - diff --git a/unit_tests/os_interface/linux/device_os_tests.cpp b/unit_tests/os_interface/linux/device_os_tests.cpp index fa89a65660..88bb5025ab 100644 --- a/unit_tests/os_interface/linux/device_os_tests.cpp +++ b/unit_tests/os_interface/linux/device_os_tests.cpp @@ -38,7 +38,7 @@ using namespace ::testing; namespace OCLRT { TEST(DeviceOsTest, osSpecificExtensions) { auto hwInfo = *platformDevices; - auto pDevice = Device::create(hwInfo); + auto pDevice = MockDevice::createWithNewExecutionEnvironment(hwInfo); std::string extensionString(pDevice->getDeviceInfo().deviceExtensions); @@ -53,7 +53,7 @@ TEST(DeviceOsTest, osSpecificExtensions) { } TEST(DeviceOsTest, supportedSimultaneousInterops) { - auto pDevice = std::unique_ptr(Device::create(*platformDevices)); + auto pDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(*platformDevices)); std::vector expected = {0}; @@ -62,7 +62,7 @@ TEST(DeviceOsTest, supportedSimultaneousInterops) { TEST(DeviceOsTest, DeviceCreationFail) { auto hwInfo = *platformDevices; - auto pDevice = Device::create(hwInfo); + auto pDevice = MockDevice::createWithNewExecutionEnvironment(hwInfo); EXPECT_THAT(pDevice, nullptr); } @@ -112,7 +112,7 @@ TEST(ApiOsTest, notSupportedApiList) { TEST(DeviceOsTest, DeviceCreationFailMidThreadPreemption) { DebugManagerStateRestore dbgRestore; DebugManager.flags.ForcePreemptionMode.set(static_cast(PreemptionMode::MidThread)); - auto pDevice = Device::create(nullptr); + auto pDevice = MockDevice::createWithNewExecutionEnvironment(nullptr); EXPECT_THAT(pDevice, nullptr); } diff --git a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp index 32afe30f33..7bbca6d8f9 100644 --- a/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp +++ b/unit_tests/os_interface/linux/drm_memory_manager_tests.cpp @@ -1120,7 +1120,7 @@ TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenAllHeapsAreExh DebugManagerStateRestore dbgRestorer; DebugManager.flags.Force32bitAddressing.set(true); - std::unique_ptr pDevice(Device::create(nullptr)); + std::unique_ptr pDevice(MockDevice::createWithNewExecutionEnvironment(nullptr)); memoryManager->device = pDevice.get(); memoryManager->setForce32BitAllocations(true); @@ -1150,7 +1150,7 @@ TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenAllHeapsAreExh DebugManagerStateRestore dbgRestorer; DebugManager.flags.Force32bitAddressing.set(true); - std::unique_ptr pDevice(Device::create(nullptr)); + std::unique_ptr pDevice(MockDevice::createWithNewExecutionEnvironment(nullptr)); pDevice->increaseProgramCount(); memoryManager->device = pDevice.get(); memoryManager->setForce32BitAllocations(true); @@ -1166,7 +1166,7 @@ TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenInternalHeapIs DebugManagerStateRestore dbgStateRestore; DebugManager.flags.Force32bitAddressing.set(true); memoryManager->setForce32BitAllocations(true); - std::unique_ptr pDevice(Device::create(nullptr)); + std::unique_ptr pDevice(MockDevice::createWithNewExecutionEnvironment(nullptr)); memoryManager->device = pDevice.get(); auto allocator = memoryManager->getDrmInternal32BitAllocator(); @@ -1195,6 +1195,8 @@ TEST_F(DrmMemoryManagerTest, GivenMemoryManagerWhenAllocateGraphicsMemoryForImag imgInfo.size = 4096u; imgInfo.rowPitch = 512u; + ExecutionEnvironment execEnv; + execEnv.initGmm(*platformDevices); auto queryGmm = MockGmm::queryImgParams(imgInfo); auto imageGraphicsAllocation = memoryManager->allocateGraphicsMemoryForImage(imgInfo, queryGmm.get()); queryGmm.release(); @@ -1738,6 +1740,8 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAlloca imgInfo.size = 4096u; imgInfo.rowPitch = 512u; + ExecutionEnvironment execEnv; + execEnv.initGmm(*platformDevices); auto queryGmm = MockGmm::queryImgParams(imgInfo); auto allocation = memoryManager->allocateGraphicsMemoryForImage(imgInfo, queryGmm.get()); queryGmm.release(); diff --git a/unit_tests/os_interface/performance_counters_tests.cpp b/unit_tests/os_interface/performance_counters_tests.cpp index e0d72fd04d..55b05d958c 100644 --- a/unit_tests/os_interface/performance_counters_tests.cpp +++ b/unit_tests/os_interface/performance_counters_tests.cpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017, Intel Corporation +* Copyright (c) 2017 - 2018, Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -24,6 +24,7 @@ #include "runtime/os_interface/os_time.h" #include "runtime/os_interface/os_interface.h" #include "unit_tests/os_interface/mock_performance_counters.h" +#include "unit_tests/mocks/mock_device.h" #include "gtest/gtest.h" using namespace OCLRT; @@ -46,7 +47,7 @@ struct PerformanceCountersDeviceTest : public PerformanceCountersDeviceFixture, TEST_F(PerformanceCountersDeviceTest, createDeviceWithPerformanceCounters) { hwInfoToModify->capabilityTable.instrumentationEnabled = true; - auto device = Device::create(hwInfoToModify); + auto device = MockDevice::createWithNewExecutionEnvironment(hwInfoToModify); EXPECT_NE(nullptr, device->getPerformanceCounters()); EXPECT_EQ(1, PerfCounterFlags::initalizeCalled); delete device; @@ -54,7 +55,7 @@ TEST_F(PerformanceCountersDeviceTest, createDeviceWithPerformanceCounters) { TEST_F(PerformanceCountersDeviceTest, createDeviceWithoutPerformanceCounters) { hwInfoToModify->capabilityTable.instrumentationEnabled = false; - auto device = Device::create(hwInfoToModify); + auto device = MockDevice::createWithNewExecutionEnvironment(hwInfoToModify); EXPECT_EQ(nullptr, device->getPerformanceCounters()); EXPECT_EQ(0, PerfCounterFlags::initalizeCalled); delete device; diff --git a/unit_tests/os_interface/windows/device_command_stream_tests.cpp b/unit_tests/os_interface/windows/device_command_stream_tests.cpp index 22118d9c44..9f73bcc96d 100644 --- a/unit_tests/os_interface/windows/device_command_stream_tests.cpp +++ b/unit_tests/os_interface/windows/device_command_stream_tests.cpp @@ -76,7 +76,7 @@ class WddmCommandStreamFixture { memManager = mockWddmMM; csr->setMemoryManager(memManager); - device = MockDevice::create(platformDevices[0]); + device = MockDevice::createWithNewExecutionEnvironment(platformDevices[0]); ASSERT_NE(nullptr, device); memManager->device = device; diff --git a/unit_tests/os_interface/windows/device_os_tests.cpp b/unit_tests/os_interface/windows/device_os_tests.cpp index 639f04245d..8ca7d09531 100644 --- a/unit_tests/os_interface/windows/device_os_tests.cpp +++ b/unit_tests/os_interface/windows/device_os_tests.cpp @@ -32,7 +32,7 @@ using namespace ::testing; namespace OCLRT { TEST(DeviceOsTest, osSpecificExtensions) { auto hwInfo = *platformDevices; - auto pDevice = Device::create(hwInfo); + auto pDevice = MockDevice::createWithNewExecutionEnvironment(hwInfo); std::string extensionString(pDevice->getDeviceInfo().deviceExtensions); @@ -48,7 +48,7 @@ TEST(DeviceOsTest, osSpecificExtensions) { } TEST(DeviceOsTest, supportedSimultaneousInterops) { - auto pDevice = std::unique_ptr(Device::create(*platformDevices)); + auto pDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(*platformDevices)); std::vector expected = {CL_GL_CONTEXT_KHR, CL_WGL_HDC_KHR, @@ -67,7 +67,7 @@ TEST(DeviceOsTest, supportedSimultaneousInterops) { TEST(DeviceOsTest, DeviceCreationFail) { auto hwInfo = *platformDevices; - auto pDevice = Device::create(hwInfo); + auto pDevice = MockDevice::createWithNewExecutionEnvironment(hwInfo); EXPECT_THAT(pDevice, nullptr); } @@ -75,7 +75,7 @@ TEST(DeviceOsTest, DeviceCreationFail) { TEST(DeviceOsTest, DeviceCreationFailMidThreadPreemption) { DebugManagerStateRestore dbgRestore; DebugManager.flags.ForcePreemptionMode.set(static_cast(PreemptionMode::MidThread)); - auto pDevice = Device::create(nullptr); + auto pDevice = MockDevice::createWithNewExecutionEnvironment(nullptr); EXPECT_THAT(pDevice, nullptr); } diff --git a/unit_tests/os_interface/windows/driver_info_tests.cpp b/unit_tests/os_interface/windows/driver_info_tests.cpp index 369df15d56..1866bbd5df 100644 --- a/unit_tests/os_interface/windows/driver_info_tests.cpp +++ b/unit_tests/os_interface/windows/driver_info_tests.cpp @@ -69,7 +69,7 @@ Wddm *DriverInfoDeviceTest::wddmMock = nullptr; TEST_F(DriverInfoDeviceTest, GivenDeviceCreatedWhenCorrectOSInterfaceThenCreateDriverInfo) { overrideCommandStreamReceiverCreation = true; - auto device = Device::create(hwInfo); + auto device = MockDevice::createWithNewExecutionEnvironment(hwInfo); EXPECT_TRUE(device->hasDriverInfo()); delete device; @@ -77,7 +77,7 @@ TEST_F(DriverInfoDeviceTest, GivenDeviceCreatedWhenCorrectOSInterfaceThenCreateD TEST_F(DriverInfoDeviceTest, GivenDeviceCreatedWithoutCorrectOSInterfaceThenDontCreateDriverInfo) { overrideCommandStreamReceiverCreation = false; - auto device = Device::create(hwInfo); + auto device = MockDevice::createWithNewExecutionEnvironment(hwInfo); EXPECT_FALSE(device->hasDriverInfo()); delete device; diff --git a/unit_tests/os_interface/windows/wddm20_tests.cpp b/unit_tests/os_interface/windows/wddm20_tests.cpp index b07a1cce07..d7259262a3 100644 --- a/unit_tests/os_interface/windows/wddm20_tests.cpp +++ b/unit_tests/os_interface/windows/wddm20_tests.cpp @@ -22,6 +22,7 @@ #include "unit_tests/os_interface/windows/wddm_fixture.h" +#include "runtime/execution_environment/execution_environment.h" #include "runtime/gmm_helper/gmm.h" #include "runtime/gmm_helper/gmm_helper.h" #include "runtime/helpers/hw_info.h" @@ -531,8 +532,9 @@ HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceOnInit) { D3DKMT_HANDLE adapterHandle = ADAPTER_HANDLE; D3DKMT_HANDLE deviceHandle = DEVICE_HANDLE; const HardwareInfo hwInfo = *platformDevices[0]; + ExecutionEnvironment execEnv; + execEnv.initGmm(&hwInfo); BOOLEAN FtrL3IACoherency = hwInfo.pSkuTable->ftrL3IACoherency ? 1 : 0; - EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(adapterHandle, deviceHandle, wddm->gdi->escape.mFunc, @@ -551,6 +553,8 @@ HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceOnInit) { HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoAdapter) { wddm->adapter = static_cast(0); + ExecutionEnvironment execEnv; + execEnv.initGmm(*platformDevices); EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(static_cast(0), ::testing::_, ::testing::_, @@ -569,6 +573,8 @@ HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoAdapter) { HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoDevice) { wddm->device = static_cast(0); + ExecutionEnvironment execEnv; + execEnv.initGmm(*platformDevices); EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(::testing::_, static_cast(0), ::testing::_, @@ -587,6 +593,8 @@ HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoDevice) { HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoEscFunc) { wddm->gdi->escape = static_cast(nullptr); + ExecutionEnvironment execEnv; + execEnv.initGmm(*platformDevices); EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(::testing::_, ::testing::_, static_cast(nullptr), diff --git a/unit_tests/os_interface/windows/wddm_calls.cpp b/unit_tests/os_interface/windows/wddm_calls.cpp index 8568a4eadc..fbeaec7b65 100644 --- a/unit_tests/os_interface/windows/wddm_calls.cpp +++ b/unit_tests/os_interface/windows/wddm_calls.cpp @@ -49,10 +49,4 @@ Wddm::VirtualFreeFcn getVirtualFree() { Wddm::VirtualAllocFcn getVirtualAlloc() { return ULTVirtualAlloc; } - -bool Wddm::initGmmContext() { - return true; -} - -void Wddm::destroyGmmContext() {} } // namespace OCLRT diff --git a/unit_tests/preamble/preamble_tests.cpp b/unit_tests/preamble/preamble_tests.cpp index a91f1771ad..22d36667f4 100644 --- a/unit_tests/preamble/preamble_tests.cpp +++ b/unit_tests/preamble/preamble_tests.cpp @@ -38,7 +38,7 @@ using PreambleTest = ::testing::Test; using namespace OCLRT; HWTEST_F(PreambleTest, PreemptionIsTakenIntoAccountWhenProgrammingPreamble) { - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); mockDevice->setPreemptionMode(PreemptionMode::MidThread); auto cmdSizePreambleMidThread = PreambleHelper::getAdditionalCommandsSize(*mockDevice); @@ -122,7 +122,7 @@ HWTEST_F(PreambleTest, whenKernelDebuggingCommandsAreProgrammedThenCorrectComman HWTEST_F(PreambleTest, givenKernelDebuggingActiveWhenPreambleIsProgrammedThenProgramKernelDebuggingIsCalled) { typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); mockDevice->setPreemptionMode(PreemptionMode::Disabled); mockDevice->setSourceLevelDebuggerActive(false); @@ -157,7 +157,7 @@ HWTEST_F(PreambleTest, givenKernelDebuggingActiveWhenPreambleIsProgrammedThenPro } HWTEST_F(PreambleTest, givenKernelDebuggingActiveAndMidThreadPreemptionWhenGetAdditionalCommandsSizeIsCalledThen2MiLoadRegisterImmCmdsAreAdded) { - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); mockDevice->setPreemptionMode(PreemptionMode::MidThread); mockDevice->setSourceLevelDebuggerActive(false); diff --git a/unit_tests/preemption/preemption_tests.cpp b/unit_tests/preemption/preemption_tests.cpp index 0e24e3d232..8798142e1a 100644 --- a/unit_tests/preemption/preemption_tests.cpp +++ b/unit_tests/preemption/preemption_tests.cpp @@ -318,7 +318,7 @@ HWTEST_P(PreemptionHwTest, getRequiredCmdStreamSizeReturns0WhenPreemptionModeIsN StackVec buffer(requiredSize); LinearStream cmdStream(buffer.begin(), buffer.size()); - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); { MockBuiltins tmpBuiltins; tmpBuiltins.overrideSipKernel(std::unique_ptr(new OCLRT::SipKernel{SipKernelType::Csr, getSipProgramWithCustomBinary()})); @@ -346,7 +346,7 @@ HWTEST_P(PreemptionHwTest, getRequiredCmdStreamSizeReturnsSizeOfMiLoadRegisterIm StackVec buffer(requiredSize); LinearStream cmdStream(buffer.begin(), buffer.size()); - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); size_t minCsrSize = mockDevice->getHardwareInfo().pSysInfo->CsrSizeInMb * MemoryConstants::megaByte; uint64_t minCsrAlignment = 2 * 256 * MemoryConstants::kiloByte; @@ -360,7 +360,7 @@ HWTEST_P(PreemptionHwTest, getRequiredCmdStreamSizeReturnsSizeOfMiLoadRegisterIm HWTEST_P(PreemptionHwTest, programCmdStreamAddsProperMiLoadRegisterImmCommandToTheStream) { PreemptionMode mode = GetParam(); PreemptionMode differentPreemptionMode = static_cast(0); - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); if (false == GetPreemptionTestHwDetails().supportsPreemptionProgramming()) { LinearStream cmdStream(nullptr, 0U); @@ -409,7 +409,7 @@ HWTEST_F(MidThreadPreemptionTests, createCsrSurfaceNoWa) { tmpWaTable.waCSRUncachable = false; const_cast(platformDevices[0])->pWaTable = &tmpWaTable; - std::unique_ptr mockDevice(Device::create(platformDevices[0])); + std::unique_ptr mockDevice(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); ASSERT_NE(nullptr, mockDevice.get()); auto &csr = mockDevice->getUltCommandStreamReceiver(); @@ -429,7 +429,7 @@ HWTEST_F(MidThreadPreemptionTests, createCsrSurfaceWa) { tmpWaTable.waCSRUncachable = true; const_cast(platformDevices[0])->pWaTable = &tmpWaTable; - std::unique_ptr mockDevice(Device::create(platformDevices[0])); + std::unique_ptr mockDevice(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); ASSERT_NE(nullptr, mockDevice.get()); auto &csr = mockDevice->getUltCommandStreamReceiver(); diff --git a/unit_tests/program/printf_helper_tests.cpp b/unit_tests/program/printf_helper_tests.cpp index 1e952377fa..55923fe7ca 100644 --- a/unit_tests/program/printf_helper_tests.cpp +++ b/unit_tests/program/printf_helper_tests.cpp @@ -23,6 +23,7 @@ #include "runtime/helpers/aligned_memory.h" #include "runtime/helpers/string.h" #include "runtime/program/print_formatter.h" +#include "unit_tests/mocks/mock_device.h" #include "unit_tests/mocks/mock_kernel.h" #include "unit_tests/mocks/mock_program.h" #include "unit_tests/mocks/mock_graphics_allocation.h" @@ -59,7 +60,7 @@ class PrintFormatterTest : public testing::Test { data = new MockGraphicsAllocation(underlyingBuffer, PrintFormatter::maxPrintfOutputLength); kernelInfo = KernelInfo::create(); - device = Device::create(nullptr); + device = MockDevice::createWithNewExecutionEnvironment(nullptr); kernel = new MockKernel(&program, *kernelInfo, *device); printFormatter = new PrintFormatter(*kernel, *data); diff --git a/unit_tests/source_level_debugger/source_level_debugger_csr_tests.cpp b/unit_tests/source_level_debugger/source_level_debugger_csr_tests.cpp index 0a5ad78c7e..40073ec1aa 100644 --- a/unit_tests/source_level_debugger/source_level_debugger_csr_tests.cpp +++ b/unit_tests/source_level_debugger/source_level_debugger_csr_tests.cpp @@ -33,7 +33,7 @@ typedef ::testing::Test CommandStreamReceiverWithActiveDebuggerTest; HWTEST_F(CommandStreamReceiverWithActiveDebuggerTest, givenCsrWithActiveDebuggerAndDisabledPreemptionWhenFlushTaskIsCalledThenSipKernelIsMadeResident) { - auto device = std::unique_ptr(Device::create(nullptr)); + auto device = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); device->setSourceLevelDebuggerActive(true); device->allocatePreemptionAllocationIfNotPresent(); auto mockCsr = new MockCsrHw2(*platformDevices[0]); diff --git a/unit_tests/source_level_debugger/source_level_debugger_device_tests.cpp b/unit_tests/source_level_debugger/source_level_debugger_device_tests.cpp index af97581a19..933c9d0063 100644 --- a/unit_tests/source_level_debugger/source_level_debugger_device_tests.cpp +++ b/unit_tests/source_level_debugger/source_level_debugger_device_tests.cpp @@ -73,7 +73,7 @@ TEST(DeviceCreation, givenDeviceWithMidThreadPreemptionAndDebuggingActiveWhenDev EXPECT_FALSE(mockBuiltins->getSipKernelCalled); DebugManager.flags.ForcePreemptionMode.set((int32_t)PreemptionMode::MidThread); - auto device = std::unique_ptr>(Device::create>(nullptr)); + auto device = std::unique_ptr>(MockDevice::createWithNewExecutionEnvironment>(nullptr)); EXPECT_TRUE(mockBuiltins->getSipKernelCalled); EXPECT_LE(SipKernelType::DbgCsr, mockBuiltins->getSipKernelType); @@ -96,7 +96,7 @@ TEST(DeviceCreation, givenDeviceWithDisabledPreemptionAndDebuggingActiveWhenDevi EXPECT_FALSE(mockBuiltins->getSipKernelCalled); DebugManager.flags.ForcePreemptionMode.set((int32_t)PreemptionMode::Disabled); - auto device = std::unique_ptr>(Device::create>(nullptr)); + auto device = std::unique_ptr>(MockDevice::createWithNewExecutionEnvironment>(nullptr)); EXPECT_TRUE(mockBuiltins->getSipKernelCalled); EXPECT_LE(SipKernelType::DbgCsr, mockBuiltins->getSipKernelType); @@ -107,12 +107,12 @@ TEST(DeviceCreation, givenDeviceWithDisabledPreemptionAndDebuggingActiveWhenDevi } TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsDestructedThenSourceLevelDebuggerIsNotified) { - auto device = std::unique_ptr>>(Device::create>>(nullptr)); + auto device = std::unique_ptr>>(MockDevice::createWithNewExecutionEnvironment>>(nullptr)); GMockSourceLevelDebugger *gmock = device->getSourceLevelDebugger(); EXPECT_CALL(*gmock, notifyDeviceDestruction()).Times(1); } TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsCreatedThenPreemptionIsDisabled) { - auto device = std::unique_ptr>(Device::create>(nullptr)); + auto device = std::unique_ptr>(MockDevice::createWithNewExecutionEnvironment>(nullptr)); EXPECT_EQ(PreemptionMode::Disabled, device->getPreemptionMode()); } diff --git a/unit_tests/source_level_debugger/source_level_debugger_preamble_test.inl b/unit_tests/source_level_debugger/source_level_debugger_preamble_test.inl index 0d13314223..38939d1090 100644 --- a/unit_tests/source_level_debugger/source_level_debugger_preamble_test.inl +++ b/unit_tests/source_level_debugger/source_level_debugger_preamble_test.inl @@ -25,7 +25,7 @@ using namespace OCLRT; template void SourceLevelDebuggerPreambleTest::givenMidThreadPreemptionAndDebuggingActiveWhenPreambleIsPrograamedThenCorrectSipKernelIsUsedTest() { using STATE_SIP = typename GfxFamily::STATE_SIP; - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); mockDevice->setSourceLevelDebuggerActive(true); mockDevice->setPreemptionMode(PreemptionMode::MidThread); @@ -54,7 +54,7 @@ void SourceLevelDebuggerPreambleTest::givenMidThreadPreemptionAndDebu template void SourceLevelDebuggerPreambleTest::givenMidThreadPreemptionAndDisabledDebuggingWhenPreambleIsPrograamedThenCorrectSipKernelIsUsedTest() { using STATE_SIP = typename GfxFamily::STATE_SIP; - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); mockDevice->setSourceLevelDebuggerActive(false); mockDevice->setPreemptionMode(PreemptionMode::MidThread); @@ -83,7 +83,7 @@ void SourceLevelDebuggerPreambleTest::givenMidThreadPreemptionAndDisa template void SourceLevelDebuggerPreambleTest::givenPreemptionDisabledAndDebuggingActiveWhenPreambleIsProgrammedThenCorrectSipKernelIsUsedTest() { using STATE_SIP = typename GfxFamily::STATE_SIP; - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); mockDevice->setSourceLevelDebuggerActive(true); mockDevice->setPreemptionMode(PreemptionMode::Disabled); @@ -111,7 +111,7 @@ void SourceLevelDebuggerPreambleTest::givenPreemptionDisabledAndDebug template void SourceLevelDebuggerPreambleTest::givenMidThreadPreemptionAndDebuggingActiveWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest() { - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); mockDevice->setSourceLevelDebuggerActive(true); mockDevice->setPreemptionMode(PreemptionMode::MidThread); size_t requiredPreambleSize = PreemptionHelper::getRequiredPreambleSize(*mockDevice); @@ -121,7 +121,7 @@ void SourceLevelDebuggerPreambleTest::givenMidThreadPreemptionAndDebu template void SourceLevelDebuggerPreambleTest::givenPreemptionDisabledAndDebuggingActiveWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest() { - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); mockDevice->setSourceLevelDebuggerActive(true); mockDevice->setPreemptionMode(PreemptionMode::Disabled); size_t requiredPreambleSize = PreemptionHelper::getRequiredPreambleSize(*mockDevice); @@ -131,7 +131,7 @@ void SourceLevelDebuggerPreambleTest::givenPreemptionDisabledAndDebug template void SourceLevelDebuggerPreambleTest::givenMidThreadPreemptionAndDisabledDebuggingWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest() { - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); mockDevice->setSourceLevelDebuggerActive(false); mockDevice->setPreemptionMode(PreemptionMode::MidThread); size_t requiredPreambleSize = PreemptionHelper::getRequiredPreambleSize(*mockDevice); @@ -141,7 +141,7 @@ void SourceLevelDebuggerPreambleTest::givenMidThreadPreemptionAndDisa template void SourceLevelDebuggerPreambleTest::givenDisabledPreemptionAndDisabledDebuggingWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest() { - auto mockDevice = std::unique_ptr(MockDevice::create(nullptr)); + auto mockDevice = std::unique_ptr(MockDevice::createWithNewExecutionEnvironment(nullptr)); mockDevice->setSourceLevelDebuggerActive(false); mockDevice->setPreemptionMode(PreemptionMode::Disabled); size_t requiredPreambleSize = PreemptionHelper::getRequiredPreambleSize(*mockDevice); diff --git a/unit_tests/source_level_debugger/source_level_debugger_tests.cpp b/unit_tests/source_level_debugger/source_level_debugger_tests.cpp index 50f1188a2f..f26e32b29f 100644 --- a/unit_tests/source_level_debugger/source_level_debugger_tests.cpp +++ b/unit_tests/source_level_debugger/source_level_debugger_tests.cpp @@ -409,8 +409,7 @@ TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenDeviceImplIsCreate DebuggerLibrary::setDebuggerActive(true); DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor); - unique_ptr device(new MockDevice(*platformDevices[0])); - MockDevice::createDeviceImpl(platformDevices[0], *device.get()); + unique_ptr device(MockDevice::createWithNewExecutionEnvironment(*platformDevices)); EXPECT_TRUE(interceptor.newDeviceCalled); uint32_t deviceHandleExpected = device->getCommandStreamReceiver().getOSInterface() != nullptr ? device->getCommandStreamReceiver().getOSInterface()->getDeviceHandle() : 0; EXPECT_EQ(reinterpret_cast(static_cast(deviceHandleExpected)), interceptor.newDeviceArgIn.dh); @@ -429,7 +428,7 @@ TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenDeviceImplIsCreate overrideCommandStreamReceiverCreation = true; // Device::create must be used to create correct OS memory manager - unique_ptr device(Device::create(platformDevices[0])); + unique_ptr device(MockDevice::createWithNewExecutionEnvironment(platformDevices[0])); ASSERT_NE(nullptr, device->getCommandStreamReceiver().getOSInterface()); EXPECT_TRUE(interceptor.newDeviceCalled);