Add instance of gmm helper to execution environment

Change-Id: I1b044611fbad91fbb681ba233938f41502f29056
This commit is contained in:
Mateusz Jablonski 2018-07-03 10:00:12 +02:00 committed by sys_ocldev
parent f26535a93d
commit 94dbdb602d
67 changed files with 220 additions and 204 deletions

2
Jenkinsfile vendored
View File

@ -1,4 +1,4 @@
#!groovy #!groovy
neoDependenciesRev='775910-972' neoDependenciesRev='775910-972'
strategy='EQUAL' strategy='EQUAL'
allowedCD=297 allowedCD=298

View File

@ -41,27 +41,15 @@ CommandStreamReceiver *createCommandStreamImpl(const HardwareInfo *pHwInfo) {
if (csr) { if (csr) {
switch (csr) { switch (csr) {
case CSR_AUB: case CSR_AUB:
GmmHelper::initContext(pHwInfo->pPlatform,
pHwInfo->pSkuTable,
pHwInfo->pWaTable,
pHwInfo->pSysInfo);
commandStreamReceiver = AUBCommandStreamReceiver::create(*pHwInfo, "aubfile", true); commandStreamReceiver = AUBCommandStreamReceiver::create(*pHwInfo, "aubfile", true);
break; break;
case CSR_TBX: case CSR_TBX:
GmmHelper::initContext(pHwInfo->pPlatform,
pHwInfo->pSkuTable,
pHwInfo->pWaTable,
pHwInfo->pSysInfo);
commandStreamReceiver = TbxCommandStreamReceiver::create(*pHwInfo, false); commandStreamReceiver = TbxCommandStreamReceiver::create(*pHwInfo, false);
break; break;
case CSR_HW_WITH_AUB: case CSR_HW_WITH_AUB:
commandStreamReceiver = funcCreate(*pHwInfo, true); commandStreamReceiver = funcCreate(*pHwInfo, true);
break; break;
case CSR_TBX_WITH_AUB: case CSR_TBX_WITH_AUB:
GmmHelper::initContext(pHwInfo->pPlatform,
pHwInfo->pSkuTable,
pHwInfo->pWaTable,
pHwInfo->pSysInfo);
commandStreamReceiver = TbxCommandStreamReceiver::create(*pHwInfo, true); commandStreamReceiver = TbxCommandStreamReceiver::create(*pHwInfo, true);
break; break;
default: default:

View File

@ -134,6 +134,7 @@ Device::~Device() {
} }
bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) { bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) {
outDevice.executionEnvironment->initGmm(pHwInfo);
CommandStreamReceiver *commandStreamReceiver = createCommandStream(pHwInfo); CommandStreamReceiver *commandStreamReceiver = createCommandStream(pHwInfo);
if (!commandStreamReceiver) { if (!commandStreamReceiver) {
return false; return false;

View File

@ -53,9 +53,10 @@ class Device : public BaseObject<_cl_device_id> {
static const cl_ulong objectMagic = 0x8055832341AC8D08LL; static const cl_ulong objectMagic = 0x8055832341AC8D08LL;
template <typename T> template <typename T>
static T *create(const HardwareInfo *pHwInfo) { static T *create(const HardwareInfo *pHwInfo, ExecutionEnvironment *execEnv) {
pHwInfo = getDeviceInitHwInfo(pHwInfo); pHwInfo = getDeviceInitHwInfo(pHwInfo);
T *device = new T(*pHwInfo); T *device = new T(*pHwInfo);
device->connectToExecutionEnvironment(execEnv);
if (false == createDeviceImpl(pHwInfo, *device)) { if (false == createDeviceImpl(pHwInfo, *device)) {
delete device; delete device;
return nullptr; return nullptr;

View File

@ -21,8 +21,15 @@
*/ */
#include "runtime/execution_environment/execution_environment.h" #include "runtime/execution_environment/execution_environment.h"
#include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/os_interface/device_factory.h" #include "runtime/os_interface/device_factory.h"
OCLRT::ExecutionEnvironment::~ExecutionEnvironment() { namespace OCLRT {
ExecutionEnvironment::ExecutionEnvironment() = default;
ExecutionEnvironment::~ExecutionEnvironment() {
DeviceFactory::releaseDevices(); DeviceFactory::releaseDevices();
} }
void ExecutionEnvironment::initGmm(const HardwareInfo *hwInfo) {
gmmHelper.reset(new GmmHelper(hwInfo));
}
} // namespace OCLRT

View File

@ -23,8 +23,15 @@
#include "runtime/utilities/reference_tracked_object.h" #include "runtime/utilities/reference_tracked_object.h"
namespace OCLRT { namespace OCLRT {
class GmmHelper;
struct HardwareInfo;
class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment> { class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment> {
public: public:
ExecutionEnvironment();
~ExecutionEnvironment() override; ~ExecutionEnvironment() override;
void initGmm(const HardwareInfo *hwInfo);
protected:
std::unique_ptr<GmmHelper> gmmHelper;
}; };
} // namespace OCLRT } // namespace OCLRT

View File

@ -30,9 +30,10 @@
#include "runtime/helpers/surface_formats.h" #include "runtime/helpers/surface_formats.h"
#include "runtime/helpers/hw_info.h" #include "runtime/helpers/hw_info.h"
#include "runtime/sku_info/operations/sku_info_transfer.h" #include "runtime/sku_info/operations/sku_info_transfer.h"
#include "runtime/os_interface/os_library.h"
namespace OCLRT { namespace OCLRT {
bool GmmHelper::initContext(const PLATFORM *pPlatform, void GmmHelper::initContext(const PLATFORM *pPlatform,
const FeatureTable *pSkuTable, const FeatureTable *pSkuTable,
const WorkaroundTable *pWaTable, const WorkaroundTable *pWaTable,
const GT_SYSTEM_INFO *pGtSysInfo) { const GT_SYSTEM_INFO *pGtSysInfo) {
@ -41,14 +42,12 @@ bool GmmHelper::initContext(const PLATFORM *pPlatform,
_WA_TABLE gmmWaTable = {}; _WA_TABLE gmmWaTable = {};
SkuInfoTransfer::transferFtrTableForGmm(&gmmFtrTable, pSkuTable); SkuInfoTransfer::transferFtrTableForGmm(&gmmFtrTable, pSkuTable);
SkuInfoTransfer::transferWaTableForGmm(&gmmWaTable, pWaTable); SkuInfoTransfer::transferWaTableForGmm(&gmmWaTable, pWaTable);
if (!isLoaded) { loadLib();
loadLib();
}
bool success = GMM_SUCCESS == initGlobalContextFunc(*pPlatform, &gmmFtrTable, &gmmWaTable, pGtSysInfo, GMM_CLIENT::GMM_OCL_VISTA); bool success = GMM_SUCCESS == initGlobalContextFunc(*pPlatform, &gmmFtrTable, &gmmWaTable, pGtSysInfo, GMM_CLIENT::GMM_OCL_VISTA);
UNRECOVERABLE_IF(!success); UNRECOVERABLE_IF(!success);
GmmHelper::gmmClientContext = GmmHelper::createClientContextFunc(GMM_CLIENT::GMM_OCL_VISTA); GmmHelper::gmmClientContext = GmmHelper::createClientContextFunc(GMM_CLIENT::GMM_OCL_VISTA);
} }
return GmmHelper::gmmClientContext != nullptr; UNRECOVERABLE_IF(!GmmHelper::gmmClientContext);
} }
void GmmHelper::destroyContext() { void GmmHelper::destroyContext() {
@ -56,6 +55,10 @@ void GmmHelper::destroyContext() {
deleteClientContextFunc(GmmHelper::gmmClientContext); deleteClientContextFunc(GmmHelper::gmmClientContext);
GmmHelper::gmmClientContext = nullptr; GmmHelper::gmmClientContext = nullptr;
destroyGlobalContextFunc(); destroyGlobalContextFunc();
if (gmmLib) {
delete gmmLib;
gmmLib = nullptr;
}
} }
} }
@ -67,7 +70,6 @@ uint32_t GmmHelper::getMOCS(uint32_t type) {
return cacheEnabledIndex; return cacheEnabledIndex;
} }
} }
MEMORY_OBJECT_CONTROL_STATE mocs = GmmHelper::gmmClientContext->CachePolicyGetMemoryObject(nullptr, static_cast<GMM_RESOURCE_USAGE_TYPE>(type)); MEMORY_OBJECT_CONTROL_STATE mocs = GmmHelper::gmmClientContext->CachePolicyGetMemoryObject(nullptr, static_cast<GMM_RESOURCE_USAGE_TYPE>(type));
return static_cast<uint32_t>(mocs.DwordValue); return static_cast<uint32_t>(mocs.DwordValue);
@ -159,10 +161,17 @@ GMM_YUV_PLANE GmmHelper::convertPlane(OCLPlane oclPlane) {
return GMM_NO_PLANE; 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; bool GmmHelper::useSimplifiedMocsTable = false;
GMM_CLIENT_CONTEXT *GmmHelper::gmmClientContext = nullptr; GMM_CLIENT_CONTEXT *GmmHelper::gmmClientContext = nullptr;
const HardwareInfo *GmmHelper::hwInfo = nullptr; const HardwareInfo *GmmHelper::hwInfo = nullptr;
bool GmmHelper::isLoaded = false; OsLibrary *GmmHelper::gmmLib = nullptr;
} // namespace OCLRT } // namespace OCLRT

View File

@ -35,18 +35,17 @@ struct WorkaroundTable;
struct ImageInfo; struct ImageInfo;
class GraphicsAllocation; class GraphicsAllocation;
class Gmm; class Gmm;
class OsLibrary;
class GmmHelper { class GmmHelper {
public: public:
GmmHelper() = delete; GmmHelper() = delete;
GmmHelper(const HardwareInfo *hwInfo);
~GmmHelper();
static constexpr uint32_t cacheDisabledIndex = 0; static constexpr uint32_t cacheDisabledIndex = 0;
static constexpr uint32_t cacheEnabledIndex = 4; static constexpr uint32_t cacheEnabledIndex = 4;
static constexpr uint32_t maxPossiblePitch = 2147483648; 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 canonize(uint64_t address);
static uint64_t decanonize(uint64_t address); static uint64_t decanonize(uint64_t address);
@ -67,6 +66,13 @@ class GmmHelper {
static bool useSimplifiedMocsTable; static bool useSimplifiedMocsTable;
static GMM_CLIENT_CONTEXT *gmmClientContext; static GMM_CLIENT_CONTEXT *gmmClientContext;
static const HardwareInfo *hwInfo; 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 } // namespace OCLRT

View File

@ -24,6 +24,9 @@
#include "runtime/gmm_helper/gmm_helper.h" #include "runtime/gmm_helper/gmm_helper.h"
namespace OCLRT { namespace OCLRT {
GmmMemoryBase::GmmMemoryBase() {
clientContext = GmmHelper::gmmClientContext;
}
bool GmmMemoryBase::configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter, bool GmmMemoryBase::configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter,
GMM_ESCAPE_HANDLE hDevice, GMM_ESCAPE_HANDLE hDevice,
GMM_ESCAPE_FUNC_TYPE pfnEscape, GMM_ESCAPE_FUNC_TYPE pfnEscape,
@ -33,7 +36,7 @@ bool GmmMemoryBase::configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter,
BOOLEAN BDWL3Coherency, BOOLEAN BDWL3Coherency,
GMM_GFX_SIZE_T SizeOverride, GMM_GFX_SIZE_T SizeOverride,
GMM_GFX_SIZE_T SlmGfxSpaceReserve) { GMM_GFX_SIZE_T SlmGfxSpaceReserve) {
return GmmHelper::gmmClientContext->ConfigureDeviceAddressSpace( return clientContext->ConfigureDeviceAddressSpace(
{hAdapter}, {hAdapter},
{hDevice}, {hDevice},
{pfnEscape}, {pfnEscape},
@ -46,7 +49,7 @@ bool GmmMemoryBase::configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter,
} }
uintptr_t GmmMemoryBase::getInternalGpuVaRangeLimit() { uintptr_t GmmMemoryBase::getInternalGpuVaRangeLimit() {
return static_cast<uintptr_t>(GmmHelper::gmmClientContext->GetInternalGpuVaRangeLimit()); return static_cast<uintptr_t>(clientContext->GetInternalGpuVaRangeLimit());
} }
}; // namespace OCLRT }; // namespace OCLRT

View File

@ -42,6 +42,7 @@ class GmmMemoryBase {
MOCKABLE_VIRTUAL uintptr_t getInternalGpuVaRangeLimit(); MOCKABLE_VIRTUAL uintptr_t getInternalGpuVaRangeLimit();
protected: protected:
GmmMemoryBase() = default; GmmMemoryBase();
GMM_CLIENT_CONTEXT *clientContext;
}; };
} // namespace OCLRT } // namespace OCLRT

View File

@ -28,7 +28,7 @@
namespace OCLRT { namespace OCLRT {
class GmmPageTableMngr { class GmmPageTableMngr {
public: public:
MOCKABLE_VIRTUAL ~GmmPageTableMngr() = default; MOCKABLE_VIRTUAL ~GmmPageTableMngr();
static GmmPageTableMngr *create(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb); static GmmPageTableMngr *create(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb);
@ -45,13 +45,10 @@ class GmmPageTableMngr {
} }
protected: protected:
static void customDeleter(GMM_PAGETABLE_MGR *gmmPageTableManager);
using UniquePtrType = std::unique_ptr<GMM_PAGETABLE_MGR, std::function<void(GMM_PAGETABLE_MGR *)>>;
GmmPageTableMngr() = default; GmmPageTableMngr() = default;
GmmPageTableMngr(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb); GmmPageTableMngr(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb);
GMM_CLIENT_CONTEXT *clientContext = nullptr;
UniquePtrType pageTableManager; GMM_PAGETABLE_MGR *pageTableManager = nullptr;
}; };
} // namespace OCLRT } // namespace OCLRT

View File

@ -24,13 +24,15 @@
#include "runtime/gmm_helper/page_table_mngr.h" #include "runtime/gmm_helper/page_table_mngr.h"
namespace OCLRT { namespace OCLRT {
void GmmPageTableMngr::customDeleter(GMM_PAGETABLE_MGR *gmmPageTableManager) { GmmPageTableMngr::~GmmPageTableMngr() {
GmmHelper::gmmClientContext->DestroyPageTblMgrObject(gmmPageTableManager); if (clientContext) {
clientContext->DestroyPageTblMgrObject(pageTableManager);
}
} }
GmmPageTableMngr::GmmPageTableMngr(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb) { GmmPageTableMngr::GmmPageTableMngr(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb) {
auto pageTableMngrPtr = GmmHelper::gmmClientContext->CreatePageTblMgrObject(deviceCb, translationTableCb, translationTableFlags); this->clientContext = GmmHelper::gmmClientContext;
this->pageTableManager = UniquePtrType(pageTableMngrPtr, GmmPageTableMngr::customDeleter); pageTableManager = clientContext->CreatePageTblMgrObject(deviceCb, translationTableCb, translationTableFlags);
} }
} // namespace OCLRT } // namespace OCLRT

View File

@ -75,8 +75,7 @@ bool DeviceFactory::getDevices(HardwareInfo **pHWInfos, size_t &numDevices) {
DeviceFactory::numDevices = devNum; DeviceFactory::numDevices = devNum;
DeviceFactory::hwInfos = ptr; DeviceFactory::hwInfos = ptr;
return GmmHelper::initContext(hwInfos->pPlatform, hwInfos->pSkuTable, return true;
hwInfos->pWaTable, hwInfos->pSysInfo);
} }
void DeviceFactory::releaseDevices() { void DeviceFactory::releaseDevices() {

View File

@ -39,9 +39,8 @@ decltype(GmmHelper::destroyGlobalContextFunc) GmmHelper::destroyGlobalContextFun
decltype(GmmHelper::createClientContextFunc) GmmHelper::createClientContextFunc = nullptr; decltype(GmmHelper::createClientContextFunc) GmmHelper::createClientContextFunc = nullptr;
decltype(GmmHelper::deleteClientContextFunc) GmmHelper::deleteClientContextFunc = nullptr; decltype(GmmHelper::deleteClientContextFunc) GmmHelper::deleteClientContextFunc = nullptr;
std::unique_ptr<OsLibrary> gmmLib;
void GmmHelper::loadLib() { void GmmHelper::loadLib() {
gmmLib.reset(OsLibrary::load(Os::gmmDllName)); gmmLib = OsLibrary::load(Os::gmmDllName);
UNRECOVERABLE_IF(!gmmLib); UNRECOVERABLE_IF(!gmmLib);
if (gmmLib->isLoaded()) { if (gmmLib->isLoaded()) {

View File

@ -85,8 +85,6 @@ Wddm::Wddm() : initialized(false),
Wddm::~Wddm() { Wddm::~Wddm() {
resetPageTableManager(nullptr); resetPageTableManager(nullptr);
if (initialized)
destroyGmmContext();
destroyContext(context); destroyContext(context);
destroyPagingQueue(); destroyPagingQueue();
destroyDevice(); destroyDevice();

View File

@ -211,8 +211,6 @@ class Wddm {
void getDeviceState(); void getDeviceState();
void handleCompletion(); void handleCompletion();
unsigned int readEnablePreemptionRegKey(); unsigned int readEnablePreemptionRegKey();
bool initGmmContext();
void destroyGmmContext();
void resetMonitoredFenceParams(D3DKMT_HANDLE &handle, uint64_t *cpuAddress, D3DGPU_VIRTUAL_ADDRESS &gpuAddress); void resetMonitoredFenceParams(D3DKMT_HANDLE &handle, uint64_t *cpuAddress, D3DGPU_VIRTUAL_ADDRESS &gpuAddress);
virtual const bool hwQueuesSupported() const { return false; } virtual const bool hwQueuesSupported() const { return false; }

View File

@ -52,9 +52,6 @@ bool Wddm::init() {
if (!createPagingQueue()) { if (!createPagingQueue()) {
return false; return false;
} }
if (!initGmmContext()) {
return false;
}
if (!configureDeviceAddressSpace<GfxFamily>()) { if (!configureDeviceAddressSpace<GfxFamily>()) {
return false; return false;
} }

View File

@ -40,15 +40,4 @@ Wddm::VirtualFreeFcn getVirtualFree() {
Wddm::VirtualAllocFcn getVirtualAlloc() { Wddm::VirtualAllocFcn getVirtualAlloc() {
return VirtualAlloc; return VirtualAlloc;
} }
bool Wddm::initGmmContext() {
return GmmHelper::initContext(gfxPlatform.get(),
featureTable.get(),
waTable.get(),
gtSystemInfo.get());
}
void Wddm::destroyGmmContext() {
GmmHelper::destroyContext();
}
} // namespace OCLRT } // namespace OCLRT

View File

@ -148,7 +148,7 @@ bool Platform::initialize() {
this->devices.resize(numDevicesReturned); this->devices.resize(numDevicesReturned);
for (size_t deviceOrdinal = 0; deviceOrdinal < numDevicesReturned; ++deviceOrdinal) { for (size_t deviceOrdinal = 0; deviceOrdinal < numDevicesReturned; ++deviceOrdinal) {
auto pDevice = Device::create<OCLRT::Device>(&hwInfo[deviceOrdinal]); auto pDevice = Device::create<OCLRT::Device>(&hwInfo[deviceOrdinal], executionEnvironment);
DEBUG_BREAK_IF(!pDevice); DEBUG_BREAK_IF(!pDevice);
if (pDevice) { if (pDevice) {
this->devices[deviceOrdinal] = pDevice; this->devices[deviceOrdinal] = pDevice;
@ -168,7 +168,6 @@ bool Platform::initialize() {
} }
compilerExtensions = convertEnabledExtensionsToCompilerInternalOptions(pDevice->getDeviceInfo().deviceExtensions); compilerExtensions = convertEnabledExtensionsToCompilerInternalOptions(pDevice->getDeviceInfo().deviceExtensions);
pDevice->connectToExecutionEnvironment(this->executionEnvironment);
} else { } else {
return false; return false;
} }

View File

@ -66,7 +66,7 @@ void api_fixture_using_aligned_memory_manager::SetUp() {
retVal = CL_SUCCESS; retVal = CL_SUCCESS;
retSize = 0; retSize = 0;
device = Device::create<MockAlignedMallocManagerDevice>(*platformDevices); device = MockDevice::createWithNewExecutionEnvironment<MockAlignedMallocManagerDevice>(*platformDevices);
Device *devPtr = reinterpret_cast<Device *>(device); Device *devPtr = reinterpret_cast<Device *>(device);
cl_device_id clDevice = devPtr; cl_device_id clDevice = devPtr;

View File

@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * 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 host_timestamp = 0;
cl_ulong zero_timestamp = 0; cl_ulong zero_timestamp = 0;
auto mDev = Device::create<MockDevice>(nullptr); auto mDev = MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr);
mDev->setOSTime(new MockOSTime()); mDev->setOSTime(new MockOSTime());
retVal = clGetDeviceAndHostTimer( retVal = clGetDeviceAndHostTimer(
@ -100,7 +100,7 @@ TEST_F(clGetDeviceAndHostTimerTest, OsCallFail) {
cl_ulong host_timestamp = 0; cl_ulong host_timestamp = 0;
cl_ulong zero_timestamp = 0; cl_ulong zero_timestamp = 0;
auto mDev = Device::create<MockDevice>(nullptr); auto mDev = MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr);
mDev->setOSTime(new FailOSTime()); mDev->setOSTime(new FailOSTime());
retVal = clGetDeviceAndHostTimer( retVal = clGetDeviceAndHostTimer(
@ -149,7 +149,7 @@ TEST_F(clGetHostTimerTest, OsCallPass) {
cl_ulong host_timestamp = 0; cl_ulong host_timestamp = 0;
cl_ulong zero_timestamp = 0; cl_ulong zero_timestamp = 0;
auto mDev = Device::create<MockDevice>(nullptr); auto mDev = MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr);
mDev->setOSTime(new MockOSTime()); mDev->setOSTime(new MockOSTime());
retVal = clGetHostTimer( retVal = clGetHostTimer(
@ -166,7 +166,7 @@ TEST_F(clGetHostTimerTest, OsCallFail) {
cl_ulong host_timestamp = 0; cl_ulong host_timestamp = 0;
cl_ulong zero_timestamp = 0; cl_ulong zero_timestamp = 0;
auto mDev = Device::create<MockDevice>(nullptr); auto mDev = MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr);
mDev->setOSTime(new FailOSTime()); mDev->setOSTime(new FailOSTime());
retVal = clGetHostTimer( retVal = clGetHostTimer(

View File

@ -61,7 +61,7 @@ TEST(Sip, WhenRequestingCsrSipKernelThenProperCompilerInternalOptionsAreReturned
} }
TEST(Sip, When32BitAddressesAreNotBeingForcedThenSipLlHasSameBitnessAsHostApplication) { TEST(Sip, When32BitAddressesAreNotBeingForcedThenSipLlHasSameBitnessAsHostApplication) {
auto mockDevice = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
EXPECT_NE(nullptr, mockDevice); EXPECT_NE(nullptr, mockDevice);
mockDevice->setForce32BitAddressing(false); mockDevice->setForce32BitAddressing(false);
const char *src = getSipLlSrc(*mockDevice); const char *src = getSipLlSrc(*mockDevice);
@ -77,7 +77,7 @@ TEST(Sip, When32BitAddressesAreNotBeingForcedThenSipLlHasSameBitnessAsHostApplic
} }
TEST(Sip, When32BitAddressesAreBeingForcedThenSipLlHas32BitAddresses) { TEST(Sip, When32BitAddressesAreBeingForcedThenSipLlHas32BitAddresses) {
auto mockDevice = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
EXPECT_NE(nullptr, mockDevice); EXPECT_NE(nullptr, mockDevice);
mockDevice->setForce32BitAddressing(true); mockDevice->setForce32BitAddressing(true);
const char *src = getSipLlSrc(*mockDevice); const char *src = getSipLlSrc(*mockDevice);
@ -88,7 +88,7 @@ TEST(Sip, When32BitAddressesAreBeingForcedThenSipLlHas32BitAddresses) {
} }
TEST(Sip, SipLlContainsMetadataRequiredByCompiler) { TEST(Sip, SipLlContainsMetadataRequiredByCompiler) {
auto mockDevice = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
EXPECT_NE(nullptr, mockDevice); EXPECT_NE(nullptr, mockDevice);
const char *src = getSipLlSrc(*mockDevice); const char *src = getSipLlSrc(*mockDevice);
ASSERT_NE(nullptr, src); ASSERT_NE(nullptr, src);
@ -138,7 +138,7 @@ TEST(DebugSip, WhenRequestingDbgCsrWithLocalMemorySipKernelThenProperCompilerInt
} }
TEST(DebugSip, DISABLED_givenBuiltInsWhenDbgCsrSipIsRequestedThanCorrectSipKernelIsReturned) { TEST(DebugSip, DISABLED_givenBuiltInsWhenDbgCsrSipIsRequestedThanCorrectSipKernelIsReturned) {
auto mockDevice = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
EXPECT_NE(nullptr, mockDevice); EXPECT_NE(nullptr, mockDevice);
MockCompilerDebugVars igcDebugVars; MockCompilerDebugVars igcDebugVars;

View File

@ -236,7 +236,7 @@ TEST(CommandQueue, givenCmdQueueBlockedByReadyVirtualEventWhenUnblockingThenUpda
TEST(CommandQueue, givenCmdQueueBlockedByAbortedVirtualEventWhenUnblockingThenUpdateFlushTaskFromEvent) { TEST(CommandQueue, givenCmdQueueBlockedByAbortedVirtualEventWhenUnblockingThenUpdateFlushTaskFromEvent) {
auto context = new MockContext; auto context = new MockContext;
std::unique_ptr<MockDevice> mockDevice(Device::create<MockDevice>(nullptr)); std::unique_ptr<MockDevice> mockDevice(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
auto cmdQ = new CommandQueue(context, mockDevice.get(), 0); auto cmdQ = new CommandQueue(context, mockDevice.get(), 0);
auto userEvent = new Event(cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0); auto userEvent = new Event(cmdQ, CL_COMMAND_NDRANGE_KERNEL, 0, 0);
@ -272,7 +272,7 @@ struct CommandQueueCommandStreamTest : public CommandQueueMemoryDevice,
HWTEST_F(CommandQueueCommandStreamTest, givenCommandQueueThatWaitsOnAbortedUserEventWhenIsQueueBlockedIsCalledThenTaskLevelAlignsToCsr) { HWTEST_F(CommandQueueCommandStreamTest, givenCommandQueueThatWaitsOnAbortedUserEventWhenIsQueueBlockedIsCalledThenTaskLevelAlignsToCsr) {
MockContext context; MockContext context;
std::unique_ptr<MockDevice> mockDevice(Device::create<MockDevice>(nullptr)); std::unique_ptr<MockDevice> mockDevice(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
CommandQueue cmdQ(&context, mockDevice.get(), 0); CommandQueue cmdQ(&context, mockDevice.get(), 0);
auto &commandStreamReceiver = mockDevice->getUltCommandStreamReceiver<FamilyType>(); auto &commandStreamReceiver = mockDevice->getUltCommandStreamReceiver<FamilyType>();
@ -679,7 +679,7 @@ INSTANTIATE_TEST_CASE_P(
using CommandQueueTests = ::testing::Test; using CommandQueueTests = ::testing::Test;
HWTEST_F(CommandQueueTests, givenMultipleCommandQueuesWhenMarkerIsEmittedThenGraphicsAllocationIsReused) { HWTEST_F(CommandQueueTests, givenMultipleCommandQueuesWhenMarkerIsEmittedThenGraphicsAllocationIsReused) {
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(*platformDevices)); std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(*platformDevices));
MockContext context(device.get()); MockContext context(device.get());
std::unique_ptr<CommandQueue> commandQ(new CommandQueue(&context, device.get(), 0)); std::unique_ptr<CommandQueue> commandQ(new CommandQueue(&context, device.get(), 0));
*device->getTagAddress() = 0; *device->getTagAddress() = 0;
@ -710,7 +710,7 @@ struct WaitForQueueCompletionTests : public ::testing::Test {
}; };
void SetUp() override { void SetUp() override {
device.reset(Device::create<MockDevice>(*platformDevices)); device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(*platformDevices));
context.reset(new MockContext(device.get())); context.reset(new MockContext(device.get()));
} }

View File

@ -477,7 +477,7 @@ TEST(SubmissionsAggregator, dontAllocateFlushStamp) {
struct SubmissionsAggregatorTests : public ::testing::Test { struct SubmissionsAggregatorTests : public ::testing::Test {
void SetUp() override { void SetUp() override {
device.reset(Device::create<MockDevice>(platformDevices[0])); device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
context.reset(new MockContext(device.get())); context.reset(new MockContext(device.get()));
} }

View File

@ -704,7 +704,7 @@ const std::string DriverInfoMock::testDeviceName = "testDeviceName";
const std::string DriverInfoMock::testVersion = "testVersion"; const std::string DriverInfoMock::testVersion = "testVersion";
TEST(Device_GetCaps, givenSystemWithDriverInfoWhenGettingNameAndVersionThenReturnValuesFromDriverInfo) { TEST(Device_GetCaps, givenSystemWithDriverInfoWhenGettingNameAndVersionThenReturnValuesFromDriverInfo) {
auto device = Device::create<OCLRT::MockDevice>(platformDevices[0]); auto device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]);
DriverInfoMock *driverInfoMock = new DriverInfoMock(); DriverInfoMock *driverInfoMock = new DriverInfoMock();
device->setDriverInfo(driverInfoMock); device->setDriverInfo(driverInfoMock);
@ -718,7 +718,7 @@ TEST(Device_GetCaps, givenSystemWithDriverInfoWhenGettingNameAndVersionThenRetur
} }
TEST(Device_GetCaps, givenSystemWithNoDriverInfoWhenGettingNameAndVersionThenReturnDefaultValues) { TEST(Device_GetCaps, givenSystemWithNoDriverInfoWhenGettingNameAndVersionThenReturnDefaultValues) {
auto device = Device::create<OCLRT::MockDevice>(platformDevices[0]); auto device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]);
device->setDriverInfo(nullptr); device->setDriverInfo(nullptr);
device->name.clear(); device->name.clear();
@ -777,7 +777,7 @@ TEST(Device_GetCaps, GivenFlagEnabled64kbPagesWhenSetThenReturnCorrectValue) {
} }
TEST(Device_GetCaps, givenDeviceWithNullSourceLevelDebuggerWhenCapsAreInitializedThenSourceLevelDebuggerActiveIsSetToFalse) { TEST(Device_GetCaps, givenDeviceWithNullSourceLevelDebuggerWhenCapsAreInitializedThenSourceLevelDebuggerActiveIsSetToFalse) {
std::unique_ptr<Device> device(Device::create<OCLRT::MockDevice>(platformDevices[0])); std::unique_ptr<Device> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
const auto &caps = device->getDeviceInfo(); const auto &caps = device->getDeviceInfo();
EXPECT_EQ(nullptr, device->getSourceLevelDebugger()); EXPECT_EQ(nullptr, device->getSourceLevelDebugger());
@ -790,7 +790,7 @@ TEST_F(DeviceCapsWithModifiedHwInfoTest, givenPlatformWithSourceLevelDebuggerNot
hwInfo.capabilityTable.sourceLevelDebuggerSupported = false; hwInfo.capabilityTable.sourceLevelDebuggerSupported = false;
std::unique_ptr<MockDeviceWithSourceLevelDebugger<>> device(Device::create<MockDeviceWithSourceLevelDebugger<>>(&hwInfo)); std::unique_ptr<MockDeviceWithSourceLevelDebugger<>> device(MockDevice::createWithNewExecutionEnvironment<MockDeviceWithSourceLevelDebugger<>>(&hwInfo));
const auto &caps = device->getDeviceInfo(); const auto &caps = device->getDeviceInfo();
EXPECT_NE(nullptr, device->getSourceLevelDebugger()); EXPECT_NE(nullptr, device->getSourceLevelDebugger());

View File

@ -134,13 +134,13 @@ struct SmallMockDevice : public Device {
TEST(DeviceCreation, givenDeviceWithUsedTagAllocationWhenItIsDestroyedThenThereAreNoCrashesAndLeaks) { TEST(DeviceCreation, givenDeviceWithUsedTagAllocationWhenItIsDestroyedThenThereAreNoCrashesAndLeaks) {
overrideCommandStreamReceiverCreation = 1; overrideCommandStreamReceiverCreation = 1;
std::unique_ptr<SmallMockDevice> device(Device::create<SmallMockDevice>(platformDevices[0])); std::unique_ptr<SmallMockDevice> device(MockDevice::createWithNewExecutionEnvironment<SmallMockDevice>(platformDevices[0]));
auto tagAllocation = device->peekTagAllocation(); auto tagAllocation = device->peekTagAllocation();
tagAllocation->taskCount = 1; tagAllocation->taskCount = 1;
} }
TEST(DeviceCleanup, givenDeviceWhenItIsDestroyedThenFlushBatchedSubmissionsIsCalled) { TEST(DeviceCleanup, givenDeviceWhenItIsDestroyedThenFlushBatchedSubmissionsIsCalled) {
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
MockCommandStreamReceiver *csr = new MockCommandStreamReceiver; MockCommandStreamReceiver *csr = new MockCommandStreamReceiver;
mockDevice->resetCommandStreamReceiver(csr); mockDevice->resetCommandStreamReceiver(csr);
int flushedBatchedSubmissionsCalledCount = 0; int flushedBatchedSubmissionsCalledCount = 0;
@ -155,7 +155,7 @@ TEST(DeviceCreation, givenSelectedAubCsrInDebugVarsWhenDeviceIsCreatedThenIsSimu
DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_AUB); DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_AUB);
overrideCommandStreamReceiverCreation = true; overrideCommandStreamReceiverCreation = true;
auto mockDevice = std::unique_ptr<Device>(Device::create<Device>(nullptr)); auto mockDevice = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
EXPECT_TRUE(mockDevice->isSimulation()); EXPECT_TRUE(mockDevice->isSimulation());
} }
@ -164,7 +164,7 @@ TEST(DeviceCreation, givenSelectedTbxCsrInDebugVarsWhenDeviceIsCreatedThenIsSimu
DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_TBX); DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_TBX);
overrideCommandStreamReceiverCreation = true; overrideCommandStreamReceiverCreation = true;
auto device = std::unique_ptr<Device>(Device::create<Device>(nullptr)); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
EXPECT_TRUE(device->isSimulation()); EXPECT_TRUE(device->isSimulation());
} }
@ -173,7 +173,7 @@ TEST(DeviceCreation, givenSelectedTbxWithAubCsrInDebugVarsWhenDeviceIsCreatedThe
DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_TBX_WITH_AUB); DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_TBX_WITH_AUB);
overrideCommandStreamReceiverCreation = true; overrideCommandStreamReceiverCreation = true;
auto device = std::unique_ptr<Device>(Device::create<Device>(nullptr)); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
EXPECT_TRUE(device->isSimulation()); EXPECT_TRUE(device->isSimulation());
} }
@ -181,7 +181,7 @@ TEST(DeviceCreation, givenHwWithAubCsrInDebugVarsWhenDeviceIsCreatedThenIsSimula
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_HW_WITH_AUB); DebugManager.flags.SetCommandStreamReceiver.set(CommandStreamReceiverType::CSR_HW_WITH_AUB);
auto device = std::unique_ptr<Device>(Device::create<Device>(nullptr)); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
EXPECT_FALSE(device->isSimulation()); EXPECT_FALSE(device->isSimulation());
} }
@ -189,6 +189,6 @@ TEST(DeviceCreation, givenDefaultHwCsrInDebugVarsWhenDeviceIsCreatedThenIsSimula
int32_t defaultHwCsr = CommandStreamReceiverType::CSR_HW; int32_t defaultHwCsr = CommandStreamReceiverType::CSR_HW;
EXPECT_EQ(defaultHwCsr, DebugManager.flags.SetCommandStreamReceiver.get()); EXPECT_EQ(defaultHwCsr, DebugManager.flags.SetCommandStreamReceiver.get());
auto device = std::unique_ptr<Device>(Device::create<Device>(nullptr)); auto device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
EXPECT_FALSE(device->isSimulation()); EXPECT_FALSE(device->isSimulation());
} }

View File

@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * 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 deviceTimestamp[2] = {0, 0};
cl_ulong hostTimestamp[2] = {0, 0}; cl_ulong hostTimestamp[2] = {0, 0};
auto mDev = Device::create<MockDevice>(nullptr); auto mDev = MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr);
mDev->setOSTime(new MockOSTime()); mDev->setOSTime(new MockOSTime());
mDev->getDeviceAndHostTimer( mDev->getDeviceAndHostTimer(
@ -97,7 +97,7 @@ TEST(MockOSTime, DeviceHostDeltaCheck) {
TEST(MockOSTime, HostIncreaseCheck) { TEST(MockOSTime, HostIncreaseCheck) {
cl_ulong hostTimestamp[2] = {0, 0}; cl_ulong hostTimestamp[2] = {0, 0};
auto mDev = Device::create<MockDevice>(nullptr); auto mDev = MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr);
mDev->setOSTime(new MockOSTime()); mDev->setOSTime(new MockOSTime());
mDev->getHostTimer( mDev->getHostTimer(
@ -114,7 +114,7 @@ TEST(MockOSTime, HostIncreaseCheck) {
} }
TEST(MockOSTime, NegativeTest) { TEST(MockOSTime, NegativeTest) {
auto mDev = Device::create<MockDevice>(nullptr); auto mDev = MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr);
mDev->setOSTime(nullptr); mDev->setOSTime(nullptr);
double zeroRes; double zeroRes;

View File

@ -494,7 +494,7 @@ class DeviceQueueHwWithKernel : public ExecutionModelKernelFixture {
0, 0, 0}; 0, 0, 0};
cl_int errcodeRet = 0; cl_int errcodeRet = 0;
device = Device::create<OCLRT::MockDevice>(platformDevices[0]); device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]);
context = new MockContext(); context = new MockContext();
ASSERT_NE(nullptr, context); ASSERT_NE(nullptr, context);
@ -625,7 +625,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, TheSimplestDeviceQueueFixture, resetDeviceQueueSetEa
DebugManager.flags.SchedulerSimulationReturnInstance.set(3); DebugManager.flags.SchedulerSimulationReturnInstance.set(3);
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(platformDevices[0])); std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
MockContext context; MockContext context;
std::unique_ptr<MockDeviceQueueHw<FamilyType>> mockDeviceQueueHw(new MockDeviceQueueHw<FamilyType>(&context, device.get(), deviceQueueProperties::minimumProperties[0])); std::unique_ptr<MockDeviceQueueHw<FamilyType>> mockDeviceQueueHw(new MockDeviceQueueHw<FamilyType>(&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 PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE; using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE;
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(platformDevices[0])); std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
MockContext context; MockContext context;
std::unique_ptr<MockDeviceQueueHw<FamilyType>> mockDeviceQueueHw(new MockDeviceQueueHw<FamilyType>(&context, device.get(), deviceQueueProperties::minimumProperties[0])); std::unique_ptr<MockDeviceQueueHw<FamilyType>> mockDeviceQueueHw(new MockDeviceQueueHw<FamilyType>(&context, device.get(), deviceQueueProperties::minimumProperties[0]));
@ -683,7 +683,7 @@ HWCMDTEST_F(IGFX_GEN8_CORE, TheSimplestDeviceQueueFixture, addExecutionModelClea
addMediaStateClearCmdsCalled = true; addMediaStateClearCmdsCalled = true;
} }
}; };
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(platformDevices[0])); std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
MockContext context; MockContext context;
std::unique_ptr<MockDeviceQueueWithMediaStateClearRegistering> mockDeviceQueueHw(new MockDeviceQueueWithMediaStateClearRegistering(&context, device.get(), deviceQueueProperties::minimumProperties[0])); std::unique_ptr<MockDeviceQueueWithMediaStateClearRegistering> 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 PIPE_CONTROL = typename FamilyType::PIPE_CONTROL;
using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE; using MEDIA_VFE_STATE = typename FamilyType::MEDIA_VFE_STATE;
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(platformDevices[0])); std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
MockContext context; MockContext context;
std::unique_ptr<MockDeviceQueueHw<FamilyType>> mockDeviceQueueHw(new MockDeviceQueueHw<FamilyType>(&context, device.get(), deviceQueueProperties::minimumProperties[0])); std::unique_ptr<MockDeviceQueueHw<FamilyType>> mockDeviceQueueHw(new MockDeviceQueueHw<FamilyType>(&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_MATH = typename FamilyType::MI_MATH;
using MI_BATCH_BUFFER_END = typename FamilyType::MI_BATCH_BUFFER_END; using MI_BATCH_BUFFER_END = typename FamilyType::MI_BATCH_BUFFER_END;
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(platformDevices[0])); std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
MockContext context; MockContext context;
std::unique_ptr<MockDeviceQueueHw<FamilyType>> mockDeviceQueueHw(new MockDeviceQueueHw<FamilyType>(&context, device.get(), deviceQueueProperties::minimumProperties[0])); std::unique_ptr<MockDeviceQueueHw<FamilyType>> mockDeviceQueueHw(new MockDeviceQueueHw<FamilyType>(&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_STORE_REGISTER_MEM = typename FamilyType::MI_STORE_REGISTER_MEM;
using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM; using MI_LOAD_REGISTER_IMM = typename FamilyType::MI_LOAD_REGISTER_IMM;
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(platformDevices[0])); std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
MockContext context; MockContext context;
std::unique_ptr<MockDeviceQueueHw<FamilyType>> mockDeviceQueueHw(new MockDeviceQueueHw<FamilyType>(&context, device.get(), deviceQueueProperties::minimumProperties[0])); std::unique_ptr<MockDeviceQueueHw<FamilyType>> mockDeviceQueueHw(new MockDeviceQueueHw<FamilyType>(&context, device.get(), deviceQueueProperties::minimumProperties[0]));

View File

@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
@ -35,7 +35,7 @@ struct DeviceDefaults {
template <typename DeviceTraits = DeviceDefaults> template <typename DeviceTraits = DeviceDefaults>
struct DeviceHelper { struct DeviceHelper {
static OCLRT::MockDevice *create(const OCLRT::HardwareInfo *hardwareInfo = nullptr) { static OCLRT::MockDevice *create(const OCLRT::HardwareInfo *hardwareInfo = nullptr) {
OCLRT::MockDevice *device = OCLRT::Device::create<OCLRT::MockDevice>(hardwareInfo); OCLRT::MockDevice *device = OCLRT::MockDevice::createWithNewExecutionEnvironment<OCLRT::MockDevice>(hardwareInfo);
assert(device != nullptr); assert(device != nullptr);
return device; return device;
} }

View File

@ -63,7 +63,7 @@ class KernelDataTest : public testing::Test {
protected: protected:
void SetUp() override { void SetUp() override {
kernelBinaryHeader.KernelNameSize = kernelNameSize; kernelBinaryHeader.KernelNameSize = kernelNameSize;
pDevice = Device::create<MockDevice>(nullptr); pDevice = MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr);
} }
void TearDown() override { void TearDown() override {

View File

@ -50,7 +50,7 @@ void DevicePreemptionTests::SetUp() {
} }
const cl_queue_properties properties[3] = {CL_QUEUE_PROPERTIES, 0, 0}; const cl_queue_properties properties[3] = {CL_QUEUE_PROPERTIES, 0, 0};
kernelInfo.reset(KernelInfo::create()); kernelInfo.reset(KernelInfo::create());
device.reset(MockDevice::create<OCLRT::MockDevice>(nullptr)); device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
context.reset(new MockContext(device.get())); context.reset(new MockContext(device.get()));
cmdQ.reset(new MockCommandQueue(context.get(), device.get(), properties)); cmdQ.reset(new MockCommandQueue(context.get(), device.get(), properties));
executionEnvironment.reset(new SPatchExecutionEnvironment); executionEnvironment.reset(new SPatchExecutionEnvironment);

View File

@ -45,7 +45,7 @@ struct Gen10CoherencyRequirements : public ::testing::Test {
void SetUp() override { void SetUp() override {
csr = new myCsr(); csr = new myCsr();
device.reset(Device::create<MockDevice>(platformDevices[0])); device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
device->resetCommandStreamReceiver(csr); device->resetCommandStreamReceiver(csr);
} }

View File

@ -62,7 +62,7 @@ GEN10TEST_F(PreambleTestGen10, givenDisabledPreemptionAndDisabledDebuggingWhenPr
GEN10TEST_F(PreambleTestGen10, givenKernelDebuggingActiveAndDisabledPreemptionWhenGetAdditionalCommandsSizeIsCalledThen2MiLoadRegisterImmCmdsAndStateSipAreInlcuded) { GEN10TEST_F(PreambleTestGen10, givenKernelDebuggingActiveAndDisabledPreemptionWhenGetAdditionalCommandsSizeIsCalledThen2MiLoadRegisterImmCmdsAndStateSipAreInlcuded) {
DebugManagerStateRestore dbgRestore; DebugManagerStateRestore dbgRestore;
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled)); DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
mockDevice->setSourceLevelDebuggerActive(false); mockDevice->setSourceLevelDebuggerActive(false);
size_t withoutDebugging = PreambleHelper<FamilyType>::getAdditionalCommandsSize(*mockDevice); size_t withoutDebugging = PreambleHelper<FamilyType>::getAdditionalCommandsSize(*mockDevice);

View File

@ -201,7 +201,7 @@ using PreambleTestGen10 = ::testing::Test;
GEN10TEST_F(PreambleTestGen10, givenProgrammingPreambleWhenPreemptionIsTakenIntoAccountThenCSRBaseAddressIsEqualCSRGpuAddress) { GEN10TEST_F(PreambleTestGen10, givenProgrammingPreambleWhenPreemptionIsTakenIntoAccountThenCSRBaseAddressIsEqualCSRGpuAddress) {
using GPGPU_CSR_BASE_ADDRESS = typename FamilyType::GPGPU_CSR_BASE_ADDRESS; using GPGPU_CSR_BASE_ADDRESS = typename FamilyType::GPGPU_CSR_BASE_ADDRESS;
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
mockDevice->setPreemptionMode(PreemptionMode::MidThread); mockDevice->setPreemptionMode(PreemptionMode::MidThread);
auto cmdSizePreemptionMidThread = PreemptionHelper::getRequiredPreambleSize<FamilyType>(*mockDevice); auto cmdSizePreemptionMidThread = PreemptionHelper::getRequiredPreambleSize<FamilyType>(*mockDevice);

View File

@ -43,7 +43,7 @@ BDWTEST_F(BdwDeviceTest, givenBdwDeviceWhenAskedForClVersionThenReport21) {
} }
BDWTEST_F(BdwDeviceTest, givenSourceLevelDebuggerAvailableWhenDeviceIsCreatedThenSourceLevelDebuggerIsDisabled) { BDWTEST_F(BdwDeviceTest, givenSourceLevelDebuggerAvailableWhenDeviceIsCreatedThenSourceLevelDebuggerIsDisabled) {
auto device = std::unique_ptr<MockDeviceWithSourceLevelDebugger<MockActiveSourceLevelDebugger>>(Device::create<MockDeviceWithSourceLevelDebugger<MockActiveSourceLevelDebugger>>(nullptr)); auto device = std::unique_ptr<MockDeviceWithSourceLevelDebugger<MockActiveSourceLevelDebugger>>(MockDevice::createWithNewExecutionEnvironment<MockDeviceWithSourceLevelDebugger<MockActiveSourceLevelDebugger>>(nullptr));
const auto &caps = device->getDeviceInfo(); const auto &caps = device->getDeviceInfo();
EXPECT_NE(nullptr, device->getSourceLevelDebugger()); EXPECT_NE(nullptr, device->getSourceLevelDebugger());
EXPECT_FALSE(caps.sourceLevelDebuggerActive); EXPECT_FALSE(caps.sourceLevelDebuggerActive);

View File

@ -62,7 +62,7 @@ GEN9TEST_F(PreambleTestGen9, givenDisabledPreemptionAndDisabledDebuggingWhenPrea
GEN9TEST_F(PreambleTestGen9, givenKernelDebuggingActiveAndDisabledPreemptionWhenGetAdditionalCommandsSizeIsCalledThen2MiLoadRegisterImmCmdsAndStateSipAreInlcuded) { GEN9TEST_F(PreambleTestGen9, givenKernelDebuggingActiveAndDisabledPreemptionWhenGetAdditionalCommandsSizeIsCalledThen2MiLoadRegisterImmCmdsAndStateSipAreInlcuded) {
DebugManagerStateRestore dbgRestore; DebugManagerStateRestore dbgRestore;
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled)); DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::Disabled));
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
mockDevice->setSourceLevelDebuggerActive(false); mockDevice->setSourceLevelDebuggerActive(false);
size_t withoutDebugging = PreambleHelper<FamilyType>::getAdditionalCommandsSize(*mockDevice); size_t withoutDebugging = PreambleHelper<FamilyType>::getAdditionalCommandsSize(*mockDevice);
@ -77,7 +77,7 @@ GEN9TEST_F(PreambleTestGen9, givenKernelDebuggingActiveAndDisabledPreemptionWhen
GEN9TEST_F(PreambleTestGen9, givenProgrammingPreambleWhenPreemptionIsTakenIntoAccountThenCSRBaseAddressIsEqualCSRGpuAddress) { GEN9TEST_F(PreambleTestGen9, givenProgrammingPreambleWhenPreemptionIsTakenIntoAccountThenCSRBaseAddressIsEqualCSRGpuAddress) {
using GPGPU_CSR_BASE_ADDRESS = typename FamilyType::GPGPU_CSR_BASE_ADDRESS; using GPGPU_CSR_BASE_ADDRESS = typename FamilyType::GPGPU_CSR_BASE_ADDRESS;
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
mockDevice->setPreemptionMode(PreemptionMode::MidThread); mockDevice->setPreemptionMode(PreemptionMode::MidThread);
auto cmdSizePreemptionMidThread = PreemptionHelper::getRequiredPreambleSize<FamilyType>(*mockDevice); auto cmdSizePreemptionMidThread = PreemptionHelper::getRequiredPreambleSize<FamilyType>(*mockDevice);

View File

@ -37,7 +37,7 @@ extern std::string getDebugSipKernelNameWithBitnessAndProductSuffix(std::string
typedef ::testing::Test gen9SipTests; typedef ::testing::Test gen9SipTests;
GEN9TEST_F(gen9SipTests, DISABLED_givenDebugCsrSipKernelWithLocalMemoryWhenAskedForDebugSurfaceBtiAndSizeThenBtiIsZeroAndSizeGreaterThanZero) { GEN9TEST_F(gen9SipTests, DISABLED_givenDebugCsrSipKernelWithLocalMemoryWhenAskedForDebugSurfaceBtiAndSizeThenBtiIsZeroAndSizeGreaterThanZero) {
auto mockDevice = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
EXPECT_NE(nullptr, mockDevice); EXPECT_NE(nullptr, mockDevice);
MockCompilerDebugVars igcDebugVars; MockCompilerDebugVars igcDebugVars;

View File

@ -35,6 +35,10 @@ using namespace ::testing;
namespace OCLRT { namespace OCLRT {
class GmmTests : public ::testing::Test { class GmmTests : public ::testing::Test {
void SetUp() override {
execEnv.initGmm(*platformDevices);
}
ExecutionEnvironment execEnv;
}; };
TEST_F(GmmTests, resourceCreation) { TEST_F(GmmTests, resourceCreation) {
@ -599,31 +603,31 @@ TEST(GmmTest, givenInvalidFlagsSetWhenAskedForUnifiedAuxTranslationCapabilityThe
EXPECT_FALSE(gmm->unifiedAuxTranslationCapable()); // RenderCompressed == 0 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) { TEST(GmmTest, whenContextIsInitializedMultipleTimesThenDontOverride) {
const HardwareInfo *hwinfo = *platformDevices; const HardwareInfo *hwinfo = *platformDevices;
EXPECT_TRUE(GmmHelper::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo)); auto gmmHelper = MockGmmHelper(hwinfo);
auto currentClientContext = GmmHelper::gmmClientContext; auto currentClientContext = GmmHelper::gmmClientContext;
gmmHelper.initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo);
EXPECT_TRUE(GmmHelper::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo));
EXPECT_EQ(currentClientContext, GmmHelper::gmmClientContext); EXPECT_EQ(currentClientContext, GmmHelper::gmmClientContext);
} }
TEST(GmmTest, whenContextIsDestroyedMultimpleTimesThenDontCrash) { TEST(GmmTest, whenContextIsDestroyedMultimpleTimesThenDontCrash) {
const HardwareInfo *hwinfo = *platformDevices; const HardwareInfo *hwinfo = *platformDevices;
EXPECT_TRUE(GmmHelper::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo)); auto gmmHelper = MockGmmHelper(hwinfo);
gmmHelper.destroyContext();
GmmHelper::destroyContext();
EXPECT_EQ(nullptr, GmmHelper::gmmClientContext);
GmmHelper::destroyContext();
EXPECT_TRUE(GmmHelper::initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo));
} }
TEST(GmmTest, givenHwInfoWhenDeviceIsCreatedTheSetThisHwInfoToGmmHelper) { TEST(GmmTest, givenHwInfoWhenDeviceIsCreatedTheSetThisHwInfoToGmmHelper) {
HardwareInfo localHwInfo = **platformDevices; HardwareInfo localHwInfo = **platformDevices;
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(&localHwInfo)); std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo));
EXPECT_EQ(&localHwInfo, GmmHelper::hwInfo); EXPECT_EQ(&localHwInfo, GmmHelper::hwInfo);
} }
@ -645,7 +649,8 @@ TEST(GmmTest, whenResourceIsCreatedThenHandleItsOwnership) {
gmmParams.Flags.Info.Cacheable = 1; gmmParams.Flags.Info.Cacheable = 1;
gmmParams.Flags.Gpu.Texture = 1; gmmParams.Flags.Gpu.Texture = 1;
gmmParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER; gmmParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER;
ExecutionEnvironment execEnv;
execEnv.initGmm(*platformDevices);
MyMockResourecInfo myMockResourceInfo1(&gmmParams); MyMockResourecInfo myMockResourceInfo1(&gmmParams);
EXPECT_NE(nullptr, myMockResourceInfo1.resourceInfo.get()); EXPECT_NE(nullptr, myMockResourceInfo1.resourceInfo.get());

View File

@ -35,7 +35,7 @@ using namespace OCLRT;
struct KmdNotifyTests : public ::testing::Test { struct KmdNotifyTests : public ::testing::Test {
void SetUp() override { void SetUp() override {
device.reset(Device::create<MockDevice>(&localHwInfo)); device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&localHwInfo));
cmdQ.reset(new CommandQueue(&context, device.get(), nullptr)); cmdQ.reset(new CommandQueue(&context, device.get(), nullptr));
*device->getTagAddress() = taskCountToWait; *device->getTagAddress() = taskCountToWait;
device->getCommandStreamReceiver().waitForFlushStamp(flushStampToWait); device->getCommandStreamReceiver().waitForFlushStamp(flushStampToWait);

View File

@ -369,7 +369,7 @@ HWTEST_TYPED_TEST(KernelArgSvmTestTyped, GivenBufferKernelArgWhenBufferOffsetIsN
using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE; using RENDER_SURFACE_STATE = typename FamilyType::RENDER_SURFACE_STATE;
constexpr size_t rendSurfSize = sizeof(RENDER_SURFACE_STATE); constexpr size_t rendSurfSize = sizeof(RENDER_SURFACE_STATE);
std::unique_ptr<Device> device(Device::create<MockDevice>(*platformDevices)); std::unique_ptr<Device> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(*platformDevices));
uint32_t svmSize = MemoryConstants::pageSize; uint32_t svmSize = MemoryConstants::pageSize;
char *svmPtr = reinterpret_cast<char *>(alignedMalloc(svmSize, MemoryConstants::pageSize)); char *svmPtr = reinterpret_cast<char *>(alignedMalloc(svmSize, MemoryConstants::pageSize));

View File

@ -32,7 +32,7 @@ class PatchedKernelTest : public ::testing::Test {
public: public:
void SetUp() override { void SetUp() override {
constructPlatform(); constructPlatform();
device.reset(MockDevice::create<MockDevice>(nullptr)); device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
context.reset(new MockContext(device.get())); context.reset(new MockContext(device.get()));
program.reset(Program::create("FillBufferBytes", context.get(), *device.get(), true, &retVal)); program.reset(Program::create("FillBufferBytes", context.get(), *device.get(), true, &retVal));
EXPECT_EQ(CL_SUCCESS, retVal); EXPECT_EQ(CL_SUCCESS, retVal);

View File

@ -655,7 +655,7 @@ TEST(KernelReflectionSurfaceTestSingle, CreateKernelReflectionSurfaceCalledOnNon
TEST(KernelReflectionSurfaceTestSingle, ObtainKernelReflectionSurfaceWithoutKernelArgs) { TEST(KernelReflectionSurfaceTestSingle, ObtainKernelReflectionSurfaceWithoutKernelArgs) {
MockProgram program; MockProgram program;
MockContext context; MockContext context;
std::unique_ptr<MockDevice> device(Device::create<OCLRT::MockDevice>(platformDevices[0])); std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
KernelInfo *blockInfo = new KernelInfo; KernelInfo *blockInfo = new KernelInfo;
KernelInfo &info = *blockInfo; KernelInfo &info = *blockInfo;
cl_queue_properties properties[1] = {0}; cl_queue_properties properties[1] = {0};
@ -706,7 +706,7 @@ TEST(KernelReflectionSurfaceTestSingle, ObtainKernelReflectionSurfaceWithoutKern
TEST(KernelReflectionSurfaceTestSingle, ObtainKernelReflectionSurfaceWithDeviceQueueKernelArg) { TEST(KernelReflectionSurfaceTestSingle, ObtainKernelReflectionSurfaceWithDeviceQueueKernelArg) {
MockProgram program; MockProgram program;
MockContext context; MockContext context;
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(platformDevices[0])); std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
KernelInfo *blockInfo = new KernelInfo; KernelInfo *blockInfo = new KernelInfo;
KernelInfo &info = *blockInfo; KernelInfo &info = *blockInfo;

View File

@ -2194,7 +2194,7 @@ TEST(KernelTest, givenKernelWithKernelInfoWith32bitPointerSizeThenReport32bit) {
MockContext context; MockContext context;
MockProgram program(&context, false); MockProgram program(&context, false);
std::unique_ptr<MockDevice> device(Device::create<OCLRT::MockDevice>(nullptr)); std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
std::unique_ptr<MockKernel> kernel(new MockKernel(&program, info, *device.get())); std::unique_ptr<MockKernel> kernel(new MockKernel(&program, info, *device.get()));
EXPECT_TRUE(kernel->is32Bit()); EXPECT_TRUE(kernel->is32Bit());
@ -2206,7 +2206,7 @@ TEST(KernelTest, givenKernelWithKernelInfoWith64bitPointerSizeThenReport64bit) {
MockContext context; MockContext context;
MockProgram program(&context, false); MockProgram program(&context, false);
std::unique_ptr<MockDevice> device(Device::create<OCLRT::MockDevice>(nullptr)); std::unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
std::unique_ptr<MockKernel> kernel(new MockKernel(&program, info, *device.get())); std::unique_ptr<MockKernel> kernel(new MockKernel(&program, info, *device.get()));
EXPECT_FALSE(kernel->is32Bit()); EXPECT_FALSE(kernel->is32Bit());

View File

@ -142,16 +142,11 @@ LONG WINAPI UltExceptionFilter(
#endif #endif
void initializeTestHelpers() { void initializeTestHelpers() {
const HardwareInfo *hwinfo = *platformDevices;
auto initialized = GmmHelper::initContext(hwinfo->pPlatform, hwinfo->pSkuTable,
hwinfo->pWaTable, hwinfo->pSysInfo);
ASSERT_TRUE(initialized);
GlobalMockSipProgram::initSipProgram(); GlobalMockSipProgram::initSipProgram();
} }
void cleanTestHelpers() { void cleanTestHelpers() {
GlobalMockSipProgram::shutDownSipProgram(); GlobalMockSipProgram::shutDownSipProgram();
GmmHelper::destroyContext();
} }
std::string getHardwarePrefix() { std::string getHardwarePrefix() {

View File

@ -765,7 +765,7 @@ TEST(SharedBuffersTest, whenBuffersIsCreatedWithSharingHandlerThenItIsSharedBuff
class BufferTests : public ::testing::Test { class BufferTests : public ::testing::Test {
protected: protected:
void SetUp() override { void SetUp() override {
device.reset(Device::create<MockDevice>(*platformDevices)); device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(*platformDevices));
} }
void TearDown() override { void TearDown() override {
} }

View File

@ -955,7 +955,7 @@ class ImageCompressionTests : public ::testing::Test {
void SetUp() override { void SetUp() override {
myMemoryManager = new MyMemoryManager(); myMemoryManager = new MyMemoryManager();
mockDevice.reset(Device::create<MockDevice>(*platformDevices)); mockDevice.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(*platformDevices));
mockDevice->injectMemoryManager(myMemoryManager); mockDevice->injectMemoryManager(myMemoryManager);
mockContext.reset(new MockContext(mockDevice.get())); mockContext.reset(new MockContext(mockDevice.get()));
} }

View File

@ -31,7 +31,7 @@ class ImageHostPtrTransferTests : public testing::Test {
public: public:
void SetUp() override { void SetUp() override {
device.reset(Device::create<MockDevice>(*platformDevices)); device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(*platformDevices));
context.reset(new MockContext(device.get())); context.reset(new MockContext(device.get()));
} }

View File

@ -822,6 +822,8 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenAllocateGraphicsMemor
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
ExecutionEnvironment execEnv;
execEnv.initGmm(*platformDevices);
auto queryGmm = MockGmm::queryImgParams(imgInfo); auto queryGmm = MockGmm::queryImgParams(imgInfo);
auto imageAllocation = memoryManager.allocateGraphicsMemoryForImage(imgInfo, queryGmm.get()); auto imageAllocation = memoryManager.allocateGraphicsMemoryForImage(imgInfo, queryGmm.get());

View File

@ -37,11 +37,13 @@ class MockBufferStorage {
} }
char data[128]; char data[128];
MockGraphicsAllocation mockGfxAllocation; MockGraphicsAllocation mockGfxAllocation;
std::unique_ptr<Device> device = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
}; };
class MockBuffer : public MockBufferStorage, public Buffer { class MockBuffer : public MockBufferStorage, public Buffer {
public: public:
using Buffer::magic; using Buffer::magic;
using MockBufferStorage::device;
MockBuffer(GraphicsAllocation &alloc) MockBuffer(GraphicsAllocation &alloc)
: MockBufferStorage(), Buffer(nullptr, CL_MEM_USE_HOST_PTR, alloc.getUnderlyingBufferSize(), alloc.getUnderlyingBuffer(), alloc.getUnderlyingBuffer(), &alloc, true, false, false), : 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 { void setArgStateful(void *memory) override {
Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), (externalAlloc != nullptr) ? externalAlloc : &mockGfxAllocation); Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), (externalAlloc != nullptr) ? externalAlloc : &mockGfxAllocation);
} }
std::unique_ptr<Device> device = std::unique_ptr<Device>(OCLRT::Device::create<OCLRT::MockDevice>(nullptr));
GraphicsAllocation *externalAlloc = nullptr; GraphicsAllocation *externalAlloc = nullptr;
}; };
class AlignedBuffer : public MockBufferStorage, public Buffer { class AlignedBuffer : public MockBufferStorage, public Buffer {
public: 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() : 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) { 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 { void setArgStateful(void *memory) override {
Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), &mockGfxAllocation); Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), &mockGfxAllocation);
} }
std::unique_ptr<Device> device = std::unique_ptr<Device>(OCLRT::Device::create<OCLRT::MockDevice>(nullptr));
}; };
class UnalignedBuffer : public MockBufferStorage, public Buffer { class UnalignedBuffer : public MockBufferStorage, public Buffer {
public: 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() : 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) { 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 { void setArgStateful(void *memory) override {
Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), &mockGfxAllocation); Buffer::setSurfaceState(device.get(), memory, getSize(), getCpuAddress(), &mockGfxAllocation);
} }
std::unique_ptr<Device> device = std::unique_ptr<Device>(OCLRT::Device::create<OCLRT::MockDevice>(nullptr));
}; };

View File

@ -23,6 +23,7 @@
#pragma once #pragma once
#include "runtime/memory_manager/memory_manager.h" #include "runtime/memory_manager/memory_manager.h"
#include "runtime/device/device.h" #include "runtime/device/device.h"
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/helpers/hw_info.h" #include "runtime/helpers/hw_info.h"
#include "runtime/memory_manager/os_agnostic_memory_manager.h" #include "runtime/memory_manager/os_agnostic_memory_manager.h"
#include "unit_tests/libult/ult_command_stream_receiver.h" #include "unit_tests/libult/ult_command_stream_receiver.h"
@ -102,6 +103,7 @@ class MockDevice : public Device {
MemoryManager *memManager) { MemoryManager *memManager) {
pHwInfo = getDeviceInitHwInfo(pHwInfo); pHwInfo = getDeviceInitHwInfo(pHwInfo);
T *device = new T(*pHwInfo); T *device = new T(*pHwInfo);
device->connectToExecutionEnvironment(new ExecutionEnvironment);
if (memManager) { if (memManager) {
device->setMemoryManager(memManager); device->setMemoryManager(memManager);
} }
@ -111,6 +113,10 @@ class MockDevice : public Device {
} }
return device; return device;
} }
template <typename T>
static T *createWithNewExecutionEnvironment(const HardwareInfo *pHwInfo) {
return Device::create<T>(pHwInfo, new ExecutionEnvironment);
}
void allocatePreemptionAllocationIfNotPresent() { void allocatePreemptionAllocationIfNotPresent() {
if (this->preemptionAllocation == nullptr) { if (this->preemptionAllocation == nullptr) {

View File

@ -30,7 +30,7 @@ using namespace OCLRT;
typedef ::testing::Test DeviceQueueHwMtTest; typedef ::testing::Test DeviceQueueHwMtTest;
HWCMDTEST_F(IGFX_GEN8_CORE, DeviceQueueHwMtTest, givenTakenIgilCriticalSectionWhenSecondThreadIsWaitingThenDontHang) { HWCMDTEST_F(IGFX_GEN8_CORE, DeviceQueueHwMtTest, givenTakenIgilCriticalSectionWhenSecondThreadIsWaitingThenDontHang) {
auto device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr)); auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
auto context = std::unique_ptr<MockContext>(new MockContext()); auto context = std::unique_ptr<MockContext>(new MockContext());
cl_queue_properties properties[3] = {0}; cl_queue_properties properties[3] = {0};

View File

@ -399,7 +399,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDontDumpKernelArgsForNullMdi) {
TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsForMdi) { TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsForMdi) {
MockProgram program; MockProgram program;
auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create()); auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create());
auto device = unique_ptr<Device>(Device::create<OCLRT::Device>(nullptr)); auto device = unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device)); auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device));
auto multiDispatchInfo = unique_ptr<MockMultiDispatchInfo>(new MockMultiDispatchInfo(kernel.get())); auto multiDispatchInfo = unique_ptr<MockMultiDispatchInfo>(new MockMultiDispatchInfo(kernel.get()));
@ -441,7 +441,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelNullKernel) {
TEST(DebugSettingsManager, WithDebugFunctionalityAndEmptyKernelDontDumpKernelArgs) { TEST(DebugSettingsManager, WithDebugFunctionalityAndEmptyKernelDontDumpKernelArgs) {
MockProgram program; MockProgram program;
auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create()); auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create());
auto device = unique_ptr<Device>(Device::create<OCLRT::Device>(nullptr)); auto device = unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device)); auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device));
FullyEnabledTestDebugManager debugManager; FullyEnabledTestDebugManager debugManager;
@ -455,7 +455,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityAndEmptyKernelDontDumpKernelArg
TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsImmediate) { TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsImmediate) {
MockProgram program; MockProgram program;
auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create()); auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create());
auto device = unique_ptr<Device>(Device::create<OCLRT::Device>(nullptr)); auto device = unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device)); auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device));
KernelArgPatchInfo kernelArgPatchInfo; KernelArgPatchInfo kernelArgPatchInfo;
@ -486,7 +486,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsImmediate) {
TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsImmediateZeroSize) { TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsImmediateZeroSize) {
MockProgram program; MockProgram program;
auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create()); auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create());
auto device = unique_ptr<Device>(Device::create<OCLRT::Device>(nullptr)); auto device = unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device)); auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device));
KernelArgPatchInfo kernelArgPatchInfo; KernelArgPatchInfo kernelArgPatchInfo;
@ -514,7 +514,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsImmediateZeroSize
TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsLocalBuffer) { TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsLocalBuffer) {
MockProgram program; MockProgram program;
auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create()); auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create());
auto device = unique_ptr<Device>(Device::create<OCLRT::Device>(nullptr)); auto device = unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device)); auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device));
KernelArgPatchInfo kernelArgPatchInfo; KernelArgPatchInfo kernelArgPatchInfo;
@ -535,7 +535,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsLocalBuffer) {
TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsBufferNotSet) { TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsBufferNotSet) {
MockProgram program; MockProgram program;
auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create()); auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create());
auto device = unique_ptr<Device>(Device::create<OCLRT::Device>(nullptr)); auto device = unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device)); auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device));
KernelArgPatchInfo kernelArgPatchInfo; KernelArgPatchInfo kernelArgPatchInfo;
@ -566,7 +566,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsBuffer) {
MockProgram program(&context, false); MockProgram program(&context, false);
auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create()); auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create());
auto device = unique_ptr<Device>(Device::create<OCLRT::Device>(nullptr)); auto device = unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device)); auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device));
KernelArgPatchInfo kernelArgPatchInfo; KernelArgPatchInfo kernelArgPatchInfo;
@ -600,7 +600,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsBuffer) {
TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsSampler) { TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsSampler) {
MockProgram program; MockProgram program;
auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create()); auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create());
auto device = unique_ptr<Device>(Device::create<OCLRT::Device>(nullptr)); auto device = unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device)); auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device));
KernelArgPatchInfo kernelArgPatchInfo; KernelArgPatchInfo kernelArgPatchInfo;
@ -623,7 +623,7 @@ TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsSampler) {
TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsImageNotSet) { TEST(DebugSettingsManager, WithDebugFunctionalityDumpKernelArgsImageNotSet) {
MockProgram program; MockProgram program;
auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create()); auto kernelInfo = unique_ptr<KernelInfo>(KernelInfo::create());
auto device = unique_ptr<Device>(Device::create<OCLRT::Device>(nullptr)); auto device = unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(nullptr));
auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device)); auto kernel = unique_ptr<MockKernel>(new MockKernel(&program, *kernelInfo, *device));
SKernelBinaryHeaderCommon kernelHeader; SKernelBinaryHeaderCommon kernelHeader;
@ -900,4 +900,3 @@ TEST(DebugSettingsManager, whenOnlyRegKeysAreEnabledThenAllOtherDebugFunctionali
static_assert(false == debugManager.kernelArgDumpingAvailable(), ""); static_assert(false == debugManager.kernelArgDumpingAvailable(), "");
static_assert(debugManager.registryReadAvailable(), ""); static_assert(debugManager.registryReadAvailable(), "");
} }

