Make gmm client context non-static member

Construct platform and initialize gmm in each test

Change-Id: I4f209369e77213420308f31f911b7a569ea93283
This commit is contained in:
Mateusz Jablonski
2018-07-23 12:23:48 +02:00
committed by sys_ocldev
parent 7423919629
commit a906ddaa66
49 changed files with 113 additions and 147 deletions

2
Jenkinsfile vendored
View File

@@ -1,4 +1,4 @@
#!groovy
neoDependenciesRev='782940-1037'
strategy='EQUAL'
allowedCD=296
allowedCD=295

View File

@@ -310,7 +310,8 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
ssh,
newGSHbase,
requiredL3Index,
memoryManager->getInternalHeapBaseAddress());
memoryManager->getInternalHeapBaseAddress(),
device->getGmmHelper());
latestSentStatelessMocsConfig = requiredL3Index;

View File

@@ -105,6 +105,7 @@ class Device : public BaseObject<_cl_device_id> {
size_t &retSize);
MemoryManager *getMemoryManager() const;
GmmHelper *getGmmHelper() const;
/* We hide the retain and release function of BaseObject. */
void retain() override;
@@ -194,4 +195,7 @@ inline volatile uint32_t *Device::getTagAddress() const {
inline MemoryManager *Device::getMemoryManager() const {
return executionEnvironment->memoryManager.get();
}
inline GmmHelper *Device::getGmmHelper() const {
return executionEnvironment->getGmmHelper();
}
} // namespace OCLRT

View File

@@ -60,7 +60,6 @@ void ExecutionEnvironment::initializeMemoryManager(bool enable64KBpages) {
DEBUG_BREAK_IF(!this->memoryManager);
}
void ExecutionEnvironment::initSourceLevelDebugger(const HardwareInfo &hwInfo) {
if (hwInfo.capabilityTable.sourceLevelDebuggerSupported) {
sourceLevelDebugger.reset(SourceLevelDebugger::create());
@@ -70,4 +69,7 @@ void ExecutionEnvironment::initSourceLevelDebugger(const HardwareInfo &hwInfo) {
sourceLevelDebugger->initialize(localMemorySipAvailable);
}
}
GmmHelper *ExecutionEnvironment::getGmmHelper() const {
return gmmHelper.get();
}
} // namespace OCLRT

View File

@@ -39,10 +39,14 @@ class ExecutionEnvironment : public ReferenceTrackedObject<ExecutionEnvironment>
public:
ExecutionEnvironment();
~ExecutionEnvironment() override;
void initGmm(const HardwareInfo *hwInfo);
bool initializeCommandStreamReceiver(const HardwareInfo *pHwInfo);
void initializeMemoryManager(bool enable64KBpages);
void initSourceLevelDebugger(const HardwareInfo &hwInfo);
GmmHelper *getGmmHelper() const;
std::unique_ptr<MemoryManager> memoryManager;
std::unique_ptr<CommandStreamReceiver> commandStreamReceiver;
std::unique_ptr<SourceLevelDebugger> sourceLevelDebugger;

View File

@@ -21,6 +21,7 @@
*/
#include "gmm_client_context.h"
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/gmm_helper/gmm.h"
#include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/gmm_helper/resource_info.h"
@@ -32,34 +33,31 @@
#include "runtime/helpers/hw_info.h"
#include "runtime/sku_info/operations/sku_info_transfer.h"
#include "runtime/os_interface/os_library.h"
#include "runtime/platform/platform.h"
namespace OCLRT {
GmmClientContext *GmmHelper::getClientContext() {
return getInstance()->gmmClientContext.get();
}
GmmHelper *GmmHelper::getInstance() {
return platform()->peekExecutionEnvironment()->getGmmHelper();
}
void GmmHelper::initContext(const PLATFORM *pPlatform,
const FeatureTable *pSkuTable,
const WorkaroundTable *pWaTable,
const GT_SYSTEM_INFO *pGtSysInfo) {
if (!GmmHelper::gmmClientContext) {
_SKU_FEATURE_TABLE gmmFtrTable = {};
_WA_TABLE gmmWaTable = {};
SkuInfoTransfer::transferFtrTableForGmm(&gmmFtrTable, pSkuTable);
SkuInfoTransfer::transferWaTableForGmm(&gmmWaTable, pWaTable);
loadLib();
bool success = GMM_SUCCESS == initGlobalContextFunc(*pPlatform, &gmmFtrTable, &gmmWaTable, pGtSysInfo);
bool success = GMM_SUCCESS == GmmHelper::initGlobalContextFunc(*pPlatform, &gmmFtrTable, &gmmWaTable, pGtSysInfo);
UNRECOVERABLE_IF(!success);
GmmHelper::gmmClientContext = GmmHelper::createGmmContextWrapperFunc(GMM_CLIENT::GMM_OCL_VISTA);
}
UNRECOVERABLE_IF(!GmmHelper::gmmClientContext);
}
void GmmHelper::destroyContext() {
if (GmmHelper::gmmClientContext) {
delete GmmHelper::gmmClientContext;
GmmHelper::gmmClientContext = nullptr;
if (gmmLib) {
delete gmmLib;
gmmLib = nullptr;
}
}
gmmClientContext.reset(GmmHelper::createGmmContextWrapperFunc(GMM_CLIENT::GMM_OCL_VISTA));
UNRECOVERABLE_IF(!gmmClientContext);
}
uint32_t GmmHelper::getMOCS(uint32_t type) {
@@ -70,7 +68,7 @@ uint32_t GmmHelper::getMOCS(uint32_t type) {
return cacheEnabledIndex;
}
}
MEMORY_OBJECT_CONTROL_STATE mocs = GmmHelper::gmmClientContext->cachePolicyGetMemoryObject(nullptr, static_cast<GMM_RESOURCE_USAGE_TYPE>(type));
MEMORY_OBJECT_CONTROL_STATE mocs = gmmClientContext->cachePolicyGetMemoryObject(nullptr, static_cast<GMM_RESOURCE_USAGE_TYPE>(type));
return static_cast<uint32_t>(mocs.DwordValue);
}
@@ -166,14 +164,10 @@ GmmHelper::GmmHelper(const HardwareInfo *pHwInfo) {
initContext(pHwInfo->pPlatform, pHwInfo->pSkuTable, pHwInfo->pWaTable, pHwInfo->pSysInfo);
}
GmmHelper::~GmmHelper() {
if (isLoaded) {
destroyContext();
}
}
GmmHelper::destroyGlobalContextFunc();
};
bool GmmHelper::useSimplifiedMocsTable = false;
GmmClientContext *GmmHelper::gmmClientContext = nullptr;
GmmClientContext *(*GmmHelper::createGmmContextWrapperFunc)(GMM_CLIENT) = GmmClientContextBase::create<GmmClientContext>;
const HardwareInfo *GmmHelper::hwInfo = nullptr;
OsLibrary *GmmHelper::gmmLib = nullptr;
} // namespace OCLRT

