2019-03-19 20:53:55 +08:00
|
|
|
/*
|
2025-03-06 17:57:13 +08:00
|
|
|
* Copyright (C) 2019-2025 Intel Corporation
|
2019-03-19 20:53:55 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2021-12-17 21:26:04 +08:00
|
|
|
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
2021-11-26 23:46:48 +08:00
|
|
|
|
2021-09-13 18:04:37 +08:00
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
2021-11-26 23:46:48 +08:00
|
|
|
#include <vector>
|
2019-03-19 20:53:55 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2021-09-14 20:36:43 +08:00
|
|
|
class Drm;
|
2021-11-26 23:46:48 +08:00
|
|
|
struct HardwareInfo;
|
2019-03-19 20:53:55 +08:00
|
|
|
|
2021-04-13 00:55:34 +08:00
|
|
|
class MemoryInfo {
|
|
|
|
public:
|
2021-12-17 21:26:04 +08:00
|
|
|
using RegionContainer = std::vector<MemoryRegion>;
|
2021-11-26 23:46:48 +08:00
|
|
|
|
|
|
|
virtual ~MemoryInfo(){};
|
|
|
|
|
2022-07-25 19:50:32 +08:00
|
|
|
MemoryInfo(const RegionContainer ®ionInfo, const Drm &drm);
|
2021-11-26 23:46:48 +08:00
|
|
|
|
2021-12-29 19:14:26 +08:00
|
|
|
void assignRegionsFromDistances(const std::vector<DistanceInfo> &distances);
|
2021-11-26 23:46:48 +08:00
|
|
|
|
2024-01-19 01:43:09 +08:00
|
|
|
MOCKABLE_VIRTUAL int createGemExt(const MemRegionsVec &memClassInstances, size_t allocSize, uint32_t &handle, uint64_t patIndex, std::optional<uint32_t> vmId, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, bool isUSMHostAllocation);
|
2021-11-26 23:46:48 +08:00
|
|
|
|
2024-04-26 01:29:57 +08:00
|
|
|
MemoryClassInstance getMemoryRegionClassAndInstance(DeviceBitfield deviceBitfield, const HardwareInfo &hwInfo);
|
2019-03-19 20:53:55 +08:00
|
|
|
|
2024-04-15 19:09:00 +08:00
|
|
|
MOCKABLE_VIRTUAL size_t getMemoryRegionSize(uint32_t memoryBank) const;
|
2021-11-26 23:46:48 +08:00
|
|
|
|
2024-04-26 01:29:57 +08:00
|
|
|
const MemoryRegion &getMemoryRegion(DeviceBitfield deviceBitfield) const;
|
2023-05-30 19:44:37 +08:00
|
|
|
|
2024-04-15 19:09:00 +08:00
|
|
|
void printRegionSizes() const;
|
2021-11-26 23:46:48 +08:00
|
|
|
|
2024-04-26 01:29:57 +08:00
|
|
|
uint32_t getLocalMemoryRegionIndex(DeviceBitfield deviceBitfield) const;
|
2022-04-27 19:21:53 +08:00
|
|
|
|
2024-05-14 00:35:40 +08:00
|
|
|
MOCKABLE_VIRTUAL int createGemExtWithSingleRegion(DeviceBitfield memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isUSMHostAllocation);
|
|
|
|
MOCKABLE_VIRTUAL int createGemExtWithMultipleRegions(DeviceBitfield memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, bool isUSMHostAllocation);
|
|
|
|
MOCKABLE_VIRTUAL int createGemExtWithMultipleRegions(DeviceBitfield memoryBanks, size_t allocSize, uint32_t &handle, uint64_t patIndex, int32_t pairHandle, bool isChunked, uint32_t numOfChunks, bool isUSMHostAllocation);
|
2024-04-26 01:29:57 +08:00
|
|
|
void populateTileToLocalMemoryRegionIndexMap();
|
2025-03-06 17:57:13 +08:00
|
|
|
uint64_t getLocalMemoryRegionSize(uint32_t tileId) const;
|
2021-11-26 23:46:48 +08:00
|
|
|
|
2024-04-15 19:09:00 +08:00
|
|
|
const RegionContainer &getLocalMemoryRegions() const { return localMemoryRegions; }
|
2021-11-26 23:46:48 +08:00
|
|
|
const RegionContainer &getDrmRegionInfos() const { return drmQueryRegions; }
|
2023-12-07 03:30:05 +08:00
|
|
|
bool isMemPolicySupported() const { return memPolicySupported; }
|
2025-04-10 05:32:48 +08:00
|
|
|
bool isSmallBarDetected() const { return smallBarDetected; }
|
2021-11-26 23:46:48 +08:00
|
|
|
|
|
|
|
protected:
|
2022-07-25 19:50:32 +08:00
|
|
|
const Drm &drm;
|
2021-11-26 23:46:48 +08:00
|
|
|
const RegionContainer drmQueryRegions;
|
|
|
|
|
2021-12-17 21:26:04 +08:00
|
|
|
const MemoryRegion &systemMemoryRegion;
|
2023-12-07 03:30:05 +08:00
|
|
|
bool memPolicySupported;
|
|
|
|
int memPolicyMode;
|
2021-11-26 23:46:48 +08:00
|
|
|
RegionContainer localMemoryRegions;
|
2024-04-26 01:29:57 +08:00
|
|
|
std::array<uint32_t, 4> tileToLocalMemoryRegionIndexMap{};
|
2025-04-10 05:32:48 +08:00
|
|
|
bool smallBarDetected;
|
2021-11-26 23:46:48 +08:00
|
|
|
};
|
2019-03-19 20:53:55 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|