Move aub related files to aub directory

Additionally remove dependencies on opencl code from aub and tbx code.

Related-To: NEO-3964

Change-Id: Ie81b7d274e2f22b6090df0e07c45123618af5cae
Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski
2020-10-14 19:22:01 +02:00
committed by sys_ocldev
parent cc6d6968dd
commit d27374b468
44 changed files with 172 additions and 312 deletions

View File

@@ -8,7 +8,7 @@
#pragma once
#include "shared/source/helpers/constants.h"
#include "opencl/source/gen_common/aub_mapper_base.h"
#include "opencl/source/aub/aub_mapper_base.h"
#include "engine_node.h"

View File

@@ -8,7 +8,7 @@
#pragma once
#include "shared/source/helpers/constants.h"
#include "opencl/source/gen_common/aub_mapper_base.h"
#include "opencl/source/aub/aub_mapper_base.h"
#include "engine_node.h"

View File

@@ -8,7 +8,7 @@
#pragma once
#include "shared/source/helpers/constants.h"
#include "opencl/source/gen_common/aub_mapper_base.h"
#include "opencl/source/aub/aub_mapper_base.h"
#include "engine_node.h"

View File

@@ -8,7 +8,7 @@
#pragma once
#include "shared/source/helpers/constants.h"
#include "opencl/source/gen_common/aub_mapper_base.h"
#include "opencl/source/aub/aub_mapper_base.h"
#include "engine_node.h"

View File

@@ -6,6 +6,8 @@
set(NEO_CORE_MEMORY_MANAGER
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/address_mapper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/address_mapper.h
${CMAKE_CURRENT_SOURCE_DIR}/allocations_list.h
${CMAKE_CURRENT_SOURCE_DIR}/allocation_properties.h
${CMAKE_CURRENT_SOURCE_DIR}/compression_selector.h
@@ -31,6 +33,7 @@ set(NEO_CORE_MEMORY_MANAGER
${CMAKE_CURRENT_SOURCE_DIR}/internal_allocation_storage.h
${CMAKE_CURRENT_SOURCE_DIR}/local_memory_usage.cpp
${CMAKE_CURRENT_SOURCE_DIR}/local_memory_usage.h
${CMAKE_CURRENT_SOURCE_DIR}/memory_banks.h
${CMAKE_CURRENT_SOURCE_DIR}/memory_manager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/memory_manager.h
${CMAKE_CURRENT_SOURCE_DIR}/memory_operations_handler.h
@@ -38,6 +41,7 @@ set(NEO_CORE_MEMORY_MANAGER
${CMAKE_CURRENT_SOURCE_DIR}/memory_pool.h
${CMAKE_CURRENT_SOURCE_DIR}/multi_graphics_allocation.cpp
${CMAKE_CURRENT_SOURCE_DIR}/multi_graphics_allocation.h
${CMAKE_CURRENT_SOURCE_DIR}/physical_address_allocator.h
${CMAKE_CURRENT_SOURCE_DIR}/residency.cpp
${CMAKE_CURRENT_SOURCE_DIR}/residency.h
${CMAKE_CURRENT_SOURCE_DIR}/residency_container.h

View File

@@ -0,0 +1,67 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/memory_manager/address_mapper.h"
#include "shared/source/helpers/aligned_memory.h"
#include <inttypes.h>
#include <iostream>
namespace NEO {
AddressMapper::AddressMapper() : nextPage(1) {
}
AddressMapper::~AddressMapper() {
for (auto &m : mapping)
delete m;
}
uint32_t AddressMapper::map(void *vm, size_t size) {
void *aligned = alignDown(vm, MemoryConstants::pageSize);
size_t alignedSize = alignSizeWholePage(vm, size);
auto it = mapping.begin();
for (; it != mapping.end(); it++) {
if ((*it)->vm == aligned) {
if ((*it)->size == alignedSize) {
return (*it)->ggtt;
}
break;
}
}
if (it != mapping.end()) {
delete *it;
mapping.erase(it);
}
uint32_t numPages = static_cast<uint32_t>(alignedSize / MemoryConstants::pageSize);
auto tmp = nextPage.fetch_add(numPages);
MapInfo *m = new MapInfo;
m->vm = aligned;
m->size = alignedSize;
m->ggtt = static_cast<uint32_t>(tmp * MemoryConstants::pageSize);
mapping.push_back(m);
return m->ggtt;
}
void AddressMapper::unmap(void *vm) {
void *aligned = alignDown(vm, MemoryConstants::pageSize);
auto it = mapping.begin();
for (; it != mapping.end(); it++) {
if ((*it)->vm == aligned) {
break;
}
}
if (it != mapping.end()) {
delete *it;
mapping.erase(it);
}
}
} // namespace NEO

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2017-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <atomic>
#include <cstddef>
#include <vector>
namespace NEO {
class AddressMapper {
public:
AddressMapper();
~AddressMapper();
// maps to continuous region
uint32_t map(void *vm, size_t size);
// unmaps
void unmap(void *vm);
protected:
struct MapInfo {
void *vm;
size_t size;
uint32_t ggtt;
};
std::vector<MapInfo *> mapping;
std::atomic<uint32_t> nextPage;
};
} // namespace NEO

View File

@@ -0,0 +1,19 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <cstdint>
namespace MemoryBanks {
constexpr uint32_t BankNotSpecified{0};
constexpr uint32_t MainBank{0};
constexpr uint32_t Bank0{1};
inline uint32_t getBank(uint32_t deviceOrdinal) {
return MemoryBanks::MainBank;
}
} // namespace MemoryBanks

View File

@@ -0,0 +1,52 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/helpers/aligned_memory.h"
#include "shared/source/helpers/constants.h"
#include "shared/source/helpers/debug_helpers.h"
#include "shared/source/memory_manager/memory_banks.h"
#include <atomic>
#include <mutex>
namespace NEO {
class PhysicalAddressAllocator {
public:
PhysicalAddressAllocator() {
mainAllocator.store(initialPageAddress);
}
virtual ~PhysicalAddressAllocator() = default;
uint64_t reserve4kPage(uint32_t memoryBank) {
return reservePage(memoryBank, MemoryConstants::pageSize, MemoryConstants::pageSize);
}
uint64_t reserve64kPage(uint32_t memoryBank) {
return reservePage(memoryBank, MemoryConstants::pageSize64k, MemoryConstants::pageSize64k);
}
virtual uint64_t reservePage(uint32_t memoryBank, size_t pageSize, size_t alignement) {
UNRECOVERABLE_IF(memoryBank != MemoryBanks::MainBank);
std::unique_lock<std::mutex> lock(pageReserveMutex);
auto currentAddress = mainAllocator.load();
auto alignmentSize = alignUp(currentAddress, alignement) - currentAddress;
mainAllocator += alignmentSize;
return mainAllocator.fetch_add(pageSize);
}
protected:
std::atomic<uint64_t> mainAllocator;
std::mutex pageReserveMutex;
const uint64_t initialPageAddress = 0x1000;
};
} // namespace NEO

View File

@@ -12,11 +12,10 @@
#include "shared/source/helpers/heap_assigner.h"
#include "shared/source/helpers/string.h"
#include "shared/source/helpers/surface_format_info.h"
#include "shared/source/memory_manager/memory_banks.h"
#include "shared/source/os_interface/linux/drm_memory_manager.h"
#include "shared/source/os_interface/linux/memory_info_impl.h"
#include "opencl/source/memory_manager/memory_banks.h"
namespace NEO {
BufferObject *DrmMemoryManager::createBufferObjectInMemoryRegion(Drm *drm,