mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 23:03:02 +08:00
Move HardwareInfo ownership to ExecutionEnvironment [1/n]
Change-Id: I5e5b4cc45947a8841282c7d431fb69d9c397a2d4 Signed-off-by: Dunajski, Bartosz <bartosz.dunajski@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
b2aee82f41
commit
bb80d327c7
@@ -409,7 +409,7 @@ TEST(Buffer, givenClMemCopyHostPointerPassedToBufferCreateWhenAllocationIsNotInS
|
||||
EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInDevicePool(::testing::_, ::testing::_))
|
||||
.WillRepeatedly(::testing::Invoke(memoryManager, &GMockMemoryManagerFailFirstAllocation::baseAllocateGraphicsMemoryInDevicePool));
|
||||
|
||||
std::unique_ptr<MockDevice> device(MockDevice::create<MockDevice>(*platformDevices, executionEnvironment, 0));
|
||||
std::unique_ptr<MockDevice> device(MockDevice::create<MockDevice>(executionEnvironment, 0));
|
||||
|
||||
MockContext ctx(device.get());
|
||||
EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInDevicePool(::testing::_, ::testing::_))
|
||||
@@ -428,15 +428,15 @@ TEST(Buffer, givenClMemCopyHostPointerPassedToBufferCreateWhenAllocationIsNotInS
|
||||
}
|
||||
struct RenderCompressedBuffersTests : public ::testing::Test {
|
||||
void SetUp() override {
|
||||
localHwInfo = *platformDevices[0];
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
device.reset(Device::create<MockDevice>(&localHwInfo, executionEnvironment, 0u));
|
||||
hwInfo = executionEnvironment->getMutableHardwareInfo();
|
||||
device.reset(Device::create<MockDevice>(executionEnvironment, 0u));
|
||||
context = std::make_unique<MockContext>(device.get(), true);
|
||||
context->setContextType(ContextType::CONTEXT_TYPE_UNRESTRICTIVE);
|
||||
}
|
||||
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
HardwareInfo localHwInfo = {};
|
||||
HardwareInfo *hwInfo = nullptr;
|
||||
std::unique_ptr<MockDevice> device;
|
||||
std::unique_ptr<MockContext> context;
|
||||
std::unique_ptr<Buffer> buffer;
|
||||
@@ -446,7 +446,7 @@ struct RenderCompressedBuffersTests : public ::testing::Test {
|
||||
};
|
||||
|
||||
TEST_F(RenderCompressedBuffersTests, givenBufferCompressedAllocationAndZeroCopyHostPtrWhenCheckingMemoryPropertiesThenUseHostPtrAndDontAllocateStorage) {
|
||||
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = false;
|
||||
hwInfo->capabilityTable.ftrRenderCompressedBuffers = false;
|
||||
|
||||
void *cacheAlignedHostPtr = alignedMalloc(MemoryConstants::cacheLineSize, MemoryConstants::cacheLineSize);
|
||||
|
||||
@@ -467,7 +467,7 @@ TEST_F(RenderCompressedBuffersTests, givenBufferCompressedAllocationAndZeroCopyH
|
||||
dest[i] = pattern[i];
|
||||
}
|
||||
|
||||
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
hwInfo->capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
buffer.reset(Buffer::create(context.get(), CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL | CL_MEM_USE_HOST_PTR, MemoryConstants::cacheLineSize, cacheAlignedHostPtr, retVal));
|
||||
EXPECT_EQ(cacheAlignedHostPtr, buffer->getGraphicsAllocation()->getUnderlyingBuffer());
|
||||
EXPECT_TRUE(buffer->isMemObjZeroCopy());
|
||||
@@ -486,7 +486,7 @@ TEST_F(RenderCompressedBuffersTests, givenAllocationCreatedWithForceSharedPhysic
|
||||
}
|
||||
|
||||
TEST_F(RenderCompressedBuffersTests, givenRenderCompressedBuffersAndAllocationCreatedWithForceSharedPhysicalMemoryWhenItIsCreatedItIsZeroCopy) {
|
||||
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
hwInfo->capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
buffer.reset(Buffer::create(context.get(), CL_MEM_FORCE_SHARED_PHYSICAL_MEMORY_INTEL, 1u, nullptr, retVal));
|
||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
|
||||
EXPECT_TRUE(buffer->isMemObjZeroCopy());
|
||||
@@ -494,7 +494,7 @@ TEST_F(RenderCompressedBuffersTests, givenRenderCompressedBuffersAndAllocationCr
|
||||
}
|
||||
|
||||
TEST_F(RenderCompressedBuffersTests, givenBufferNotCompressedAllocationAndNoHostPtrWhenCheckingMemoryPropertiesThenForceDisableZeroCopy) {
|
||||
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = false;
|
||||
hwInfo->capabilityTable.ftrRenderCompressedBuffers = false;
|
||||
|
||||
buffer.reset(Buffer::create(context.get(), 0, bufferSize, nullptr, retVal));
|
||||
EXPECT_TRUE(buffer->isMemObjZeroCopy());
|
||||
@@ -504,13 +504,13 @@ TEST_F(RenderCompressedBuffersTests, givenBufferNotCompressedAllocationAndNoHost
|
||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER);
|
||||
}
|
||||
|
||||
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
hwInfo->capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
buffer.reset(Buffer::create(context.get(), 0, bufferSize, nullptr, retVal));
|
||||
if (is32bit) {
|
||||
EXPECT_TRUE(buffer->isMemObjZeroCopy());
|
||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
|
||||
} else {
|
||||
if (HwHelper::get(context->getDevice(0)->getHardwareInfo().pPlatform->eRenderCoreFamily).obtainRenderBufferCompressionPreference(bufferSize)) {
|
||||
if (HwHelper::get(context->getDevice(0)->getHardwareInfo().pPlatform.eRenderCoreFamily).obtainRenderBufferCompressionPreference(bufferSize)) {
|
||||
EXPECT_FALSE(buffer->isMemObjZeroCopy());
|
||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
|
||||
} else {
|
||||
@@ -521,14 +521,14 @@ TEST_F(RenderCompressedBuffersTests, givenBufferNotCompressedAllocationAndNoHost
|
||||
}
|
||||
|
||||
TEST_F(RenderCompressedBuffersTests, givenBufferCompressedAllocationWhenSharedContextIsUsedThenForceDisableCompression) {
|
||||
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
hwInfo->capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
context->isSharedContext = false;
|
||||
|
||||
buffer.reset(Buffer::create(context.get(), CL_MEM_READ_WRITE, bufferSize, nullptr, retVal));
|
||||
if (is32bit) {
|
||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
|
||||
} else {
|
||||
if (HwHelper::get(context->getDevice(0)->getHardwareInfo().pPlatform->eRenderCoreFamily).obtainRenderBufferCompressionPreference(bufferSize)) {
|
||||
if (HwHelper::get(context->getDevice(0)->getHardwareInfo().pPlatform.eRenderCoreFamily).obtainRenderBufferCompressionPreference(bufferSize)) {
|
||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
|
||||
} else {
|
||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
|
||||
@@ -542,14 +542,14 @@ TEST_F(RenderCompressedBuffersTests, givenBufferCompressedAllocationWhenSharedCo
|
||||
TEST_F(RenderCompressedBuffersTests, givenDebugVariableSetWhenHwFlagIsNotSetThenSelectOptionFromDebugFlag) {
|
||||
DebugManagerStateRestore restore;
|
||||
|
||||
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = false;
|
||||
hwInfo->capabilityTable.ftrRenderCompressedBuffers = false;
|
||||
|
||||
DebugManager.flags.RenderCompressedBuffersEnabled.set(1);
|
||||
buffer.reset(Buffer::create(context.get(), 0, bufferSize, nullptr, retVal));
|
||||
if (is32bit) {
|
||||
EXPECT_NE(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
|
||||
} else {
|
||||
if (HwHelper::get(context->getDevice(0)->getHardwareInfo().pPlatform->eRenderCoreFamily).obtainRenderBufferCompressionPreference(bufferSize)) {
|
||||
if (HwHelper::get(context->getDevice(0)->getHardwareInfo().pPlatform.eRenderCoreFamily).obtainRenderBufferCompressionPreference(bufferSize)) {
|
||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
|
||||
} else {
|
||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY);
|
||||
@@ -562,7 +562,7 @@ TEST_F(RenderCompressedBuffersTests, givenDebugVariableSetWhenHwFlagIsNotSetThen
|
||||
}
|
||||
|
||||
TEST_F(RenderCompressedBuffersTests, givenSvmAllocationWhenCreatingBufferThenForceDisableCompression) {
|
||||
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
hwInfo->capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
|
||||
auto svmPtr = context->getSVMAllocsManager()->createSVMAlloc(sizeof(uint32_t), {});
|
||||
auto expectedAllocationType = context->getSVMAllocsManager()->getSVMAlloc(svmPtr)->gpuAllocation->getAllocationType();
|
||||
@@ -589,10 +589,10 @@ TEST_F(RenderCompressedBuffersCopyHostMemoryTests, givenRenderCompressedBufferWh
|
||||
if (is32bit) {
|
||||
return;
|
||||
}
|
||||
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
hwInfo->capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
|
||||
buffer.reset(Buffer::create(context.get(), CL_MEM_COPY_HOST_PTR, bufferSize, hostPtr, retVal));
|
||||
if (HwHelper::get(context->getDevice(0)->getHardwareInfo().pPlatform->eRenderCoreFamily).obtainRenderBufferCompressionPreference(bufferSize)) {
|
||||
if (HwHelper::get(context->getDevice(0)->getHardwareInfo().pPlatform.eRenderCoreFamily).obtainRenderBufferCompressionPreference(bufferSize)) {
|
||||
EXPECT_EQ(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
|
||||
EXPECT_EQ(1u, mockCmdQ->writeBufferCounter);
|
||||
EXPECT_TRUE(mockCmdQ->writeBufferBlocking);
|
||||
@@ -643,7 +643,7 @@ HWTEST_F(RenderCompressedBuffersCopyHostMemoryTests, givenBufferWithInitializati
|
||||
}
|
||||
|
||||
TEST_F(RenderCompressedBuffersCopyHostMemoryTests, givenNonRenderCompressedBufferWhenCopyFromHostPtrIsRequiredThenDontCallWriteBuffer) {
|
||||
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = false;
|
||||
hwInfo->capabilityTable.ftrRenderCompressedBuffers = false;
|
||||
|
||||
buffer.reset(Buffer::create(context.get(), CL_MEM_COPY_HOST_PTR, sizeof(uint32_t), &hostPtr, retVal));
|
||||
EXPECT_NE(buffer->getGraphicsAllocation()->getAllocationType(), GraphicsAllocation::AllocationType::BUFFER_COMPRESSED);
|
||||
@@ -654,10 +654,10 @@ TEST_F(RenderCompressedBuffersCopyHostMemoryTests, givenNonRenderCompressedBuffe
|
||||
}
|
||||
|
||||
TEST_F(RenderCompressedBuffersCopyHostMemoryTests, givenRenderCompressedBufferWhenWriteBufferFailsThenReturnErrorCode) {
|
||||
if (is32bit || !HwHelper::get(context->getDevice(0)->getHardwareInfo().pPlatform->eRenderCoreFamily).obtainRenderBufferCompressionPreference(bufferSize)) {
|
||||
if (is32bit || !HwHelper::get(context->getDevice(0)->getHardwareInfo().pPlatform.eRenderCoreFamily).obtainRenderBufferCompressionPreference(bufferSize)) {
|
||||
return;
|
||||
}
|
||||
localHwInfo.capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
hwInfo->capabilityTable.ftrRenderCompressedBuffers = true;
|
||||
mockCmdQ->writeBufferRetValue = CL_INVALID_VALUE;
|
||||
|
||||
buffer.reset(Buffer::create(context.get(), CL_MEM_COPY_HOST_PTR, bufferSize, hostPtr, retVal));
|
||||
|
||||
@@ -406,7 +406,7 @@ HWTEST_F(Image2dFromBufferTest, givenBufferWhenImageFromBufferThenIsImageFromBuf
|
||||
}
|
||||
};
|
||||
|
||||
auto raiiFactory = RAIIHwHelperFactory<MockHwHelperHw>(context.getDevice(0)->getHardwareInfo().pPlatform->eRenderCoreFamily);
|
||||
auto raiiFactory = RAIIHwHelperFactory<MockHwHelperHw>(context.getDevice(0)->getHardwareInfo().pPlatform.eRenderCoreFamily);
|
||||
|
||||
cl_int errCode = CL_SUCCESS;
|
||||
auto buffer = Buffer::create(&context, 0, 1, nullptr, errCode);
|
||||
|
||||
@@ -1309,7 +1309,7 @@ TEST(ImageTest, givenClMemCopyHostPointerPassedToImageCreateWhenAllocationIsNotI
|
||||
EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInDevicePool(::testing::_, ::testing::_))
|
||||
.WillRepeatedly(::testing::Invoke(memoryManager, &GMockMemoryManagerFailFirstAllocation::baseAllocateGraphicsMemoryInDevicePool));
|
||||
|
||||
std::unique_ptr<MockDevice> device(MockDevice::create<MockDevice>(*platformDevices, executionEnvironment, 0));
|
||||
std::unique_ptr<MockDevice> device(MockDevice::create<MockDevice>(executionEnvironment, 0));
|
||||
|
||||
MockContext ctx(device.get());
|
||||
EXPECT_CALL(*memoryManager, allocateGraphicsMemoryInDevicePool(::testing::_, ::testing::_))
|
||||
|
||||
@@ -33,7 +33,7 @@ class MemObjDestructionTest : public ::testing::TestWithParam<bool> {
|
||||
executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
memoryManager = new MockMemoryManager(*executionEnvironment);
|
||||
executionEnvironment->memoryManager.reset(memoryManager);
|
||||
device.reset(MockDevice::create<MockDevice>(*platformDevices, executionEnvironment, 0));
|
||||
device.reset(MockDevice::create<MockDevice>(executionEnvironment, 0));
|
||||
context.reset(new MockContext(device.get()));
|
||||
|
||||
allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{size});
|
||||
|
||||
@@ -163,7 +163,7 @@ TEST(MemObj, givenNotReadyGraphicsAllocationWhenMemObjDestroysAllocationAsyncThe
|
||||
|
||||
TEST(MemObj, givenReadyGraphicsAllocationWhenMemObjDestroysAllocationAsyncThenAllocationIsNotAddedToMemoryManagerAllocationList) {
|
||||
ExecutionEnvironment *executionEnvironment = platformImpl->peekExecutionEnvironment();
|
||||
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(*platformDevices, executionEnvironment, 0));
|
||||
auto device = std::unique_ptr<MockDevice>(MockDevice::create<MockDevice>(executionEnvironment, 0));
|
||||
MockContext context(device.get());
|
||||
auto memoryManager = executionEnvironment->memoryManager.get();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user