mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Pass compression hints to memory properties
Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
fb376639ee
commit
6098290a0b
@ -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) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user