View File

@@ -43,6 +43,9 @@ class GmmHelper {
GmmHelper() = delete;
GmmHelper(const HardwareInfo *hwInfo);
MOCKABLE_VIRTUAL ~GmmHelper();
uint32_t getMOCS(uint32_t type);
static constexpr uint32_t cacheDisabledIndex = 0;
static constexpr uint32_t cacheEnabledIndex = 4;
static constexpr uint32_t maxPossiblePitch = 2147483648;
@@ -50,7 +53,8 @@ class GmmHelper {
static uint64_t canonize(uint64_t address);
static uint64_t decanonize(uint64_t address);
static uint32_t getMOCS(uint32_t type);
static GmmClientContext *getClientContext();
static GmmHelper *getInstance();
static void queryImgFromBufferParams(ImageInfo &imgInfo, GraphicsAllocation *gfxAlloc);
static GMM_CUBE_FACE_ENUM getCubeFaceIndex(uint32_t target);
static bool allowTiling(const cl_image_desc &imageDesc);
@@ -63,18 +67,17 @@ class GmmHelper {
static decltype(GmmExportEntries::pfnDestroySingletonContext) destroyGlobalContextFunc;
static decltype(GmmExportEntries::pfnCreateClientContext) createClientContextFunc;
static decltype(GmmExportEntries::pfnDeleteClientContext) deleteClientContextFunc;
static GmmClientContext *(*createGmmContextWrapperFunc)(GMM_CLIENT);
static bool useSimplifiedMocsTable;
static const HardwareInfo *hwInfo;
static OsLibrary *gmmLib;
static GmmClientContext *gmmClientContext;
protected:
void loadLib();
void initContext(const PLATFORM *pPlatform, const FeatureTable *pSkuTable, const WorkaroundTable *pWaTable, const GT_SYSTEM_INFO *pGtSysInfo);
void destroyContext();
bool isLoaded = false;
std::unique_ptr<OsLibrary> gmmLib;
std::unique_ptr<GmmClientContext> gmmClientContext;
};
} // namespace OCLRT

View File

@@ -36,8 +36,8 @@ decltype(GmmHelper::createClientContextFunc) GmmHelper::createClientContextFunc
decltype(GmmHelper::deleteClientContextFunc) GmmHelper::deleteClientContextFunc = nullptr;
void GmmHelper::loadLib() {
gmmLib = OsLibrary::load(Os::gmmDllName);
gmmLib.reset(OsLibrary::load(Os::gmmDllName));
bool isLoaded = false;
UNRECOVERABLE_IF(!gmmLib);
if (gmmLib->isLoaded()) {
auto openGmmFunc = reinterpret_cast<decltype(&OpenGmm)>(gmmLib->getProcAddress(Os::gmmEntryName));

View File

@@ -36,6 +36,5 @@ void GmmHelper::loadLib() {
GmmHelper::destroyGlobalContextFunc = GmmDestroyGlobalContext;
GmmHelper::createClientContextFunc = GmmCreateClientContext;
GmmHelper::deleteClientContextFunc = GmmDeleteClientContext;
isLoaded = true;
}
} // namespace OCLRT

View File

@@ -26,7 +26,7 @@
namespace OCLRT {
GmmMemoryBase::GmmMemoryBase() {
clientContext = GmmHelper::gmmClientContext->getHandle();
clientContext = GmmHelper::getClientContext()->getHandle();
}
bool GmmMemoryBase::configureDeviceAddressSpace(GMM_ESCAPE_HANDLE hAdapter,
GMM_ESCAPE_HANDLE hDevice,

View File

@@ -32,7 +32,7 @@ GmmPageTableMngr::~GmmPageTableMngr() {
}
GmmPageTableMngr::GmmPageTableMngr(GMM_DEVICE_CALLBACKS_INT *deviceCb, unsigned int translationTableFlags, GMM_TRANSLATIONTABLE_CALLBACKS *translationTableCb) {
clientContext = GmmHelper::gmmClientContext->getHandle();
clientContext = GmmHelper::getClientContext()->getHandle();
pageTableManager = clientContext->CreatePageTblMgrObject(deviceCb, translationTableCb, translationTableFlags);
}

View File

@@ -26,16 +26,16 @@
namespace OCLRT {
void GmmResourceInfo::customDeleter(GMM_RESOURCE_INFO *gmmResourceInfo) {
GmmHelper::gmmClientContext->destroyResInfoObject(gmmResourceInfo);
GmmHelper::getClientContext()->destroyResInfoObject(gmmResourceInfo);
}
GmmResourceInfo::GmmResourceInfo(GMM_RESCREATE_PARAMS *resourceCreateParams) {
auto resourceInfoPtr = GmmHelper::gmmClientContext->createResInfoObject(resourceCreateParams);
auto resourceInfoPtr = GmmHelper::getClientContext()->createResInfoObject(resourceCreateParams);
this->resourceInfo = UniquePtrType(resourceInfoPtr, GmmResourceInfo::customDeleter);
}
GmmResourceInfo::GmmResourceInfo(GMM_RESOURCE_INFO *inputGmmResourceInfo) {
auto resourceInfoPtr = GmmHelper::gmmClientContext->copyResInfoObject(inputGmmResourceInfo);
auto resourceInfoPtr = GmmHelper::getClientContext()->copyResInfoObject(inputGmmResourceInfo);
this->resourceInfo = UniquePtrType(resourceInfoPtr, GmmResourceInfo::customDeleter);
}

View File

@@ -25,6 +25,7 @@
namespace OCLRT {
class GmmHelper;
class IndirectHeap;
class LinearStream;
@@ -39,7 +40,8 @@ struct StateBaseAddressHelper {
const IndirectHeap &ssh,
uint64_t generalStateBase,
uint32_t statelessMocsIndex,
uint64_t internalHeapBase);
uint64_t internalHeapBase,
GmmHelper *gmmHelper);
static void appendStateBaseAddressParameters(
STATE_BASE_ADDRESS *stateBaseAddress,

View File

@@ -36,7 +36,8 @@ void StateBaseAddressHelper<GfxFamily>::programStateBaseAddress(
const IndirectHeap &ssh,
uint64_t generalStateBase,
uint32_t statelessMocsIndex,
uint64_t internalHeapBase) {
uint64_t internalHeapBase,
GmmHelper *gmmHelper) {
auto pCmd = static_cast<STATE_BASE_ADDRESS *>(commandStream.getSpace(sizeof(STATE_BASE_ADDRESS)));
*pCmd = STATE_BASE_ADDRESS::sInit();
@@ -67,8 +68,8 @@ void StateBaseAddressHelper<GfxFamily>::programStateBaseAddress(
pCmd->setInstructionBufferSize(MemoryConstants::sizeOf4GBinPageEntities);
//set cache settings
pCmd->setStatelessDataPortAccessMemoryObjectControlState(GmmHelper::getMOCS(statelessMocsIndex));
pCmd->setInstructionMemoryObjectControlState(GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER));
pCmd->setStatelessDataPortAccessMemoryObjectControlState(gmmHelper->getMOCS(statelessMocsIndex));
pCmd->setInstructionMemoryObjectControlState(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER));
appendStateBaseAddressParameters(pCmd, dsh, ioh, ssh, generalStateBase, internalHeapBase);
}

View File

@@ -408,6 +408,7 @@ Buffer *Buffer::createBufferHwFromDevice(const Device *device,
DEBUG_BREAK_IF(nullptr == funcCreate);
auto pBuffer = funcCreate(nullptr, flags, size, memoryStorage, hostPtr, gfxAllocation,
zeroCopy, isHostPtrSVM, isImageRedescribed);
pBuffer->device = const_cast<Device *>(device);
return pBuffer;
}

View File

@@ -21,6 +21,7 @@
*/
#include "hw_cmds.h"
#include "runtime/device/device.h"
#include "runtime/helpers/surface_formats.h"
#include "runtime/helpers/aligned_memory.h"
#include "runtime/mem_obj/buffer.h"
@@ -45,6 +46,7 @@ void BufferHw<GfxFamily>::setArgStateful(void *memory) {
using SURFACE_FORMAT = typename RENDER_SURFACE_STATE::SURFACE_FORMAT;
using AUXILIARY_SURFACE_MODE = typename RENDER_SURFACE_STATE::AUXILIARY_SURFACE_MODE;
auto gmmHelper = device->getGmmHelper();
auto surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(memory);
auto surfaceSize = alignUp(getSize(), 4);
@@ -73,12 +75,11 @@ void BufferHw<GfxFamily>::setArgStateful(void *memory) {
surfaceState->setTileMode(RENDER_SURFACE_STATE::TILE_MODE_LINEAR);
surfaceState->setVerticalLineStride(0);
surfaceState->setVerticalLineStrideOffset(0);
if ((isAligned<MemoryConstants::cacheLineSize>(bufferAddress) && isAligned<MemoryConstants::cacheLineSize>(bufferSize)) ||
((getFlags() & CL_MEM_READ_ONLY)) != 0) {
surfaceState->setMemoryObjectControlState(GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER));
surfaceState->setMemoryObjectControlState(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER));
} else {
surfaceState->setMemoryObjectControlState(GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED));
surfaceState->setMemoryObjectControlState(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED));
}
surfaceState->setSurfaceBaseAddress(bufferAddress);

View File

@@ -21,6 +21,7 @@
*/
#include "hw_cmds.h"
#include "runtime/device/device.h"
#include "runtime/helpers/surface_formats.h"
#include "runtime/helpers/aligned_memory.h"
#include "runtime/mem_obj/image.h"
@@ -44,6 +45,7 @@ void ImageHw<GfxFamily>::setImageArg(void *memory, bool setAsMediaBlockImage, ui
using SURFACE_FORMAT = typename RENDER_SURFACE_STATE::SURFACE_FORMAT;
auto surfaceState = reinterpret_cast<RENDER_SURFACE_STATE *>(memory);
auto gmm = getGraphicsAllocation()->gmm;
auto gmmHelper = device->getGmmHelper();
auto imageCount = std::max(getImageDesc().image_depth, getImageDesc().image_array_size);
if (imageCount == 0) {
@@ -153,7 +155,7 @@ void ImageHw<GfxFamily>::setImageArg(void *memory, bool setAsMediaBlockImage, ui
}
surfaceState->setTileMode(tileMode);
surfaceState->setMemoryObjectControlState(GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_IMAGE));
surfaceState->setMemoryObjectControlState(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_IMAGE));
surfaceState->setXOffset(this->surfaceOffsets.xOffset);
surfaceState->setYOffset(this->surfaceOffsets.yOffset);
@@ -218,6 +220,7 @@ void ImageHw<GfxFamily>::setMediaImageArg(void *memory) {
using SURFACE_FORMAT = typename MEDIA_SURFACE_STATE::SURFACE_FORMAT;
SURFACE_FORMAT surfaceFormat = MEDIA_SURFACE_STATE::SURFACE_FORMAT_Y8_UNORM_VA;
auto gmmHelper = device->getGmmHelper();
auto surfaceState = reinterpret_cast<MEDIA_SURFACE_STATE *>(memory);
*surfaceState = MEDIA_SURFACE_STATE::sInit();
@@ -243,7 +246,7 @@ void ImageHw<GfxFamily>::setMediaImageArg(void *memory) {
setSurfaceMemoryObjectControlStateIndexToMocsTable(
reinterpret_cast<void *>(surfaceState),
GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_IMAGE));
gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_IMAGE));
if (IsNV12Image(&this->getImageFormat())) {
surfaceState->setInterleaveChroma(true);

View File

@@ -53,6 +53,7 @@ MemObj::MemObj(Context *context,
if (context) {
context->incRefInternal();
memoryManager = context->getMemoryManager();
device = context->getDevice(0);
}
}
@@ -218,7 +219,6 @@ size_t MemObj::getSize() const {
void MemObj::setCompletionStamp(CompletionStamp completionStamp, Device *pDevice, CommandQueue *pCmdQ) {
this->completionStamp = completionStamp;
device = pDevice;
cmdQueuePtr = pCmdQ;
}

View File

@@ -105,7 +105,6 @@ class MemObj : public BaseObject<_cl_mem> {
virtual bool allowTiling() const { return false; }
CommandQueue *getAssociatedCommandQueue() { return cmdQueuePtr; }
Device *getAssociatedDevice() { return device; }
bool isImageFromImage() const { return isImageFromImageCreated; }
void *getCpuAddressForMapping();

View File

@@ -63,6 +63,7 @@ struct clCreateCommandQueueWithPropertiesApi : public api_fixture,
}
void SetUp() override {
platformImpl.reset();
MemoryManagementFixture::SetUp();
api_fixture::SetUp();
}

View File

@@ -21,7 +21,6 @@
*/
#pragma once
#include "runtime/platform/platform.h"
#include "unit_tests/aub_tests/command_stream/aub_command_stream_fixture.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/fixtures/built_in_fixture.h"
@@ -37,7 +36,6 @@ struct CommandEnqueueAUBFixture : public CommandEnqueueBaseFixture,
public AUBCommandStreamFixture {
using AUBCommandStreamFixture::SetUp;
void SetUp() {
constructPlatform();
CommandEnqueueBaseFixture::SetUp(cl_command_queue_properties(0));
AUBCommandStreamFixture::SetUp(pCmdQ);
}
@@ -45,7 +43,6 @@ struct CommandEnqueueAUBFixture : public CommandEnqueueBaseFixture,
void TearDown() {
AUBCommandStreamFixture::TearDown();
CommandEnqueueBaseFixture::TearDown();
platformImpl.reset(nullptr);
}
};
} // namespace OCLRT

View File

@@ -41,7 +41,6 @@ struct AUBCopyImage
typedef AUBCommandStreamFixture CommandStreamFixture;
void SetUp() override {
constructPlatform();
CommandDeviceFixture::SetUp(cl_command_queue_properties(0));
CommandStreamFixture::SetUp(pCmdQ);
context = new MockContext(pDevice);
@@ -53,7 +52,6 @@ struct AUBCopyImage
delete context;
CommandStreamFixture::TearDown();
CommandDeviceFixture::TearDown();
platformImpl.reset(nullptr);
}
MockContext *context;

View File

@@ -103,7 +103,6 @@ struct AubFillImage
typedef AUBCommandStreamFixture CommandStreamFixture;
void SetUp() override {
constructPlatform();
CommandDeviceFixture::SetUp(cl_command_queue_properties(0));
CommandStreamFixture::SetUp(pCmdQ);
context = new MockContext(pDevice);
@@ -114,7 +113,6 @@ struct AubFillImage
delete context;
CommandStreamFixture::TearDown();
CommandDeviceFixture::TearDown();
platformImpl.reset(nullptr);
}
MockContext *context;

View File

@@ -53,7 +53,6 @@ struct AUBMapImage
using AUBCommandStreamFixture::SetUp;
void SetUp() override {
constructPlatform();
CommandDeviceFixture::SetUp(cl_command_queue_properties(0));
CommandStreamFixture::SetUp(pCmdQ);
context = new MockContext(pDevice);
@@ -64,7 +63,6 @@ struct AUBMapImage
delete context;
CommandStreamFixture::TearDown();
CommandDeviceFixture::TearDown();
platformImpl.reset(nullptr);
}
MockContext *context;

View File

@@ -55,7 +55,6 @@ struct AUBReadImage
using AUBCommandStreamFixture::SetUp;
void SetUp() override {
constructPlatform();
CommandDeviceFixture::SetUp(cl_command_queue_properties(0));
CommandStreamFixture::SetUp(pCmdQ);
context = new MockContext(pDevice);
@@ -66,7 +65,6 @@ struct AUBReadImage
delete context;
CommandStreamFixture::TearDown();
CommandDeviceFixture::TearDown();
platformImpl.reset(nullptr);
}
MockContext *context;

View File

@@ -53,7 +53,6 @@ struct AUBWriteImage
using AUBCommandStreamFixture::SetUp;
void SetUp() override {
constructPlatform();
CommandDeviceFixture::SetUp(cl_command_queue_properties(0));
CommandStreamFixture::SetUp(pCmdQ);
context = new MockContext(pDevice);
@@ -64,7 +63,6 @@ struct AUBWriteImage
delete context;
CommandStreamFixture::TearDown();
CommandDeviceFixture::TearDown();
platformImpl.reset(nullptr);
}
MockContext *context;

View File

@@ -48,7 +48,6 @@ struct AUBCreateImage
using AUBCommandStreamFixture::SetUp;
void SetUp() override {
constructPlatform();
CommandDeviceFixture::SetUp(cl_command_queue_properties(0));
CommandStreamFixture::SetUp(pCmdQ);
@@ -72,7 +71,6 @@ struct AUBCreateImage
//delete context;
CommandStreamFixture::TearDown();
CommandDeviceFixture::TearDown();
platformImpl.reset(nullptr);
}
//MockContext *context;

View File

@@ -30,7 +30,6 @@
#include "runtime/helpers/string.h"
#include "runtime/kernel/kernel.h"
#include "runtime/os_interface/debug_settings_manager.h"
#include "runtime/platform/platform.h"
#include "unit_tests/fixtures/built_in_fixture.h"
#include "unit_tests/fixtures/device_fixture.h"
#include "unit_tests/fixtures/context_fixture.h"
@@ -65,7 +64,6 @@ class BuiltInTests
}
void SetUp() override {
constructPlatform();
DeviceFixture::SetUp();
cl_device_id device = pDevice;
ContextFixture::SetUp(1, &device);
@@ -77,7 +75,6 @@ class BuiltInTests
BuiltInFixture::TearDown();
ContextFixture::TearDown();
DeviceFixture::TearDown();
platformImpl.reset(nullptr);
}
void AppendBuiltInStringFromFile(std::string builtInFile, size_t &size) {

View File

@@ -24,12 +24,10 @@
#include "buffer_operations_fixture.h"
#include "runtime/helpers/options.h"
#include "runtime/platform/platform.h"
namespace OCLRT {
struct AsyncGPUoperations : public EnqueueWriteBufferTypeTest {
void SetUp() override {
constructPlatform();
storeInitHWTag = initialHardwareTag;
initialHardwareTag = 0;
EnqueueWriteBufferTypeTest::SetUp();
@@ -38,7 +36,6 @@ struct AsyncGPUoperations : public EnqueueWriteBufferTypeTest {
void TearDown() override {
initialHardwareTag = storeInitHWTag;
EnqueueWriteBufferTypeTest::TearDown();
platformImpl.reset(nullptr);
}
protected:

View File

@@ -22,7 +22,6 @@
#include "runtime/compiler_interface/compiler_options.h"
#include "runtime/command_queue/command_queue.h"
#include "runtime/platform/platform.h"
#include "runtime/program/program.h"
#include "runtime/source_level_debugger/source_level_debugger.h"
#include "unit_tests/fixtures/enqueue_handler_fixture.h"
@@ -44,7 +43,6 @@ class EnqueueDebugKernelTest : public ProgramSimpleFixture,
public ::testing::Test {
public:
void SetUp() override {
constructPlatform();
ProgramSimpleFixture::SetUp();
device = pDevice;
pDevice->executionEnvironment->sourceLevelDebugger.reset(new SourceLevelDebugger(nullptr));
@@ -92,7 +90,6 @@ class EnqueueDebugKernelTest : public ProgramSimpleFixture,
debugKernel->release();
}
ProgramSimpleFixture::TearDown();
platformImpl.reset(nullptr);
}
cl_device_id device;
Kernel *debugKernel = nullptr;

View File

@@ -87,7 +87,6 @@ HWCMDTEST_F(IGFX_GEN8_CORE, EnqueueReadBufferTypeTest, GPGPUWalker) {
// Verify srcBuffer internal state
EXPECT_EQ(nullptr, srcBuffer->getAssociatedCommandQueue());
EXPECT_EQ(nullptr, srcBuffer->getAssociatedDevice());
// Compute the SIMD lane mask
size_t simd =

View File

@@ -26,7 +26,6 @@
#include "unit_tests/fixtures/buffer_fixture.h"
#include "unit_tests/helpers/debug_manager_state_restore.h"
#include "runtime/memory_manager/svm_memory_manager.h"
#include "runtime/platform/platform.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_kernel.h"
#include "runtime/memory_manager/surface.h"
@@ -46,7 +45,6 @@ struct EnqueueSvmTest : public DeviceFixture,
}
void SetUp() override {
constructPlatform();
DeviceFixture::SetUp();
CommandQueueFixture::SetUp(pDevice, 0);
ptrSVM = context->getSVMAllocsManager()->createSVMAlloc(256);
@@ -56,7 +54,6 @@ struct EnqueueSvmTest : public DeviceFixture,
context->getSVMAllocsManager()->freeSVMAlloc(ptrSVM);
CommandQueueFixture::TearDown();
DeviceFixture::TearDown();
platformImpl.reset(nullptr);
}
cl_int retVal = CL_SUCCESS;

View File

@@ -32,7 +32,6 @@
#include "runtime/event/perf_counter.h"
#include "runtime/kernel/kernel.h"
#include "runtime/helpers/kernel_commands.h"
#include "runtime/platform/platform.h"
#include "unit_tests/command_queue/command_enqueue_fixture.h"
#include "unit_tests/command_queue/enqueue_fixture.h"
#include "unit_tests/command_queue/enqueue_write_image_fixture.h"
@@ -50,7 +49,6 @@ struct GetSizeRequiredImageTest : public CommandEnqueueFixture,
}
void SetUp() override {
constructPlatform();
CommandEnqueueFixture::SetUp();
srcImage = Image2dHelper<>::create(context);
@@ -64,7 +62,6 @@ struct GetSizeRequiredImageTest : public CommandEnqueueFixture,
delete srcImage;
CommandEnqueueFixture::TearDown();
platformImpl.reset(nullptr);
}
Image *srcImage = nullptr;

View File

@@ -435,8 +435,9 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, stateBaseAddressTracking) {
HWCMDTEST_F(IGFX_GEN8_CORE, CommandStreamReceiverFlushTaskTests, stateBaseAddressProgrammingShouldMatchTracking) {
typedef typename FamilyType::STATE_BASE_ADDRESS STATE_BASE_ADDRESS;
auto stateHeapMocs = GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER);
auto l3CacheOnMocs = GmmHelper::getMOCS(CacheSettings::l3CacheOn);
auto gmmHelper = pDevice->getGmmHelper();
auto stateHeapMocs = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_STATE_HEAP_BUFFER);
auto l3CacheOnMocs = gmmHelper->getMOCS(CacheSettings::l3CacheOn);
auto &commandStreamReceiver = pDevice->getUltCommandStreamReceiver<FamilyType>();
flushTask(commandStreamReceiver);

View File

@@ -53,7 +53,6 @@ class CompilerInterfaceTest : public DeviceFixture,
public ::testing::Test {
public:
void SetUp() override {
constructPlatform();
DeviceFixture::SetUp();
retVal = CL_SUCCESS;
@@ -99,7 +98,6 @@ class CompilerInterfaceTest : public DeviceFixture,
pCompilerInterface.reset();
DeviceFixture::TearDown();
platformImpl.reset(nullptr);
}
std::unique_ptr<MockCompilerInterface> pCompilerInterface = nullptr;

View File

@@ -55,7 +55,6 @@ class AsyncEventsHandlerTests : public ::testing::Test {
}
void SetUp() override {
constructPlatform();
dbgRestore.reset(new DebugManagerStateRestore());
DebugManager.flags.EnableAsyncEventsHandler.set(false);
handler.reset(new MockHandler());
@@ -69,7 +68,6 @@ class AsyncEventsHandlerTests : public ::testing::Test {
event1->release();
event2->release();
event3->release();
platformImpl.reset(nullptr);
}
std::unique_ptr<DebugManagerStateRestore> dbgRestore;

View File

@@ -56,7 +56,6 @@ TEST(EventCallbackTest, NestedCallbacksAreCalledForUserEvent) {
}
TEST(EventCallbackTest, NestedCallbacksAreCalledForEvent) {
constructPlatform();
std::unique_ptr<Device> device(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
MockContext context;
MockCommandQueue queue(&context, device.get(), nullptr);
@@ -69,5 +68,4 @@ TEST(EventCallbackTest, NestedCallbacksAreCalledForEvent) {
platform()->getAsyncEventsHandler()->closeThread();
EXPECT_EQ(4u, nestLevel);
platformImpl.reset(nullptr);
}

View File

@@ -73,7 +73,6 @@ struct HelloWorldFixture : public FixtureFactory::IndirectHeapFixture,
public:
virtual void SetUp() {
constructPlatform();
DeviceFixture::SetUp();
ASSERT_NE(nullptr, pDevice);
CommandQueueFixture::SetUp(pDevice, 0);
@@ -107,7 +106,6 @@ struct HelloWorldFixture : public FixtureFactory::IndirectHeapFixture,
CommandQueueFixture::TearDown();
delete BufferDefaults::context;
DeviceFixture::TearDown();
platformImpl.reset(nullptr);
}
void *pSrcMemory;

View File

@@ -31,6 +31,7 @@
#include "runtime/gmm_helper/gmm_helper.h"
#include "unit_tests/mocks/mock_device.h"
#include "unit_tests/mocks/mock_gmm.h"
#include "runtime/platform/platform.h"
using namespace ::testing;
@@ -604,30 +605,6 @@ TEST(GmmTest, givenInvalidFlagsSetWhenAskedForUnifiedAuxTranslationCapabilityThe
EXPECT_FALSE(gmm->unifiedAuxTranslationCapable()); // RenderCompressed == 0
}
class MockGmmHelper : public GmmHelper {
public:
using GmmHelper::destroyContext;
using GmmHelper::initContext;
MockGmmHelper(const HardwareInfo *hwInfo) : GmmHelper(hwInfo) {}
};
TEST(GmmTest, whenContextIsInitializedMultipleTimesThenDontOverride) {
const HardwareInfo *hwinfo = *platformDevices;
auto gmmHelper = MockGmmHelper(hwinfo);
auto currentClientContext = GmmHelper::gmmClientContext;
auto currentClientContextHandle = GmmHelper::gmmClientContext->getHandle();
gmmHelper.initContext(hwinfo->pPlatform, hwinfo->pSkuTable, hwinfo->pWaTable, hwinfo->pSysInfo);
EXPECT_EQ(currentClientContext, GmmHelper::gmmClientContext);
EXPECT_EQ(currentClientContextHandle, GmmHelper::gmmClientContext->getHandle());
}
TEST(GmmTest, whenContextIsDestroyedMultimpleTimesThenDontCrash) {
const HardwareInfo *hwinfo = *platformDevices;
auto gmmHelper = MockGmmHelper(hwinfo);
gmmHelper.destroyContext();
}
TEST(GmmTest, givenHwInfoWhenDeviceIsCreatedTheSetThisHwInfoToGmmHelper) {
HardwareInfo localHwInfo = **platformDevices;
@@ -653,8 +630,7 @@ TEST(GmmTest, whenResourceIsCreatedThenHandleItsOwnership) {
gmmParams.Flags.Info.Cacheable = 1;
gmmParams.Flags.Gpu.Texture = 1;
gmmParams.Usage = GMM_RESOURCE_USAGE_OCL_BUFFER;
ExecutionEnvironment executionEnvironment;
executionEnvironment.initGmm(*platformDevices);
MyMockResourecInfo myMockResourceInfo1(&gmmParams);
EXPECT_NE(nullptr, myMockResourceInfo1.resourceInfo.get());
@@ -666,7 +642,8 @@ TEST(GmmTest, whenResourceIsCreatedThenHandleItsOwnership) {
TEST(GmmSimplifiedCacheSelectionPolicy, givenGmmInSimplifiedCacheSelectionPolicyWhenItIsAskedForUncachedIndexThen0IsReturned) {
GmmHelper::useSimplifiedMocsTable = true;
auto index = GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED);
GmmHelper gmmHelper(*platformDevices);
auto index = gmmHelper.getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED);
auto expectedIndex = GmmHelper::cacheDisabledIndex;
EXPECT_EQ(expectedIndex, index);
GmmHelper::useSimplifiedMocsTable = false;
@@ -674,10 +651,16 @@ TEST(GmmSimplifiedCacheSelectionPolicy, givenGmmInSimplifiedCacheSelectionPolicy
TEST(GmmSimplifiedCacheSelectionPolicy, givenGmmInSimplifiedCacheSelectionPolicyWhenItIsAskedForCachedIndexThen4IsReturned) {
GmmHelper::useSimplifiedMocsTable = true;
auto index = GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER);
GmmHelper gmmHelper(*platformDevices);
auto index = gmmHelper.getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER);
auto expectedIndex = GmmHelper::cacheEnabledIndex;
EXPECT_EQ(expectedIndex, index);
GmmHelper::useSimplifiedMocsTable = false;
}
TEST(GmmHelperTest, whenGmmHelperIsInitializedThenClientContextIsSet) {
ASSERT_NE(nullptr, GmmHelper::getClientContext());
EXPECT_NE(nullptr, GmmHelper::getClientContext()->getHandle());
}
} // namespace OCLRT

View File

@@ -150,6 +150,7 @@ class GTPinFixture : public ContextFixture, public MemoryManagementFixture {
public:
void SetUp() override {
platformImpl.reset();
MemoryManagementFixture::SetUp();
constructPlatform();
pPlatform = platform();

View File

@@ -21,7 +21,6 @@
*/
#include "gtest/gtest.h"
#include "runtime/platform/platform.h"
#include "unit_tests/mocks/mock_context.h"
#include "unit_tests/mocks/mock_device.h"
#include "unit_tests/mocks/mock_kernel.h"
@@ -31,7 +30,6 @@ using namespace OCLRT;
class PatchedKernelTest : public ::testing::Test {
public:
void SetUp() override {
constructPlatform();
device.reset(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));
context.reset(new MockContext(device.get()));
program.reset(Program::create("FillBufferBytes", context.get(), *device.get(), true, &retVal));
@@ -43,7 +41,6 @@ class PatchedKernelTest : public ::testing::Test {
}
void TearDown() override {
context.reset();
platformImpl.reset(nullptr);
}
std::unique_ptr<MockContext> context;

View File

@@ -899,7 +899,8 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferSetSurfaceThatMemoryPtrAndSizeIsAlign
ptr);
auto mocs = surfaceState.getMemoryObjectControlState();
EXPECT_EQ(GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER), mocs);
auto gmmHelper = device->getGmmHelper();
EXPECT_EQ(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER), mocs);
alignedFree(ptr);
}
@@ -921,7 +922,8 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferSetSurfaceThatMemoryPtrIsUnalignedToC
offsetedPtr);
auto mocs = surfaceState.getMemoryObjectControlState();
EXPECT_EQ(GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED), mocs);
auto gmmHelper = device->getGmmHelper();
EXPECT_EQ(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED), mocs);
alignedFree(ptr);
}
@@ -943,7 +945,8 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferSetSurfaceThatMemorySizeIsUnalignedTo
ptr);
auto mocs = surfaceState.getMemoryObjectControlState();
EXPECT_EQ(GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED), mocs);
auto gmmHelper = device->getGmmHelper();
EXPECT_EQ(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED), mocs);
alignedFree(ptr);
}
@@ -967,7 +970,8 @@ HWTEST_F(BufferSetSurfaceTests, givenBufferSetSurfaceThatMemoryIsUnalignedToCach
CL_MEM_READ_ONLY);
auto mocs = surfaceState.getMemoryObjectControlState();
EXPECT_EQ(GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER), mocs);
auto gmmHelper = device->getGmmHelper();
EXPECT_EQ(gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER), mocs);
alignedFree(ptr);
}

