2019-07-18 00:07:10 +02:00
|
|
|
/*
|
2019-12-30 14:40:24 +01:00
|
|
|
* Copyright (C) 2019-2020 Intel Corporation
|
2019-07-18 00:07:10 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/bit_helpers.h"
|
|
|
|
|
#include "shared/source/memory_manager/allocation_properties.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2020-02-26 14:21:01 +01:00
|
|
|
#include "opencl/extensions/public/cl_ext_private.h"
|
2019-07-18 00:07:10 +02:00
|
|
|
|
2019-08-12 10:36:23 +02:00
|
|
|
#include "memory_properties_flags.h"
|
2019-07-18 00:07:10 +02:00
|
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
|
2020-03-30 11:42:07 +02:00
|
|
|
class Context;
|
|
|
|
|
|
2020-04-22 14:37:30 +02:00
|
|
|
class MemoryPropertiesParserHelper {
|
2019-07-18 00:07:10 +02:00
|
|
|
public:
|
2019-08-29 08:59:15 +02:00
|
|
|
enum class ObjType {
|
|
|
|
|
UNKNOWN,
|
|
|
|
|
BUFFER,
|
|
|
|
|
IMAGE,
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-22 14:37:30 +02:00
|
|
|
static bool parseMemoryProperties(const cl_mem_properties_intel *properties, MemoryProperties &memoryProperties,
|
2020-03-30 11:42:07 +02:00
|
|
|
cl_mem_flags &flags, cl_mem_flags_intel &flagsIntel, cl_mem_alloc_flags_intel &allocflags,
|
|
|
|
|
ObjType objectType, Context &context);
|
2019-07-18 00:07:10 +02:00
|
|
|
|
2020-04-22 14:37:30 +02:00
|
|
|
static AllocationProperties getAllocationProperties(uint32_t rootDeviceIndex, MemoryProperties memoryProperties, bool allocateMemory, size_t size,
|
2020-04-14 17:07:38 +02:00
|
|
|
GraphicsAllocation::AllocationType type, bool multiStorageResource, const HardwareInfo &hwInfo, DeviceBitfield subDevicesBitfieldParam) {
|
|
|
|
|
AllocationProperties allocationProperties(rootDeviceIndex, allocateMemory, size, type, multiStorageResource, subDevicesBitfieldParam);
|
2020-03-11 12:42:44 +01:00
|
|
|
fillPoliciesInProperties(allocationProperties, memoryProperties, hwInfo);
|
2019-07-18 00:07:10 +02:00
|
|
|
return allocationProperties;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-22 14:37:30 +02:00
|
|
|
static void fillPoliciesInProperties(AllocationProperties &allocationProperties, const MemoryProperties &memoryProperties, const HardwareInfo &hwInfo);
|
2019-07-18 00:07:10 +02:00
|
|
|
|
|
|
|
|
static void fillCachePolicyInProperties(AllocationProperties &allocationProperties, bool uncached, bool readOnly,
|
|
|
|
|
bool deviceOnlyVisibilty) {
|
|
|
|
|
allocationProperties.flags.uncacheable = uncached;
|
|
|
|
|
auto cacheFlushRequired = !uncached && !readOnly && !deviceOnlyVisibilty;
|
|
|
|
|
allocationProperties.flags.flushL3RequiredForRead = cacheFlushRequired;
|
|
|
|
|
allocationProperties.flags.flushL3RequiredForWrite = cacheFlushRequired;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
} // namespace NEO
|