2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2018-09-18 15:11:08 +08:00
|
|
|
* Copyright (C) 2017-2018 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
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cinttypes>
|
2018-09-05 21:17:52 +08:00
|
|
|
#include "runtime/memory_manager/residency.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
namespace OCLRT {
|
|
|
|
|
|
|
|
struct OsHandle;
|
2018-08-27 21:48:29 +08:00
|
|
|
|
|
|
|
using OsGraphicsHandle = OsHandle;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
const int max_fragments_count = 3;
|
|
|
|
|
2018-07-12 16:53:18 +08:00
|
|
|
enum class FragmentPosition {
|
2017-12-21 07:45:38 +08:00
|
|
|
NONE = 0,
|
|
|
|
LEADING,
|
|
|
|
MIDDLE,
|
|
|
|
TRAILING
|
|
|
|
};
|
|
|
|
|
|
|
|
enum OverlapStatus {
|
|
|
|
FRAGMENT_NOT_OVERLAPING_WITH_ANY_OTHER = 0,
|
|
|
|
FRAGMENT_WITHIN_STORED_FRAGMENT,
|
|
|
|
FRAGMENT_WITH_EXACT_SIZE_AS_STORED_FRAGMENT,
|
|
|
|
FRAGMENT_OVERLAPING_AND_BIGGER_THEN_STORED_FRAGMENT,
|
|
|
|
FRAGMENT_NOT_CHECKED
|
|
|
|
};
|
|
|
|
|
|
|
|
enum RequirementsStatus {
|
|
|
|
SUCCESS = 0,
|
|
|
|
FATAL
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PartialAllocation {
|
2018-07-12 16:53:18 +08:00
|
|
|
FragmentPosition fragmentPosition = FragmentPosition::NONE;
|
2017-12-21 07:45:38 +08:00
|
|
|
const void *allocationPtr = nullptr;
|
|
|
|
size_t allocationSize = 0u;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct AllocationRequirements {
|
|
|
|
PartialAllocation AllocationFragments[max_fragments_count];
|
|
|
|
uint64_t totalRequiredSize = 0u;
|
|
|
|
uint32_t requiredFragmentsCount = 0u;
|
|
|
|
};
|
|
|
|
|
|
|
|
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 {
|
|
|
|
OsHandle *osHandleStorage;
|
|
|
|
size_t fragmentSize = 0;
|
|
|
|
const void *cpuPtr = nullptr;
|
|
|
|
bool freeTheFragment = false;
|
|
|
|
ResidencyData *residency = nullptr;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct OsHandleStorage {
|
|
|
|
AllocationStorageData fragmentStorageData[max_fragments_count];
|
|
|
|
uint32_t fragmentCount = 0;
|
|
|
|
OsHandleStorage() {
|
|
|
|
for (int i = 0; i < max_fragments_count; i++) {
|
|
|
|
fragmentStorageData[i].osHandleStorage = nullptr;
|
|
|
|
fragmentStorageData[i].cpuPtr = nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CheckedFragments {
|
|
|
|
FragmentStorage *fragments[max_fragments_count];
|
|
|
|
OverlapStatus status[max_fragments_count];
|
|
|
|
size_t count = 0;
|
|
|
|
};
|
|
|
|
} // namespace OCLRT
|