mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Reorganization directory structure [3/n]
Change-Id: If3dfa3f6007f8810a6a1ae1a4f0c7da38544648d
This commit is contained in:
63
shared/source/os_interface/aub_memory_operations_handler.cpp
Normal file
63
shared/source/os_interface/aub_memory_operations_handler.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2019-2020 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "os_interface/aub_memory_operations_handler.h"
|
||||
|
||||
#include "memory_manager/graphics_allocation.h"
|
||||
#include "opencl/source/aub_mem_dump/aub_mem_dump.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
AubMemoryOperationsHandler::AubMemoryOperationsHandler(aub_stream::AubManager *aubManager) {
|
||||
this->aubManager = aubManager;
|
||||
}
|
||||
|
||||
MemoryOperationsStatus AubMemoryOperationsHandler::makeResident(ArrayRef<GraphicsAllocation *> gfxAllocations) {
|
||||
if (!aubManager) {
|
||||
return MemoryOperationsStatus::DEVICE_UNINITIALIZED;
|
||||
}
|
||||
auto lock = acquireLock(resourcesLock);
|
||||
int hint = AubMemDump::DataTypeHintValues::TraceNotype;
|
||||
for (const auto &allocation : gfxAllocations) {
|
||||
aubManager->writeMemory(allocation->getGpuAddress(),
|
||||
allocation->getUnderlyingBuffer(),
|
||||
allocation->getUnderlyingBufferSize(),
|
||||
allocation->storageInfo.getMemoryBanks(),
|
||||
hint,
|
||||
allocation->getUsedPageSize());
|
||||
residentAllocations.push_back(allocation);
|
||||
}
|
||||
return MemoryOperationsStatus::SUCCESS;
|
||||
}
|
||||
|
||||
MemoryOperationsStatus AubMemoryOperationsHandler::evict(GraphicsAllocation &gfxAllocation) {
|
||||
auto lock = acquireLock(resourcesLock);
|
||||
auto itor = std::find(residentAllocations.begin(), residentAllocations.end(), &gfxAllocation);
|
||||
if (itor == residentAllocations.end()) {
|
||||
return MemoryOperationsStatus::MEMORY_NOT_FOUND;
|
||||
} else {
|
||||
residentAllocations.erase(itor, itor + 1);
|
||||
return MemoryOperationsStatus::SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
MemoryOperationsStatus AubMemoryOperationsHandler::isResident(GraphicsAllocation &gfxAllocation) {
|
||||
auto lock = acquireLock(resourcesLock);
|
||||
auto itor = std::find(residentAllocations.begin(), residentAllocations.end(), &gfxAllocation);
|
||||
if (itor == residentAllocations.end()) {
|
||||
return MemoryOperationsStatus::MEMORY_NOT_FOUND;
|
||||
} else {
|
||||
return MemoryOperationsStatus::SUCCESS;
|
||||
}
|
||||
}
|
||||
void AubMemoryOperationsHandler::setAubManager(aub_stream::AubManager *aubManager) {
|
||||
this->aubManager = aubManager;
|
||||
}
|
||||
|
||||
} // namespace NEO
|
Reference in New Issue
Block a user