mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Add implementation of memory operation handler on Linux
Related-To: NEO-4302 Change-Id: Ic2b0eb9dde67d0c672914764592c8326f5bdd9c1 Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "shared/source/memory_manager/host_ptr_manager.h"
|
||||
#include "shared/source/memory_manager/residency.h"
|
||||
#include "shared/source/os_interface/linux/allocator_helper.h"
|
||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/source/os_interface/linux/os_interface.h"
|
||||
|
||||
@@ -545,6 +546,8 @@ void DrmMemoryManager::removeAllocationFromHostPtrManager(GraphicsAllocation *gf
|
||||
}
|
||||
|
||||
void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) {
|
||||
executionEnvironment.rootDeviceEnvironments[gfxAllocation->getRootDeviceIndex()]->memoryOperationsInterface->evict(*gfxAllocation);
|
||||
|
||||
for (auto handleId = 0u; handleId < EngineLimits::maxHandleCount; handleId++) {
|
||||
if (gfxAllocation->getGmm(handleId)) {
|
||||
delete gfxAllocation->getGmm(handleId);
|
||||
|
||||
@@ -7,21 +7,42 @@
|
||||
|
||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
DrmMemoryOperationsHandler::DrmMemoryOperationsHandler() {
|
||||
}
|
||||
DrmMemoryOperationsHandler::DrmMemoryOperationsHandler() = default;
|
||||
DrmMemoryOperationsHandler::~DrmMemoryOperationsHandler() = default;
|
||||
|
||||
MemoryOperationsStatus DrmMemoryOperationsHandler::makeResident(ArrayRef<GraphicsAllocation *> gfxAllocations) {
|
||||
return MemoryOperationsStatus::UNSUPPORTED;
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
this->residency.insert(gfxAllocations.begin(), gfxAllocations.end());
|
||||
return MemoryOperationsStatus::SUCCESS;
|
||||
}
|
||||
|
||||
MemoryOperationsStatus DrmMemoryOperationsHandler::evict(GraphicsAllocation &gfxAllocation) {
|
||||
return MemoryOperationsStatus::UNSUPPORTED;
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
this->residency.erase(&gfxAllocation);
|
||||
return MemoryOperationsStatus::SUCCESS;
|
||||
}
|
||||
|
||||
MemoryOperationsStatus DrmMemoryOperationsHandler::isResident(GraphicsAllocation &gfxAllocation) {
|
||||
return MemoryOperationsStatus::UNSUPPORTED;
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
auto ret = this->residency.find(&gfxAllocation);
|
||||
if (ret == this->residency.end()) {
|
||||
return MemoryOperationsStatus::MEMORY_NOT_FOUND;
|
||||
}
|
||||
return MemoryOperationsStatus::SUCCESS;
|
||||
}
|
||||
|
||||
void DrmMemoryOperationsHandler::mergeWithResidencyContainer(ResidencyContainer &residencyContainer) {
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
for (auto gfxAllocation = this->residency.begin(); gfxAllocation != this->residency.end(); gfxAllocation++) {
|
||||
auto ret = std::find(residencyContainer.begin(), residencyContainer.end(), *gfxAllocation);
|
||||
if (ret == residencyContainer.end()) {
|
||||
residencyContainer.push_back(*gfxAllocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
|
||||
@@ -7,16 +7,25 @@
|
||||
|
||||
#pragma once
|
||||
#include "shared/source/memory_manager/memory_operations_handler.h"
|
||||
#include "shared/source/memory_manager/residency_container.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class DrmMemoryOperationsHandler : public MemoryOperationsHandler {
|
||||
public:
|
||||
DrmMemoryOperationsHandler();
|
||||
~DrmMemoryOperationsHandler() override = default;
|
||||
~DrmMemoryOperationsHandler() override;
|
||||
|
||||
MemoryOperationsStatus makeResident(ArrayRef<GraphicsAllocation *> gfxAllocations) override;
|
||||
MemoryOperationsStatus evict(GraphicsAllocation &gfxAllocation) override;
|
||||
MemoryOperationsStatus isResident(GraphicsAllocation &gfxAllocation) override;
|
||||
|
||||
void mergeWithResidencyContainer(ResidencyContainer &residencyContainer);
|
||||
|
||||
protected:
|
||||
std::unordered_set<GraphicsAllocation *> residency;
|
||||
std::mutex mutex;
|
||||
};
|
||||
} // namespace NEO
|
||||
|
||||
Reference in New Issue
Block a user