View File

@@ -251,7 +251,8 @@ HWTEST_F(ImageSetArgTest, givenOffsetedBufferWhenSetKernelArgImageIscalledThenFu
}
HWTEST_F(ImageSetArgTest, clSetKernelArgImage) {
auto imageMocs = GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_IMAGE);
auto gmmHelper = pDevice->getGmmHelper();
auto imageMocs = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_IMAGE);
typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE;
cl_mem memObj = srcImage;
@@ -784,7 +785,8 @@ class ImageMediaBlockSetArgTest : public ImageSetArgTest {
};
HWTEST_F(ImageMediaBlockSetArgTest, clSetKernelArgImage) {
auto imageMocs = GmmHelper::getMOCS(GMM_RESOURCE_USAGE_OCL_IMAGE);
auto gmmHelper = pDevice->getGmmHelper();
auto imageMocs = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_IMAGE);
typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE;
cl_mem memObj = srcImage;

View File

@@ -24,6 +24,8 @@
#include "runtime/helpers/options.h"
#include "gmm_memory.h"
#include "gmm_client_context.h"
#include "runtime/platform/platform.h"
#include "runtime/execution_environment/execution_environment.h"
#include "gtest/gtest.h"
using namespace OCLRT;
@@ -33,8 +35,7 @@ class PublicGmmMemory : public GmmMemory {
};
TEST(GmmMemoryTest, givenGmmHelperWhenCreateGmmMemoryThenItHasClientContextFromGmmHelper) {
GmmHelper gmmHelper(*platformDevices);
ASSERT_NE(nullptr, GmmHelper::gmmClientContext);
ASSERT_NE(nullptr, GmmHelper::getClientContext());
PublicGmmMemory gmmMemory;
EXPECT_EQ(gmmMemory.clientContext, GmmHelper::gmmClientContext->getHandle());
EXPECT_EQ(gmmMemory.clientContext, GmmHelper::getClientContext()->getHandle());
}

