2019-08-05 21:16:57 +08:00
|
|
|
/*
|
2023-01-12 01:04:14 +08:00
|
|
|
* Copyright (C) 2020-2023 Intel Corporation
|
2019-08-05 21:16:57 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/bit_helpers.h"
|
2020-02-24 17:22:30 +08:00
|
|
|
|
2020-02-26 21:21:01 +08:00
|
|
|
#include "opencl/extensions/public/cl_ext_private.h"
|
2021-10-07 01:00:24 +08:00
|
|
|
#include "opencl/source/helpers/cl_memory_properties_helpers.h"
|
2019-08-05 21:16:57 +08:00
|
|
|
|
2022-06-21 21:00:57 +08:00
|
|
|
#include "CL/cl_ext.h"
|
2023-01-12 01:04:14 +08:00
|
|
|
#include "memory_properties_flags.h"
|
2019-08-05 21:16:57 +08:00
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
2021-10-07 01:00:24 +08:00
|
|
|
MemoryProperties ClMemoryPropertiesHelper::createMemoryProperties(cl_mem_flags flags, cl_mem_flags_intel flagsIntel,
|
|
|
|
cl_mem_alloc_flags_intel allocflags, const Device *pDevice) {
|
2020-04-22 20:37:30 +08:00
|
|
|
MemoryProperties memoryProperties;
|
2019-08-05 21:16:57 +08:00
|
|
|
|
2019-10-23 01:51:53 +08:00
|
|
|
if (isValueSet(flags, CL_MEM_READ_WRITE)) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.flags.readWrite = true;
|
2019-08-05 21:16:57 +08:00
|
|
|
}
|
2019-10-23 01:51:53 +08:00
|
|
|
if (isValueSet(flags, CL_MEM_WRITE_ONLY)) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.flags.writeOnly = true;
|
2019-08-05 21:16:57 +08:00
|
|
|
}
|
2019-10-23 01:51:53 +08:00
|
|
|
if (isValueSet(flags, CL_MEM_READ_ONLY)) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.flags.readOnly = true;
|
2019-08-05 21:16:57 +08:00
|
|
|
}
|
2019-10-23 01:51:53 +08:00
|
|
|
if (isValueSet(flags, CL_MEM_USE_HOST_PTR)) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.flags.useHostPtr = true;
|
2019-08-05 21:16:57 +08:00
|
|
|
}
|
2019-10-23 01:51:53 +08:00
|
|
|
if (isValueSet(flags, CL_MEM_ALLOC_HOST_PTR)) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.flags.allocHostPtr = true;
|
2019-08-05 21:16:57 +08:00
|
|
|
}
|
2019-10-23 01:51:53 +08:00
|
|
|
if (isValueSet(flags, CL_MEM_COPY_HOST_PTR)) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.flags.copyHostPtr = true;
|
2019-08-05 21:16:57 +08:00
|
|
|
}
|
2019-10-23 01:51:53 +08:00
|
|
|
if (isValueSet(flags, CL_MEM_HOST_WRITE_ONLY)) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.flags.hostWriteOnly = true;
|
2019-08-05 21:16:57 +08:00
|
|
|
}
|
2019-10-23 01:51:53 +08:00
|
|
|
if (isValueSet(flags, CL_MEM_HOST_READ_ONLY)) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.flags.hostReadOnly = true;
|
2019-08-05 21:16:57 +08:00
|
|
|
}
|
2019-10-23 01:51:53 +08:00
|
|
|
if (isValueSet(flags, CL_MEM_HOST_NO_ACCESS)) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.flags.hostNoAccess = true;
|
2019-08-05 21:16:57 +08:00
|
|
|
}
|
2019-10-23 01:51:53 +08:00
|
|
|
if (isValueSet(flags, CL_MEM_KERNEL_READ_AND_WRITE)) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.flags.kernelReadAndWrite = true;
|
2019-08-05 21:16:57 +08:00
|
|
|
}
|
2019-10-23 01:51:53 +08:00
|
|
|
if (isValueSet(flags, CL_MEM_FORCE_LINEAR_STORAGE_INTEL) ||
|
|
|
|
isValueSet(flagsIntel, CL_MEM_FORCE_LINEAR_STORAGE_INTEL)) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.flags.forceLinearStorage = true;
|
2019-08-05 21:16:57 +08:00
|
|
|
}
|
2019-10-23 01:51:53 +08:00
|
|
|
if (isValueSet(flags, CL_MEM_ACCESS_FLAGS_UNRESTRICTED_INTEL)) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.flags.accessFlagsUnrestricted = true;
|
2019-08-05 21:16:57 +08:00
|
|
|
}
|
2019-10-23 01:51:53 +08:00
|
|
|
if (isValueSet(flags, CL_MEM_NO_ACCESS_INTEL)) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.flags.noAccess = true;
|
2019-08-05 21:16:57 +08:00
|
|
|
}
|
2019-10-23 01:51:53 +08:00
|
|
|
if (isValueSet(flags, CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL) ||
|
2021-08-05 18:10:20 +08:00
|
|
|
isValueSet(flagsIntel, CL_MEM_ALLOW_UNRESTRICTED_SIZE_INTEL) ||
|
2023-11-30 16:32:25 +08:00
|
|
|
debugManager.flags.AllowUnrestrictedSize.get()) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.flags.allowUnrestrictedSize = true;
|
2019-08-05 21:16:57 +08:00
|
|
|
}
|
2019-10-23 01:51:53 +08:00
|
|
|
if (isValueSet(flagsIntel, CL_MEM_LOCALLY_UNCACHED_RESOURCE)) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.flags.locallyUncachedResource = true;
|
2019-08-05 21:16:57 +08:00
|
|
|
}
|
2019-10-23 01:51:53 +08:00
|
|
|
if (isValueSet(flagsIntel, CL_MEM_LOCALLY_UNCACHED_SURFACE_STATE_RESOURCE)) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.flags.locallyUncachedInSurfaceState = true;
|
2019-08-30 14:18:34 +08:00
|
|
|
}
|
2020-10-05 22:17:51 +08:00
|
|
|
if (isValueSet(flags, CL_MEM_FORCE_HOST_MEMORY_INTEL)) {
|
|
|
|
memoryProperties.flags.forceHostMemory = true;
|
2019-08-09 18:20:05 +08:00
|
|
|
}
|
2019-12-05 17:32:42 +08:00
|
|
|
if (isValueSet(allocflags, CL_MEM_ALLOC_WRITE_COMBINED_INTEL)) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.allocFlags.allocWriteCombined = true;
|
2019-12-05 17:32:42 +08:00
|
|
|
}
|
2020-11-27 01:52:21 +08:00
|
|
|
if (isValueSet(allocflags, CL_MEM_ALLOC_INITIAL_PLACEMENT_DEVICE_INTEL)) {
|
|
|
|
memoryProperties.allocFlags.usmInitialPlacementGpu = true;
|
|
|
|
}
|
|
|
|
if (isValueSet(allocflags, CL_MEM_ALLOC_INITIAL_PLACEMENT_HOST_INTEL)) {
|
|
|
|
memoryProperties.allocFlags.usmInitialPlacementCpu = true;
|
|
|
|
}
|
2020-02-11 00:58:02 +08:00
|
|
|
if (isValueSet(flagsIntel, CL_MEM_48BIT_RESOURCE_INTEL)) {
|
2020-04-22 20:37:30 +08:00
|
|
|
memoryProperties.flags.resource48Bit = true;
|
2020-02-11 00:58:02 +08:00
|
|
|
}
|
|
|
|
|
2021-11-25 21:11:34 +08:00
|
|
|
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;
|
|
|
|
}
|
2021-08-05 23:51:25 +08:00
|
|
|
|
2021-11-25 21:11:34 +08:00
|
|
|
memoryProperties.pDevice = pDevice;
|
2019-08-05 21:16:57 +08:00
|
|
|
|
2020-04-22 20:37:30 +08:00
|
|
|
return memoryProperties;
|
2019-08-05 21:16:57 +08:00
|
|
|
}
|
2019-08-30 14:18:34 +08:00
|
|
|
} // namespace NEO
|