diff --git a/opencl/source/helpers/cl_memory_properties_helpers.cpp b/opencl/source/helpers/cl_memory_properties_helpers.cpp index ef6fbfd82f..fa3f54942f 100644 --- a/opencl/source/helpers/cl_memory_properties_helpers.cpp +++ b/opencl/source/helpers/cl_memory_properties_helpers.cpp @@ -12,9 +12,6 @@ namespace NEO { -void ClMemoryPropertiesHelper::addExtraMemoryProperties(MemoryProperties &properties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel) { -} - bool ClMemoryPropertiesHelper::parseMemoryProperties(const cl_mem_properties_intel *properties, MemoryProperties &memoryProperties, cl_mem_flags &flags, cl_mem_flags_intel &flagsIntel, cl_mem_alloc_flags_intel &allocflags, MemoryPropertiesHelper::ObjType objectType, Context &context) { diff --git a/opencl/source/helpers/cl_memory_properties_helpers.h b/opencl/source/helpers/cl_memory_properties_helpers.h index 201009adf8..00a88bbe73 100644 --- a/opencl/source/helpers/cl_memory_properties_helpers.h +++ b/opencl/source/helpers/cl_memory_properties_helpers.h @@ -16,7 +16,6 @@ class Context; class ClMemoryPropertiesHelper { public: - static void addExtraMemoryProperties(MemoryProperties &properties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel); static MemoryProperties createMemoryProperties(cl_mem_flags flags, cl_mem_flags_intel flagsIntel, cl_mem_alloc_flags_intel allocflags, const Device *pDevice); diff --git a/opencl/source/helpers/cl_memory_properties_helpers_base.inl b/opencl/source/helpers/cl_memory_properties_helpers_base.inl index 6842caaa76..e8eb71406d 100644 --- a/opencl/source/helpers/cl_memory_properties_helpers_base.inl +++ b/opencl/source/helpers/cl_memory_properties_helpers_base.inl @@ -85,9 +85,16 @@ MemoryProperties ClMemoryPropertiesHelper::createMemoryProperties(cl_mem_flags f memoryProperties.flags.resource48Bit = true; } - memoryProperties.pDevice = pDevice; + if (isValueSet(flags, CL_MEM_COMPRESSED_HINT_INTEL) || + isValueSet(flagsIntel, CL_MEM_COMPRESSED_HINT_INTEL)) { + memoryProperties.flags.compressedHint = true; + } + if (isValueSet(flags, CL_MEM_UNCOMPRESSED_HINT_INTEL) || + isValueSet(flagsIntel, CL_MEM_UNCOMPRESSED_HINT_INTEL)) { + memoryProperties.flags.uncompressedHint = true; + } - addExtraMemoryProperties(memoryProperties, flags, flagsIntel); + memoryProperties.pDevice = pDevice; return memoryProperties; } diff --git a/opencl/test/unit_test/helpers/memory_properties_helpers_tests.cpp b/opencl/test/unit_test/helpers/memory_properties_helpers_tests.cpp index ca6b364a64..6adc787b60 100644 --- a/opencl/test/unit_test/helpers/memory_properties_helpers_tests.cpp +++ b/opencl/test/unit_test/helpers/memory_properties_helpers_tests.cpp @@ -138,6 +138,58 @@ TEST(MemoryProperties, givenClAllowUnrestrictedSizeFlagWhenCreateMemoryPropertie EXPECT_FALSE(memoryProperties.flags.allowUnrestrictedSize); } +TEST(MemoryProperties, givenClCompressedHintFlagWhenCreateMemoryPropertiesThenReturnProperValue) { + MemoryProperties memoryProperties; + UltDeviceFactory deviceFactory{1, 0}; + auto pDevice = deviceFactory.rootDevices[0]; + + cl_mem_flags flags = CL_MEM_COMPRESSED_HINT_INTEL; + cl_mem_flags_intel flagsIntel = 0; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, pDevice); + EXPECT_TRUE(memoryProperties.flags.compressedHint); + + flags = 0; + flagsIntel |= CL_MEM_COMPRESSED_HINT_INTEL; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, pDevice); + EXPECT_TRUE(memoryProperties.flags.compressedHint); + + flags |= CL_MEM_COMPRESSED_HINT_INTEL; + flagsIntel |= CL_MEM_COMPRESSED_HINT_INTEL; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, pDevice); + EXPECT_TRUE(memoryProperties.flags.compressedHint); + + flags = 0; + flagsIntel = 0; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, pDevice); + EXPECT_FALSE(memoryProperties.flags.compressedHint); +} + +TEST(MemoryProperties, givenClUncompressedHintFlagWhenCreateMemoryPropertiesThenReturnProperValue) { + MemoryProperties memoryProperties; + UltDeviceFactory deviceFactory{1, 0}; + auto pDevice = deviceFactory.rootDevices[0]; + + cl_mem_flags flags = CL_MEM_UNCOMPRESSED_HINT_INTEL; + cl_mem_flags_intel flagsIntel = 0; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, pDevice); + EXPECT_TRUE(memoryProperties.flags.uncompressedHint); + + flags = 0; + flagsIntel |= CL_MEM_UNCOMPRESSED_HINT_INTEL; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, pDevice); + EXPECT_TRUE(memoryProperties.flags.uncompressedHint); + + flags |= CL_MEM_UNCOMPRESSED_HINT_INTEL; + flagsIntel |= CL_MEM_UNCOMPRESSED_HINT_INTEL; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, pDevice); + EXPECT_TRUE(memoryProperties.flags.uncompressedHint); + + flags = 0; + flagsIntel = 0; + memoryProperties = ClMemoryPropertiesHelper::createMemoryProperties(flags, flagsIntel, 0, pDevice); + EXPECT_FALSE(memoryProperties.flags.uncompressedHint); +} + struct MemoryPropertiesHelperTests : ::testing::Test { MockContext context; MemoryProperties memoryProperties; diff --git a/shared/source/memory_properties/memory_properties_flags_common.inl b/shared/source/memory_properties/memory_properties_flags_common.inl index 5fa43f97c8..7af2419d43 100644 --- a/shared/source/memory_properties/memory_properties_flags_common.inl +++ b/shared/source/memory_properties/memory_properties_flags_common.inl @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2020 Intel Corporation + * Copyright (C) 2019-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -28,6 +28,8 @@ struct MemoryFlags { uint32_t forceHostMemory : 1; uint32_t shareable : 1; uint32_t resource48Bit : 1; + uint32_t compressedHint : 1; + uint32_t uncompressedHint : 1; }; struct MemoryAllocFlags {