View File

@@ -181,16 +181,17 @@ TEST_F(PlatformTest, testRemoveLastSpace) {
EXPECT_EQ(std::string("x"), xSpaceString);
}
TEST(PlatformConstructionTest, givenPlatformConstructorWhenItIsCalledTwiceThenTheSamePlatformIsReturned) {
platformImpl.reset();
ASSERT_EQ(nullptr, platformImpl);
auto platform = constructPlatform();
EXPECT_EQ(platform, platformImpl.get());
auto platform2 = constructPlatform();
EXPECT_EQ(platform2, platform);
EXPECT_NE(platform, nullptr);
platformImpl.reset(nullptr);
}
TEST(PlatformConstructionTest, givenPlatformConstructorWhenItIsCalledAfterResetThenNewPlatformIsConstructed) {
platformImpl.reset();
ASSERT_EQ(nullptr, platformImpl);
auto platform = constructPlatform();
std::unique_ptr<Platform> temporaryOwnership(std::move(platformImpl));

View File

@@ -56,7 +56,6 @@
using namespace OCLRT;
void ProgramTests::SetUp() {
constructPlatform();
DeviceFixture::SetUp();
cl_device_id device = pDevice;
ContextFixture::SetUp(1, &device);
@@ -64,7 +63,6 @@ void ProgramTests::SetUp() {
void ProgramTests::TearDown() {
ContextFixture::TearDown();
DeviceFixture::TearDown();
platformImpl.reset(nullptr);
}
void CL_CALLBACK notifyFunc(
@@ -2962,7 +2960,6 @@ TEST(SimpleProgramTests, givenDefaultProgramWhenSetDeviceIsCalledThenDeviceIsSet
}
TEST(ProgramDestructionTests, givenProgramUsingDeviceWhenItIsDestroyedAfterPlatfromCleanupThenItIsCleanedUpProperly) {
constructPlatform();
platformImpl->initialize();
auto device = platformImpl->getDevice(0);
MockContext *context = new MockContext(device, false);

View File

@@ -21,7 +21,6 @@
*/
#include "runtime/compiler_interface/compiler_options.h"
#include "runtime/platform/platform.h"
#include "unit_tests/fixtures/program_fixture.h"
#include "unit_tests/global_environment.h"
#include "unit_tests/helpers/kernel_binary_helper.h"
@@ -53,7 +52,6 @@ class ProgramWithKernelDebuggingTest : public ProgramSimpleFixture,
public ::testing::Test {
public:
void SetUp() override {
constructPlatform();
ProgramSimpleFixture::SetUp();
device = pDevice;
@@ -73,7 +71,6 @@ class ProgramWithKernelDebuggingTest : public ProgramSimpleFixture,
void TearDown() override {
delete kbHelper;
ProgramSimpleFixture::TearDown();
platformImpl.reset(nullptr);
}
cl_device_id device;
KernelBinaryHelper *kbHelper = nullptr;

View File

@@ -20,11 +20,16 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include "runtime/gmm_helper/gmm_helper.h"
#include "runtime/execution_environment/execution_environment.h"
#include "runtime/helpers/options.h"
#include "runtime/platform/platform.h"
#include "unit_tests/ult_config_listener.h"
void OCLRT::UltConfigListener::OnTestStart(const ::testing::TestInfo &testInfo) {
// Set default HardwareInfo for all ULTs that dont want to create Device and test initialization path
GmmHelper::hwInfo = platformDevices[0];
// Create platform and initialize gmm that dont want to create Platform and test gmm initialization path
constructPlatform()->peekExecutionEnvironment()->initGmm(*platformDevices);
}
void OCLRT::UltConfigListener::OnTestEnd(const ::testing::TestInfo &testInfo) {
// Clear global platform that it shouldn't be reused between tests
platformImpl.reset();
}

View File

@@ -27,5 +27,6 @@ namespace OCLRT {
class UltConfigListener : public ::testing::EmptyTestEventListener {
private:
void OnTestStart(const ::testing::TestInfo &) override;
void OnTestEnd(const ::testing::TestInfo &) override;
};
} // namespace OCLRT