2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2023-01-13 23:18:40 +08:00
|
|
|
* Copyright (C) 2018-2023 Intel Corporation
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
2018-09-18 15:11:08 +08:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 07:45:38 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-02-27 18:39:32 +08:00
|
|
|
#include <cinttypes>
|
2022-12-02 03:42:57 +08:00
|
|
|
#include <cstddef>
|
2020-07-07 14:41:26 +08:00
|
|
|
#include <limits>
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2021-04-03 01:01:51 +08:00
|
|
|
struct OsHandle {
|
2022-07-07 19:11:29 +08:00
|
|
|
virtual ~OsHandle() = default;
|
|
|
|
|
2021-04-03 01:01:51 +08:00
|
|
|
protected:
|
|
|
|
OsHandle() = default;
|
|
|
|
};
|
2019-12-17 15:11:16 +08:00
|
|
|
struct ResidencyData;
|
2018-08-27 21:48:29 +08:00
|
|
|
|
2018-10-22 20:20:05 +08:00
|
|
|
constexpr int maxFragmentsCount = 3;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-07-12 16:53:18 +08:00
|
|
|
enum class FragmentPosition {
|
2023-12-12 19:37:31 +08:00
|
|
|
none = 0,
|
|
|
|
leading,
|
|
|
|
middle,
|
|
|
|
trailing
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
2020-10-23 19:01:46 +08:00
|
|
|
enum class RequirementsStatus {
|
2023-12-12 19:37:31 +08:00
|
|
|
success = 0,
|
|
|
|
fatal
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct PartialAllocation {
|
2023-12-12 19:37:31 +08:00
|
|
|
FragmentPosition fragmentPosition = FragmentPosition::none;
|
2017-12-21 07:45:38 +08:00
|
|
|
const void *allocationPtr = nullptr;
|
|
|
|
size_t allocationSize = 0u;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AllocationRequirements {
|
2019-08-07 14:31:20 +08:00
|
|
|
PartialAllocation allocationFragments[maxFragmentsCount];
|
2017-12-21 07:45:38 +08:00
|
|
|
uint64_t totalRequiredSize = 0u;
|
|
|
|
uint32_t requiredFragmentsCount = 0u;
|
2020-07-07 14:41:26 +08:00
|
|
|
uint32_t rootDeviceIndex = std::numeric_limits<uint32_t>::max();
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct FragmentStorage {
|
2018-03-27 20:01:04 +08:00
|
|
|
const void *fragmentCpuPointer = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
size_t fragmentSize = 0;
|
|
|
|
int refCount = 0;
|
|
|
|
OsHandle *osInternalStorage = nullptr;
|
|
|
|
ResidencyData *residency = nullptr;
|
2018-05-08 16:00:23 +08:00
|
|
|
bool driverAllocation = false;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct AllocationStorageData {
|
2019-07-29 22:11:51 +08:00
|
|
|
OsHandle *osHandleStorage = nullptr;
|
2017-12-21 07:45:38 +08:00
|
|
|
size_t fragmentSize = 0;
|
|
|
|
const void *cpuPtr = nullptr;
|
|
|
|
bool freeTheFragment = false;
|
|
|
|
ResidencyData *residency = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct OsHandleStorage {
|
2018-10-22 20:20:05 +08:00
|
|
|
AllocationStorageData fragmentStorageData[maxFragmentsCount];
|
2017-12-21 07:45:38 +08:00
|
|
|
uint32_t fragmentCount = 0;
|
|
|
|
};
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|