2019-07-18 06:07:10 +08:00
|
|
|
/*
|
2021-05-17 02:51:16 +08:00
|
|
|
* Copyright (C) 2020-2021 Intel Corporation
|
2019-07-18 06:07:10 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/bit_helpers.h"
|
|
|
|
#include "shared/source/memory_manager/allocation_properties.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"
|
2019-07-18 06:07:10 +08:00
|
|
|
|
2019-08-12 16:36:23 +08:00
|
|
|
#include "memory_properties_flags.h"
|
2019-07-18 06:07:10 +08:00
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
2020-03-30 17:42:07 +08:00
|
|
|
class Context;
|
|
|
|
|
2020-05-04 17:04:43 +08:00
|
|
|
class MemoryPropertiesHelper {
|
2019-07-18 06:07:10 +08:00
|
|
|
public:
|
2019-08-29 14:59:15 +08:00
|
|
|
enum class ObjType {
|
|
|
|
UNKNOWN,
|
|
|
|
BUFFER,
|
|
|
|
IMAGE,
|
|
|
|
};
|
|
|
|
|
2020-06-05 06:16:55 +08:00
|
|
|
static void addExtraMemoryProperties(MemoryProperties &properties, cl_mem_flags flags, cl_mem_flags_intel flagsIntel,
|
|
|
|
const Device *pDevice);
|
2020-05-04 17:04:43 +08:00
|
|
|
|
2020-06-05 06:16:55 +08:00
|
|
|
static MemoryProperties createMemoryProperties(cl_mem_flags flags, cl_mem_flags_intel flagsIntel,
|
|
|
|
cl_mem_alloc_flags_intel allocflags, const Device *pDevice);
|
2020-05-04 17:04:43 +08:00
|
|
|
|
2020-04-22 20:37:30 +08:00
|
|
|
static bool parseMemoryProperties(const cl_mem_properties_intel *properties, MemoryProperties &memoryProperties,
|
2020-03-30 17:42:07 +08:00
|
|
|
cl_mem_flags &flags, cl_mem_flags_intel &flagsIntel, cl_mem_alloc_flags_intel &allocflags,
|
|
|
|
ObjType objectType, Context &context);
|
2019-07-18 06:07:10 +08:00
|
|
|
|
2020-11-17 08:23:13 +08:00
|
|
|
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);
|
2019-07-18 06:07:10 +08:00
|
|
|
|
2020-04-22 20:37:30 +08:00
|
|
|
static void fillPoliciesInProperties(AllocationProperties &allocationProperties, const MemoryProperties &memoryProperties, const HardwareInfo &hwInfo);
|
2019-07-18 06:07:10 +08:00
|
|
|
|
|
|
|
static void fillCachePolicyInProperties(AllocationProperties &allocationProperties, bool uncached, bool readOnly,
|
2021-02-09 08:31:32 +08:00
|
|
|
bool deviceOnlyVisibilty, uint32_t cacheRegion);
|
|
|
|
|
|
|
|
static uint32_t getCacheRegion(const MemoryProperties &memoryProperties);
|
2019-07-18 06:07:10 +08:00
|
|
|
};
|
|
|
|
} // namespace NEO
|