mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-05 17:41:26 +08:00
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:
committed by
sys_ocldev
parent
cc6d6968dd
commit
d27374b468
52
shared/source/memory_manager/physical_address_allocator.h
Normal file
52
shared/source/memory_manager/physical_address_allocator.h
Normal 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
|
||||
Reference in New Issue
Block a user