diff --git a/opencl/source/device/cl_device.cpp b/opencl/source/device/cl_device.cpp index 63aae3505e..32172193ab 100644 --- a/opencl/source/device/cl_device.cpp +++ b/opencl/source/device/cl_device.cpp @@ -104,6 +104,7 @@ EngineControl &ClDevice::getDefaultEngine() { return device.getDefaultEngine(); EngineControl &ClDevice::getInternalEngine() { return device.getInternalEngine(); } MemoryManager *ClDevice::getMemoryManager() const { return device.getMemoryManager(); } GmmHelper *ClDevice::getGmmHelper() const { return device.getGmmHelper(); } +GmmClientContext *ClDevice::getGmmClientContext() const { return device.getGmmClientContext(); } double ClDevice::getProfilingTimerResolution() { return device.getProfilingTimerResolution(); } double ClDevice::getPlatformHostTimerResolution() const { return device.getPlatformHostTimerResolution(); } bool ClDevice::isSimulation() const { return device.isSimulation(); } diff --git a/opencl/source/device/cl_device.h b/opencl/source/device/cl_device.h index 9570d502f6..e1c688c2cd 100644 --- a/opencl/source/device/cl_device.h +++ b/opencl/source/device/cl_device.h @@ -22,6 +22,7 @@ namespace NEO { class Device; class ExecutionEnvironment; class GmmHelper; +class GmmClientContext; class MemoryManager; class PerformanceCounters; class SourceLevelDebugger; @@ -62,6 +63,7 @@ class ClDevice : public BaseObject<_cl_device_id> { EngineControl &getInternalEngine(); MemoryManager *getMemoryManager() const; GmmHelper *getGmmHelper() const; + GmmClientContext *getGmmClientContext() const; double getProfilingTimerResolution(); double getPlatformHostTimerResolution() const; bool isSimulation() const; diff --git a/opencl/source/mem_obj/buffer.cpp b/opencl/source/mem_obj/buffer.cpp index c782cb36be..21e0f485bd 100644 --- a/opencl/source/mem_obj/buffer.cpp +++ b/opencl/source/mem_obj/buffer.cpp @@ -586,6 +586,7 @@ Buffer *Buffer::createBufferHwFromDevice(const Device *device, zeroCopy, isHostPtrSVM, isImageRedescribed); pBuffer->offset = offset; pBuffer->executionEnvironment = device->getExecutionEnvironment(); + pBuffer->rootDeviceEnvironment = pBuffer->executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()].get(); return pBuffer; } @@ -605,7 +606,7 @@ uint32_t Buffer::getMocsValue(bool disableL3Cache, bool isReadOnlyArgument) cons bool alignedMemObj = isAligned(bufferAddress) && isAligned(bufferSize); - auto gmmHelper = executionEnvironment->getGmmHelper(); + auto gmmHelper = rootDeviceEnvironment->getGmmHelper(); if (!disableL3Cache && !isMemObjUncacheableForSurfaceState() && (alignedMemObj || readOnlyMemObj || !isMemObjZeroCopy())) { return gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); } else { diff --git a/opencl/source/mem_obj/image.cpp b/opencl/source/mem_obj/image.cpp index 847de14ab0..bc202fb4ee 100644 --- a/opencl/source/mem_obj/image.cpp +++ b/opencl/source/mem_obj/image.cpp @@ -130,7 +130,7 @@ Image *Image::create(Context *context, Image *parentImage = castToObject(imageDesc->mem_object); auto &hwHelper = HwHelper::get(context->getDevice(0)->getHardwareInfo().platform.eRenderCoreFamily); auto rootDeviceIndex = context->getDevice(0)->getRootDeviceIndex(); - auto clientContext = context->getDevice(0)->getExecutionEnvironment()->getGmmClientContext(); + auto clientContext = context->getDevice(0)->getRootDeviceEnvironment().getGmmClientContext(); do { size_t imageWidth = imageDesc->image_width; @@ -675,7 +675,7 @@ cl_int Image::getImageParams(Context *context, size_t *imageRowPitch, size_t *imageSlicePitch) { cl_int retVal = CL_SUCCESS; - auto clientContext = context->getDevice(0)->getExecutionEnvironment()->getGmmClientContext(); + auto clientContext = context->getDevice(0)->getRootDeviceEnvironment().getGmmClientContext(); ImageInfo imgInfo = {}; cl_image_desc imageDescriptor = *imageDesc; diff --git a/opencl/source/mem_obj/image.inl b/opencl/source/mem_obj/image.inl index d661701efd..8303c83adf 100644 --- a/opencl/source/mem_obj/image.inl +++ b/opencl/source/mem_obj/image.inl @@ -5,7 +5,7 @@ * */ -#include "shared/source/execution_environment/execution_environment.h" +#include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/gmm_helper/gmm.h" #include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/gmm_helper/resource_info.h" @@ -34,7 +34,7 @@ void ImageHw::setImageArg(void *memory, bool setAsMediaBlockImage, ui auto surfaceState = reinterpret_cast(memory); auto gmm = getGraphicsAllocation()->getDefaultGmm(); - auto gmmHelper = executionEnvironment->getGmmHelper(); + auto gmmHelper = rootDeviceEnvironment->getGmmHelper(); auto imageDescriptor = Image::convertDescriptor(getImageDesc()); ImageInfo imgInfo; @@ -133,7 +133,7 @@ void ImageHw::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 = executionEnvironment->getGmmHelper(); + auto gmmHelper = rootDeviceEnvironment->getGmmHelper(); auto surfaceState = reinterpret_cast(memory); *surfaceState = GfxFamily::cmdInitMediaSurfaceState; diff --git a/opencl/source/mem_obj/mem_obj.cpp b/opencl/source/mem_obj/mem_obj.cpp index 2c7a625950..4869a6e38f 100644 --- a/opencl/source/mem_obj/mem_obj.cpp +++ b/opencl/source/mem_obj/mem_obj.cpp @@ -47,7 +47,9 @@ MemObj::MemObj(Context *context, if (context) { context->incRefInternal(); memoryManager = context->getMemoryManager(); - executionEnvironment = context->getDevice(0)->getExecutionEnvironment(); + auto device = context->getDevice(0); + executionEnvironment = device->getExecutionEnvironment(); + rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[device->getRootDeviceIndex()].get(); } } diff --git a/opencl/source/mem_obj/mem_obj.h b/opencl/source/mem_obj/mem_obj.h index b2e1527407..604196f822 100644 --- a/opencl/source/mem_obj/mem_obj.h +++ b/opencl/source/mem_obj/mem_obj.h @@ -23,6 +23,7 @@ namespace NEO { class ExecutionEnvironment; +struct RootDeviceEnvironment; class GraphicsAllocation; struct KernelInfo; class MemoryManager; @@ -145,6 +146,7 @@ class MemObj : public BaseObject<_cl_mem> { MemObj *associatedMemObject = nullptr; cl_uint refCount = 0; ExecutionEnvironment *executionEnvironment = nullptr; + RootDeviceEnvironment *rootDeviceEnvironment = nullptr; bool isZeroCopy; bool isHostPtrSVM; bool isObjectRedescribed; diff --git a/opencl/source/memory_manager/os_agnostic_memory_manager.cpp b/opencl/source/memory_manager/os_agnostic_memory_manager.cpp index cfb8315d05..5c33a92e8d 100644 --- a/opencl/source/memory_manager/os_agnostic_memory_manager.cpp +++ b/opencl/source/memory_manager/os_agnostic_memory_manager.cpp @@ -158,7 +158,7 @@ GraphicsAllocation *OsAgnosticMemoryManager::createGraphicsAllocationFromSharedH graphicsAllocation->set32BitAllocation(requireSpecificBitness); if (properties.imgInfo) { - Gmm *gmm = new Gmm(executionEnvironment.getGmmClientContext(), *properties.imgInfo, createStorageInfoFromProperties(properties)); + Gmm *gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex]->getGmmClientContext(), *properties.imgInfo, createStorageInfoFromProperties(properties)); graphicsAllocation->setDefaultGmm(gmm); } @@ -276,7 +276,7 @@ void OsAgnosticMemoryManager::cleanOsHandles(OsHandleStorage &handleStorage, uin } GraphicsAllocation *OsAgnosticMemoryManager::allocateShareableMemory(const AllocationData &allocationData) { - auto gmm = std::make_unique(executionEnvironment.getGmmClientContext(), allocationData.hostPtr, allocationData.size, false); + auto gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), allocationData.hostPtr, allocationData.size, false); GraphicsAllocation *alloc = nullptr; auto ptr = allocateSystemMemory(alignUp(allocationData.size, MemoryConstants::pageSize), MemoryConstants::pageSize); diff --git a/opencl/source/os_interface/linux/drm_command_stream.inl b/opencl/source/os_interface/linux/drm_command_stream.inl index b3f2db7eac..9b4d3aa426 100644 --- a/opencl/source/os_interface/linux/drm_command_stream.inl +++ b/opencl/source/os_interface/linux/drm_command_stream.inl @@ -146,7 +146,7 @@ DrmMemoryManager *DrmCommandStreamReceiver::getMemoryManager() const template GmmPageTableMngr *DrmCommandStreamReceiver::createPageTableManager() { - GmmPageTableMngr *gmmPageTableMngr = GmmPageTableMngr::create(this->executionEnvironment.getGmmClientContext(), TT_TYPE::AUXTT, nullptr); + GmmPageTableMngr *gmmPageTableMngr = GmmPageTableMngr::create(this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex]->getGmmClientContext(), TT_TYPE::AUXTT, nullptr); gmmPageTableMngr->setCsrHandle(this); this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex]->pageTableManager.reset(gmmPageTableMngr); return gmmPageTableMngr; diff --git a/opencl/source/os_interface/windows/wddm_device_command_stream.inl b/opencl/source/os_interface/windows/wddm_device_command_stream.inl index 9a187d2ce1..8b6cdbe0c3 100644 --- a/opencl/source/os_interface/windows/wddm_device_command_stream.inl +++ b/opencl/source/os_interface/windows/wddm_device_command_stream.inl @@ -136,7 +136,7 @@ GmmPageTableMngr *WddmCommandStreamReceiver::createPageTableManager() auto rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex].get(); - GmmPageTableMngr *gmmPageTableMngr = GmmPageTableMngr::create(executionEnvironment.getGmmClientContext(), TT_TYPE::AUXTT, &ttCallbacks); + GmmPageTableMngr *gmmPageTableMngr = GmmPageTableMngr::create(rootDeviceEnvironment->getGmmClientContext(), TT_TYPE::AUXTT, &ttCallbacks); gmmPageTableMngr->setCsrHandle(this); rootDeviceEnvironment->pageTableManager.reset(gmmPageTableMngr); return gmmPageTableMngr; diff --git a/opencl/source/platform/platform.cpp b/opencl/source/platform/platform.cpp index 7cfb191a2f..40eaad82d5 100644 --- a/opencl/source/platform/platform.cpp +++ b/opencl/source/platform/platform.cpp @@ -252,7 +252,7 @@ std::unique_ptr Platform::setAsyncEventsHandler(std::unique_ } GmmHelper *Platform::peekGmmHelper() const { - return executionEnvironment.getGmmHelper(); + return executionEnvironment.rootDeviceEnvironments[0]->getGmmHelper(); } GmmClientContext *Platform::peekGmmClientContext() const { diff --git a/opencl/source/sharings/gl/windows/gl_buffer_windows.cpp b/opencl/source/sharings/gl/windows/gl_buffer_windows.cpp index fb7fa74934..899d1650fe 100644 --- a/opencl/source/sharings/gl/windows/gl_buffer_windows.cpp +++ b/opencl/source/sharings/gl/windows/gl_buffer_windows.cpp @@ -151,7 +151,7 @@ GraphicsAllocation *GlBuffer::createGraphicsAllocation(Context *context, unsigne sharingFunctions->graphicsAllocationsForGlBufferReuse.push_back(std::make_pair(bufferId, graphicsAllocation)); if (bufferInfo.pGmmResInfo) { DEBUG_BREAK_IF(graphicsAllocation->getDefaultGmm() != nullptr); - auto clientContext = context->getDevice(0)->getExecutionEnvironment()->getGmmClientContext(); + auto clientContext = context->getDevice(0)->getRootDeviceEnvironment().getGmmClientContext(); graphicsAllocation->setDefaultGmm(new Gmm(clientContext, bufferInfo.pGmmResInfo)); } } diff --git a/opencl/source/sharings/gl/windows/gl_texture_windows.cpp b/opencl/source/sharings/gl/windows/gl_texture_windows.cpp index 6501b05504..f484ff289f 100644 --- a/opencl/source/sharings/gl/windows/gl_texture_windows.cpp +++ b/opencl/source/sharings/gl/windows/gl_texture_windows.cpp @@ -30,7 +30,7 @@ namespace NEO { Image *GlTexture::createSharedGlTexture(Context *context, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture, cl_int *errcodeRet) { ErrorCodeHelper errorCode(errcodeRet, CL_INVALID_GL_OBJECT); - auto clientContext = context->getDevice(0)->getExecutionEnvironment()->getGmmClientContext(); + auto clientContext = context->getDevice(0)->getRootDeviceEnvironment().getGmmClientContext(); auto memoryManager = context->getMemoryManager(); cl_image_desc imgDesc = {}; cl_image_format imgFormat = {}; diff --git a/opencl/test/unit_test/aub_mem_dump/aub_alloc_dump_tests.cpp b/opencl/test/unit_test/aub_mem_dump/aub_alloc_dump_tests.cpp index 796cbfed13..2a1825c3e3 100644 --- a/opencl/test/unit_test/aub_mem_dump/aub_alloc_dump_tests.cpp +++ b/opencl/test/unit_test/aub_mem_dump/aub_alloc_dump_tests.cpp @@ -445,7 +445,7 @@ HWTEST_P(AubSurfaceDumpTests, givenGraphicsAllocationWhenGetDumpSurfaceIsCalledA imgDesc.image_height = 1; imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - MockGmm::queryImgParams(pDevice->getExecutionEnvironment()->getGmmClientContext(), imgInfo); + MockGmm::queryImgParams(pDevice->getGmmClientContext(), imgInfo); MockMemoryManager::AllocationData allocationData; allocationData.imgInfo = &imgInfo; auto imageAllocation = memoryManager.allocateGraphicsMemoryForImage(allocationData); diff --git a/opencl/test/unit_test/aub_tests/mem_obj/create_image_aub_tests.cpp b/opencl/test/unit_test/aub_tests/mem_obj/create_image_aub_tests.cpp index 4b472537e2..bf22ab3971 100644 --- a/opencl/test/unit_test/aub_tests/mem_obj/create_image_aub_tests.cpp +++ b/opencl/test/unit_test/aub_tests/mem_obj/create_image_aub_tests.cpp @@ -98,7 +98,7 @@ HWTEST_P(AUBCreateImageArray, CheckArrayImages) { auto surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imageFormat, context->getDevice(0)->getHardwareInfo().capabilityTable.clVersionSupport); auto imgInfo = MockGmm::initImgInfo(imageDesc, 0, surfaceFormat); imgInfo.linearStorage = !hwHelper.tilingAllowed(false, Image::isImage1d(imageDesc), false); - auto queryGmm = MockGmm::queryImgParams(pDevice->getExecutionEnvironment()->getGmmClientContext(), imgInfo); + auto queryGmm = MockGmm::queryImgParams(pDevice->getGmmClientContext(), imgInfo); //allocate host_ptr auto pixelSize = 4; @@ -224,7 +224,7 @@ HWTEST_P(CopyHostPtrTest, imageWithDoubledRowPitchThatIsCreatedWithCopyHostPtrFl auto surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imageFormat, context->getDevice(0)->getHardwareInfo().capabilityTable.clVersionSupport); auto imgInfo = MockGmm::initImgInfo(imageDesc, 0, surfaceFormat); - MockGmm::queryImgParams(pDevice->getExecutionEnvironment()->getGmmClientContext(), imgInfo); + MockGmm::queryImgParams(pDevice->getGmmClientContext(), imgInfo); auto lineWidth = imageDesc.image_width * elementSize; auto passedRowPitch = imgInfo.rowPitch * 2; imageDesc.image_row_pitch = passedRowPitch; @@ -293,7 +293,7 @@ HWTEST_P(UseHostPtrTest, imageWithRowPitchCreatedWithUseHostPtrFlagCopiedActuall imageDesc.image_height = 1; auto surfaceFormat = Image::getSurfaceFormatFromTable(flags, &imageFormat, context->getDevice(0)->getHardwareInfo().capabilityTable.clVersionSupport); auto imgInfo = MockGmm::initImgInfo(imageDesc, 0, surfaceFormat); - MockGmm::queryImgParams(pDevice->getExecutionEnvironment()->getGmmClientContext(), imgInfo); + MockGmm::queryImgParams(pDevice->getGmmClientContext(), imgInfo); auto passedRowPitch = imgInfo.rowPitch + 32; imageDesc.image_row_pitch = passedRowPitch; unsigned char *pUseHostPtr = new unsigned char[passedRowPitch * imageDesc.image_height * elementSize]; diff --git a/opencl/test/unit_test/built_ins/built_in_tests.cpp b/opencl/test/unit_test/built_ins/built_in_tests.cpp index e439bc0b7b..17b9897c00 100644 --- a/opencl/test/unit_test/built_ins/built_in_tests.cpp +++ b/opencl/test/unit_test/built_ins/built_in_tests.cpp @@ -482,7 +482,7 @@ HWTEST_F(BuiltInTests, givenAuxTranslationKernelWhenSettingKernelArgsThenSetVali { // read args auto argNum = 0; - auto expectedMocs = pDevice->getExecutionEnvironment()->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED); + auto expectedMocs = pDevice->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED); auto sshBase = mockAuxBuiltInOp.convertToAuxKernel[0]->getSurfaceStateHeap(); auto sshOffset = mockAuxBuiltInOp.convertToAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap; auto surfaceState = reinterpret_cast(ptrOffset(sshBase, sshOffset)); @@ -497,7 +497,7 @@ HWTEST_F(BuiltInTests, givenAuxTranslationKernelWhenSettingKernelArgsThenSetVali { // write args auto argNum = 1; - auto expectedMocs = pDevice->getExecutionEnvironment()->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); + auto expectedMocs = pDevice->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); auto sshBase = mockAuxBuiltInOp.convertToAuxKernel[0]->getSurfaceStateHeap(); auto sshOffset = mockAuxBuiltInOp.convertToAuxKernel[0]->getKernelInfo().kernelArgInfo[argNum].offsetHeap; auto surfaceState = reinterpret_cast(ptrOffset(sshBase, sshOffset)); @@ -529,7 +529,7 @@ HWTEST_F(BuiltInTests, givenAuxToNonAuxTranslationWhenSettingSurfaceStateThenSet cl_int retVal = CL_SUCCESS; auto buffer = std::unique_ptr(Buffer::create(pContext, 0, MemoryConstants::pageSize, nullptr, retVal)); buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED); - auto gmm = new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false); + auto gmm = new Gmm(pDevice->getGmmClientContext(), nullptr, 1, false); gmm->isRenderCompressed = true; buffer->getGraphicsAllocation()->setDefaultGmm(gmm); @@ -575,7 +575,7 @@ HWTEST_F(BuiltInTests, givenNonAuxToAuxTranslationWhenSettingSurfaceStateThenSet cl_int retVal = CL_SUCCESS; auto buffer = std::unique_ptr(Buffer::create(pContext, 0, MemoryConstants::pageSize, nullptr, retVal)); buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED); - auto gmm = new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false); + auto gmm = new Gmm(pDevice->getGmmClientContext(), nullptr, 1, false); gmm->isRenderCompressed = true; buffer->getGraphicsAllocation()->setDefaultGmm(gmm); memObjsForAuxTranslation.insert(buffer.get()); diff --git a/opencl/test/unit_test/command_queue/enqueue_kernel_1_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_kernel_1_tests.cpp index 7b7e9e8913..74ad359741 100644 --- a/opencl/test/unit_test/command_queue/enqueue_kernel_1_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_kernel_1_tests.cpp @@ -519,7 +519,7 @@ HWTEST_F(EnqueueKernelTest, whenEnqueueKernelWithNoStatelessWriteWhenSbaIsBeingP EXPECT_EQ(csr.recordedDispatchFlags.l3CacheSettings, L3CachingSettings::l3AndL1On); auto &helper = HwHelper::get(renderCoreFamily); - auto gmmHelper = this->pDevice->getExecutionEnvironment()->getGmmHelper(); + auto gmmHelper = this->pDevice->getGmmHelper(); auto expectedMocsIndex = helper.getMocsIndex(*gmmHelper, true, true); EXPECT_EQ(expectedMocsIndex, csr.latestSentStatelessMocsConfig); } @@ -541,7 +541,7 @@ HWTEST_F(EnqueueKernelTest, whenEnqueueKernelWithNoStatelessWriteOnBlockedCodePa EXPECT_EQ(csr.recordedDispatchFlags.l3CacheSettings, L3CachingSettings::l3AndL1On); auto &helper = HwHelper::get(renderCoreFamily); - auto gmmHelper = this->pDevice->getExecutionEnvironment()->getGmmHelper(); + auto gmmHelper = this->pDevice->getGmmHelper(); auto expectedMocsIndex = helper.getMocsIndex(*gmmHelper, true, true); EXPECT_EQ(expectedMocsIndex, csr.latestSentStatelessMocsConfig); diff --git a/opencl/test/unit_test/command_queue/enqueue_read_buffer_tests.cpp b/opencl/test/unit_test/command_queue/enqueue_read_buffer_tests.cpp index 7f46491bab..161dd9815b 100644 --- a/opencl/test/unit_test/command_queue/enqueue_read_buffer_tests.cpp +++ b/opencl/test/unit_test/command_queue/enqueue_read_buffer_tests.cpp @@ -298,7 +298,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, givenAlignedPointerAndAlignedSizeWhenReadBuf EXPECT_EQ(CL_SUCCESS, retVal); auto &csr = pDevice->getUltCommandStreamReceiver(); - auto gmmHelper = csr.peekExecutionEnvironment().getGmmHelper(); + auto gmmHelper = pDevice->getGmmHelper(); auto mocsIndexL3on = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER) >> 1; auto mocsIndexL1on = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST) >> 1; @@ -321,7 +321,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, givenNotAlignedPointerAndAlignedSizeWhenRead EXPECT_EQ(CL_SUCCESS, retVal); auto &csr = pDevice->getUltCommandStreamReceiver(); - auto gmmHelper = csr.peekExecutionEnvironment().getGmmHelper(); + auto gmmHelper = pDevice->getGmmHelper(); auto mocsIndexL3off = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED) >> 1; auto mocsIndexL3on = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER) >> 1; auto mocsIndexL1on = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST) >> 1; @@ -362,7 +362,7 @@ HWTEST_F(EnqueueReadBufferTypeTest, givenNotAlignedPointerAndSizeWhenBlockedRead EXPECT_EQ(CL_SUCCESS, retVal); auto &csr = pDevice->getUltCommandStreamReceiver(); - auto gmmHelper = csr.peekExecutionEnvironment().getGmmHelper(); + auto gmmHelper = pDevice->getGmmHelper(); auto mocsIndexL3off = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED) >> 1; EXPECT_EQ(mocsIndexL3off, csr.latestSentStatelessMocsConfig); diff --git a/opencl/test/unit_test/command_queue/read_write_buffer_cpu_copy.cpp b/opencl/test/unit_test/command_queue/read_write_buffer_cpu_copy.cpp index 00b604e9ee..0b4537751f 100644 --- a/opencl/test/unit_test/command_queue/read_write_buffer_cpu_copy.cpp +++ b/opencl/test/unit_test/command_queue/read_write_buffer_cpu_copy.cpp @@ -20,7 +20,7 @@ typedef EnqueueReadBufferTypeTest ReadWriteBufferCpuCopyTest; HWTEST_F(ReadWriteBufferCpuCopyTest, givenRenderCompressedGmmWhenAskingForCpuOperationThenDisallow) { cl_int retVal; std::unique_ptr buffer(Buffer::create(context, CL_MEM_READ_WRITE, 1, nullptr, retVal)); - auto gmm = new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false); + auto gmm = new Gmm(pDevice->getGmmClientContext(), nullptr, 1, false); gmm->isRenderCompressed = false; buffer->getGraphicsAllocation()->setDefaultGmm(gmm); diff --git a/opencl/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp b/opencl/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp index 50b3c24648..43cb59b860 100644 --- a/opencl/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp +++ b/opencl/test/unit_test/command_stream/aub_command_stream_receiver_2_tests.cpp @@ -672,7 +672,7 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenWriteMe auto gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); aubCsr->setAubWritable(true, *gfxAllocation); - auto gmm = new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false); + auto gmm = new Gmm(pDevice->getGmmClientContext(), nullptr, 1, false); gfxAllocation->setDefaultGmm(gmm); for (bool compressed : {false, true}) { diff --git a/opencl/test/unit_test/context/driver_diagnostics_tests.cpp b/opencl/test/unit_test/context/driver_diagnostics_tests.cpp index 2a2400c0fa..3f2a8b4c7c 100644 --- a/opencl/test/unit_test/context/driver_diagnostics_tests.cpp +++ b/opencl/test/unit_test/context/driver_diagnostics_tests.cpp @@ -540,7 +540,7 @@ TEST_F(PerformanceHintTest, givenCompressedImageWhenItsCreatedThenProperPerforma auto mockBuffer = std::unique_ptr(new MockBuffer()); StorageInfo info; size_t t = 4; - auto gmm = std::unique_ptr(new Gmm(device->getExecutionEnvironment()->getGmmClientContext(), static_cast(nullptr), t, false, true, true, info)); + auto gmm = std::unique_ptr(new Gmm(device->getGmmClientContext(), static_cast(nullptr), t, false, true, true, info)); gmm->isRenderCompressed = true; mockBuffer->getGraphicsAllocation()->setDefaultGmm(gmm.get()); @@ -660,7 +660,7 @@ TEST_F(PerformanceHintTest, givenUncompressedImageWhenItsCreatedThenProperPerfor auto mockBuffer = std::unique_ptr(new MockBuffer()); StorageInfo info; size_t t = 4; - auto gmm = std::unique_ptr(new Gmm(device->getExecutionEnvironment()->getGmmClientContext(), (const void *)nullptr, t, false, true, true, info)); + auto gmm = std::unique_ptr(new Gmm(device->getGmmClientContext(), (const void *)nullptr, t, false, true, true, info)); gmm->isRenderCompressed = false; mockBuffer->getGraphicsAllocation()->setDefaultGmm(gmm.get()); diff --git a/opencl/test/unit_test/d3d_sharing/d3d9_tests.cpp b/opencl/test/unit_test/d3d_sharing/d3d9_tests.cpp index 9c1ab0773e..3ea2081f52 100644 --- a/opencl/test/unit_test/d3d_sharing/d3d9_tests.cpp +++ b/opencl/test/unit_test/d3d_sharing/d3d9_tests.cpp @@ -39,7 +39,7 @@ class MockMM : public OsAgnosticMemoryManager { return alloc; } GraphicsAllocation *allocateGraphicsMemoryForImage(const AllocationData &allocationData) override { - auto gmm = std::make_unique(executionEnvironment.getGmmClientContext(), *allocationData.imgInfo, StorageInfo{}); + auto gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), *allocationData.imgInfo, StorageInfo{}); AllocationProperties properties(allocationData.rootDeviceIndex, nullptr, false, GraphicsAllocation::AllocationType::SHARED_IMAGE, false); auto alloc = OsAgnosticMemoryManager::createGraphicsAllocationFromSharedHandle(1, properties, false); alloc->setDefaultGmm(forceGmm); @@ -82,7 +82,7 @@ class D3D9Tests : public PlatformFixture, public ::testing::Test { imgDesc.image_depth = 1; imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - gmm = MockGmm::queryImgParams(pPlatform->peekExecutionEnvironment()->getGmmClientContext(), imgInfo).release(); + gmm = MockGmm::queryImgParams(pPlatform->getDevice(0)->getGmmClientContext(), imgInfo).release(); mockGmmResInfo = reinterpret_cast *>(gmm->gmmResourceInfo.get()); memoryManager->forceGmm = gmm; @@ -1146,7 +1146,7 @@ TEST_F(D3D9MultiRootDeviceTest, givenD3DHandleIsNullWhenCreatingSharedSurfaceAnd imgDesc.image_depth = 1; imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - auto gmm = MockGmm::queryImgParams(device->getExecutionEnvironment()->getGmmClientContext(), imgInfo).release(); + auto gmm = MockGmm::queryImgParams(device->getGmmClientContext(), imgInfo).release(); auto memoryManager = std::make_unique(*device->executionEnvironment); memoryManager->forceGmm = gmm; @@ -1178,7 +1178,7 @@ TEST_F(D3D9MultiRootDeviceTest, givenD3DHandleIsNotNullWhenCreatingSharedSurface imgDesc.image_depth = 1; imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - auto gmm = MockGmm::queryImgParams(device->getExecutionEnvironment()->getGmmClientContext(), imgInfo).release(); + auto gmm = MockGmm::queryImgParams(device->getGmmClientContext(), imgInfo).release(); auto memoryManager = std::make_unique(*device->executionEnvironment); memoryManager->forceGmm = gmm; diff --git a/opencl/test/unit_test/fixtures/d3d_test_fixture.h b/opencl/test/unit_test/fixtures/d3d_test_fixture.h index 323e1e5243..de81338b60 100644 --- a/opencl/test/unit_test/fixtures/d3d_test_fixture.h +++ b/opencl/test/unit_test/fixtures/d3d_test_fixture.h @@ -75,7 +75,7 @@ class D3DTests : public PlatformFixture, public ::testing::Test { imgDesc.image_depth = 1; imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - gmm = MockGmm::queryImgParams(pPlatform->peekExecutionEnvironment()->getGmmClientContext(), imgInfo).release(); + gmm = MockGmm::queryImgParams(pPlatform->peekExecutionEnvironment()->rootDeviceEnvironments[0]->getGmmClientContext(), imgInfo).release(); mockGmmResInfo = reinterpret_cast *>(gmm->gmmResourceInfo.get()); mockMM->forceGmm = gmm; diff --git a/opencl/test/unit_test/fixtures/ult_command_stream_receiver_fixture.h b/opencl/test/unit_test/fixtures/ult_command_stream_receiver_fixture.h index 7dbb6c4c49..2e79e8bd4c 100644 --- a/opencl/test/unit_test/fixtures/ult_command_stream_receiver_fixture.h +++ b/opencl/test/unit_test/fixtures/ult_command_stream_receiver_fixture.h @@ -120,7 +120,7 @@ struct UltCommandStreamReceiverTest commandStreamReceiver.isPreambleSent = true; commandStreamReceiver.lastPreemptionMode = pDevice->getPreemptionMode(); commandStreamReceiver.setMediaVFEStateDirty(false); - auto gmmHelper = commandStreamReceiver.peekExecutionEnvironment().getGmmHelper(); + auto gmmHelper = pDevice->getGmmHelper(); auto mocsIndex = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); commandStreamReceiver.latestSentStatelessMocsConfig = mocsIndex >> 1; diff --git a/opencl/test/unit_test/gen12lp/image_tests_gen12lp.inl b/opencl/test/unit_test/gen12lp/image_tests_gen12lp.inl index ff6f14d9b3..f4635b6141 100644 --- a/opencl/test/unit_test/gen12lp/image_tests_gen12lp.inl +++ b/opencl/test/unit_test/gen12lp/image_tests_gen12lp.inl @@ -95,7 +95,7 @@ GEN12LPTEST_F(ImageClearColorFixture, givenMcsAllocationWhenSetArgIsCalledWithUn auto surfaceState = FamilyType::cmdInitRenderSurfaceState; auto imageHw = static_cast *>(image.get()); - mcsAlloc->setDefaultGmm(new Gmm(context->getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); + mcsAlloc->setDefaultGmm(new Gmm(context->getDevice(0)->getGmmClientContext(), nullptr, 1, false)); surfaceState.setSurfaceBaseAddress(0xABCDEF1000); imageHw->setMcsSurfaceInfo(msi); imageHw->setMcsAllocation(mcsAlloc); diff --git a/opencl/test/unit_test/gen12lp/windows/wddm_tests_gen12lp.cpp b/opencl/test/unit_test/gen12lp/windows/wddm_tests_gen12lp.cpp index 4fc7839725..79747c179a 100644 --- a/opencl/test/unit_test/gen12lp/windows/wddm_tests_gen12lp.cpp +++ b/opencl/test/unit_test/gen12lp/windows/wddm_tests_gen12lp.cpp @@ -26,7 +26,7 @@ struct Gen12LpWddmTest : public GdiDllFixture, ::testing::Test { executionEnvironment->initGmm(); rootDeviceEnvironment = std::make_unique(*executionEnvironment); wddm.reset(static_cast(Wddm::createWddm(nullptr, *rootDeviceEnvironment))); - gmmMemory = new ::testing::NiceMock(executionEnvironment->getGmmClientContext()); + gmmMemory = new ::testing::NiceMock(rootDeviceEnvironment->getGmmClientContext()); wddm->gmmMemory.reset(gmmMemory); } diff --git a/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp b/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp index e1753a8d37..be4bfa5e8b 100644 --- a/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp +++ b/opencl/test/unit_test/gmm_helper/gmm_helper_tests.cpp @@ -40,8 +40,10 @@ extern bool copyInputArgs; struct GmmTests : public ::testing::Test { void SetUp() override { executionEnvironment = platform()->peekExecutionEnvironment(); + rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get(); } - ExecutionEnvironment *executionEnvironment; + ExecutionEnvironment *executionEnvironment = nullptr; + RootDeviceEnvironment *rootDeviceEnvironment = nullptr; }; TEST(GmmGlTests, givenGmmWhenAskedforCubeFaceIndexThenProperValueIsReturned) { @@ -64,7 +66,7 @@ TEST(GmmGlTests, givenGmmWhenAskedforCubeFaceIndexThenProperValueIsReturned) { TEST_F(GmmTests, resourceCreation) { std::unique_ptr mm(new MemoryManagerCreate(false, false, *executionEnvironment)); void *pSysMem = mm->allocateSystemMemory(4096, 4096); - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096, false)); ASSERT_TRUE(gmm->gmmResourceInfo.get() != nullptr); @@ -79,7 +81,7 @@ TEST_F(GmmTests, resourceCreationUncacheable) { std::unique_ptr mm(new MemoryManagerCreate(false, false, *executionEnvironment)); void *pSysMem = mm->allocateSystemMemory(4096, 4096); - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096, true)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096, true)); ASSERT_TRUE(gmm->gmmResourceInfo.get() != nullptr); @@ -95,7 +97,7 @@ TEST_F(GmmTests, resourceCleanupOnDelete) { std::unique_ptr mm(new MemoryManagerCreate(false, false, *executionEnvironment)); void *pSysMem = mm->allocateSystemMemory(4096, 4096); - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096, false)); ASSERT_TRUE(gmm->gmmResourceInfo.get() != nullptr); @@ -107,7 +109,7 @@ TEST_F(GmmTests, givenHostPointerWithHighestBitSetWhenGmmIsCreatedItHasTheSameAd auto address = reinterpret_cast(addressWithHighestBitSet); auto expectedAddress = castToUint64(address); - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), address, 4096, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), address, 4096, false)); EXPECT_EQ(gmm->resourceParams.pExistingSysMem, expectedAddress); } @@ -117,7 +119,7 @@ TEST_F(GmmTests, GivenBufferSizeLargerThenMaxPitchWhenAskedForGmmCreationThenGMM MemoryManager *mm = new MemoryManagerCreate(false, false, *executionEnvironment); void *pSysMem = mm->allocateSystemMemory(4096, 4096); - auto gmmRes = new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, maxSize, false); + auto gmmRes = new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, maxSize, false); ASSERT_TRUE(gmmRes->gmmResourceInfo.get() != nullptr); @@ -130,8 +132,8 @@ TEST_F(GmmTests, GivenBufferSizeLargerThenMaxPitchWhenAskedForGmmCreationThenGMM TEST_F(GmmTests, givenGmmCreatedFromExistingGmmThenHelperDoesNotReleaseParentGmm) { auto size = 4096u; void *incomingPtr = (void *)0x1000; - auto gmmRes = new Gmm(executionEnvironment->getGmmClientContext(), incomingPtr, size, false); - auto gmmRes2 = new Gmm(executionEnvironment->getGmmClientContext(), gmmRes->gmmResourceInfo->peekHandle()); + auto gmmRes = new Gmm(rootDeviceEnvironment->getGmmClientContext(), incomingPtr, size, false); + auto gmmRes2 = new Gmm(rootDeviceEnvironment->getGmmClientContext(), gmmRes->gmmResourceInfo->peekHandle()); //copy is being made EXPECT_NE(gmmRes2->gmmResourceInfo->peekHandle(), gmmRes->gmmResourceInfo->peekHandle()); @@ -153,7 +155,7 @@ TEST_F(GmmTests, invalidImageTypeQuery) { imgDesc.image_type = 0; // invalid auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - EXPECT_THROW(MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo), std::exception); + EXPECT_THROW(MockGmm::queryImgParams(rootDeviceEnvironment->getGmmClientContext(), imgInfo), std::exception); } TEST_F(GmmTests, validImageTypeQuery) { @@ -168,7 +170,7 @@ TEST_F(GmmTests, validImageTypeQuery) { auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - auto queryGmm = MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); + auto queryGmm = MockGmm::queryImgParams(rootDeviceEnvironment->getGmmClientContext(), imgInfo); EXPECT_GT(imgInfo.size, minSize); EXPECT_GT(imgInfo.rowPitch, 0u); @@ -198,20 +200,20 @@ TEST_F(GmmTests, validImageTypeQuery) { TEST_F(GmmTests, givenWidthWhenCreatingResourceThenSetWidth64Field) { const void *dummyPtr = reinterpret_cast(0x123); size_t allocationSize = std::numeric_limits::max(); - Gmm gmm(executionEnvironment->getGmmClientContext(), dummyPtr, allocationSize, false); + Gmm gmm(rootDeviceEnvironment->getGmmClientContext(), dummyPtr, allocationSize, false); EXPECT_EQ(static_cast(allocationSize), gmm.resourceParams.BaseWidth64); } TEST_F(GmmTests, givenNullptrWhenGmmConstructorIsCalledThenNoGfxMemoryIsProperlySet) { void *pSysMem = nullptr; - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096, false)); EXPECT_EQ(gmm->resourceParams.NoGfxMemory, 1u); } TEST_F(GmmTests, givenPtrWhenGmmConstructorIsCalledThenNoGfxMemoryIsProperlySet) { void *pSysMem = reinterpret_cast(0x1111); - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096, false)); EXPECT_EQ(gmm->resourceParams.NoGfxMemory, 0u); } @@ -228,7 +230,7 @@ TEST_F(GmmTests, given2DimageFromBufferParametersWhenGmmResourceIsCreatedThenItH ClSurfaceFormatInfo surfaceFormat = {{CL_RGBA, CL_FLOAT}, {GMM_FORMAT_R32G32B32A32_FLOAT_TYPE, (GFX3DSTATE_SURFACEFORMAT)0, 0, 4, 4, 16}}; auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, &surfaceFormat); - auto queryGmm = MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); + auto queryGmm = MockGmm::queryImgParams(rootDeviceEnvironment->getGmmClientContext(), imgInfo); auto renderSize = queryGmm->gmmResourceInfo->getSizeAllocation(); size_t expectedSize = imgDesc.image_row_pitch * imgDesc.image_height; @@ -249,7 +251,7 @@ TEST_F(GmmTests, given2DimageFromBufferParametersWhenGmmResourceIsCreatedAndPitc auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, &surfaceFormat); EXPECT_EQ(imgInfo.imgDesc.imageRowPitch, imgDesc.image_row_pitch); - auto queryGmm = MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); + auto queryGmm = MockGmm::queryImgParams(rootDeviceEnvironment->getGmmClientContext(), imgInfo); auto renderSize = queryGmm->gmmResourceInfo->getSizeAllocation(); size_t expectedSize = imgDesc.image_row_pitch * imgDesc.image_height; @@ -269,14 +271,14 @@ TEST_F(GmmTests, givenPlanarFormatsWhenQueryingImageParamsThenUVOffsetIsQueried) auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, &surfaceFormatNV12); imgInfo.yOffsetForUVPlane = 0; - MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); + MockGmm::queryImgParams(rootDeviceEnvironment->getGmmClientContext(), imgInfo); EXPECT_NE(0u, imgInfo.yOffsetForUVPlane); imgInfo = MockGmm::initImgInfo(imgDesc, 0, &surfaceFormatP010); imgInfo.yOffsetForUVPlane = 0; - MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); + MockGmm::queryImgParams(rootDeviceEnvironment->getGmmClientContext(), imgInfo); EXPECT_NE(0u, imgInfo.yOffsetForUVPlane); } @@ -289,7 +291,7 @@ TEST_F(GmmTests, givenTilingModeSetToTileYWhenHwSupportsTilingThenTileYFlagIsSet auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); imgInfo.linearStorage = false; - auto gmm = std::make_unique(executionEnvironment->getGmmClientContext(), imgInfo, StorageInfo{}); + auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), imgInfo, StorageInfo{}); EXPECT_EQ(gmm->resourceParams.Flags.Info.Linear, 0u); EXPECT_EQ(gmm->resourceParams.Flags.Info.TiledY, 0u); @@ -304,7 +306,7 @@ TEST_F(GmmTests, givenTilingModeSetToNonTiledWhenCreatingGmmThenLinearFlagIsSet) auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); imgInfo.linearStorage = true; - auto gmm = std::make_unique(executionEnvironment->getGmmClientContext(), imgInfo, StorageInfo{}); + auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), imgInfo, StorageInfo{}); EXPECT_EQ(gmm->resourceParams.Flags.Info.Linear, 1u); EXPECT_EQ(gmm->resourceParams.Flags.Info.TiledY, 0u); @@ -398,7 +400,7 @@ TEST_F(GmmTests, givenMipmapedInputWhenAskedForHalingThenNonDefaultValueIsReturn auto imgInfo = MockGmm::initImgInfo(imgDesc, mipLevel, nullptr); - auto queryGmm = MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); + auto queryGmm = MockGmm::queryImgParams(rootDeviceEnvironment->getGmmClientContext(), imgInfo); EXPECT_EQ(static_cast(queryGmm->resourceParams.MaxLod), mipLevel); } @@ -415,7 +417,7 @@ struct GmmMediaCompressedTests : public GmmTests { void SetUp() override { GmmTests::SetUp(); StorageInfo info; - gmm = std::make_unique(executionEnvironment->getGmmClientContext(), nullptr, 4, false, true, true, info); + gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 4, false, true, true, info); flags = gmm->gmmResourceInfo->getResourceFlags(); flags->Gpu.CCS = true; flags->Gpu.UnifiedAuxSurface = true; @@ -531,7 +533,7 @@ TEST_P(GmmImgTest, updateImgInfoAndDesc) { } auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - auto queryGmm = MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); + auto queryGmm = MockGmm::queryImgParams(rootDeviceEnvironment->getGmmClientContext(), imgInfo); auto mockResInfo = new NiceMock(&queryGmm->resourceParams); queryGmm->gmmResourceInfo.reset(mockResInfo); @@ -595,7 +597,7 @@ TEST(GmmImgTest, givenImgInfoWhenUpdatingOffsetsCallGmmToGetOffsets) { imgDesc.image_array_size = 10; ImageInfo imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - std::unique_ptr gmm = MockGmm::queryImgParams(platform()->peekExecutionEnvironment()->getGmmClientContext(), imgInfo); + std::unique_ptr gmm = MockGmm::queryImgParams(platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->getGmmClientContext(), imgInfo); MyMockGmmResourceInfo *mockGmmResourceInfo = new MyMockGmmResourceInfo(&gmm->resourceParams); gmm->gmmResourceInfo.reset(mockGmmResourceInfo); @@ -619,7 +621,7 @@ TEST_F(GmmTests, copyResourceBlt) { auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - auto gmm = MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); + auto gmm = MockGmm::queryImgParams(rootDeviceEnvironment->getGmmClientContext(), imgInfo); auto mockResInfo = reinterpret_cast *>(gmm->gmmResourceInfo.get()); GMM_RES_COPY_BLT requestedCpuBlt = {}; @@ -679,7 +681,7 @@ TEST_F(GmmTests, copyResourceBlt) { } TEST(GmmTest, givenAllValidFlagsWhenAskedForUnifiedAuxTranslationCapabilityThenReturnTrue) { - auto gmm = std::unique_ptr(new Gmm(platform()->peekExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); + auto gmm = std::unique_ptr(new Gmm(platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 1, false)); auto mockResource = reinterpret_cast(gmm->gmmResourceInfo.get()); mockResource->setUnifiedAuxTranslationCapable(); @@ -691,7 +693,7 @@ TEST(GmmTest, givenAllValidFlagsWhenAskedForUnifiedAuxTranslationCapabilityThenR } TEST(GmmTest, givenInvalidFlagsSetWhenAskedForUnifiedAuxTranslationCapabilityThenReturnFalse) { - auto gmm = std::unique_ptr(new Gmm(platform()->peekExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); + auto gmm = std::unique_ptr(new Gmm(platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 1, false)); auto mockResource = reinterpret_cast(gmm->gmmResourceInfo.get()); mockResource->mockResourceCreateParams.Flags.Gpu.CCS = 0; @@ -717,8 +719,8 @@ TEST(GmmTest, whenResourceIsCreatedThenHandleItsOwnership) { struct MyMockResourecInfo : public GmmResourceInfo { using GmmResourceInfo::resourceInfo; - MyMockResourecInfo(GMM_RESCREATE_PARAMS *inputParams) : GmmResourceInfo(platform()->peekExecutionEnvironment()->getGmmClientContext(), inputParams){}; - MyMockResourecInfo(GMM_RESOURCE_INFO *inputGmmResourceInfo) : GmmResourceInfo(platform()->peekExecutionEnvironment()->getGmmClientContext(), inputGmmResourceInfo){}; + MyMockResourecInfo(GMM_RESCREATE_PARAMS *inputParams) : GmmResourceInfo(platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->getGmmClientContext(), inputParams){}; + MyMockResourecInfo(GMM_RESOURCE_INFO *inputGmmResourceInfo) : GmmResourceInfo(platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->getGmmClientContext(), inputGmmResourceInfo){}; }; GMM_RESCREATE_PARAMS gmmParams = {}; @@ -742,12 +744,12 @@ TEST(GmmTest, whenResourceIsCreatedThenHandleItsOwnership) { } TEST(GmmTest, givenGmmWithNotSetMCSInResourceInfoGpuFlagsWhenCallHasMultisampleControlSurfaceThenReturnFalse) { - auto gmm = std::unique_ptr(new Gmm(platform()->peekExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); + auto gmm = std::unique_ptr(new Gmm(platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 1, false)); EXPECT_FALSE(gmm->hasMultisampleControlSurface()); } TEST(GmmTest, givenGmmWithSetMCSInResourceInfoGpuFlagsWhenCallhasMultisampleControlSurfaceThenReturnTrue) { - auto gmm = std::unique_ptr(new Gmm(platform()->peekExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); + auto gmm = std::unique_ptr(new Gmm(platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 1, false)); auto mockResource = reinterpret_cast(gmm->gmmResourceInfo.get()); mockResource->setMultisampleControlSurface(); EXPECT_TRUE(gmm->hasMultisampleControlSurface()); @@ -761,7 +763,7 @@ TEST(GmmHelperTest, whenGmmHelperIsInitializedThenClientContextIsSet) { TEST(GmmHelperTest, givenPlatformAlreadyDestroyedWhenResourceIsBeingDestroyedThenObserveNoExceptions) { struct MockGmmResourecInfo : public GmmResourceInfo { using GmmResourceInfo::resourceInfo; - MockGmmResourecInfo(GMM_RESCREATE_PARAMS *inputParams) : GmmResourceInfo(platform()->peekExecutionEnvironment()->getGmmClientContext(), inputParams){}; + MockGmmResourecInfo(GMM_RESCREATE_PARAMS *inputParams) : GmmResourceInfo(platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->getGmmClientContext(), inputParams){}; }; GMM_RESCREATE_PARAMS gmmParams = {}; diff --git a/opencl/test/unit_test/helpers/hw_helper_tests.cpp b/opencl/test/unit_test/helpers/hw_helper_tests.cpp index 5666663104..3543d00066 100644 --- a/opencl/test/unit_test/helpers/hw_helper_tests.cpp +++ b/opencl/test/unit_test/helpers/hw_helper_tests.cpp @@ -260,7 +260,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenNoAllocationProvidedThe using SURFACE_TYPE = typename RENDER_SURFACE_STATE::SURFACE_TYPE; ExecutionEnvironment &executionEnvironment = *pDevice->getExecutionEnvironment(); - auto gmmHelper = executionEnvironment.getGmmHelper(); + auto gmmHelper = pDevice->getGmmHelper(); void *stateBuffer = alignedMalloc(sizeof(RENDER_SURFACE_STATE), sizeof(RENDER_SURFACE_STATE)); ASSERT_NE(nullptr, stateBuffer); @@ -345,7 +345,7 @@ HWTEST_F(HwHelperTest, givenCreatedSurfaceStateBufferWhenAllocationProvidedThenU size_t allocSize = size; length.Length = static_cast(allocSize - 1); GraphicsAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, cpuAddr, gpuAddr, 0u, allocSize, MemoryPool::MemoryNull); - allocation.setDefaultGmm(new Gmm(executionEnvironment.getGmmClientContext(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); + allocation.setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), allocation.getUnderlyingBuffer(), allocation.getUnderlyingBufferSize(), false)); SURFACE_TYPE type = RENDER_SURFACE_STATE::SURFACE_TYPE_SURFTYPE_BUFFER; helper.setRenderSurfaceStateForBuffer(executionEnvironment, stateBuffer, size, addr, 0, pitch, &allocation, false, type, true); EXPECT_EQ(length.SurfaceState.Depth + 1u, state->getDepth()); @@ -669,7 +669,7 @@ TEST_F(HwHelperTest, givenAUBDumpForceAllToLocalMemoryDebugVarWhenSetThenGetEnab TEST_F(HwHelperTest, givenVariousCachesRequestProperMOCSIndexesAreBeingReturned) { auto &helper = HwHelper::get(renderCoreFamily); - auto gmmHelper = this->pDevice->getExecutionEnvironment()->getGmmHelper(); + auto gmmHelper = this->pDevice->getGmmHelper(); auto expectedMocsForL3off = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CACHELINE_MISALIGNED) >> 1; auto expectedMocsForL3on = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER) >> 1; auto expectedMocsForL3andL1on = gmmHelper->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST) >> 1; diff --git a/opencl/test/unit_test/mem_obj/buffer_set_arg_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_set_arg_tests.cpp index e671da2a33..8c39a61c67 100644 --- a/opencl/test/unit_test/mem_obj/buffer_set_arg_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_set_arg_tests.cpp @@ -188,7 +188,7 @@ HWTEST_F(BufferSetArgTest, givenNonPureStatefulArgWhenRenderCompressedBufferIsSe auto surfaceState = reinterpret_cast(ptrOffset(pKernel->getSurfaceStateHeap(), pKernelInfo->kernelArgInfo[0].offsetHeap)); buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED); - buffer->getGraphicsAllocation()->setDefaultGmm(new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), buffer->getGraphicsAllocation()->getUnderlyingBuffer(), buffer->getSize(), false)); + buffer->getGraphicsAllocation()->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), buffer->getGraphicsAllocation()->getUnderlyingBuffer(), buffer->getSize(), false)); buffer->getGraphicsAllocation()->getDefaultGmm()->isRenderCompressed = true; pKernelInfo->requiresSshForBuffers = true; cl_mem clMem = buffer; diff --git a/opencl/test/unit_test/mem_obj/buffer_tests.cpp b/opencl/test/unit_test/mem_obj/buffer_tests.cpp index b36a02b84d..48ab794939 100644 --- a/opencl/test/unit_test/mem_obj/buffer_tests.cpp +++ b/opencl/test/unit_test/mem_obj/buffer_tests.cpp @@ -2185,7 +2185,7 @@ HWTEST_F(BufferSetSurfaceTests, givenRenderCompressedGmmResourceWhenSurfaceState std::unique_ptr buffer(Buffer::create(&context, CL_MEM_READ_WRITE, 1, nullptr, retVal)); buffer->getGraphicsAllocation()->setAllocationType(GraphicsAllocation::AllocationType::BUFFER_COMPRESSED); - auto gmm = new Gmm(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false); + auto gmm = new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, false); buffer->getGraphicsAllocation()->setDefaultGmm(gmm); gmm->isRenderCompressed = true; @@ -2209,7 +2209,7 @@ HWTEST_F(BufferSetSurfaceTests, givenNonRenderCompressedGmmResourceWhenSurfaceSt auto retVal = CL_SUCCESS; std::unique_ptr buffer(Buffer::create(&context, CL_MEM_READ_WRITE, 1, nullptr, retVal)); - auto gmm = new Gmm(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false); + auto gmm = new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, false); buffer->getGraphicsAllocation()->setDefaultGmm(gmm); gmm->isRenderCompressed = false; @@ -2290,8 +2290,8 @@ HWTEST_P(BufferL3CacheTests, givenMisalignedAndAlignedBufferWhenClEnqueueWriteIm clEnqueueWriteImage(&cmdQ, image, false, origin, region, 0, 0, hostPtr, 0, nullptr, nullptr); - auto expect = ctx.getDevice(0)->getExecutionEnvironment()->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); - auto expect2 = ctx.getDevice(0)->getExecutionEnvironment()->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST); + auto expect = ctx.getDevice(0)->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); + auto expect2 = ctx.getDevice(0)->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST); EXPECT_NE(NULL, surfaceState->getMemoryObjectControlState()); EXPECT_TRUE(expect == surfaceState->getMemoryObjectControlState() || expect2 == surfaceState->getMemoryObjectControlState()); @@ -2311,8 +2311,8 @@ HWTEST_P(BufferL3CacheTests, givenMisalignedAndAlignedBufferWhenClEnqueueWriteBu clEnqueueWriteBufferRect(&cmdQ, buffer, false, origin, origin, region, 0, 0, 0, 0, hostPtr, 0, nullptr, nullptr); - auto expect = ctx.getDevice(0)->getExecutionEnvironment()->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); - auto expect2 = ctx.getDevice(0)->getExecutionEnvironment()->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST); + auto expect = ctx.getDevice(0)->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); + auto expect2 = ctx.getDevice(0)->getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER_CONST); EXPECT_NE(NULL, surfaceState->getMemoryObjectControlState()); EXPECT_TRUE(expect == surfaceState->getMemoryObjectControlState() || expect2 == surfaceState->getMemoryObjectControlState()); diff --git a/opencl/test/unit_test/mem_obj/image2d_from_buffer_tests.cpp b/opencl/test/unit_test/mem_obj/image2d_from_buffer_tests.cpp index 5766804bd2..86e28ef722 100644 --- a/opencl/test/unit_test/mem_obj/image2d_from_buffer_tests.cpp +++ b/opencl/test/unit_test/mem_obj/image2d_from_buffer_tests.cpp @@ -304,7 +304,7 @@ TEST_F(Image2dFromBufferTest, givenMemoryManagerSupportingVirtualPaddingWhenImag EXPECT_EQ(this->size, bufferGraphicsAllocation->getUnderlyingBufferSize()); auto imgInfo = MockGmm::initImgInfo(imageDesc, 0, &imageFromBuffer->getSurfaceFormatInfo()); - auto queryGmm = MockGmm::queryImgParams(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), imgInfo); + auto queryGmm = MockGmm::queryImgParams(context.getDevice(0)->getGmmClientContext(), imgInfo); EXPECT_TRUE(queryGmm->gmmResourceInfo->getSizeAllocation() >= this->size); @@ -341,7 +341,7 @@ TEST_F(Image2dFromBufferTest, givenMemoryManagerSupportingVirtualPaddingWhenImag EXPECT_EQ(bufferSize, bufferGraphicsAllocation->getUnderlyingBufferSize()); auto imgInfo = MockGmm::initImgInfo(imageDesc, 0, &imageFromBuffer->getSurfaceFormatInfo()); - auto queryGmm = MockGmm::queryImgParams(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), imgInfo); + auto queryGmm = MockGmm::queryImgParams(context.getDevice(0)->getGmmClientContext(), imgInfo); EXPECT_GT(queryGmm->gmmResourceInfo->getSizeAllocation(), bufferSize); diff --git a/opencl/test/unit_test/mem_obj/image3d_tests.cpp b/opencl/test/unit_test/mem_obj/image3d_tests.cpp index 3791b8bfb6..072ec367c8 100644 --- a/opencl/test/unit_test/mem_obj/image3d_tests.cpp +++ b/opencl/test/unit_test/mem_obj/image3d_tests.cpp @@ -90,7 +90,7 @@ HWTEST_F(CreateImage3DTest, calculate3dImageQpitchTiledAndLinear) { imageDesc.image_height = 1; auto surfaceFormat = Image::getSurfaceFormatFromTable(0, &imageFormat, context->getDevice(0)->getHardwareInfo().capabilityTable.clVersionSupport); auto imgInfo = MockGmm::initImgInfo(imageDesc, 0, surfaceFormat); - MockGmm::queryImgParams(context->getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), imgInfo); + MockGmm::queryImgParams(context->getDevice(0)->getGmmClientContext(), imgInfo); auto image = Image::create( context, @@ -114,7 +114,7 @@ HWTEST_F(CreateImage3DTest, calculate3dImageQpitchTiledAndLinear) { // query again surfaceFormat = Image::getSurfaceFormatFromTable(0, &imageFormat, context->getDevice(0)->getHardwareInfo().capabilityTable.clVersionSupport); - MockGmm::queryImgParams(context->getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), imgInfo); + MockGmm::queryImgParams(context->getDevice(0)->getGmmClientContext(), imgInfo); image = Image::create( context, diff --git a/opencl/test/unit_test/mem_obj/image_set_arg_tests.cpp b/opencl/test/unit_test/mem_obj/image_set_arg_tests.cpp index 164670f618..18b10568e6 100644 --- a/opencl/test/unit_test/mem_obj/image_set_arg_tests.cpp +++ b/opencl/test/unit_test/mem_obj/image_set_arg_tests.cpp @@ -276,7 +276,7 @@ HWTEST_F(ImageSetArgTest, givenImageArraySizeGreaterThanOneButTypeIsNotImageArra imageInfo.imgDesc = Image::convertDescriptor(imageDesc); imageInfo.plane = GMM_NO_PLANE; - auto gmm = MockGmm::queryImgParams(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), imageInfo); + auto gmm = MockGmm::queryImgParams(context.getDevice(0)->getGmmClientContext(), imageInfo); allocation->setDefaultGmm(gmm.release()); auto image = std::unique_ptr{Image::createSharedImage( @@ -514,7 +514,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithoutUnifiedAuxC typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE; McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - mcsAlloc->setDefaultGmm(new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); + mcsAlloc->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, false)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -613,7 +613,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationAndRenderCompressionWhenSetArgOnMult typedef typename FamilyType::RENDER_SURFACE_STATE RENDER_SURFACE_STATE; McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - mcsAlloc->setDefaultGmm(new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); + mcsAlloc->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, false)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -674,7 +674,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapa McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - mcsAlloc->setDefaultGmm(new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); + mcsAlloc->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, false)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -704,7 +704,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapa McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - mcsAlloc->setDefaultGmm(new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); + mcsAlloc->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, false)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; @@ -733,7 +733,7 @@ HWTEST_F(ImageSetArgTest, givenMcsAllocationWhenSetArgIsCalledWithUnifiedAuxCapa McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - mcsAlloc->setDefaultGmm(new Gmm(pDevice->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); + mcsAlloc->setDefaultGmm(new Gmm(pDevice->getGmmClientContext(), nullptr, 1, false)); cl_image_desc imgDesc = Image2dDefaults::imageDesc; imgDesc.num_samples = 8; diff --git a/opencl/test/unit_test/mem_obj/image_tests.cpp b/opencl/test/unit_test/mem_obj/image_tests.cpp index 6747bb806e..d8a548124f 100644 --- a/opencl/test/unit_test/mem_obj/image_tests.cpp +++ b/opencl/test/unit_test/mem_obj/image_tests.cpp @@ -1377,7 +1377,7 @@ HWTEST_F(ImageTransformTest, givenSurfaceBaseAddressAndUnifiedSurfaceWhenSetUnif MockContext context; auto image = std::unique_ptr(ImageHelper::create(&context)); auto surfaceState = FamilyType::cmdInitRenderSurfaceState; - auto gmm = std::unique_ptr(new Gmm(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); + auto gmm = std::unique_ptr(new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, false)); uint64_t surfBsaseAddress = 0xABCDEF1000; surfaceState.setSurfaceBaseAddress(surfBsaseAddress); auto mockResource = reinterpret_cast(gmm->gmmResourceInfo.get()); @@ -1431,7 +1431,7 @@ HWTEST_F(HwImageTest, givenImageHwWithUnifiedSurfaceAndMcsWhenSettingParamsForMu McsSurfaceInfo msi = {10, 20, 3}; auto mcsAlloc = context.getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - mcsAlloc->setDefaultGmm(new Gmm(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); + mcsAlloc->setDefaultGmm(new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, false)); auto mockMcsGmmResInfo = reinterpret_cast<::testing::NiceMock *>(mcsAlloc->getDefaultGmm()->gmmResourceInfo.get()); mockMcsGmmResInfo->setUnifiedAuxTranslationCapable(); diff --git a/opencl/test/unit_test/mem_obj/image_tiled_tests.cpp b/opencl/test/unit_test/mem_obj/image_tiled_tests.cpp index 33090610dd..823ef2681a 100644 --- a/opencl/test/unit_test/mem_obj/image_tiled_tests.cpp +++ b/opencl/test/unit_test/mem_obj/image_tiled_tests.cpp @@ -99,7 +99,7 @@ TEST_P(CreateTiledImageTest, isTiledImageIsSetForSharedImages) { info.imgDesc = Image::convertDescriptor(imageDesc); info.plane = GMM_NO_PLANE; - auto gmm = MockGmm::queryImgParams(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), info); + auto gmm = MockGmm::queryImgParams(context.getDevice(0)->getGmmClientContext(), info); alloc->setDefaultGmm(gmm.release()); @@ -138,7 +138,7 @@ TEST_P(CreateNonTiledImageTest, isTiledImageIsNotSetForNonTiledSharedImage) { info.imgDesc = Image::convertDescriptor(imageDesc); info.plane = GMM_NO_PLANE; - auto gmm = MockGmm::queryImgParams(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), info); + auto gmm = MockGmm::queryImgParams(context.getDevice(0)->getGmmClientContext(), info); alloc->setDefaultGmm(gmm.release()); diff --git a/opencl/test/unit_test/mem_obj/mem_obj_tests.cpp b/opencl/test/unit_test/mem_obj/mem_obj_tests.cpp index c1da3a20c3..b9dd4bfe06 100644 --- a/opencl/test/unit_test/mem_obj/mem_obj_tests.cpp +++ b/opencl/test/unit_test/mem_obj/mem_obj_tests.cpp @@ -306,7 +306,7 @@ TEST(MemObj, givenRenderCompressedGmmWhenAskingForMappingOnCpuThenDisallow) { context.memoryManager = &memoryManager; auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - allocation->setDefaultGmm(new Gmm(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); + allocation->setDefaultGmm(new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, false)); MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_READ_WRITE, 0, 0); MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_READ_WRITE, 0, 1, allocation->getUnderlyingBuffer(), nullptr, allocation, false, false, false); @@ -340,7 +340,7 @@ TEST(MemObj, givenNonCpuAccessibleMemoryWhenAskingForMappingOnCpuThenDisallow) { context.memoryManager = &memoryManager; auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); - allocation->setDefaultGmm(new Gmm(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false)); + allocation->setDefaultGmm(new Gmm(context.getDevice(0)->getGmmClientContext(), nullptr, 1, false)); MemoryPropertiesFlags memoryProperties = MemoryPropertiesFlagsParser::createMemoryPropertiesFlags(CL_MEM_READ_WRITE, 0, 0); MemObj memObj(&context, CL_MEM_OBJECT_BUFFER, memoryProperties, CL_MEM_READ_WRITE, 0, 1, allocation->getUnderlyingBuffer(), nullptr, allocation, false, false, false); diff --git a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp index 45d974a7f4..f83d96c5a9 100644 --- a/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp +++ b/opencl/test/unit_test/memory_manager/memory_manager_tests.cpp @@ -770,7 +770,7 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerAndUnifiedAuxCapableAlloc executionEnvironment.initGmm(); OsAgnosticMemoryManager memoryManager(executionEnvironment); - auto gmm = new Gmm(executionEnvironment.getGmmClientContext(), nullptr, 123, false); + auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 123, false); auto allocation = memoryManager.allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); allocation->setDefaultGmm(gmm); @@ -1299,7 +1299,7 @@ TEST(MemoryManager, givenShareableWhenAllocatingGraphicsMemoryThenAllocateSharea } TEST_F(MemoryAllocatorTest, GivenSizeWhenGmmIsCreatedThenSuccess) { - Gmm *gmm = new Gmm(executionEnvironment->getGmmClientContext(), nullptr, 65536, false); + Gmm *gmm = new Gmm(device->getGmmClientContext(), nullptr, 65536, false); EXPECT_NE(nullptr, gmm); delete gmm; } @@ -2030,7 +2030,8 @@ TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocati TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndResourceIs64KSuitableThenStandard64kHeapIsUsed) { GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; - auto gmm = std::make_unique(platform()->peekExecutionEnvironment()->getGmmClientContext(), nullptr, 0, false); + auto rootDeviceEnvironment = platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0].get(); + auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, false); auto resourceInfo = static_cast(gmm->gmmResourceInfo.get()); resourceInfo->is64KBPageSuitableValue = true; allocation.setDefaultGmm(gmm.get()); @@ -2039,7 +2040,8 @@ TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocati TEST(HeapSelectorTest, givenFullAddressSpaceWhenSelectingHeapForExternalAllocationWithoutPtrAndResourceIsNot64KSuitableThenStandardHeapIsUsed) { GraphicsAllocation allocation{0, GraphicsAllocation::AllocationType::UNKNOWN, nullptr, 0, 0, 0, MemoryPool::MemoryNull}; - auto gmm = std::make_unique(platform()->peekExecutionEnvironment()->getGmmClientContext(), nullptr, 0, false); + auto rootDeviceEnvironment = platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0].get(); + auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, false); auto resourceInfo = static_cast(gmm->gmmResourceInfo.get()); resourceInfo->is64KBPageSuitableValue = false; allocation.setDefaultGmm(gmm.get()); diff --git a/opencl/test/unit_test/mocks/mock_gmm.h b/opencl/test/unit_test/mocks/mock_gmm.h index 14b2c7bc77..66950bfc5a 100644 --- a/opencl/test/unit_test/mocks/mock_gmm.h +++ b/opencl/test/unit_test/mocks/mock_gmm.h @@ -23,7 +23,7 @@ class MockGmm : public Gmm { using Gmm::Gmm; using Gmm::setupImageResourceParams; - MockGmm() : Gmm(platform()->peekExecutionEnvironment()->getGmmClientContext(), nullptr, 1, false){}; + MockGmm() : Gmm(platform()->peekGmmClientContext(), nullptr, 1, false){}; static std::unique_ptr queryImgParams(GmmClientContext *clientContext, ImageInfo &imgInfo) { return std::unique_ptr(new Gmm(clientContext, imgInfo, {})); diff --git a/opencl/test/unit_test/mocks/mock_memory_manager.cpp b/opencl/test/unit_test/mocks/mock_memory_manager.cpp index 36ec2db3cd..3304632ddc 100644 --- a/opencl/test/unit_test/mocks/mock_memory_manager.cpp +++ b/opencl/test/unit_test/mocks/mock_memory_manager.cpp @@ -62,7 +62,7 @@ GraphicsAllocation *MockMemoryManager::allocateGraphicsMemory64kb(const Allocati auto allocation = OsAgnosticMemoryManager::allocateGraphicsMemory64kb(allocationData); if (allocation) { - allocation->setDefaultGmm(new Gmm(executionEnvironment.getGmmClientContext(), allocation->getUnderlyingBuffer(), allocationData.size, false, preferRenderCompressedFlagPassed, true, {})); + allocation->setDefaultGmm(new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), allocation->getUnderlyingBuffer(), allocationData.size, false, preferRenderCompressedFlagPassed, true, {})); allocation->getDefaultGmm()->isRenderCompressed = preferRenderCompressedFlagPassed; } return allocation; diff --git a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp index 61b9e39999..104753b664 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.cpp @@ -2214,7 +2214,7 @@ TEST_F(DrmMemoryManagerTest, givenDrmMemoryManagerAndUnifiedAuxCapableAllocation mock->ioctl_expected.gemWait = 1; mock->ioctl_expected.gemClose = 1; - auto gmm = new Gmm(executionEnvironment->getGmmClientContext(), nullptr, 123, false); + auto gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), nullptr, 123, false); auto allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize}); allocation->setDefaultGmm(gmm); diff --git a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.h b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.h index 1fceed3d0a..673bd90959 100644 --- a/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.h +++ b/opencl/test/unit_test/os_interface/linux/drm_memory_manager_tests.h @@ -48,8 +48,9 @@ class DrmMemoryManagerFixture : public MemoryManagementFixture { this->mock = mock; executionEnvironment = new MockExecutionEnvironment(*platformDevices); executionEnvironment->incRefInternal(); - executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique(); - executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->setDrm(mock); + rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get(); + rootDeviceEnvironment->osInterface = std::make_unique(); + rootDeviceEnvironment->osInterface->get()->setDrm(mock); memoryManager = new (std::nothrow) TestedDrmMemoryManager(localMemoryEnabled, false, false, *executionEnvironment); //assert we have memory manager @@ -71,6 +72,7 @@ class DrmMemoryManagerFixture : public MemoryManagementFixture { protected: ExecutionEnvironment *executionEnvironment; + RootDeviceEnvironment *rootDeviceEnvironment = nullptr; DrmMockCustom::IoctlResExt ioctlResExt = {0, 0}; AllocationData allocationData; }; diff --git a/opencl/test/unit_test/os_interface/windows/file_logger_win_tests.cpp b/opencl/test/unit_test/os_interface/windows/file_logger_win_tests.cpp index bfbc6d06b2..48732f8003 100644 --- a/opencl/test/unit_test/os_interface/windows/file_logger_win_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/file_logger_win_tests.cpp @@ -29,7 +29,7 @@ TEST(FileLogger, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) { allocation.handle = 4; allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER); allocation.memoryPool = MemoryPool::System64KBPages; - auto gmm = std::make_unique(platform()->peekExecutionEnvironment()->getGmmClientContext(), nullptr, 0, false); + auto gmm = std::make_unique(platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 0, false); allocation.setDefaultGmm(gmm.get()); allocation.getDefaultGmm()->resourceParams.Flags.Info.NonLocalOnly = 0; @@ -66,7 +66,7 @@ TEST(FileLogger, GivenLogAllocationMemoryPoolFlagSetFalseThenAllocationIsNotLogg allocation.handle = 4; allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER); allocation.memoryPool = MemoryPool::System64KBPages; - auto gmm = std::make_unique(platform()->peekExecutionEnvironment()->getGmmClientContext(), nullptr, 0, false); + auto gmm = std::make_unique(platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->getGmmClientContext(), nullptr, 0, false); allocation.setDefaultGmm(gmm.get()); allocation.getDefaultGmm()->resourceParams.Flags.Info.NonLocalOnly = 0; diff --git a/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp index 3f38682c60..1b2c2dbde7 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm20_tests.cpp @@ -48,7 +48,7 @@ Gmm *getGmm(void *ptr, size_t size) { size_t alignedSize = alignSizeWholePage(ptr, size); void *alignedPtr = alignUp(ptr, 4096); - Gmm *gmm = new Gmm(platform()->peekExecutionEnvironment()->getGmmClientContext(), alignedPtr, alignedSize, false); + Gmm *gmm = new Gmm(platform()->peekExecutionEnvironment()->rootDeviceEnvironments[0]->getGmmClientContext(), alignedPtr, alignedSize, false); EXPECT_NE(gmm->gmmResourceInfo.get(), nullptr); return gmm; } @@ -79,7 +79,7 @@ TEST_F(Wddm20Tests, doubleCreation) { } TEST_F(Wddm20Tests, givenNullPageTableManagerAndRenderCompressedResourceWhenMappingGpuVaThenDontUpdateAuxTable) { - auto gmm = std::unique_ptr(new Gmm(executionEnvironment->getGmmClientContext(), nullptr, 1, false)); + auto gmm = std::unique_ptr(new Gmm(rootDeviceEnvironemnt->getGmmClientContext(), nullptr, 1, false)); auto mockGmmRes = reinterpret_cast(gmm->gmmResourceInfo.get()); mockGmmRes->setUnifiedAuxTranslationCapable(); @@ -430,7 +430,7 @@ TEST_F(Wddm20Tests, makeResidentNonResident) { TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationFromSharedHandleIsCalledThenGraphicsAllocationWithSharedPropertiesIsCreated) { void *pSysMem = (void *)0x1000; - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); EXPECT_EQ(0u, status); @@ -467,7 +467,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationF TEST_F(Wddm20WithMockGdiDllTests, givenSharedHandleWhenCreateGraphicsAllocationFromSharedHandleIsCalledThenMapGpuVaWithCpuPtrDepensOnBitness) { void *pSysMem = (void *)0x1000; - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); auto status = setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); EXPECT_EQ(0u, status); @@ -762,7 +762,7 @@ TEST_F(Wddm20Tests, whenCreateAllocation64kFailsThenReturnFalse) { gdi->createAllocation = FailingCreateAllocation::mockCreateAllocation; void *fakePtr = reinterpret_cast(0x123); - auto gmm = std::make_unique(executionEnvironment->getGmmClientContext(), fakePtr, 100, false); + auto gmm = std::make_unique(rootDeviceEnvironemnt->getGmmClientContext(), fakePtr, 100, false); WddmAllocation allocation(0, GraphicsAllocation::AllocationType::UNKNOWN, fakePtr, 100, nullptr, MemoryPool::MemoryNull); allocation.setDefaultGmm(gmm.get()); @@ -1153,7 +1153,7 @@ TEST_F(Wddm20WithMockGdiDllTests, whenSetDeviceInfoSucceedsThenDeviceCallbacksAr TEST_F(Wddm20WithMockGdiDllTests, whenSetDeviceInfoFailsThenDeviceIsNotConfigured) { - auto gmockGmmMemory = new ::testing::NiceMock(executionEnvironment->getGmmClientContext()); + auto gmockGmmMemory = new ::testing::NiceMock(rootDeviceEnvironment->getGmmClientContext()); ON_CALL(*gmockGmmMemory, setDeviceInfo(::testing::_)) .WillByDefault(::testing::Return(false)); EXPECT_CALL(*gmockGmmMemory, configureDeviceAddressSpace(::testing::_, @@ -1172,7 +1172,7 @@ HWTEST_F(Wddm20WithMockGdiDllTests, givenNonGen12LPPlatformWhenConfigureDeviceAd if (platformDevices[0]->platform.eRenderCoreFamily == IGFX_GEN12LP_CORE) { GTEST_SKIP(); } - auto gmmMemory = new ::testing::NiceMock(executionEnvironment->getGmmClientContext()); + auto gmmMemory = new ::testing::NiceMock(rootDeviceEnvironment->getGmmClientContext()); wddm->gmmMemory.reset(gmmMemory); ON_CALL(*gmmMemory, configureDeviceAddressSpace(::testing::_, ::testing::_, diff --git a/opencl/test/unit_test/os_interface/windows/wddm_fixture.h b/opencl/test/unit_test/os_interface/windows/wddm_fixture.h index f771e5caab..17bdc08107 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_fixture.h +++ b/opencl/test/unit_test/os_interface/windows/wddm_fixture.h @@ -31,11 +31,12 @@ namespace NEO { struct WddmFixture : ::testing::Test { void SetUp() override { executionEnvironment = platform()->peekExecutionEnvironment(); - wddm = static_cast(Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[0].get())); - executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique(); - executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->setWddm(wddm); - executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique(wddm); - osInterface = executionEnvironment->rootDeviceEnvironments[0]->osInterface.get(); + rootDeviceEnvironemnt = executionEnvironment->rootDeviceEnvironments[0].get(); + wddm = static_cast(Wddm::createWddm(nullptr, *rootDeviceEnvironemnt)); + rootDeviceEnvironemnt->osInterface = std::make_unique(); + rootDeviceEnvironemnt->osInterface->get()->setWddm(wddm); + rootDeviceEnvironemnt->memoryOperationsInterface = std::make_unique(wddm); + osInterface = rootDeviceEnvironemnt->osInterface.get(); gdi = new MockGdi(); wddm->resetGdi(gdi); auto preemptionMode = PreemptionHelper::getDefaultPreemptionMode(*platformDevices[0]); @@ -50,6 +51,7 @@ struct WddmFixture : ::testing::Test { OSInterface *osInterface; std::unique_ptr osContext; ExecutionEnvironment *executionEnvironment; + RootDeviceEnvironment *rootDeviceEnvironemnt = nullptr; MockGdi *gdi = nullptr; MockWddmResidentAllocationsContainer *mockTemporaryResources; @@ -58,14 +60,15 @@ struct WddmFixture : ::testing::Test { struct WddmFixtureWithMockGdiDll : public GdiDllFixture { void SetUp() override { executionEnvironment = platform()->peekExecutionEnvironment(); + rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get(); GdiDllFixture::SetUp(); - wddm = static_cast(Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[0].get())); + wddm = static_cast(Wddm::createWddm(nullptr, *rootDeviceEnvironment)); wddmMockInterface = new WddmMockInterface20(*wddm); wddm->wddmInterface.reset(wddmMockInterface); - executionEnvironment->rootDeviceEnvironments[0]->osInterface = std::make_unique(); - executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->setWddm(wddm); - executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique(wddm); - osInterface = executionEnvironment->rootDeviceEnvironments[0]->osInterface.get(); + rootDeviceEnvironment->osInterface = std::make_unique(); + rootDeviceEnvironment->osInterface->get()->setWddm(wddm); + rootDeviceEnvironment->memoryOperationsInterface = std::make_unique(wddm); + osInterface = rootDeviceEnvironment->osInterface.get(); } void init() { @@ -88,13 +91,15 @@ struct WddmFixtureWithMockGdiDll : public GdiDllFixture { std::unique_ptr osContext; ExecutionEnvironment *executionEnvironment; WddmMockInterface20 *wddmMockInterface = nullptr; + RootDeviceEnvironment *rootDeviceEnvironment = nullptr; }; struct WddmInstrumentationGmmFixture { void SetUp() { executionEnvironment = platform()->peekExecutionEnvironment(); - wddm.reset(static_cast(Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[0].get()))); - gmmMem = new ::testing::NiceMock(executionEnvironment->getGmmClientContext()); + auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get(); + wddm.reset(static_cast(Wddm::createWddm(nullptr, *rootDeviceEnvironment))); + gmmMem = new ::testing::NiceMock(rootDeviceEnvironment->getGmmClientContext()); wddm->gmmMemory.reset(gmmMem); } void TearDown() { diff --git a/opencl/test/unit_test/os_interface/windows/wddm_kmdaf_listener_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm_kmdaf_listener_tests.cpp index 8616595b2e..027908fa64 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_kmdaf_listener_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm_kmdaf_listener_tests.cpp @@ -40,7 +40,8 @@ class WddmKmDafListenerTest : public ::testing::Test { public: void SetUp() { executionEnvironment = platform()->peekExecutionEnvironment(); - wddmWithKmDafMock.reset(new WddmWithKmDafMock(*executionEnvironment->rootDeviceEnvironments[0].get(), new MockGdi())); + rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get(); + wddmWithKmDafMock.reset(new WddmWithKmDafMock(*rootDeviceEnvironment, new MockGdi())); wddmWithKmDafMock->init(); wddmWithKmDafMock->featureTable->ftrKmdDaf = true; } @@ -49,6 +50,7 @@ class WddmKmDafListenerTest : public ::testing::Test { std::unique_ptr wddmWithKmDafMock; ExecutionEnvironment *executionEnvironment; + RootDeviceEnvironment *rootDeviceEnvironment = nullptr; }; TEST_F(WddmKmDafListenerTest, givenWddmWhenLockResourceIsCalledThenKmDafListenerNotifyLockIsFedWithCorrectParams) { @@ -75,7 +77,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenUnlockResourceIsCalledThenKmDafListen TEST_F(WddmKmDafListenerTest, givenWddmWhenMapGpuVirtualAddressIsCalledThenKmDafListenerNotifyMapGpuVAIsFedWithCorrectParams) { uint64_t gpuPtr = 0u; - auto gmm = std::make_unique(executionEnvironment->getGmmClientContext(), nullptr, 1, false); + auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 1, false); wddmWithKmDafMock->mapGpuVirtualAddress(gmm.get(), ALLOCATION_HANDLE, wddmWithKmDafMock->getGfxPartition().Standard.Base, wddmWithKmDafMock->getGfxPartition().Standard.Limit, 0u, gpuPtr); @@ -128,7 +130,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenEvictIsCalledThenKmDafListenerNotifyE } TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationIsCalledThenKmDafListenerNotifyWriteTargetIsFedWithCorrectParams) { - auto gmm = std::make_unique(executionEnvironment->getGmmClientContext(), nullptr, 1, false); + auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 1, false); auto handle = 0u; auto ptr = reinterpret_cast(0x10000); @@ -142,7 +144,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationIsCalledThenKmDafList } TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocation64IsCalledThenKmDafListenerNotifyWriteTargetIsFedWithCorrectParams) { - auto gmm = std::make_unique(executionEnvironment->getGmmClientContext(), nullptr, 1, false); + auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 1, false); auto handle = 0u; wddmWithKmDafMock->createAllocation64k(gmm.get(), handle); @@ -157,7 +159,7 @@ TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocation64IsCalledThenKmDafLi TEST_F(WddmKmDafListenerTest, givenWddmWhenCreateAllocationsAndMapGpuVaIsCalledThenKmDafListenerNotifyWriteTargetAndMapGpuVAIsFedWithCorrectParams) { OsHandleStorage storage; OsHandle osHandle = {0}; - auto gmm = std::unique_ptr(new Gmm(executionEnvironment->getGmmClientContext(), nullptr, 1, false)); + auto gmm = std::unique_ptr(new Gmm(rootDeviceEnvironment->getGmmClientContext(), nullptr, 1, false)); storage.fragmentStorageData[0].osHandleStorage = &osHandle; storage.fragmentStorageData[0].fragmentSize = 100; storage.fragmentStorageData[0].osHandleStorage->gmm = gmm.get(); diff --git a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp index d76dea0c3e..a97cfada3c 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp +++ b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.cpp @@ -39,6 +39,7 @@ void WddmMemoryManagerFixture::SetUp() { GdiDllFixture::SetUp(); executionEnvironment = platform()->peekExecutionEnvironment(); + rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get(); wddm = static_cast(Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[0].get())); if (platformDevices[0]->capabilityTable.ftrRenderCompressedBuffers || platformDevices[0]->capabilityTable.ftrRenderCompressedImages) { GMM_TRANSLATIONTABLE_CALLBACKS dummyTTCallbacks = {}; @@ -209,7 +210,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenMemoryManagerWhenCreateAllocationFromHa memoryManager.reset(new MockWddmMemoryManager(false, false, *executionEnvironment)); auto osHandle = 1u; gdi->getQueryResourceInfoArgOut().NumAllocations = 1; - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), nullptr, 0, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, false)); D3DDDI_OPENALLOCATIONINFO allocationInfo; allocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle(); @@ -229,7 +230,7 @@ TEST_F(WddmMemoryManagerSimpleTest, givenAllocationPropertiesWhenCreateAllocatio memoryManager.reset(new MockWddmMemoryManager(false, false, *executionEnvironment)); auto osHandle = 1u; gdi->getQueryResourceInfoArgOut().NumAllocations = 1; - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), nullptr, 0, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, false)); D3DDDI_OPENALLOCATIONINFO allocationInfo; allocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle(); @@ -255,7 +256,7 @@ TEST_F(WddmMemoryManagerSimpleTest, whenCreateAllocationFromHandleAndMapCallFail memoryManager.reset(new MockWddmMemoryManager(false, false, *executionEnvironment)); auto osHandle = 1u; gdi->getQueryResourceInfoArgOut().NumAllocations = 1; - auto gmm = std::make_unique(executionEnvironment->getGmmClientContext(), nullptr, 0, false); + auto gmm = std::make_unique(rootDeviceEnvironment->getGmmClientContext(), nullptr, 0, false); D3DDDI_OPENALLOCATIONINFO allocationInfo; allocationInfo.pPrivateDriverData = gmm->gmmResourceInfo->peekHandle(); @@ -473,7 +474,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandleIs auto osHandle = 1u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); AllocationProperties properties(0, false, 4096u, GraphicsAllocation::AllocationType::SHARED_BUFFER, false, false, 0); @@ -490,7 +491,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandleIs TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromNTHandleIsCalledThenNonNullGraphicsAllocationIsReturned) { void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); auto *gpuAllocation = memoryManager->createGraphicsAllocationFromNTHandle(reinterpret_cast(1), 0); @@ -522,7 +523,7 @@ TEST_F(WddmMemoryManagerTest, createAllocationFromSharedHandleReturns32BitAllocW auto osHandle = 1u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); memoryManager->setForce32BitAllocations(true); @@ -545,7 +546,7 @@ TEST_F(WddmMemoryManagerTest, createAllocationFromSharedHandleDoesNotReturn32Bit auto osHandle = 1u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); memoryManager->setForce32BitAllocations(true); @@ -567,7 +568,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenFreeAllocFromSharedHandl auto osHandle = 1u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, false)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); AllocationProperties properties(0, false, 4096u, GraphicsAllocation::AllocationType::SHARED_BUFFER, false, false, 0); @@ -589,7 +590,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerSizeZeroWhenCreateFromShared auto size = 4096u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, size, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, size, false)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); AllocationProperties properties(0, false, size, GraphicsAllocation::AllocationType::SHARED_BUFFER, false, false, 0); @@ -604,7 +605,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCreateFromSharedHandleFa auto size = 4096u; void *pSysMem = reinterpret_cast(0x1000); - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, size, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, size, false)); setSizesFcn(gmm->gmmResourceInfo.get(), 1u, 1024u, 1u); wddm->failOpenSharedHandle = true; @@ -946,7 +947,7 @@ TEST_F(WddmMemoryManagerTest, GivenThreeOsHandlesWhenAskedForDestroyAllocationsT storage.fragmentStorageData[0].osHandleStorage->handle = ALLOCATION_HANDLE; storage.fragmentStorageData[0].freeTheFragment = true; - storage.fragmentStorageData[0].osHandleStorage->gmm = new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false); + storage.fragmentStorageData[0].osHandleStorage->gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, false); storage.fragmentStorageData[1].osHandleStorage = new OsHandle; storage.fragmentStorageData[1].osHandleStorage->handle = ALLOCATION_HANDLE; @@ -957,7 +958,7 @@ TEST_F(WddmMemoryManagerTest, GivenThreeOsHandlesWhenAskedForDestroyAllocationsT storage.fragmentStorageData[2].osHandleStorage = new OsHandle; storage.fragmentStorageData[2].osHandleStorage->handle = ALLOCATION_HANDLE; storage.fragmentStorageData[2].freeTheFragment = true; - storage.fragmentStorageData[2].osHandleStorage->gmm = new Gmm(executionEnvironment->getGmmClientContext(), pSysMem, 4096u, false); + storage.fragmentStorageData[2].osHandleStorage->gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), pSysMem, 4096u, false); storage.fragmentStorageData[2].residency = new ResidencyData; memoryManager->cleanOsHandles(storage, 0); @@ -1002,7 +1003,7 @@ TEST_F(WddmMemoryManagerTest, givenWddmMemoryManagerWhenCpuMemNotMeetRestriction TEST_F(WddmMemoryManagerTest, givenManagerWithDisabledDeferredDeleterWhenMapGpuVaFailThenFailToCreateAllocation) { void *ptr = reinterpret_cast(0x1000); size_t size = 0x1000; - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), ptr, size, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), ptr, size, false)); memoryManager->setDeferredDeleter(nullptr); setMapGpuVaFailConfigFcn(0, 1); @@ -1016,7 +1017,7 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithDisabledDeferredDeleterWhenMapGpuV TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstMapGpuVaFailSecondAfterDrainSuccessThenCreateAllocation) { void *ptr = reinterpret_cast(0x10000); size_t size = 0x1000; - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), ptr, size, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), ptr, size, false)); MockDeferredDeleter *deleter = new MockDeferredDeleter; memoryManager->setDeferredDeleter(deleter); @@ -1032,7 +1033,7 @@ TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstMap TEST_F(WddmMemoryManagerTest, givenManagerWithEnabledDeferredDeleterWhenFirstAndMapGpuVaFailSecondAfterDrainFailThenFailToCreateAllocation) { void *ptr = reinterpret_cast(0x1000); size_t size = 0x1000; - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), ptr, size, false)); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), ptr, size, false)); MockDeferredDeleter *deleter = new MockDeferredDeleter; memoryManager->setDeferredDeleter(deleter); @@ -1196,7 +1197,8 @@ TEST_F(BufferWithWddmMemory, givenFragmentsThatAreNotInOrderWhenGraphicsAllocati handleStorage.fragmentStorageData[0].osHandleStorage = new OsHandle(); handleStorage.fragmentStorageData[0].residency = new ResidencyData(); handleStorage.fragmentStorageData[0].freeTheFragment = true; - handleStorage.fragmentStorageData[0].osHandleStorage->gmm = new Gmm(executionEnvironment->getGmmClientContext(), ptr, size, false); + auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get(); + handleStorage.fragmentStorageData[0].osHandleStorage->gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), ptr, size, false); handleStorage.fragmentCount = 1; FragmentStorage fragment = {}; @@ -1230,7 +1232,8 @@ TEST_F(BufferWithWddmMemory, givenFragmentsThatAreNotInOrderWhenGraphicsAllocati handleStorage.fragmentStorageData[0].osHandleStorage = new OsHandle(); handleStorage.fragmentStorageData[0].residency = new ResidencyData(); handleStorage.fragmentStorageData[0].freeTheFragment = true; - handleStorage.fragmentStorageData[0].osHandleStorage->gmm = new Gmm(executionEnvironment->getGmmClientContext(), ptr, size, false); + auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get(); + handleStorage.fragmentStorageData[0].osHandleStorage->gmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), ptr, size, false); handleStorage.fragmentCount = 1; FragmentStorage fragment = {}; @@ -1515,14 +1518,15 @@ TEST_F(MockWddmMemoryManagerTest, givenPageTableManagerWhenMapAuxGpuVaCalledThen } TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedAllocationWhenMappedGpuVaThenMapAuxVa) { - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, false)); + auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[1].get(); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, false)); gmm->isRenderCompressed = true; D3DGPU_VIRTUAL_ADDRESS gpuVa = 0; WddmMock wddm(*executionEnvironment->rootDeviceEnvironments[1].get()); wddm.init(); auto mockMngr = new NiceMock(); - executionEnvironment->rootDeviceEnvironments[1]->pageTableManager.reset(mockMngr); + rootDeviceEnvironment->pageTableManager.reset(mockMngr); GMM_DDI_UPDATEAUXTABLE givenDdiUpdateAuxTable = {}; GMM_DDI_UPDATEAUXTABLE expectedDdiUpdateAuxTable = {}; @@ -1583,14 +1587,15 @@ TEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenReleasei } TEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenMappedGpuVaThenDontMapAuxVa) { - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, false)); + auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[1].get(); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, false)); gmm->isRenderCompressed = false; D3DGPU_VIRTUAL_ADDRESS gpuVa = 0; - WddmMock wddm(*executionEnvironment->rootDeviceEnvironments[0].get()); + WddmMock wddm(*rootDeviceEnvironment); wddm.init(); auto mockMngr = new NiceMock(); - executionEnvironment->rootDeviceEnvironments[1]->pageTableManager.reset(mockMngr); + rootDeviceEnvironment->pageTableManager.reset(mockMngr); EXPECT_CALL(*mockMngr, updateAuxTable(_)).Times(0); @@ -1599,10 +1604,11 @@ TEST_F(MockWddmMemoryManagerTest, givenNonRenderCompressedAllocationWhenMappedGp } TEST_F(MockWddmMemoryManagerTest, givenFailingAllocationWhenMappedGpuVaThenReturnFalse) { - std::unique_ptr gmm(new Gmm(executionEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, false)); + auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[1].get(); + std::unique_ptr gmm(new Gmm(rootDeviceEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, false)); gmm->isRenderCompressed = false; D3DGPU_VIRTUAL_ADDRESS gpuVa = 0; - WddmMock wddm(*executionEnvironment->rootDeviceEnvironments[1].get()); + WddmMock wddm(*rootDeviceEnvironment); wddm.init(); auto result = wddm.mapGpuVirtualAddress(gmm.get(), 0, 0, 0, 0, gpuVa); @@ -1615,9 +1621,10 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedFlagSetWhenInternalIsUnse WddmMemoryManager memoryManager(*executionEnvironment); auto mockMngr = new NiceMock(); - executionEnvironment->rootDeviceEnvironments[1]->pageTableManager.reset(mockMngr); + auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[1].get(); + rootDeviceEnvironment->pageTableManager.reset(mockMngr); - auto myGmm = new Gmm(executionEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, false); + auto myGmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, false); myGmm->isRenderCompressed = false; myGmm->gmmResourceInfo->getResourceFlags()->Info.RenderCompressed = 1; @@ -1638,9 +1645,10 @@ TEST_F(MockWddmMemoryManagerTest, givenRenderCompressedFlagSetWhenInternalIsSetT WddmMemoryManager memoryManager(*executionEnvironment); auto mockMngr = new NiceMock(); - executionEnvironment->rootDeviceEnvironments[1]->pageTableManager.reset(mockMngr); + auto rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[1].get(); + rootDeviceEnvironment->pageTableManager.reset(mockMngr); - auto myGmm = new Gmm(executionEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, false); + auto myGmm = new Gmm(rootDeviceEnvironment->getGmmClientContext(), reinterpret_cast(123), 4096u, false); myGmm->isRenderCompressed = true; myGmm->gmmResourceInfo->getResourceFlags()->Info.RenderCompressed = 1; diff --git a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.h b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.h index 2aaddd184e..452687d047 100644 --- a/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.h +++ b/opencl/test/unit_test/os_interface/windows/wddm_memory_manager_tests.h @@ -37,6 +37,7 @@ class WddmMemoryManagerFixture : public GdiDllFixture { } ExecutionEnvironment *executionEnvironment; + RootDeviceEnvironment *rootDeviceEnvironment = nullptr; std::unique_ptr memoryManager; WddmMock *wddm; }; @@ -47,17 +48,18 @@ class MockWddmMemoryManagerFixture { public: void SetUp() { executionEnvironment = platform()->peekExecutionEnvironment(); + rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get(); gdi = new MockGdi(); - wddm = static_cast(Wddm::createWddm(nullptr, *executionEnvironment->rootDeviceEnvironments[0].get())); + wddm = static_cast(Wddm::createWddm(nullptr, *rootDeviceEnvironment)); wddm->resetGdi(gdi); constexpr uint64_t heap32Base = (is32bit) ? 0x1000 : 0x800000000000; wddm->setHeap32(heap32Base, 1000 * MemoryConstants::pageSize - 1); wddm->init(); - executionEnvironment->rootDeviceEnvironments[0]->osInterface.reset(new OSInterface()); - executionEnvironment->rootDeviceEnvironments[0]->osInterface->get()->setWddm(wddm); - executionEnvironment->rootDeviceEnvironments[0]->memoryOperationsInterface = std::make_unique(wddm); + rootDeviceEnvironment->osInterface.reset(new OSInterface()); + rootDeviceEnvironment->osInterface->get()->setWddm(wddm); + rootDeviceEnvironment->memoryOperationsInterface = std::make_unique(wddm); executionEnvironment->initializeMemoryManager(); memoryManager = std::make_unique(*executionEnvironment); @@ -75,6 +77,7 @@ class MockWddmMemoryManagerFixture { osContext->decRefInternal(); } + RootDeviceEnvironment *rootDeviceEnvironment = nullptr; ExecutionEnvironment *executionEnvironment; std::unique_ptr memoryManager; std::unique_ptr csr; diff --git a/opencl/test/unit_test/sharings/gl/windows/gl_create_from_texture_tests.cpp b/opencl/test/unit_test/sharings/gl/windows/gl_create_from_texture_tests.cpp index 7e83dbb892..0e77a903f1 100644 --- a/opencl/test/unit_test/sharings/gl/windows/gl_create_from_texture_tests.cpp +++ b/opencl/test/unit_test/sharings/gl/windows/gl_create_from_texture_tests.cpp @@ -57,7 +57,7 @@ class CreateFromGlTexture : public ::testing::Test { void updateImgInfoAndForceGmm() { imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr); - gmm = MockGmm::queryImgParams(clContext.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), imgInfo); + gmm = MockGmm::queryImgParams(clContext.getDevice(0)->getGmmClientContext(), imgInfo); tempMM.forceAllocationSize = imgInfo.size; tempMM.forceGmm = gmm.get(); @@ -69,7 +69,7 @@ class CreateFromGlTexture : public ::testing::Test { mcsImgDesc.image_width = 128; mcsImgDesc.image_type = CL_MEM_OBJECT_IMAGE2D; auto mcsImgInfo = MockGmm::initImgInfo(mcsImgDesc, 0, nullptr); - mcsGmm = MockGmm::queryImgParams(clContext.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), mcsImgInfo); + mcsGmm = MockGmm::queryImgParams(clContext.getDevice(0)->getGmmClientContext(), mcsImgInfo); tempMM.forceMcsGmm = mcsGmm.get(); } } diff --git a/opencl/test/unit_test/sharings/gl/windows/gl_reused_buffers_tests.cpp b/opencl/test/unit_test/sharings/gl/windows/gl_reused_buffers_tests.cpp index 7fdfaf27a7..d05569265f 100644 --- a/opencl/test/unit_test/sharings/gl/windows/gl_reused_buffers_tests.cpp +++ b/opencl/test/unit_test/sharings/gl/windows/gl_reused_buffers_tests.cpp @@ -85,7 +85,7 @@ TEST_F(GlReusedBufferTests, givenMultipleBuffersWithReusedAllocationWhenReleasin TEST_F(GlReusedBufferTests, givenMultipleBuffersWithReusedAllocationWhenCreatingThenReuseGmmResourceToo) { std::unique_ptr glBuffer1(GlBuffer::createSharedGlBuffer(&context, CL_MEM_READ_WRITE, bufferId1, &retVal)); - glBuffer1->getGraphicsAllocation()->setDefaultGmm(new Gmm(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), (void *)0x100, 1, false)); + glBuffer1->getGraphicsAllocation()->setDefaultGmm(new Gmm(context.getDevice(0)->getGmmClientContext(), (void *)0x100, 1, false)); std::unique_ptr glBuffer2(GlBuffer::createSharedGlBuffer(&context, CL_MEM_READ_WRITE, bufferId1, &retVal)); diff --git a/opencl/test/unit_test/sharings/gl/windows/gl_sharing_tests.cpp b/opencl/test/unit_test/sharings/gl/windows/gl_sharing_tests.cpp index c548a0e741..4c34e5b06b 100644 --- a/opencl/test/unit_test/sharings/gl/windows/gl_sharing_tests.cpp +++ b/opencl/test/unit_test/sharings/gl/windows/gl_sharing_tests.cpp @@ -251,7 +251,7 @@ TEST_F(glSharingTests, givenClGLBufferWhenItIsAcquiredTwiceThenAcuqireIsNotCalle TEST_F(glSharingTests, givenClGLBufferWhenItIsCreatedAndGmmIsAvailableThenItIsUsedInGraphicsAllocation) { void *ptr = (void *)0x1000; - auto gmm = new Gmm(context.getDevice(0)->getExecutionEnvironment()->getGmmClientContext(), ptr, 4096u, false); + auto gmm = new Gmm(context.getDevice(0)->getGmmClientContext(), ptr, 4096u, false); mockGlSharing->m_bufferInfoOutput.pGmmResInfo = gmm->gmmResourceInfo->peekHandle(); mockGlSharing->uploadDataToBufferInfo(); diff --git a/opencl/test/unit_test/sharings/gl/windows/gl_texture_tests.cpp b/opencl/test/unit_test/sharings/gl/windows/gl_texture_tests.cpp index def9c367b4..065d00668b 100644 --- a/opencl/test/unit_test/sharings/gl/windows/gl_texture_tests.cpp +++ b/opencl/test/unit_test/sharings/gl/windows/gl_texture_tests.cpp @@ -64,7 +64,7 @@ class GlSharingTextureTests : public ::testing::Test { mockGlSharingFunctions = glSharing->sharingFunctions.release(); clContext->setSharingFunctions(mockGlSharingFunctions); - tempMM->forceGmm = MockGmm::queryImgParams(executionEnvironment->getGmmClientContext(), imgInfo); + tempMM->forceGmm = MockGmm::queryImgParams(device->getGmmClientContext(), imgInfo); tempMM->forceAllocationSize = textureSize; textureSize = imgInfo.size; textureId = 1; diff --git a/shared/source/command_container/command_encoder_base.inl b/shared/source/command_container/command_encoder_base.inl index b5370288f1..2143ade554 100644 --- a/shared/source/command_container/command_encoder_base.inl +++ b/shared/source/command_container/command_encoder_base.inl @@ -222,7 +222,7 @@ void EncodeMediaInterfaceDescriptorLoad::encode(CommandContainer &contai template void EncodeStateBaseAddress::encode(CommandContainer &container) { - auto gmmHelper = container.getDevice()->getExecutionEnvironment()->getGmmHelper(); + auto gmmHelper = container.getDevice()->getGmmHelper(); StateBaseAddressHelper::programStateBaseAddress( *container.getCommandStream(), diff --git a/shared/source/device/device.cpp b/shared/source/device/device.cpp index feb0655c22..f5b3eed0cc 100644 --- a/shared/source/device/device.cpp +++ b/shared/source/device/device.cpp @@ -11,6 +11,7 @@ #include "shared/source/command_stream/experimental_command_buffer.h" #include "shared/source/command_stream/preemption.h" #include "shared/source/execution_environment/root_device_environment.h" +#include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/helpers/hw_helper.h" #include "shared/source/memory_manager/memory_manager.h" #include "shared/source/os_interface/os_context.h" @@ -228,4 +229,8 @@ bool Device::getHostTimer(uint64_t *hostTimestamp) const { return getOSTime()->getCpuTime(hostTimestamp); } +GmmClientContext *Device::getGmmClientContext() const { + return getGmmHelper()->getClientContext(); +} + } // namespace NEO diff --git a/shared/source/device/device.h b/shared/source/device/device.h index 9316e63685..83227c4ea3 100644 --- a/shared/source/device/device.h +++ b/shared/source/device/device.h @@ -7,6 +7,7 @@ #pragma once #include "shared/source/execution_environment/execution_environment.h" +#include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/helpers/common_types.h" #include "shared/source/helpers/engine_control.h" #include "shared/source/helpers/hw_info.h" @@ -45,6 +46,7 @@ class Device : public ReferenceTrackedObject { EngineControl &getInternalEngine(); MemoryManager *getMemoryManager() const; GmmHelper *getGmmHelper() const; + GmmClientContext *getGmmClientContext() const; OSTime *getOSTime() const { return osTime.get(); }; double getProfilingTimerResolution(); double getPlatformHostTimerResolution() const; @@ -129,7 +131,6 @@ inline MemoryManager *Device::getMemoryManager() const { } inline GmmHelper *Device::getGmmHelper() const { - return executionEnvironment->getGmmHelper(); + return getRootDeviceEnvironment().getGmmHelper(); } - } // namespace NEO diff --git a/shared/source/execution_environment/root_device_environment.cpp b/shared/source/execution_environment/root_device_environment.cpp index 9b017542f5..cefaf3a251 100644 --- a/shared/source/execution_environment/root_device_environment.cpp +++ b/shared/source/execution_environment/root_device_environment.cpp @@ -8,6 +8,7 @@ #include "shared/source/execution_environment/root_device_environment.h" #include "shared/source/execution_environment/execution_environment.h" +#include "shared/source/gmm_helper/gmm_helper.h" #include "shared/source/gmm_helper/page_table_mngr.h" #include "shared/source/memory_manager/memory_operations_handler.h" #include "shared/source/os_interface/os_interface.h" @@ -27,4 +28,11 @@ void RootDeviceEnvironment::initAubCenter(bool localMemoryEnabled, const std::st const HardwareInfo *RootDeviceEnvironment::getHardwareInfo() const { return executionEnvironment.getHardwareInfo(); } + +GmmHelper *RootDeviceEnvironment::getGmmHelper() const { + return executionEnvironment.getGmmHelper(); +} +GmmClientContext *RootDeviceEnvironment::getGmmClientContext() const { + return executionEnvironment.getGmmClientContext(); +} } // namespace NEO diff --git a/shared/source/execution_environment/root_device_environment.h b/shared/source/execution_environment/root_device_environment.h index 0930824bc3..51cbf5ee01 100644 --- a/shared/source/execution_environment/root_device_environment.h +++ b/shared/source/execution_environment/root_device_environment.h @@ -15,6 +15,8 @@ namespace NEO { class AubCenter; +class GmmClientContext; +class GmmHelper; class ExecutionEnvironment; class GmmPageTableMngr; class MemoryOperationsHandler; @@ -30,6 +32,8 @@ struct RootDeviceEnvironment { MOCKABLE_VIRTUAL void initAubCenter(bool localMemoryEnabled, const std::string &aubFileName, CommandStreamReceiverType csrType); bool initOsInterface(std::unique_ptr &&hwDeviceId); + GmmHelper *getGmmHelper() const; + GmmClientContext *getGmmClientContext() const; std::unique_ptr osInterface; std::unique_ptr pageTableManager; diff --git a/shared/source/memory_manager/memory_manager.cpp b/shared/source/memory_manager/memory_manager.cpp index 3df6404f2b..c99c7b6d2d 100644 --- a/shared/source/memory_manager/memory_manager.cpp +++ b/shared/source/memory_manager/memory_manager.cpp @@ -380,7 +380,7 @@ GraphicsAllocation *MemoryManager::allocateGraphicsMemory(const AllocationData & } GraphicsAllocation *MemoryManager::allocateGraphicsMemoryForImage(const AllocationData &allocationData) { - auto gmm = std::make_unique(executionEnvironment.getGmmClientContext(), *allocationData.imgInfo, allocationData.storageInfo); + auto gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), *allocationData.imgInfo, allocationData.storageInfo); // AllocationData needs to be reconfigured for System Memory paths AllocationData allocationDataWithSize = allocationData; diff --git a/shared/source/os_interface/linux/drm_memory_manager.cpp b/shared/source/os_interface/linux/drm_memory_manager.cpp index 9542c22420..5cd1edf600 100644 --- a/shared/source/os_interface/linux/drm_memory_manager.cpp +++ b/shared/source/os_interface/linux/drm_memory_manager.cpp @@ -283,7 +283,7 @@ DrmAllocation *DrmMemoryManager::allocateGraphicsMemory64kb(const AllocationData } GraphicsAllocation *DrmMemoryManager::allocateShareableMemory(const AllocationData &allocationData) { - auto gmm = std::make_unique(executionEnvironment.getGmmClientContext(), allocationData.hostPtr, allocationData.size, false); + auto gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), allocationData.hostPtr, allocationData.size, false); size_t bufferSize = allocationData.size; uint64_t gpuRange = acquireGpuRange(bufferSize, false, allocationData.rootDeviceIndex); @@ -491,7 +491,7 @@ GraphicsAllocation *DrmMemoryManager::createGraphicsAllocationFromSharedHandle(o } } - Gmm *gmm = new Gmm(executionEnvironment.getGmmClientContext(), *properties.imgInfo, createStorageInfoFromProperties(properties)); + Gmm *gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[properties.rootDeviceIndex]->getGmmClientContext(), *properties.imgInfo, createStorageInfoFromProperties(properties)); drmAllocation->setDefaultGmm(gmm); } return drmAllocation; diff --git a/shared/source/os_interface/windows/wddm/wddm.cpp b/shared/source/os_interface/windows/wddm/wddm.cpp index c9688d29ef..6da63257cb 100644 --- a/shared/source/os_interface/windows/wddm/wddm.cpp +++ b/shared/source/os_interface/windows/wddm/wddm.cpp @@ -126,7 +126,7 @@ bool Wddm::init() { return false; } if (!gmmMemory) { - gmmMemory.reset(GmmMemory::create(rootDeviceEnvironment.executionEnvironment.getGmmClientContext())); + gmmMemory.reset(GmmMemory::create(rootDeviceEnvironment.getGmmClientContext())); } return configureDeviceAddressSpace(); @@ -638,7 +638,7 @@ bool Wddm::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) { alloc->resourceHandle = OpenResource.hResource; auto resourceInfo = const_cast(allocationInfo[0].pPrivateDriverData); - alloc->setDefaultGmm(new Gmm(rootDeviceEnvironment.executionEnvironment.getGmmClientContext(), static_cast(resourceInfo))); + alloc->setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmClientContext(), static_cast(resourceInfo))); return true; } @@ -675,7 +675,7 @@ bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) { alloc->resourceHandle = openResourceFromNtHandle.hResource; auto resourceInfo = const_cast(allocationInfo2[0].pPrivateDriverData); - alloc->setDefaultGmm(new Gmm(rootDeviceEnvironment.executionEnvironment.getGmmClientContext(), static_cast(resourceInfo))); + alloc->setDefaultGmm(new Gmm(rootDeviceEnvironment.getGmmClientContext(), static_cast(resourceInfo))); return true; } diff --git a/shared/source/os_interface/windows/wddm_memory_manager.cpp b/shared/source/os_interface/windows/wddm_memory_manager.cpp index d2ff218e93..c18f2ae924 100644 --- a/shared/source/os_interface/windows/wddm_memory_manager.cpp +++ b/shared/source/os_interface/windows/wddm_memory_manager.cpp @@ -48,7 +48,7 @@ WddmMemoryManager::WddmMemoryManager(ExecutionEnvironment &executionEnvironment) } GraphicsAllocation *WddmMemoryManager::allocateShareableMemory(const AllocationData &allocationData) { - auto gmm = std::make_unique(executionEnvironment.getGmmClientContext(), allocationData.hostPtr, allocationData.size, false); + auto gmm = std::make_unique(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), allocationData.hostPtr, allocationData.size, false); auto allocation = std::make_unique(allocationData.rootDeviceIndex, allocationData.type, nullptr, allocationData.size, nullptr, MemoryPool::SystemCpuInaccessible, allocationData.flags.shareable); allocation->setDefaultGmm(gmm.get()); if (!createWddmAllocation(allocation.get(), nullptr)) { @@ -81,7 +81,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(const Allocati auto wddmAllocation = std::make_unique(allocationData.rootDeviceIndex, allocationData.type, nullptr, sizeAligned, nullptr, MemoryPool::System64KBPages); - auto gmm = new Gmm(executionEnvironment.getGmmClientContext(), nullptr, sizeAligned, false, allocationData.flags.preferRenderCompressed, true, {}); + auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), nullptr, sizeAligned, false, allocationData.flags.preferRenderCompressed, true, {}); wddmAllocation->setDefaultGmm(gmm); if (!getWddm(allocationData.rootDeviceIndex).createAllocation64k(gmm, wddmAllocation->getHandleToModify(0u))) { @@ -112,7 +112,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithAlignment(const auto wddmAllocation = std::make_unique(allocationData.rootDeviceIndex, allocationData.type, pSysMem, sizeAligned, nullptr, MemoryPool::System4KBPages); wddmAllocation->setDriverAllocatedCpuPtr(pSysMem); - gmm = new Gmm(executionEnvironment.getGmmClientContext(), pSysMem, sizeAligned, allocationData.flags.uncacheable); + gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), pSysMem, sizeAligned, allocationData.flags.uncacheable); wddmAllocation->setDefaultGmm(gmm); void *mapPtr = wddmAllocation->getAlignedCpuPtr(); @@ -147,7 +147,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(co allocationData.size, nullptr, MemoryPool::System4KBPages); wddmAllocation->setAllocationOffset(offsetInPage); - auto gmm = new Gmm(executionEnvironment.getGmmClientContext(), alignedPtr, alignedSize, false); + auto gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), alignedPtr, alignedSize, false); wddmAllocation->setDefaultGmm(gmm); @@ -174,7 +174,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithHostPtr(const A auto allocation = new WddmAllocation(allocationData.rootDeviceIndex, allocationData.type, const_cast(inputPtr), allocationData.size, reserve, MemoryPool::System4KBPages); allocation->setAllocationOffset(offset); - Gmm *gmm = new Gmm(executionEnvironment.getGmmClientContext(), ptrAligned, sizeAligned, false); + Gmm *gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), ptrAligned, sizeAligned, false); allocation->setDefaultGmm(gmm); if (createWddmAllocation(allocation, reserve)) { return allocation; @@ -211,7 +211,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemoryImpl(const All wddmAllocation->set32BitAllocation(true); wddmAllocation->setAllocationOffset(offset); - gmm = new Gmm(executionEnvironment.getGmmClientContext(), ptrAligned, sizeAligned, false); + gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[allocationData.rootDeviceIndex]->getGmmClientContext(), ptrAligned, sizeAligned, false); wddmAllocation->setDefaultGmm(gmm); if (!createWddmAllocation(wddmAllocation.get(), nullptr)) { @@ -417,7 +417,7 @@ MemoryManager::AllocationStatus WddmMemoryManager::populateOsHandles(OsHandleSto handleStorage.fragmentStorageData[i].osHandleStorage = new OsHandle(); handleStorage.fragmentStorageData[i].residency = new ResidencyData(); - handleStorage.fragmentStorageData[i].osHandleStorage->gmm = new Gmm(executionEnvironment.getGmmClientContext(), handleStorage.fragmentStorageData[i].cpuPtr, + handleStorage.fragmentStorageData[i].osHandleStorage->gmm = new Gmm(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getGmmClientContext(), handleStorage.fragmentStorageData[i].cpuPtr, handleStorage.fragmentStorageData[i].fragmentSize, false); allocatedFragmentIndexes[allocatedFragmentsCounter] = i; allocatedFragmentsCounter++;