mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 00:24:58 +08:00
Cleaned up files: level_zero/tools/source/debug/windows/debug_session.h level_zero/tools/source/sysman/memory/windows/os_memory_imp.h level_zero/tools/source/sysman/windows/kmd_sys_manager.h opencl/test/unit_test/aub_tests/command_stream/copy_engine_aub_tests_xehp_and shared/source/command_container/command_encoder.inl shared/source/command_stream/command_stream_receiver_hw_xehp_and_later.inl shared/source/helpers/blit_commands_helper_base.inl shared/test/unit_test/image/image_surface_state_fixture.h shared/test/unit_test/os_interface/windows/os_interface_win_tests.h Related-To: NEO-5548 Signed-off-by: Warchulski, Jaroslaw <jaroslaw.warchulski@intel.com>
101 lines
3.5 KiB
C++
101 lines
3.5 KiB
C++
/*
|
|
* Copyright (C) 2020-2023 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "shared/source/memory_manager/multi_graphics_allocation.h"
|
|
|
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
|
#include "shared/source/memory_manager/migration_sync_data.h"
|
|
|
|
namespace NEO {
|
|
|
|
MultiGraphicsAllocation::MultiGraphicsAllocation(uint32_t maxRootDeviceIndex) {
|
|
graphicsAllocations.resize(maxRootDeviceIndex + 1);
|
|
for (auto &allocation : graphicsAllocations) {
|
|
allocation = nullptr;
|
|
}
|
|
}
|
|
|
|
MultiGraphicsAllocation::MultiGraphicsAllocation(const MultiGraphicsAllocation &multiGraphicsAllocation) {
|
|
this->graphicsAllocations = multiGraphicsAllocation.graphicsAllocations;
|
|
this->migrationSyncData = multiGraphicsAllocation.migrationSyncData;
|
|
this->isMultiStorage = multiGraphicsAllocation.isMultiStorage;
|
|
if (migrationSyncData) {
|
|
migrationSyncData->incRefInternal();
|
|
}
|
|
}
|
|
MultiGraphicsAllocation::MultiGraphicsAllocation(MultiGraphicsAllocation &&multiGraphicsAllocation) {
|
|
this->graphicsAllocations = std::move(multiGraphicsAllocation.graphicsAllocations);
|
|
std::swap(this->migrationSyncData, multiGraphicsAllocation.migrationSyncData);
|
|
this->isMultiStorage = multiGraphicsAllocation.isMultiStorage;
|
|
};
|
|
|
|
MultiGraphicsAllocation::~MultiGraphicsAllocation() {
|
|
if (migrationSyncData) {
|
|
migrationSyncData->decRefInternal();
|
|
}
|
|
}
|
|
|
|
GraphicsAllocation *MultiGraphicsAllocation::getDefaultGraphicsAllocation() const {
|
|
for (auto &allocation : graphicsAllocations) {
|
|
if (allocation) {
|
|
return allocation;
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
void MultiGraphicsAllocation::addAllocation(GraphicsAllocation *graphicsAllocation) {
|
|
UNRECOVERABLE_IF(graphicsAllocation == nullptr);
|
|
UNRECOVERABLE_IF(graphicsAllocations.size() < graphicsAllocation->getRootDeviceIndex() + 1);
|
|
graphicsAllocations[graphicsAllocation->getRootDeviceIndex()] = graphicsAllocation;
|
|
}
|
|
|
|
void MultiGraphicsAllocation::removeAllocation(uint32_t rootDeviceIndex) {
|
|
graphicsAllocations[rootDeviceIndex] = nullptr;
|
|
}
|
|
|
|
GraphicsAllocation *MultiGraphicsAllocation::getGraphicsAllocation(uint32_t rootDeviceIndex) const {
|
|
if (rootDeviceIndex >= graphicsAllocations.size()) {
|
|
return nullptr;
|
|
}
|
|
return graphicsAllocations[rootDeviceIndex];
|
|
}
|
|
|
|
AllocationType MultiGraphicsAllocation::getAllocationType() const {
|
|
return getDefaultGraphicsAllocation()->getAllocationType();
|
|
}
|
|
|
|
bool MultiGraphicsAllocation::isCoherent() const {
|
|
return getDefaultGraphicsAllocation()->isCoherent();
|
|
}
|
|
|
|
StackVec<GraphicsAllocation *, 1> const &MultiGraphicsAllocation::getGraphicsAllocations() const {
|
|
return graphicsAllocations;
|
|
}
|
|
|
|
void MultiGraphicsAllocation::setMultiStorage(bool value) {
|
|
isMultiStorage = value;
|
|
if (isMultiStorage && !migrationSyncData) {
|
|
auto graphicsAllocation = getDefaultGraphicsAllocation();
|
|
UNRECOVERABLE_IF(!graphicsAllocation);
|
|
migrationSyncData = createMigrationSyncDataFunc(graphicsAllocation->getUnderlyingBufferSize());
|
|
migrationSyncData->incRefInternal();
|
|
}
|
|
}
|
|
|
|
bool MultiGraphicsAllocation::requiresMigrations() const {
|
|
if (migrationSyncData && migrationSyncData->isMigrationInProgress()) {
|
|
return false;
|
|
}
|
|
return isMultiStorage;
|
|
}
|
|
|
|
decltype(MultiGraphicsAllocation::createMigrationSyncDataFunc) MultiGraphicsAllocation::createMigrationSyncDataFunc = [](size_t size) -> MigrationSyncData * {
|
|
return new MigrationSyncData(size);
|
|
};
|
|
} // namespace NEO
|