View File

@ -38,7 +38,7 @@ using namespace ::testing;
namespace OCLRT { namespace OCLRT {
TEST(DeviceOsTest, osSpecificExtensions) { TEST(DeviceOsTest, osSpecificExtensions) {
auto hwInfo = *platformDevices; auto hwInfo = *platformDevices;
auto pDevice = Device::create<OCLRT::Device>(hwInfo); auto pDevice = MockDevice::createWithNewExecutionEnvironment<Device>(hwInfo);
std::string extensionString(pDevice->getDeviceInfo().deviceExtensions); std::string extensionString(pDevice->getDeviceInfo().deviceExtensions);
@ -53,7 +53,7 @@ TEST(DeviceOsTest, osSpecificExtensions) {
} }
TEST(DeviceOsTest, supportedSimultaneousInterops) { TEST(DeviceOsTest, supportedSimultaneousInterops) {
auto pDevice = std::unique_ptr<Device>(Device::create<OCLRT::Device>(*platformDevices)); auto pDevice = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(*platformDevices));
std::vector<unsigned int> expected = {0}; std::vector<unsigned int> expected = {0};
@ -62,7 +62,7 @@ TEST(DeviceOsTest, supportedSimultaneousInterops) {
TEST(DeviceOsTest, DeviceCreationFail) { TEST(DeviceOsTest, DeviceCreationFail) {
auto hwInfo = *platformDevices; auto hwInfo = *platformDevices;
auto pDevice = Device::create<OCLRT::FailDevice>(hwInfo); auto pDevice = MockDevice::createWithNewExecutionEnvironment<FailDevice>(hwInfo);
EXPECT_THAT(pDevice, nullptr); EXPECT_THAT(pDevice, nullptr);
} }
@ -112,7 +112,7 @@ TEST(ApiOsTest, notSupportedApiList) {
TEST(DeviceOsTest, DeviceCreationFailMidThreadPreemption) { TEST(DeviceOsTest, DeviceCreationFailMidThreadPreemption) {
DebugManagerStateRestore dbgRestore; DebugManagerStateRestore dbgRestore;
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread)); DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread));
auto pDevice = Device::create<OCLRT::FailDeviceAfterOne>(nullptr); auto pDevice = MockDevice::createWithNewExecutionEnvironment<FailDeviceAfterOne>(nullptr);
EXPECT_THAT(pDevice, nullptr); EXPECT_THAT(pDevice, nullptr);
} }

View File

@ -1120,7 +1120,7 @@ TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenAllHeapsAreExh
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.Force32bitAddressing.set(true); DebugManager.flags.Force32bitAddressing.set(true);
std::unique_ptr<Device> pDevice(Device::create<OCLRT::MockDevice>(nullptr)); std::unique_ptr<Device> pDevice(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
memoryManager->device = pDevice.get(); memoryManager->device = pDevice.get();
memoryManager->setForce32BitAllocations(true); memoryManager->setForce32BitAllocations(true);
@ -1150,7 +1150,7 @@ TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenAllHeapsAreExh
DebugManagerStateRestore dbgRestorer; DebugManagerStateRestore dbgRestorer;
DebugManager.flags.Force32bitAddressing.set(true); DebugManager.flags.Force32bitAddressing.set(true);
std::unique_ptr<Device> pDevice(Device::create<OCLRT::MockDevice>(nullptr)); std::unique_ptr<Device> pDevice(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
pDevice->increaseProgramCount(); pDevice->increaseProgramCount();
memoryManager->device = pDevice.get(); memoryManager->device = pDevice.get();
memoryManager->setForce32BitAllocations(true); memoryManager->setForce32BitAllocations(true);
@ -1166,7 +1166,7 @@ TEST_F(DrmMemoryManagerTest, Given32BitDeviceWithMemoryManagerWhenInternalHeapIs
DebugManagerStateRestore dbgStateRestore; DebugManagerStateRestore dbgStateRestore;
DebugManager.flags.Force32bitAddressing.set(true); DebugManager.flags.Force32bitAddressing.set(true);
memoryManager->setForce32BitAllocations(true); memoryManager->setForce32BitAllocations(true);
std::unique_ptr<Device> pDevice(Device::create<OCLRT::MockDevice>(nullptr)); std::unique_ptr<Device> pDevice(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
memoryManager->device = pDevice.get(); memoryManager->device = pDevice.get();
auto allocator = memoryManager->getDrmInternal32BitAllocator(); auto allocator = memoryManager->getDrmInternal32BitAllocator();
@ -1195,6 +1195,8 @@ TEST_F(DrmMemoryManagerTest, GivenMemoryManagerWhenAllocateGraphicsMemoryForImag
imgInfo.size = 4096u; imgInfo.size = 4096u;
imgInfo.rowPitch = 512u; imgInfo.rowPitch = 512u;
ExecutionEnvironment execEnv;
execEnv.initGmm(*platformDevices);
auto queryGmm = MockGmm::queryImgParams(imgInfo); auto queryGmm = MockGmm::queryImgParams(imgInfo);
auto imageGraphicsAllocation = memoryManager->allocateGraphicsMemoryForImage(imgInfo, queryGmm.get()); auto imageGraphicsAllocation = memoryManager->allocateGraphicsMemoryForImage(imgInfo, queryGmm.get());
queryGmm.release(); queryGmm.release();
@ -1738,6 +1740,8 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerWhenLockUnlockIsCalledOnAlloca
imgInfo.size = 4096u; imgInfo.size = 4096u;
imgInfo.rowPitch = 512u; imgInfo.rowPitch = 512u;
ExecutionEnvironment execEnv;
execEnv.initGmm(*platformDevices);
auto queryGmm = MockGmm::queryImgParams(imgInfo); auto queryGmm = MockGmm::queryImgParams(imgInfo);
auto allocation = memoryManager->allocateGraphicsMemoryForImage(imgInfo, queryGmm.get()); auto allocation = memoryManager->allocateGraphicsMemoryForImage(imgInfo, queryGmm.get());
queryGmm.release(); queryGmm.release();

View File

@ -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 * Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"), * 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_time.h"
#include "runtime/os_interface/os_interface.h" #include "runtime/os_interface/os_interface.h"
#include "unit_tests/os_interface/mock_performance_counters.h" #include "unit_tests/os_interface/mock_performance_counters.h"
#include "unit_tests/mocks/mock_device.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
using namespace OCLRT; using namespace OCLRT;
@ -46,7 +47,7 @@ struct PerformanceCountersDeviceTest : public PerformanceCountersDeviceFixture,
TEST_F(PerformanceCountersDeviceTest, createDeviceWithPerformanceCounters) { TEST_F(PerformanceCountersDeviceTest, createDeviceWithPerformanceCounters) {
hwInfoToModify->capabilityTable.instrumentationEnabled = true; hwInfoToModify->capabilityTable.instrumentationEnabled = true;
auto device = Device::create<OCLRT::Device>(hwInfoToModify); auto device = MockDevice::createWithNewExecutionEnvironment<Device>(hwInfoToModify);
EXPECT_NE(nullptr, device->getPerformanceCounters()); EXPECT_NE(nullptr, device->getPerformanceCounters());
EXPECT_EQ(1, PerfCounterFlags::initalizeCalled); EXPECT_EQ(1, PerfCounterFlags::initalizeCalled);
delete device; delete device;
@ -54,7 +55,7 @@ TEST_F(PerformanceCountersDeviceTest, createDeviceWithPerformanceCounters) {
TEST_F(PerformanceCountersDeviceTest, createDeviceWithoutPerformanceCounters) { TEST_F(PerformanceCountersDeviceTest, createDeviceWithoutPerformanceCounters) {
hwInfoToModify->capabilityTable.instrumentationEnabled = false; hwInfoToModify->capabilityTable.instrumentationEnabled = false;
auto device = Device::create<OCLRT::Device>(hwInfoToModify); auto device = MockDevice::createWithNewExecutionEnvironment<Device>(hwInfoToModify);
EXPECT_EQ(nullptr, device->getPerformanceCounters()); EXPECT_EQ(nullptr, device->getPerformanceCounters());
EXPECT_EQ(0, PerfCounterFlags::initalizeCalled); EXPECT_EQ(0, PerfCounterFlags::initalizeCalled);
delete device; delete device;

View File

@ -76,7 +76,7 @@ class WddmCommandStreamFixture {
memManager = mockWddmMM; memManager = mockWddmMM;
csr->setMemoryManager(memManager); csr->setMemoryManager(memManager);
device = MockDevice::create<MockDevice>(platformDevices[0]); device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]);
ASSERT_NE(nullptr, device); ASSERT_NE(nullptr, device);
memManager->device = device; memManager->device = device;

View File

@ -32,7 +32,7 @@ using namespace ::testing;
namespace OCLRT { namespace OCLRT {
TEST(DeviceOsTest, osSpecificExtensions) { TEST(DeviceOsTest, osSpecificExtensions) {
auto hwInfo = *platformDevices; auto hwInfo = *platformDevices;
auto pDevice = Device::create<OCLRT::Device>(hwInfo); auto pDevice = MockDevice::createWithNewExecutionEnvironment<Device>(hwInfo);
std::string extensionString(pDevice->getDeviceInfo().deviceExtensions); std::string extensionString(pDevice->getDeviceInfo().deviceExtensions);
@ -48,7 +48,7 @@ TEST(DeviceOsTest, osSpecificExtensions) {
} }
TEST(DeviceOsTest, supportedSimultaneousInterops) { TEST(DeviceOsTest, supportedSimultaneousInterops) {
auto pDevice = std::unique_ptr<Device>(Device::create<OCLRT::Device>(*platformDevices)); auto pDevice = std::unique_ptr<Device>(MockDevice::createWithNewExecutionEnvironment<Device>(*platformDevices));
std::vector<unsigned int> expected = {CL_GL_CONTEXT_KHR, std::vector<unsigned int> expected = {CL_GL_CONTEXT_KHR,
CL_WGL_HDC_KHR, CL_WGL_HDC_KHR,
@ -67,7 +67,7 @@ TEST(DeviceOsTest, supportedSimultaneousInterops) {
TEST(DeviceOsTest, DeviceCreationFail) { TEST(DeviceOsTest, DeviceCreationFail) {
auto hwInfo = *platformDevices; auto hwInfo = *platformDevices;
auto pDevice = Device::create<OCLRT::FailDevice>(hwInfo); auto pDevice = MockDevice::createWithNewExecutionEnvironment<FailDevice>(hwInfo);
EXPECT_THAT(pDevice, nullptr); EXPECT_THAT(pDevice, nullptr);
} }
@ -75,7 +75,7 @@ TEST(DeviceOsTest, DeviceCreationFail) {
TEST(DeviceOsTest, DeviceCreationFailMidThreadPreemption) { TEST(DeviceOsTest, DeviceCreationFailMidThreadPreemption) {
DebugManagerStateRestore dbgRestore; DebugManagerStateRestore dbgRestore;
DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread)); DebugManager.flags.ForcePreemptionMode.set(static_cast<int32_t>(PreemptionMode::MidThread));
auto pDevice = Device::create<OCLRT::FailDeviceAfterOne>(nullptr); auto pDevice = MockDevice::createWithNewExecutionEnvironment<FailDeviceAfterOne>(nullptr);
EXPECT_THAT(pDevice, nullptr); EXPECT_THAT(pDevice, nullptr);
} }

View File

@ -69,7 +69,7 @@ Wddm *DriverInfoDeviceTest::wddmMock = nullptr;
TEST_F(DriverInfoDeviceTest, GivenDeviceCreatedWhenCorrectOSInterfaceThenCreateDriverInfo) { TEST_F(DriverInfoDeviceTest, GivenDeviceCreatedWhenCorrectOSInterfaceThenCreateDriverInfo) {
overrideCommandStreamReceiverCreation = true; overrideCommandStreamReceiverCreation = true;
auto device = Device::create<OCLRT::MockDevice>(hwInfo); auto device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(hwInfo);
EXPECT_TRUE(device->hasDriverInfo()); EXPECT_TRUE(device->hasDriverInfo());
delete device; delete device;
@ -77,7 +77,7 @@ TEST_F(DriverInfoDeviceTest, GivenDeviceCreatedWhenCorrectOSInterfaceThenCreateD
TEST_F(DriverInfoDeviceTest, GivenDeviceCreatedWithoutCorrectOSInterfaceThenDontCreateDriverInfo) { TEST_F(DriverInfoDeviceTest, GivenDeviceCreatedWithoutCorrectOSInterfaceThenDontCreateDriverInfo) {
overrideCommandStreamReceiverCreation = false; overrideCommandStreamReceiverCreation = false;
auto device = Device::create<OCLRT::MockDevice>(hwInfo); auto device = MockDevice::createWithNewExecutionEnvironment<MockDevice>(hwInfo);
EXPECT_FALSE(device->hasDriverInfo()); EXPECT_FALSE(device->hasDriverInfo());
delete device; delete device;

View File

@ -22,6 +22,7 @@
#include "unit_tests/os_interface/windows/wddm_fixture.h" #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.h"
#include "runtime/gmm_helper/gmm_helper.h" #include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/helpers/hw_info.h" #include "runtime/helpers/hw_info.h"
@ -531,8 +532,9 @@ HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceOnInit) {
D3DKMT_HANDLE adapterHandle = ADAPTER_HANDLE; D3DKMT_HANDLE adapterHandle = ADAPTER_HANDLE;
D3DKMT_HANDLE deviceHandle = DEVICE_HANDLE; D3DKMT_HANDLE deviceHandle = DEVICE_HANDLE;
const HardwareInfo hwInfo = *platformDevices[0]; const HardwareInfo hwInfo = *platformDevices[0];
ExecutionEnvironment execEnv;
execEnv.initGmm(&hwInfo);
BOOLEAN FtrL3IACoherency = hwInfo.pSkuTable->ftrL3IACoherency ? 1 : 0; BOOLEAN FtrL3IACoherency = hwInfo.pSkuTable->ftrL3IACoherency ? 1 : 0;
EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(adapterHandle, EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(adapterHandle,
deviceHandle, deviceHandle,
wddm->gdi->escape.mFunc, wddm->gdi->escape.mFunc,
@ -551,6 +553,8 @@ HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceOnInit) {
HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoAdapter) { HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoAdapter) {
wddm->adapter = static_cast<D3DKMT_HANDLE>(0); wddm->adapter = static_cast<D3DKMT_HANDLE>(0);
ExecutionEnvironment execEnv;
execEnv.initGmm(*platformDevices);
EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(static_cast<D3DKMT_HANDLE>(0), EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(static_cast<D3DKMT_HANDLE>(0),
::testing::_, ::testing::_,
::testing::_, ::testing::_,
@ -569,6 +573,8 @@ HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoAdapter) {
HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoDevice) { HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoDevice) {
wddm->device = static_cast<D3DKMT_HANDLE>(0); wddm->device = static_cast<D3DKMT_HANDLE>(0);
ExecutionEnvironment execEnv;
execEnv.initGmm(*platformDevices);
EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(::testing::_, EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(::testing::_,
static_cast<D3DKMT_HANDLE>(0), static_cast<D3DKMT_HANDLE>(0),
::testing::_, ::testing::_,
@ -587,6 +593,8 @@ HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoDevice) {
HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoEscFunc) { HWTEST_F(Wddm20InstrumentationTest, configureDeviceAddressSpaceNoEscFunc) {
wddm->gdi->escape = static_cast<PFND3DKMT_ESCAPE>(nullptr); wddm->gdi->escape = static_cast<PFND3DKMT_ESCAPE>(nullptr);
ExecutionEnvironment execEnv;
execEnv.initGmm(*platformDevices);
EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(::testing::_, EXPECT_CALL(*gmmMem, configureDeviceAddressSpace(::testing::_,
::testing::_, ::testing::_,
static_cast<PFND3DKMT_ESCAPE>(nullptr), static_cast<PFND3DKMT_ESCAPE>(nullptr),

View File

@ -49,10 +49,4 @@ Wddm::VirtualFreeFcn getVirtualFree() {
Wddm::VirtualAllocFcn getVirtualAlloc() { Wddm::VirtualAllocFcn getVirtualAlloc() {
return ULTVirtualAlloc; return ULTVirtualAlloc;
} }
bool Wddm::initGmmContext() {
return true;
}
void Wddm::destroyGmmContext() {}
} // namespace OCLRT } // namespace OCLRT

View File

@ -38,7 +38,7 @@ using PreambleTest = ::testing::Test;
using namespace OCLRT; using namespace OCLRT;
HWTEST_F(PreambleTest, PreemptionIsTakenIntoAccountWhenProgrammingPreamble) { HWTEST_F(PreambleTest, PreemptionIsTakenIntoAccountWhenProgrammingPreamble) {
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
mockDevice->setPreemptionMode(PreemptionMode::MidThread); mockDevice->setPreemptionMode(PreemptionMode::MidThread);
auto cmdSizePreambleMidThread = PreambleHelper<FamilyType>::getAdditionalCommandsSize(*mockDevice); auto cmdSizePreambleMidThread = PreambleHelper<FamilyType>::getAdditionalCommandsSize(*mockDevice);
@ -122,7 +122,7 @@ HWTEST_F(PreambleTest, whenKernelDebuggingCommandsAreProgrammedThenCorrectComman
HWTEST_F(PreambleTest, givenKernelDebuggingActiveWhenPreambleIsProgrammedThenProgramKernelDebuggingIsCalled) { HWTEST_F(PreambleTest, givenKernelDebuggingActiveWhenPreambleIsProgrammedThenProgramKernelDebuggingIsCalled) {
typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM; typedef typename FamilyType::MI_LOAD_REGISTER_IMM MI_LOAD_REGISTER_IMM;
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
mockDevice->setPreemptionMode(PreemptionMode::Disabled); mockDevice->setPreemptionMode(PreemptionMode::Disabled);
mockDevice->setSourceLevelDebuggerActive(false); mockDevice->setSourceLevelDebuggerActive(false);
@ -157,7 +157,7 @@ HWTEST_F(PreambleTest, givenKernelDebuggingActiveWhenPreambleIsProgrammedThenPro
} }
HWTEST_F(PreambleTest, givenKernelDebuggingActiveAndMidThreadPreemptionWhenGetAdditionalCommandsSizeIsCalledThen2MiLoadRegisterImmCmdsAreAdded) { HWTEST_F(PreambleTest, givenKernelDebuggingActiveAndMidThreadPreemptionWhenGetAdditionalCommandsSizeIsCalledThen2MiLoadRegisterImmCmdsAreAdded) {
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
mockDevice->setPreemptionMode(PreemptionMode::MidThread); mockDevice->setPreemptionMode(PreemptionMode::MidThread);
mockDevice->setSourceLevelDebuggerActive(false); mockDevice->setSourceLevelDebuggerActive(false);

View File

@ -318,7 +318,7 @@ HWTEST_P(PreemptionHwTest, getRequiredCmdStreamSizeReturns0WhenPreemptionModeIsN
StackVec<char, 4096> buffer(requiredSize); StackVec<char, 4096> buffer(requiredSize);
LinearStream cmdStream(buffer.begin(), buffer.size()); LinearStream cmdStream(buffer.begin(), buffer.size());
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
{ {
MockBuiltins tmpBuiltins; MockBuiltins tmpBuiltins;
tmpBuiltins.overrideSipKernel(std::unique_ptr<OCLRT::SipKernel>(new OCLRT::SipKernel{SipKernelType::Csr, getSipProgramWithCustomBinary()})); tmpBuiltins.overrideSipKernel(std::unique_ptr<OCLRT::SipKernel>(new OCLRT::SipKernel{SipKernelType::Csr, getSipProgramWithCustomBinary()}));
@ -346,7 +346,7 @@ HWTEST_P(PreemptionHwTest, getRequiredCmdStreamSizeReturnsSizeOfMiLoadRegisterIm
StackVec<char, 4096> buffer(requiredSize); StackVec<char, 4096> buffer(requiredSize);
LinearStream cmdStream(buffer.begin(), buffer.size()); LinearStream cmdStream(buffer.begin(), buffer.size());
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
size_t minCsrSize = mockDevice->getHardwareInfo().pSysInfo->CsrSizeInMb * MemoryConstants::megaByte; size_t minCsrSize = mockDevice->getHardwareInfo().pSysInfo->CsrSizeInMb * MemoryConstants::megaByte;
uint64_t minCsrAlignment = 2 * 256 * MemoryConstants::kiloByte; uint64_t minCsrAlignment = 2 * 256 * MemoryConstants::kiloByte;
@ -360,7 +360,7 @@ HWTEST_P(PreemptionHwTest, getRequiredCmdStreamSizeReturnsSizeOfMiLoadRegisterIm
HWTEST_P(PreemptionHwTest, programCmdStreamAddsProperMiLoadRegisterImmCommandToTheStream) { HWTEST_P(PreemptionHwTest, programCmdStreamAddsProperMiLoadRegisterImmCommandToTheStream) {
PreemptionMode mode = GetParam(); PreemptionMode mode = GetParam();
PreemptionMode differentPreemptionMode = static_cast<PreemptionMode>(0); PreemptionMode differentPreemptionMode = static_cast<PreemptionMode>(0);
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
if (false == GetPreemptionTestHwDetails<FamilyType>().supportsPreemptionProgramming()) { if (false == GetPreemptionTestHwDetails<FamilyType>().supportsPreemptionProgramming()) {
LinearStream cmdStream(nullptr, 0U); LinearStream cmdStream(nullptr, 0U);
@ -409,7 +409,7 @@ HWTEST_F(MidThreadPreemptionTests, createCsrSurfaceNoWa) {
tmpWaTable.waCSRUncachable = false; tmpWaTable.waCSRUncachable = false;
const_cast<HardwareInfo *>(platformDevices[0])->pWaTable = &tmpWaTable; const_cast<HardwareInfo *>(platformDevices[0])->pWaTable = &tmpWaTable;
std::unique_ptr<MockDevice> mockDevice(Device::create<OCLRT::MockDevice>(platformDevices[0])); std::unique_ptr<MockDevice> mockDevice(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
ASSERT_NE(nullptr, mockDevice.get()); ASSERT_NE(nullptr, mockDevice.get());
auto &csr = mockDevice->getUltCommandStreamReceiver<FamilyType>(); auto &csr = mockDevice->getUltCommandStreamReceiver<FamilyType>();
@ -429,7 +429,7 @@ HWTEST_F(MidThreadPreemptionTests, createCsrSurfaceWa) {
tmpWaTable.waCSRUncachable = true; tmpWaTable.waCSRUncachable = true;
const_cast<HardwareInfo *>(platformDevices[0])->pWaTable = &tmpWaTable; const_cast<HardwareInfo *>(platformDevices[0])->pWaTable = &tmpWaTable;
std::unique_ptr<MockDevice> mockDevice(Device::create<OCLRT::MockDevice>(platformDevices[0])); std::unique_ptr<MockDevice> mockDevice(MockDevice::createWithNewExecutionEnvironment<MockDevice>(platformDevices[0]));
ASSERT_NE(nullptr, mockDevice.get()); ASSERT_NE(nullptr, mockDevice.get());
auto &csr = mockDevice->getUltCommandStreamReceiver<FamilyType>(); auto &csr = mockDevice->getUltCommandStreamReceiver<FamilyType>();

View File

@ -23,6 +23,7 @@
#include "runtime/helpers/aligned_memory.h" #include "runtime/helpers/aligned_memory.h"
#include "runtime/helpers/string.h" #include "runtime/helpers/string.h"
#include "runtime/program/print_formatter.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_kernel.h"
#include "unit_tests/mocks/mock_program.h" #include "unit_tests/mocks/mock_program.h"
#include "unit_tests/mocks/mock_graphics_allocation.h" #include "unit_tests/mocks/mock_graphics_allocation.h"
@ -59,7 +60,7 @@ class PrintFormatterTest : public testing::Test {
data = new MockGraphicsAllocation(underlyingBuffer, PrintFormatter::maxPrintfOutputLength); data = new MockGraphicsAllocation(underlyingBuffer, PrintFormatter::maxPrintfOutputLength);
kernelInfo = KernelInfo::create(); kernelInfo = KernelInfo::create();
device = Device::create<OCLRT::Device>(nullptr); device = MockDevice::createWithNewExecutionEnvironment<Device>(nullptr);
kernel = new MockKernel(&program, *kernelInfo, *device); kernel = new MockKernel(&program, *kernelInfo, *device);
printFormatter = new PrintFormatter(*kernel, *data); printFormatter = new PrintFormatter(*kernel, *data);

View File

@ -33,7 +33,7 @@
typedef ::testing::Test CommandStreamReceiverWithActiveDebuggerTest; typedef ::testing::Test CommandStreamReceiverWithActiveDebuggerTest;
HWTEST_F(CommandStreamReceiverWithActiveDebuggerTest, givenCsrWithActiveDebuggerAndDisabledPreemptionWhenFlushTaskIsCalledThenSipKernelIsMadeResident) { HWTEST_F(CommandStreamReceiverWithActiveDebuggerTest, givenCsrWithActiveDebuggerAndDisabledPreemptionWhenFlushTaskIsCalledThenSipKernelIsMadeResident) {
auto device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(nullptr)); auto device = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
device->setSourceLevelDebuggerActive(true); device->setSourceLevelDebuggerActive(true);
device->allocatePreemptionAllocationIfNotPresent(); device->allocatePreemptionAllocationIfNotPresent();
auto mockCsr = new MockCsrHw2<FamilyType>(*platformDevices[0]); auto mockCsr = new MockCsrHw2<FamilyType>(*platformDevices[0]);

View File

@ -73,7 +73,7 @@ TEST(DeviceCreation, givenDeviceWithMidThreadPreemptionAndDebuggingActiveWhenDev
EXPECT_FALSE(mockBuiltins->getSipKernelCalled); EXPECT_FALSE(mockBuiltins->getSipKernelCalled);
DebugManager.flags.ForcePreemptionMode.set((int32_t)PreemptionMode::MidThread); DebugManager.flags.ForcePreemptionMode.set((int32_t)PreemptionMode::MidThread);
auto device = std::unique_ptr<MockDeviceWithActiveDebugger<>>(Device::create<MockDeviceWithActiveDebugger<>>(nullptr)); auto device = std::unique_ptr<MockDeviceWithActiveDebugger<>>(MockDevice::createWithNewExecutionEnvironment<MockDeviceWithActiveDebugger<>>(nullptr));
EXPECT_TRUE(mockBuiltins->getSipKernelCalled); EXPECT_TRUE(mockBuiltins->getSipKernelCalled);
EXPECT_LE(SipKernelType::DbgCsr, mockBuiltins->getSipKernelType); EXPECT_LE(SipKernelType::DbgCsr, mockBuiltins->getSipKernelType);
@ -96,7 +96,7 @@ TEST(DeviceCreation, givenDeviceWithDisabledPreemptionAndDebuggingActiveWhenDevi
EXPECT_FALSE(mockBuiltins->getSipKernelCalled); EXPECT_FALSE(mockBuiltins->getSipKernelCalled);
DebugManager.flags.ForcePreemptionMode.set((int32_t)PreemptionMode::Disabled); DebugManager.flags.ForcePreemptionMode.set((int32_t)PreemptionMode::Disabled);
auto device = std::unique_ptr<MockDeviceWithActiveDebugger<>>(Device::create<MockDeviceWithActiveDebugger<>>(nullptr)); auto device = std::unique_ptr<MockDeviceWithActiveDebugger<>>(MockDevice::createWithNewExecutionEnvironment<MockDeviceWithActiveDebugger<>>(nullptr));
EXPECT_TRUE(mockBuiltins->getSipKernelCalled); EXPECT_TRUE(mockBuiltins->getSipKernelCalled);
EXPECT_LE(SipKernelType::DbgCsr, mockBuiltins->getSipKernelType); EXPECT_LE(SipKernelType::DbgCsr, mockBuiltins->getSipKernelType);
@ -107,12 +107,12 @@ TEST(DeviceCreation, givenDeviceWithDisabledPreemptionAndDebuggingActiveWhenDevi
} }
TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsDestructedThenSourceLevelDebuggerIsNotified) { TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsDestructedThenSourceLevelDebuggerIsNotified) {
auto device = std::unique_ptr<MockDeviceWithActiveDebugger<::testing::NiceMock<GMockSourceLevelDebugger>>>(Device::create<MockDeviceWithActiveDebugger<::testing::NiceMock<GMockSourceLevelDebugger>>>(nullptr)); auto device = std::unique_ptr<MockDeviceWithActiveDebugger<::testing::NiceMock<GMockSourceLevelDebugger>>>(MockDevice::createWithNewExecutionEnvironment<MockDeviceWithActiveDebugger<::testing::NiceMock<GMockSourceLevelDebugger>>>(nullptr));
GMockSourceLevelDebugger *gmock = device->getSourceLevelDebugger(); GMockSourceLevelDebugger *gmock = device->getSourceLevelDebugger();
EXPECT_CALL(*gmock, notifyDeviceDestruction()).Times(1); EXPECT_CALL(*gmock, notifyDeviceDestruction()).Times(1);
} }
TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsCreatedThenPreemptionIsDisabled) { TEST(DeviceWithSourceLevelDebugger, givenDeviceWithSourceLevelDebuggerActiveWhenDeviceIsCreatedThenPreemptionIsDisabled) {
auto device = std::unique_ptr<MockDeviceWithActiveDebugger<MockActiveSourceLevelDebugger>>(Device::create<MockDeviceWithActiveDebugger<MockActiveSourceLevelDebugger>>(nullptr)); auto device = std::unique_ptr<MockDeviceWithActiveDebugger<MockActiveSourceLevelDebugger>>(MockDevice::createWithNewExecutionEnvironment<MockDeviceWithActiveDebugger<MockActiveSourceLevelDebugger>>(nullptr));
EXPECT_EQ(PreemptionMode::Disabled, device->getPreemptionMode()); EXPECT_EQ(PreemptionMode::Disabled, device->getPreemptionMode());
} }

View File

@ -25,7 +25,7 @@ using namespace OCLRT;
template <typename GfxFamily> template <typename GfxFamily>
void SourceLevelDebuggerPreambleTest<GfxFamily>::givenMidThreadPreemptionAndDebuggingActiveWhenPreambleIsPrograamedThenCorrectSipKernelIsUsedTest() { void SourceLevelDebuggerPreambleTest<GfxFamily>::givenMidThreadPreemptionAndDebuggingActiveWhenPreambleIsPrograamedThenCorrectSipKernelIsUsedTest() {
using STATE_SIP = typename GfxFamily::STATE_SIP; using STATE_SIP = typename GfxFamily::STATE_SIP;
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
mockDevice->setSourceLevelDebuggerActive(true); mockDevice->setSourceLevelDebuggerActive(true);
mockDevice->setPreemptionMode(PreemptionMode::MidThread); mockDevice->setPreemptionMode(PreemptionMode::MidThread);
@ -54,7 +54,7 @@ void SourceLevelDebuggerPreambleTest<GfxFamily>::givenMidThreadPreemptionAndDebu
template <typename GfxFamily> template <typename GfxFamily>
void SourceLevelDebuggerPreambleTest<GfxFamily>::givenMidThreadPreemptionAndDisabledDebuggingWhenPreambleIsPrograamedThenCorrectSipKernelIsUsedTest() { void SourceLevelDebuggerPreambleTest<GfxFamily>::givenMidThreadPreemptionAndDisabledDebuggingWhenPreambleIsPrograamedThenCorrectSipKernelIsUsedTest() {
using STATE_SIP = typename GfxFamily::STATE_SIP; using STATE_SIP = typename GfxFamily::STATE_SIP;
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
mockDevice->setSourceLevelDebuggerActive(false); mockDevice->setSourceLevelDebuggerActive(false);
mockDevice->setPreemptionMode(PreemptionMode::MidThread); mockDevice->setPreemptionMode(PreemptionMode::MidThread);
@ -83,7 +83,7 @@ void SourceLevelDebuggerPreambleTest<GfxFamily>::givenMidThreadPreemptionAndDisa
template <typename GfxFamily> template <typename GfxFamily>
void SourceLevelDebuggerPreambleTest<GfxFamily>::givenPreemptionDisabledAndDebuggingActiveWhenPreambleIsProgrammedThenCorrectSipKernelIsUsedTest() { void SourceLevelDebuggerPreambleTest<GfxFamily>::givenPreemptionDisabledAndDebuggingActiveWhenPreambleIsProgrammedThenCorrectSipKernelIsUsedTest() {
using STATE_SIP = typename GfxFamily::STATE_SIP; using STATE_SIP = typename GfxFamily::STATE_SIP;
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
mockDevice->setSourceLevelDebuggerActive(true); mockDevice->setSourceLevelDebuggerActive(true);
mockDevice->setPreemptionMode(PreemptionMode::Disabled); mockDevice->setPreemptionMode(PreemptionMode::Disabled);
@ -111,7 +111,7 @@ void SourceLevelDebuggerPreambleTest<GfxFamily>::givenPreemptionDisabledAndDebug
template <typename GfxFamily> template <typename GfxFamily>
void SourceLevelDebuggerPreambleTest<GfxFamily>::givenMidThreadPreemptionAndDebuggingActiveWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest() { void SourceLevelDebuggerPreambleTest<GfxFamily>::givenMidThreadPreemptionAndDebuggingActiveWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest() {
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
mockDevice->setSourceLevelDebuggerActive(true); mockDevice->setSourceLevelDebuggerActive(true);
mockDevice->setPreemptionMode(PreemptionMode::MidThread); mockDevice->setPreemptionMode(PreemptionMode::MidThread);
size_t requiredPreambleSize = PreemptionHelper::getRequiredPreambleSize<GfxFamily>(*mockDevice); size_t requiredPreambleSize = PreemptionHelper::getRequiredPreambleSize<GfxFamily>(*mockDevice);
@ -121,7 +121,7 @@ void SourceLevelDebuggerPreambleTest<GfxFamily>::givenMidThreadPreemptionAndDebu
template <typename GfxFamily> template <typename GfxFamily>
void SourceLevelDebuggerPreambleTest<GfxFamily>::givenPreemptionDisabledAndDebuggingActiveWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest() { void SourceLevelDebuggerPreambleTest<GfxFamily>::givenPreemptionDisabledAndDebuggingActiveWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest() {
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
mockDevice->setSourceLevelDebuggerActive(true); mockDevice->setSourceLevelDebuggerActive(true);
mockDevice->setPreemptionMode(PreemptionMode::Disabled); mockDevice->setPreemptionMode(PreemptionMode::Disabled);
size_t requiredPreambleSize = PreemptionHelper::getRequiredPreambleSize<GfxFamily>(*mockDevice); size_t requiredPreambleSize = PreemptionHelper::getRequiredPreambleSize<GfxFamily>(*mockDevice);
@ -131,7 +131,7 @@ void SourceLevelDebuggerPreambleTest<GfxFamily>::givenPreemptionDisabledAndDebug
template <typename GfxFamily> template <typename GfxFamily>
void SourceLevelDebuggerPreambleTest<GfxFamily>::givenMidThreadPreemptionAndDisabledDebuggingWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest() { void SourceLevelDebuggerPreambleTest<GfxFamily>::givenMidThreadPreemptionAndDisabledDebuggingWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest() {
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
mockDevice->setSourceLevelDebuggerActive(false); mockDevice->setSourceLevelDebuggerActive(false);
mockDevice->setPreemptionMode(PreemptionMode::MidThread); mockDevice->setPreemptionMode(PreemptionMode::MidThread);
size_t requiredPreambleSize = PreemptionHelper::getRequiredPreambleSize<GfxFamily>(*mockDevice); size_t requiredPreambleSize = PreemptionHelper::getRequiredPreambleSize<GfxFamily>(*mockDevice);
@ -141,7 +141,7 @@ void SourceLevelDebuggerPreambleTest<GfxFamily>::givenMidThreadPreemptionAndDisa
template <typename GfxFamily> template <typename GfxFamily>
void SourceLevelDebuggerPreambleTest<GfxFamily>::givenDisabledPreemptionAndDisabledDebuggingWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest() { void SourceLevelDebuggerPreambleTest<GfxFamily>::givenDisabledPreemptionAndDisabledDebuggingWhenPreambleSizeIsQueriedThenCorrecrSizeIsReturnedTest() {
auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(nullptr)); auto mockDevice = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
mockDevice->setSourceLevelDebuggerActive(false); mockDevice->setSourceLevelDebuggerActive(false);
mockDevice->setPreemptionMode(PreemptionMode::Disabled); mockDevice->setPreemptionMode(PreemptionMode::Disabled);
size_t requiredPreambleSize = PreemptionHelper::getRequiredPreambleSize<GfxFamily>(*mockDevice); size_t requiredPreambleSize = PreemptionHelper::getRequiredPreambleSize<GfxFamily>(*mockDevice);

View File

@ -409,8 +409,7 @@ TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenDeviceImplIsCreate
DebuggerLibrary::setDebuggerActive(true); DebuggerLibrary::setDebuggerActive(true);
DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor); DebuggerLibrary::injectDebuggerLibraryInterceptor(&interceptor);
unique_ptr<MockDevice> device(new MockDevice(*platformDevices[0])); unique_ptr<MockDevice> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(*platformDevices));
MockDevice::createDeviceImpl(platformDevices[0], *device.get());
EXPECT_TRUE(interceptor.newDeviceCalled); EXPECT_TRUE(interceptor.newDeviceCalled);
uint32_t deviceHandleExpected = device->getCommandStreamReceiver().getOSInterface() != nullptr ? device->getCommandStreamReceiver().getOSInterface()->getDeviceHandle() : 0; uint32_t deviceHandleExpected = device->getCommandStreamReceiver().getOSInterface() != nullptr ? device->getCommandStreamReceiver().getOSInterface()->getDeviceHandle() : 0;
EXPECT_EQ(reinterpret_cast<GfxDeviceHandle>(static_cast<uint64_t>(deviceHandleExpected)), interceptor.newDeviceArgIn.dh); EXPECT_EQ(reinterpret_cast<GfxDeviceHandle>(static_cast<uint64_t>(deviceHandleExpected)), interceptor.newDeviceArgIn.dh);
@ -429,7 +428,7 @@ TEST(SourceLevelDebugger, givenKernelDebuggerLibraryActiveWhenDeviceImplIsCreate
overrideCommandStreamReceiverCreation = true; overrideCommandStreamReceiverCreation = true;
// Device::create must be used to create correct OS memory manager // Device::create must be used to create correct OS memory manager
unique_ptr<Device> device(Device::create<Device>(platformDevices[0])); unique_ptr<Device> device(MockDevice::createWithNewExecutionEnvironment<Device>(platformDevices[0]));
ASSERT_NE(nullptr, device->getCommandStreamReceiver().getOSInterface()); ASSERT_NE(nullptr, device->getCommandStreamReceiver().getOSInterface());
EXPECT_TRUE(interceptor.newDeviceCalled); EXPECT_TRUE(interceptor.newDeviceCalled);