mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 09:09:04 +08:00
Cleanup includes 20
Cleaned up files: opencl/source/cl_device/cl_device.h opencl/source/helpers/properties_helper.h opencl/source/program/program.h shared/source/device_binary_format/debug_zebin.h shared/source/device_binary_format/elf/zebin_elf.h shared/source/program/program_info.h shared/source/utilities/heap_allocator.h Related-To: NEO-5548 Signed-off-by: Warchulski, Jaroslaw <jaroslaw.warchulski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
1e8169ca3d
commit
d793f37dd8
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "shared/offline_compiler/source/ocloc_arg_helper.h"
|
||||
#include "shared/source/compiler_interface/external_functions.h"
|
||||
#include "shared/source/compiler_interface/linker.h"
|
||||
#include "shared/source/device_binary_format/zebin_decoder.h"
|
||||
#include "shared/source/program/kernel_info.h"
|
||||
#include "shared/source/program/program_info.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "shared/source/device_binary_format/elf/elf_decoder.h"
|
||||
#include "shared/source/device_binary_format/elf/elf_encoder.h"
|
||||
#include "shared/source/device_binary_format/elf/zebin_elf.h"
|
||||
#include "shared/source/helpers/aligned_memory.h"
|
||||
#include "shared/source/memory_manager/graphics_allocation.h"
|
||||
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 Intel Corporation
|
||||
* Copyright (C) 2021-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/device_binary_format/elf/zebin_elf.h"
|
||||
#include "shared/source/device_binary_format/elf/elf_decoder.h"
|
||||
#include "shared/source/utilities/arrayref.h"
|
||||
|
||||
#include <limits>
|
||||
@@ -16,6 +15,10 @@
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
namespace Elf {
|
||||
enum RELOC_TYPE_ZEBIN : uint32_t;
|
||||
}
|
||||
|
||||
class GraphicsAllocation;
|
||||
namespace Debug {
|
||||
struct Segments {
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/device_binary_format/elf/elf.h"
|
||||
#include "shared/source/device_binary_format/elf/elf_decoder.h"
|
||||
#include "shared/source/utilities/arrayref.h"
|
||||
#include "shared/source/utilities/const_stringref.h"
|
||||
|
||||
#include <array>
|
||||
#include <cinttypes>
|
||||
#include <cstddef>
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "shared/source/program/program_info.h"
|
||||
|
||||
#include "shared/source/compiler_interface/external_functions.h"
|
||||
#include "shared/source/compiler_interface/linker.h"
|
||||
#include "shared/source/device/device.h"
|
||||
#include "shared/source/program/kernel_info.h"
|
||||
|
||||
|
||||
@@ -6,14 +6,18 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/compiler_interface/linker.h"
|
||||
#include "shared/source/utilities/arrayref.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
class Device;
|
||||
struct ExternalFunctionInfo;
|
||||
struct LinkerInput;
|
||||
struct KernelInfo;
|
||||
|
||||
struct ProgramInfo {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2022 Intel Corporation
|
||||
* Copyright (C) 2019-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "shared/source/utilities/heap_allocator.h"
|
||||
|
||||
#include "shared/source/helpers/aligned_memory.h"
|
||||
#include "shared/source/utilities/logger.h"
|
||||
|
||||
namespace NEO {
|
||||
|
||||
@@ -79,6 +80,33 @@ uint64_t HeapAllocator::allocateWithCustomAlignment(size_t &sizeToAllocate, size
|
||||
}
|
||||
}
|
||||
|
||||
void HeapAllocator::free(uint64_t ptr, size_t size) {
|
||||
if (ptr == 0llu)
|
||||
return;
|
||||
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
DBG_LOG(LogAllocationMemoryPool, __FUNCTION__, "Allocator usage == ", this->getUsage());
|
||||
|
||||
if (ptr == pRightBound) {
|
||||
pRightBound = ptr + size;
|
||||
mergeLastFreedSmall();
|
||||
} else if (ptr == pLeftBound - size) {
|
||||
pLeftBound = ptr;
|
||||
mergeLastFreedBig();
|
||||
} else if (ptr < pLeftBound) {
|
||||
DEBUG_BREAK_IF(size <= sizeThreshold);
|
||||
storeInFreedChunks(ptr, size, freedChunksBig);
|
||||
} else {
|
||||
storeInFreedChunks(ptr, size, freedChunksSmall);
|
||||
}
|
||||
availableSize += size;
|
||||
}
|
||||
|
||||
NO_SANITIZE
|
||||
double HeapAllocator::getUsage() const {
|
||||
return static_cast<double>(size - availableSize) / size;
|
||||
}
|
||||
|
||||
uint64_t HeapAllocator::getFromFreedChunks(size_t size, std::vector<HeapChunk> &freedChunks, size_t &sizeOfFreedChunk, size_t requiredAlignment) {
|
||||
size_t elements = freedChunks.size();
|
||||
size_t bestFitIndex = -1;
|
||||
@@ -128,4 +156,38 @@ uint64_t HeapAllocator::getFromFreedChunks(size_t size, std::vector<HeapChunk> &
|
||||
return 0llu;
|
||||
}
|
||||
|
||||
void HeapAllocator::defragment() {
|
||||
|
||||
if (freedChunksSmall.size() > 1) {
|
||||
std::sort(freedChunksSmall.rbegin(), freedChunksSmall.rend());
|
||||
size_t maxSize = freedChunksSmall.size();
|
||||
for (size_t i = maxSize - 1; i > 0; --i) {
|
||||
auto ptr = freedChunksSmall[i].ptr;
|
||||
size_t chunkSize = freedChunksSmall[i].size;
|
||||
|
||||
if (freedChunksSmall[i - 1].ptr == ptr + chunkSize) {
|
||||
freedChunksSmall[i - 1].ptr = ptr;
|
||||
freedChunksSmall[i - 1].size += chunkSize;
|
||||
freedChunksSmall.erase(freedChunksSmall.begin() + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
mergeLastFreedSmall();
|
||||
if (freedChunksBig.size() > 1) {
|
||||
std::sort(freedChunksBig.begin(), freedChunksBig.end());
|
||||
|
||||
size_t maxSize = freedChunksBig.size();
|
||||
for (size_t i = maxSize - 1; i > 0; --i) {
|
||||
auto ptr = freedChunksBig[i].ptr;
|
||||
size_t chunkSize = freedChunksBig[i].size;
|
||||
if ((freedChunksBig[i - 1].ptr + freedChunksBig[i - 1].size) == ptr) {
|
||||
freedChunksBig[i - 1].size += chunkSize;
|
||||
freedChunksBig.erase(freedChunksBig.begin() + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
mergeLastFreedBig();
|
||||
DBG_LOG(LogAllocationMemoryPool, __FUNCTION__, "Allocator usage == ", this->getUsage());
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
* Copyright (C) 2018-2023 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -8,10 +8,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "shared/source/helpers/constants.h"
|
||||
#include "shared/source/helpers/debug_helpers.h"
|
||||
#include "shared/source/utilities/logger.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
#include <vector>
|
||||
|
||||
namespace NEO {
|
||||
@@ -45,27 +44,7 @@ class HeapAllocator {
|
||||
|
||||
uint64_t allocateWithCustomAlignment(size_t &sizeToAllocate, size_t alignment);
|
||||
|
||||
void free(uint64_t ptr, size_t size) {
|
||||
if (ptr == 0llu)
|
||||
return;
|
||||
|
||||
std::lock_guard<std::mutex> lock(mtx);
|
||||
DBG_LOG(LogAllocationMemoryPool, __FUNCTION__, "Allocator usage == ", this->getUsage());
|
||||
|
||||
if (ptr == pRightBound) {
|
||||
pRightBound = ptr + size;
|
||||
mergeLastFreedSmall();
|
||||
} else if (ptr == pLeftBound - size) {
|
||||
pLeftBound = ptr;
|
||||
mergeLastFreedBig();
|
||||
} else if (ptr < pLeftBound) {
|
||||
DEBUG_BREAK_IF(size <= sizeThreshold);
|
||||
storeInFreedChunks(ptr, size, freedChunksBig);
|
||||
} else {
|
||||
storeInFreedChunks(ptr, size, freedChunksSmall);
|
||||
}
|
||||
availableSize += size;
|
||||
}
|
||||
void free(uint64_t ptr, size_t size);
|
||||
|
||||
uint64_t getLeftSize() const {
|
||||
return availableSize;
|
||||
@@ -75,10 +54,7 @@ class HeapAllocator {
|
||||
return size - availableSize;
|
||||
}
|
||||
|
||||
NO_SANITIZE
|
||||
double getUsage() const {
|
||||
return static_cast<double>(size - availableSize) / size;
|
||||
}
|
||||
double getUsage() const;
|
||||
|
||||
protected:
|
||||
const uint64_t size;
|
||||
@@ -143,38 +119,6 @@ class HeapAllocator {
|
||||
}
|
||||
}
|
||||
|
||||
void defragment() {
|
||||
|
||||
if (freedChunksSmall.size() > 1) {
|
||||
std::sort(freedChunksSmall.rbegin(), freedChunksSmall.rend());
|
||||
size_t maxSize = freedChunksSmall.size();
|
||||
for (size_t i = maxSize - 1; i > 0; --i) {
|
||||
auto ptr = freedChunksSmall[i].ptr;
|
||||
size_t chunkSize = freedChunksSmall[i].size;
|
||||
|
||||
if (freedChunksSmall[i - 1].ptr == ptr + chunkSize) {
|
||||
freedChunksSmall[i - 1].ptr = ptr;
|
||||
freedChunksSmall[i - 1].size += chunkSize;
|
||||
freedChunksSmall.erase(freedChunksSmall.begin() + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
mergeLastFreedSmall();
|
||||
if (freedChunksBig.size() > 1) {
|
||||
std::sort(freedChunksBig.begin(), freedChunksBig.end());
|
||||
|
||||
size_t maxSize = freedChunksBig.size();
|
||||
for (size_t i = maxSize - 1; i > 0; --i) {
|
||||
auto ptr = freedChunksBig[i].ptr;
|
||||
size_t chunkSize = freedChunksBig[i].size;
|
||||
if ((freedChunksBig[i - 1].ptr + freedChunksBig[i - 1].size) == ptr) {
|
||||
freedChunksBig[i - 1].size += chunkSize;
|
||||
freedChunksBig.erase(freedChunksBig.begin() + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
mergeLastFreedBig();
|
||||
DBG_LOG(LogAllocationMemoryPool, __FUNCTION__, "Allocator usage == ", this->getUsage());
|
||||
}
|
||||
void defragment();
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "shared/source/compiler_interface/external_functions.h"
|
||||
#include "shared/source/compiler_interface/intermediate_representations.h"
|
||||
#include "shared/source/compiler_interface/linker.h"
|
||||
#include "shared/source/device_binary_format/device_binary_formats.h"
|
||||
#include "shared/source/device_binary_format/elf/elf_decoder.h"
|
||||
#include "shared/source/device_binary_format/elf/elf_encoder.h"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/compiler_interface/external_functions.h"
|
||||
#include "shared/source/compiler_interface/linker.h"
|
||||
#include "shared/source/device_binary_format/device_binary_formats.h"
|
||||
#include "shared/source/program/program_info.h"
|
||||
#include "shared/test/common/device_binary_format/patchtokens_tests.h"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/compiler_interface/external_functions.h"
|
||||
#include "shared/source/compiler_interface/linker.h"
|
||||
#include "shared/source/device_binary_format/ar/ar_encoder.h"
|
||||
#include "shared/source/device_binary_format/device_binary_formats.h"
|
||||
#include "shared/source/device_binary_format/elf/elf_encoder.h"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/compiler_interface/external_functions.h"
|
||||
#include "shared/source/compiler_interface/linker.h"
|
||||
#include "shared/source/device_binary_format/device_binary_formats.h"
|
||||
#include "shared/source/device_binary_format/elf/zebin_elf.h"
|
||||
#include "shared/source/device_binary_format/elf/zeinfo_enum_lookup.h"
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/compiler_interface/external_functions.h"
|
||||
#include "shared/source/compiler_interface/linker.h"
|
||||
#include "shared/source/program/kernel_info.h"
|
||||
#include "shared/source/program/program_info.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
|
||||
Reference in New Issue
Block a user