mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
[1/n] Move Hardware Info to Execution Environment
- remove gmm_environment_fixture - remove hwInfo parameter from ExecutionEnvironment methods Change-Id: Ieb0f9b5b89191fbbaf7676685c77644d42d69c26 Signed-off-by: Adam Stefanowski <adam.stefanowski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
a1bfbcf293
commit
341fcfc091
@@ -10,6 +10,7 @@
|
||||
#include "runtime/memory_manager/deferrable_allocation_deletion.h"
|
||||
#include "runtime/memory_manager/deferred_deleter.h"
|
||||
#include "runtime/os_interface/os_context.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
#include "test.h"
|
||||
#include "unit_tests/libult/ult_command_stream_receiver.h"
|
||||
#include "unit_tests/mocks/mock_allocation_properties.h"
|
||||
@@ -36,10 +37,10 @@ struct DeferredDeleterPublic : DeferredDeleter {
|
||||
|
||||
struct DeferrableAllocationDeletionTest : ::testing::Test {
|
||||
void SetUp() override {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
memoryManager = new MockMemoryManager(*executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
device.reset(Device::create<MockDevice>(nullptr, executionEnvironment.release(), 0u));
|
||||
device.reset(Device::create<MockDevice>(nullptr, executionEnvironment, 0u));
|
||||
hwTag = device->getDefaultEngine().commandStreamReceiver->getTagAddress();
|
||||
defaultOsContextId = device->getDefaultEngine().osContext->getContextId();
|
||||
asyncDeleter = std::make_unique<DeferredDeleterPublic>();
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "runtime/memory_manager/memory_constants.h"
|
||||
#include "runtime/os_interface/os_context.h"
|
||||
#include "runtime/os_interface/os_interface.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
#include "runtime/program/printf_handler.h"
|
||||
#include "runtime/program/program.h"
|
||||
#include "test.h"
|
||||
@@ -550,16 +551,14 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenForce32bitallocationI
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenAllocateGraphicsMemoryForImageIsCalledThenGraphicsAllocationIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
MockMemoryManager memoryManager(false, false, *executionEnvironment);
|
||||
cl_image_desc imgDesc = {};
|
||||
imgDesc.image_width = 512;
|
||||
imgDesc.image_height = 1;
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
|
||||
|
||||
executionEnvironment.initGmm(*platformDevices);
|
||||
|
||||
MockMemoryManager::AllocationData allocationData;
|
||||
allocationData.imgInfo = &imgInfo;
|
||||
|
||||
@@ -571,16 +570,14 @@ TEST(OsAgnosticMemoryManager, givenDefaultMemoryManagerWhenAllocateGraphicsMemor
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenEnabledLocalMemoryWhenAllocateGraphicsMemoryForImageIsCalledThenUseLocalMemoryIsNotSet) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
MockMemoryManager memoryManager(false, true, *executionEnvironment);
|
||||
cl_image_desc imgDesc = {};
|
||||
imgDesc.image_width = 1;
|
||||
imgDesc.image_height = 1;
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
|
||||
|
||||
executionEnvironment.initGmm(*platformDevices);
|
||||
|
||||
MockMemoryManager::AllocationData allocationData;
|
||||
allocationData.imgInfo = &imgInfo;
|
||||
|
||||
@@ -591,9 +588,8 @@ TEST(OsAgnosticMemoryManager, givenEnabledLocalMemoryWhenAllocateGraphicsMemoryF
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenHostPointerNotRequiringCopyWhenAllocateGraphicsMemoryForImageFromHostPtrIsCalledThenGraphicsAllocationIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
executionEnvironment.initGmm(*platformDevices);
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
MockMemoryManager memoryManager(false, false, *executionEnvironment);
|
||||
|
||||
cl_image_desc imgDesc = {};
|
||||
imgDesc.image_width = 4;
|
||||
@@ -631,9 +627,8 @@ TEST(OsAgnosticMemoryManager, givenHostPointerNotRequiringCopyWhenAllocateGraphi
|
||||
}
|
||||
|
||||
TEST(OsAgnosticMemoryManager, givenHostPointerRequiringCopyWhenAllocateGraphicsMemoryForImageFromHostPtrIsCalledThenNullptrIsReturned) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockMemoryManager memoryManager(false, false, executionEnvironment);
|
||||
executionEnvironment.initGmm(*platformDevices);
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
MockMemoryManager memoryManager(false, false, *executionEnvironment);
|
||||
|
||||
cl_image_desc imgDesc = {};
|
||||
imgDesc.image_width = 4;
|
||||
@@ -1168,16 +1163,14 @@ TEST(OsAgnosticMemoryManager, givenLocalMemorySupportedAndAubUsageWhenMemoryMana
|
||||
}
|
||||
|
||||
TEST(MemoryManager, givenSharedResourceCopyWhenAllocatingGraphicsMemoryThenAllocateGraphicsMemoryForImageIsCalled) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
MockMemoryManager memoryManager(false, true, executionEnvironment);
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
MockMemoryManager memoryManager(false, true, *executionEnvironment);
|
||||
cl_image_desc imgDesc = {};
|
||||
imgDesc.image_width = 1;
|
||||
imgDesc.image_height = 1;
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
|
||||
|
||||
executionEnvironment.initGmm(*platformDevices);
|
||||
|
||||
MockMemoryManager::AllocationData allocationData;
|
||||
allocationData.imgInfo = &imgInfo;
|
||||
allocationData.type = GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY;
|
||||
@@ -1479,12 +1472,11 @@ HWTEST_F(GraphicsAllocationTests, givenAllocationUsedOnlyByNonDefaultCsrWhenChec
|
||||
}
|
||||
|
||||
HWTEST_F(GraphicsAllocationTests, givenAllocationUsedOnlyByNonDefaultDeviceWhenCheckingUsageBeforeDestroyThenStoreItAsTemporaryAllocation) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.incRefInternal();
|
||||
auto device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(platformDevices[0], &executionEnvironment, 0u));
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
auto device = std::unique_ptr<MockDevice>(Device::create<MockDevice>(platformDevices[0], executionEnvironment, 0u));
|
||||
auto &defaultCommandStreamReceiver = device->getCommandStreamReceiver();
|
||||
auto &nonDefaultCommandStreamReceiver = static_cast<UltCommandStreamReceiver<FamilyType> &>(*executionEnvironment.commandStreamReceivers[0][1]);
|
||||
auto memoryManager = executionEnvironment.memoryManager.get();
|
||||
auto &nonDefaultCommandStreamReceiver = static_cast<UltCommandStreamReceiver<FamilyType> &>(*executionEnvironment->commandStreamReceivers[0][1]);
|
||||
auto memoryManager = executionEnvironment->memoryManager.get();
|
||||
auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
|
||||
auto notReadyTaskCount = *nonDefaultCommandStreamReceiver.getTagAddress() + 1;
|
||||
|
||||
@@ -1502,15 +1494,14 @@ HWTEST_F(GraphicsAllocationTests, givenAllocationUsedOnlyByNonDefaultDeviceWhenC
|
||||
}
|
||||
|
||||
HWTEST_F(GraphicsAllocationTests, givenAllocationUsedByManyOsContextsWhenCheckingUsageBeforeDestroyThenMultiContextDestructorIsUsedForWaitingForAllOsContexts) {
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
executionEnvironment.incRefInternal();
|
||||
auto memoryManager = new MockMemoryManager(false, false, executionEnvironment);
|
||||
executionEnvironment.memoryManager.reset(memoryManager);
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
auto memoryManager = new MockMemoryManager(false, false, *executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
auto multiContextDestructor = new MockDeferredDeleter();
|
||||
multiContextDestructor->expectDrainBlockingValue(false);
|
||||
memoryManager->multiContextResourceDestructor.reset(multiContextDestructor);
|
||||
|
||||
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(platformDevices[0], &executionEnvironment, 0u));
|
||||
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(platformDevices[0], executionEnvironment, 0u));
|
||||
auto nonDefaultOsContext = device->getEngine(EngineInstanceConstants::lowPriorityGpgpuEngineIndex).osContext;
|
||||
auto nonDefaultCsr = reinterpret_cast<UltCommandStreamReceiver<FamilyType> *>(device->getEngine(EngineInstanceConstants::lowPriorityGpgpuEngineIndex).commandStreamReceiver);
|
||||
auto defaultCsr = reinterpret_cast<UltCommandStreamReceiver<FamilyType> *>(device->getDefaultEngine().commandStreamReceiver);
|
||||
|
||||
Reference in New Issue
Block a user