Update MemoryProperties initialization

Always specify the device.

Related-To: NEO-4651

Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski
2020-11-17 00:23:13 +00:00
committed by Compute-Runtime-Automation
parent a116d454fe
commit bfbc0e07ba
15 changed files with 86 additions and 38 deletions

View File

@@ -5,6 +5,8 @@
*
*/
#include "opencl/source/cl_device/cl_device.h"
#include "opencl/source/context/context.h"
#include "opencl/source/helpers/memory_properties_helpers_base.inl"
#include "opencl/source/mem_obj/mem_obj_helper.h"
@@ -13,13 +15,16 @@ namespace NEO {
void MemoryPropertiesHelper::addExtraMemoryProperties(MemoryProperties &properties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel,
const Device *pDevice) {
}
DeviceBitfield MemoryPropertiesHelper::adjustDeviceBitfield(const MemoryProperties &memoryProperties, DeviceBitfield deviceBitfield) {
DeviceBitfield MemoryPropertiesHelper::adjustDeviceBitfield(uint32_t rootDeviceIndex, const MemoryProperties &memoryProperties,
DeviceBitfield deviceBitfield) {
return deviceBitfield;
}
bool MemoryPropertiesHelper::parseMemoryProperties(const cl_mem_properties_intel *properties, MemoryProperties &memoryProperties,
cl_mem_flags &flags, cl_mem_flags_intel &flagsIntel,
cl_mem_alloc_flags_intel &allocflags, ObjType objectType, Context &context) {
Device *pDevice = &context.getDevice(0)->getDevice();
if (properties != nullptr) {
for (int i = 0; properties[i] != 0; i += 2) {
@@ -39,7 +44,7 @@ bool MemoryPropertiesHelper::parseMemoryProperties(const cl_mem_properties_intel
}
}
memoryProperties = MemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, allocflags, nullptr);
memoryProperties = MemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, allocflags, pDevice);
switch (objectType) {
case MemoryPropertiesHelper::ObjType::BUFFER:

View File

@@ -35,9 +35,13 @@ class MemoryPropertiesHelper {
cl_mem_flags &flags, cl_mem_flags_intel &flagsIntel, cl_mem_alloc_flags_intel &allocflags,
ObjType objectType, Context &context);
static AllocationProperties getAllocationProperties(uint32_t rootDeviceIndex, MemoryProperties memoryProperties, bool allocateMemory, size_t size,
GraphicsAllocation::AllocationType type, bool multiStorageResource, const HardwareInfo &hwInfo, DeviceBitfield subDevicesBitfieldParam);
static DeviceBitfield adjustDeviceBitfield(const MemoryProperties &memoryProperties, DeviceBitfield subDevicesBitfieldParam);
static AllocationProperties getAllocationProperties(
uint32_t rootDeviceIndex, MemoryProperties memoryProperties, bool allocateMemory, size_t size,
GraphicsAllocation::AllocationType type, bool multiStorageResource, const HardwareInfo &hwInfo,
DeviceBitfield subDevicesBitfieldParam);
static DeviceBitfield adjustDeviceBitfield(uint32_t rootDeviceIndex, const MemoryProperties &memoryProperties,
DeviceBitfield subDevicesBitfieldParam);
static void fillPoliciesInProperties(AllocationProperties &allocationProperties, const MemoryProperties &memoryProperties, const HardwareInfo &hwInfo);

View File

@@ -87,9 +87,12 @@ MemoryProperties MemoryPropertiesHelper::createMemoryProperties(cl_mem_flags fla
return memoryProperties;
}
AllocationProperties MemoryPropertiesHelper::getAllocationProperties(uint32_t rootDeviceIndex, MemoryProperties memoryProperties, bool allocateMemory, size_t size,
GraphicsAllocation::AllocationType type, bool multiStorageResource, const HardwareInfo &hwInfo, DeviceBitfield subDevicesBitfieldParam) {
auto deviceBitfield = adjustDeviceBitfield(memoryProperties, subDevicesBitfieldParam);
AllocationProperties MemoryPropertiesHelper::getAllocationProperties(
uint32_t rootDeviceIndex, MemoryProperties memoryProperties, bool allocateMemory, size_t size,
GraphicsAllocation::AllocationType type, bool multiStorageResource, const HardwareInfo &hwInfo,
DeviceBitfield subDevicesBitfieldParam) {
auto deviceBitfield = adjustDeviceBitfield(rootDeviceIndex, memoryProperties, subDevicesBitfieldParam);
AllocationProperties allocationProperties(rootDeviceIndex, allocateMemory, size, type, multiStorageResource, deviceBitfield);
fillPoliciesInProperties(allocationProperties, memoryProperties, hwInfo);
return allocationProperties;

View File

@@ -69,9 +69,11 @@ bool MemObjHelper::validateMemoryPropertiesForImage(const MemoryProperties &memo
return validateExtraMemoryProperties(memoryProperties, flags, flagsIntel, context);
}
AllocationProperties MemObjHelper::getAllocationPropertiesWithImageInfo(uint32_t rootDeviceIndex, ImageInfo &imgInfo, bool allocateMemory,
const MemoryProperties &memoryProperties, const HardwareInfo &hwInfo, DeviceBitfield subDevicesBitfieldParam) {
auto deviceBitfield = MemoryPropertiesHelper::adjustDeviceBitfield(memoryProperties, subDevicesBitfieldParam);
AllocationProperties MemObjHelper::getAllocationPropertiesWithImageInfo(
uint32_t rootDeviceIndex, ImageInfo &imgInfo, bool allocateMemory, const MemoryProperties &memoryProperties,
const HardwareInfo &hwInfo, DeviceBitfield subDevicesBitfieldParam) {
auto deviceBitfield = MemoryPropertiesHelper::adjustDeviceBitfield(rootDeviceIndex, memoryProperties, subDevicesBitfieldParam);
AllocationProperties allocationProperties{rootDeviceIndex, allocateMemory, imgInfo, GraphicsAllocation::AllocationType::IMAGE, deviceBitfield};
MemoryPropertiesHelper::fillPoliciesInProperties(allocationProperties, memoryProperties, hwInfo);
return allocationProperties;

View File

@@ -56,10 +56,11 @@ GEN8TEST_F(GEN8AUBParentKernelFixture, EnqueueParentKernel) {
desc.image_row_pitch = 0;
desc.image_slice_pitch = 0;
auto memoryProperties = MemoryPropertiesHelper::createMemoryProperties(0, 0, 0, &pClDevice->getDevice());
auto surfaceFormat = Image::getSurfaceFormatFromTable(0, &imageFormat, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
std::unique_ptr<Image> image(Image::create(
pContext,
{},
memoryProperties,
0,
0,
surfaceFormat,

View File

@@ -54,10 +54,11 @@ GEN9TEST_F(AUBParentKernelFixture, EnqueueParentKernel) {
desc.image_slice_pitch = 0;
// clang-format on
auto memoryProperties = MemoryPropertiesHelper::createMemoryProperties(0, 0, 0, &context->getDevice(0)->getDevice());
auto surfaceFormat = Image::getSurfaceFormatFromTable(0, &imageFormat, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
Image *image = Image::create(
pContext,
{},
memoryProperties,
0,
0,
surfaceFormat,

View File

@@ -11,6 +11,7 @@
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/os_interface/os_context.h"
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
#include "shared/test/unit_test/mocks/ult_device_factory.h"
#include "opencl/source/helpers/hardware_context_controller.h"
#include "opencl/source/mem_obj/mem_obj_helper.h"
@@ -500,6 +501,7 @@ HWTEST_F(AubCommandStreamReceiverNoHostPtrTests, givenAubCommandStreamReceiverWh
executionEnvironment->memoryManager.reset(memoryManager);
auto hwInfo = executionEnvironment->rootDeviceEnvironments[0]->getHardwareInfo();
auto engineInstance = HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0];
UltDeviceFactory deviceFactory{1, 0};
DeviceBitfield deviceBitfield(1);
MockOsContext osContext(0, deviceBitfield, engineInstance.first, PreemptionMode::Disabled,
false, false, false);
@@ -513,7 +515,8 @@ HWTEST_F(AubCommandStreamReceiverNoHostPtrTests, givenAubCommandStreamReceiverWh
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(aubCsr->getRootDeviceIndex(), imgInfo, true, {}, *hwInfo, osContext.getDeviceBitfield());
auto memoryProperties = MemoryPropertiesHelper::createMemoryProperties(0, 0, 0, deviceFactory.rootDevices[0]);
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(aubCsr->getRootDeviceIndex(), imgInfo, true, memoryProperties, *hwInfo, osContext.getDeviceBitfield());
auto imageAllocation = memoryManager->allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr);
ASSERT_NE(nullptr, imageAllocation);

View File

@@ -287,9 +287,11 @@ TEST(CastToImage, WhenCastingFromMemObjThenBehavesAsExpected) {
extern std::thread::id tempThreadID;
class MockBuffer : public MockBufferStorage, public Buffer {
using MockBufferStorage::device;
public:
MockBuffer() : MockBufferStorage(),
Buffer(nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, nullptr),
Buffer(nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, MockBufferStorage::device.get()),
CL_MEM_USE_HOST_PTR, 0, sizeof(data), &data, &data, GraphicsAllocationHelper::toMultiGraphicsAllocation(&mockGfxAllocation), true, false, false) {
}

View File

@@ -98,8 +98,9 @@ TEST_F(KernelImageArgTest, givenImageWithNumSamplesWhenSetArgIsCalledThenPatchNu
imgDesc.image_width = 5;
imgDesc.image_height = 5;
auto memoryProperties = MemoryPropertiesHelper::createMemoryProperties(0, 0, 0, pDevice);
auto surfaceFormat = Image::getSurfaceFormatFromTable(0, &imgFormat, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
auto sampleImg = Image::create(context.get(), {}, 0, 0, surfaceFormat, &imgDesc, nullptr, retVal);
auto sampleImg = Image::create(context.get(), memoryProperties, 0, 0, surfaceFormat, &imgDesc, nullptr, retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
cl_mem memObj = sampleImg;
@@ -224,8 +225,9 @@ HWTEST_F(KernelImageArgTest, givenImgWithMcsAllocWhenMakeResidentThenMakeMcsAllo
imgDesc.image_width = 5;
imgDesc.image_height = 5;
auto memoryProperties = MemoryPropertiesHelper::createMemoryProperties(0, 0, 0, pDevice);
auto surfaceFormat = Image::getSurfaceFormatFromTable(0, &imgFormat, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
auto img = Image::create(context.get(), {}, 0, 0, surfaceFormat, &imgDesc, nullptr, retVal);
auto img = Image::create(context.get(), memoryProperties, 0, 0, surfaceFormat, &imgDesc, nullptr, retVal);
EXPECT_EQ(CL_SUCCESS, retVal);
auto mcsAlloc = context->getMemoryManager()->allocateGraphicsMemoryWithProperties(MockAllocationProperties{pDevice->getRootDeviceIndex(), MemoryConstants::pageSize});
img->setMcsAllocation(mcsAlloc);

View File

@@ -93,10 +93,11 @@ HWTEST_F(CreateImage3DTest, GivenTiledOrForcedLinearWhenCreatingImageThenPropert
auto surfaceFormat = Image::getSurfaceFormatFromTable(0, &imageFormat, context->getDevice(0)->getHardwareInfo().capabilityTable.supportsOcl21Features);
auto imgInfo = MockGmm::initImgInfo(imageDesc, 0, surfaceFormat);
MockGmm::queryImgParams(context->getDevice(0)->getGmmClientContext(), imgInfo);
auto memoryProperties = MemoryPropertiesHelper::createMemoryProperties(0, 0, 0, &context->getDevice(0)->getDevice());
auto image = Image::create(
context,
{},
memoryProperties,
0,
0,
surfaceFormat,
@@ -120,7 +121,7 @@ HWTEST_F(CreateImage3DTest, GivenTiledOrForcedLinearWhenCreatingImageThenPropert
image = Image::create(
context,
{},
memoryProperties,
0,
0,
surfaceFormat,

View File

@@ -1623,7 +1623,8 @@ HWTEST_F(HwImageTest, givenImageHwWithUnifiedSurfaceAndMcsWhenSettingParamsForMu
cl_image_format format = {};
auto imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(0, imgInfo, true, {}, context.getDevice(0)->getHardwareInfo(), context.getDeviceBitfieldForAllocation(0));
auto memoryProperties = MemoryPropertiesHelper::createMemoryProperties(0, 0, 0, &context.getDevice(0)->getDevice());
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(0, imgInfo, true, memoryProperties, context.getDevice(0)->getHardwareInfo(), context.getDeviceBitfieldForAllocation(0));
auto graphicsAllocation = memoryManager.allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr);

View File

@@ -52,10 +52,13 @@ TEST(MemoryManagerTest, givenAllowed32BitAndFroce32BitWhenGraphicsAllocationInDe
TEST(AllocationFlagsTest, givenAllocateMemoryFlagWhenGetAllocationFlagsIsCalledThenAllocateFlagIsCorrectlySet) {
HardwareInfo hwInfo(*defaultHwInfo);
auto allocationProperties = MemoryPropertiesHelper::getAllocationProperties(0, {}, true, 0, GraphicsAllocation::AllocationType::BUFFER, false, hwInfo, {});
UltDeviceFactory deviceFactory{1, 0};
auto pDevice = deviceFactory.rootDevices[0];
MemoryProperties memoryProperties = MemoryPropertiesHelper::createMemoryProperties(0, 0, 0, pDevice);
auto allocationProperties = MemoryPropertiesHelper::getAllocationProperties(0, memoryProperties, true, 0, GraphicsAllocation::AllocationType::BUFFER, false, hwInfo, {});
EXPECT_TRUE(allocationProperties.flags.allocateMemory);
auto allocationProperties2 = MemoryPropertiesHelper::getAllocationProperties(0, {}, false, 0, GraphicsAllocation::AllocationType::BUFFER, false, hwInfo, {});
auto allocationProperties2 = MemoryPropertiesHelper::getAllocationProperties(0, memoryProperties, false, 0, GraphicsAllocation::AllocationType::BUFFER, false, hwInfo, {});
EXPECT_FALSE(allocationProperties2.flags.allocateMemory);
}
@@ -87,8 +90,9 @@ TEST(AllocationFlagsTest, givenReadOnlyResourceFlagWhenGetAllocationFlagsIsCalle
EXPECT_FALSE(allocationFlags.flags.flushL3RequiredForRead);
EXPECT_FALSE(allocationFlags.flags.flushL3RequiredForWrite);
memoryProperties = MemoryPropertiesHelper::createMemoryProperties(0, 0, 0, pDevice);
auto allocationFlags2 = MemoryPropertiesHelper::getAllocationProperties(
0, {}, true, 0, GraphicsAllocation::AllocationType::BUFFER, false, pDevice->getHardwareInfo(), {});
0, memoryProperties, true, 0, GraphicsAllocation::AllocationType::BUFFER, false, pDevice->getHardwareInfo(), {});
EXPECT_TRUE(allocationFlags2.flags.flushL3RequiredForRead);
EXPECT_TRUE(allocationFlags2.flags.flushL3RequiredForWrite);
}

View File

@@ -39,13 +39,15 @@ class MockBuffer : public MockBufferStorage, public Buffer {
using MockBufferStorage::device;
MockBuffer(GraphicsAllocation &alloc)
: MockBufferStorage(), Buffer(
nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, nullptr), CL_MEM_USE_HOST_PTR, 0, alloc.getUnderlyingBufferSize(), alloc.getUnderlyingBuffer(), alloc.getUnderlyingBuffer(),
nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, MockBufferStorage::device.get()),
CL_MEM_USE_HOST_PTR, 0, alloc.getUnderlyingBufferSize(), alloc.getUnderlyingBuffer(), alloc.getUnderlyingBuffer(),
GraphicsAllocationHelper::toMultiGraphicsAllocation(&alloc), true, false, false),
externalAlloc(&alloc) {
}
MockBuffer()
: MockBufferStorage(), Buffer(
nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, nullptr), CL_MEM_USE_HOST_PTR, 0, sizeof(data), &data, &data,
nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, MockBufferStorage::device.get()),
CL_MEM_USE_HOST_PTR, 0, sizeof(data), &data, &data,
GraphicsAllocationHelper::toMultiGraphicsAllocation(&mockGfxAllocation), true, false, false) {
}
~MockBuffer() override {
@@ -66,12 +68,15 @@ class AlignedBuffer : public MockBufferStorage, public Buffer {
using MockBufferStorage::device;
AlignedBuffer() : MockBufferStorage(false), Buffer(
nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, nullptr), CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64),
nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, MockBufferStorage::device.get()),
CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64),
GraphicsAllocationHelper::toMultiGraphicsAllocation(&mockGfxAllocation), true, false, false) {
}
AlignedBuffer(GraphicsAllocation *gfxAllocation) : MockBufferStorage(), Buffer(
nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, nullptr), CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64),
GraphicsAllocationHelper::toMultiGraphicsAllocation(gfxAllocation), true, false, false) {
AlignedBuffer(GraphicsAllocation *gfxAllocation)
: MockBufferStorage(), Buffer(
nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, MockBufferStorage::device.get()),
CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 64), alignUp(&data, 64),
GraphicsAllocationHelper::toMultiGraphicsAllocation(gfxAllocation), true, false, false) {
}
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly, const Device &device) override {
Buffer::setSurfaceState(this->device.get(), memory, getSize(), getCpuAddress(), 0, &mockGfxAllocation, 0, 0);
@@ -83,12 +88,15 @@ class UnalignedBuffer : public MockBufferStorage, public Buffer {
using MockBufferStorage::device;
UnalignedBuffer() : MockBufferStorage(true), Buffer(
nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, nullptr), CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4),
nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, MockBufferStorage::device.get()),
CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4),
GraphicsAllocationHelper::toMultiGraphicsAllocation(&mockGfxAllocation), false, false, false) {
}
UnalignedBuffer(GraphicsAllocation *gfxAllocation) : MockBufferStorage(true), Buffer(
nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, nullptr), CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4),
GraphicsAllocationHelper::toMultiGraphicsAllocation(gfxAllocation), false, false, false) {
UnalignedBuffer(GraphicsAllocation *gfxAllocation)
: MockBufferStorage(true), Buffer(
nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, MockBufferStorage::device.get()),
CL_MEM_USE_HOST_PTR, 0, sizeof(data) / 2, alignUp(&data, 4), alignUp(&data, 4),
GraphicsAllocationHelper::toMultiGraphicsAllocation(gfxAllocation), false, false, false) {
}
void setArgStateful(void *memory, bool forceNonAuxMode, bool disableL3, bool alignSizeForAuxTranslation, bool isReadOnly, const Device &device) override {
Buffer::setSurfaceState(this->device.get(), memory, getSize(), getCpuAddress(), 0, &mockGfxAllocation, 0, 0);

View File

@@ -30,6 +30,7 @@
#include "opencl/test/unit_test/helpers/execution_environment_helper.h"
#include "opencl/test/unit_test/mocks/linux/mock_drm_command_stream_receiver.h"
#include "opencl/test/unit_test/mocks/mock_allocation_properties.h"
#include "opencl/test/unit_test/mocks/mock_buffer.h"
#include "opencl/test/unit_test/mocks/mock_gmm.h"
#include "opencl/test/unit_test/mocks/mock_gmm_page_table_mngr.h"
#include "opencl/test/unit_test/mocks/mock_host_ptr_manager.h"
@@ -1498,7 +1499,9 @@ HWTEST_TEMPLATED_F(DrmCommandStreamEnhancedTest, makeNonResidentOnMemObjectCalls
mm->freeGraphicsMemory(allocation1);
}
class DrmMockBuffer : public Buffer {
class DrmMockBuffer : public MockBufferStorage, public Buffer {
using MockBufferStorage::device;
public:
static DrmMockBuffer *create() {
char *data = static_cast<char *>(::alignedMalloc(128, 64));
@@ -1513,7 +1516,8 @@ class DrmMockBuffer : public Buffer {
DrmMockBuffer(char *data, size_t size, DrmAllocation *alloc)
: Buffer(
nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, nullptr), CL_MEM_USE_HOST_PTR, 0, size, data, data,
nullptr, MemoryPropertiesHelper::createMemoryProperties(CL_MEM_USE_HOST_PTR, 0, 0, MockBufferStorage::device.get()),
CL_MEM_USE_HOST_PTR, 0, size, data, data,
GraphicsAllocationHelper::toMultiGraphicsAllocation(alloc), true, false, false),
data(data),
gfxAllocation(alloc) {

View File

@@ -19,6 +19,7 @@
#include "shared/test/unit_test/helpers/debug_manager_state_restore.h"
#include "shared/test/unit_test/helpers/ult_hw_config.h"
#include "shared/test/unit_test/mocks/mock_device.h"
#include "shared/test/unit_test/mocks/ult_device_factory.h"
#include "shared/test/unit_test/utilities/base_object_utils.h"
#include "opencl/source/helpers/memory_properties_helpers.h"
@@ -1432,6 +1433,7 @@ TEST_F(WddmMemoryManagerWithAsyncDeleterTest, givenWddmWhenAsyncDeleterIsDisable
}
TEST_F(WddmMemoryManagerWithAsyncDeleterTest, givenMemoryManagerWithAsyncDeleterWhenCannotAllocateMemoryForTiledImageThenDrainIsCalledAndCreateAllocationIsCalledTwice) {
UltDeviceFactory deviceFactory{1, 0};
cl_image_desc imgDesc = {};
imgDesc.image_type = CL_MEM_OBJECT_IMAGE3D;
ImageInfo imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
@@ -1440,7 +1442,8 @@ TEST_F(WddmMemoryManagerWithAsyncDeleterTest, givenMemoryManagerWithAsyncDeleter
EXPECT_EQ(0, deleter->drainCalled);
EXPECT_EQ(0u, wddm->createAllocationResult.called);
deleter->expectDrainBlockingValue(true);
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(0, imgInfo, true, {}, *hwInfo, mockDeviceBitfield);
auto memoryProperties = MemoryPropertiesHelper::createMemoryProperties(0, 0, 0, deviceFactory.rootDevices[0]);
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(0, imgInfo, true, memoryProperties, *hwInfo, mockDeviceBitfield);
memoryManager->allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr);
EXPECT_EQ(1, deleter->drainCalled);
@@ -1448,6 +1451,7 @@ TEST_F(WddmMemoryManagerWithAsyncDeleterTest, givenMemoryManagerWithAsyncDeleter
}
TEST_F(WddmMemoryManagerWithAsyncDeleterTest, givenMemoryManagerWithAsyncDeleterWhenCanAllocateMemoryForTiledImageThenDrainIsNotCalledAndCreateAllocationIsCalledOnce) {
UltDeviceFactory deviceFactory{1, 0};
cl_image_desc imgDesc;
imgDesc.image_type = CL_MEM_OBJECT_IMAGE3D;
ImageInfo imgInfo = MockGmm::initImgInfo(imgDesc, 0, nullptr);
@@ -1459,7 +1463,8 @@ TEST_F(WddmMemoryManagerWithAsyncDeleterTest, givenMemoryManagerWithAsyncDeleter
EXPECT_EQ(0u, wddm->createAllocationResult.called);
EXPECT_EQ(0u, wddm->mapGpuVirtualAddressResult.called);
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(0, imgInfo, true, {}, *hwInfo, mockDeviceBitfield);
auto memoryProperties = MemoryPropertiesHelper::createMemoryProperties(0, 0, 0, deviceFactory.rootDevices[0]);
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(0, imgInfo, true, memoryProperties, *hwInfo, mockDeviceBitfield);
auto allocation = memoryManager->allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr);
EXPECT_EQ(0, deleter->drainCalled);
@@ -1469,6 +1474,7 @@ TEST_F(WddmMemoryManagerWithAsyncDeleterTest, givenMemoryManagerWithAsyncDeleter
}
TEST_F(WddmMemoryManagerWithAsyncDeleterTest, givenMemoryManagerWithoutAsyncDeleterWhenCannotAllocateMemoryForTiledImageThenCreateAllocationIsCalledOnce) {
UltDeviceFactory deviceFactory{1, 0};
memoryManager->setDeferredDeleter(nullptr);
cl_image_desc imgDesc;
imgDesc.image_type = CL_MEM_OBJECT_IMAGE3D;
@@ -1477,7 +1483,8 @@ TEST_F(WddmMemoryManagerWithAsyncDeleterTest, givenMemoryManagerWithoutAsyncDele
wddm->createAllocationStatus = STATUS_GRAPHICS_NO_VIDEO_MEMORY;
EXPECT_EQ(0u, wddm->createAllocationResult.called);
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(0, imgInfo, true, {}, *hwInfo, mockDeviceBitfield);
auto memoryProperties = MemoryPropertiesHelper::createMemoryProperties(0, 0, 0, deviceFactory.rootDevices[0]);
AllocationProperties allocProperties = MemObjHelper::getAllocationPropertiesWithImageInfo(0, imgInfo, true, memoryProperties, *hwInfo, mockDeviceBitfield);
memoryManager->allocateGraphicsMemoryInPreferredPool(allocProperties, nullptr);
EXPECT_EQ(1u, wddm->createAllocationResult.called);