2018-11-22 22:16:20 +08:00
|
|
|
/*
|
2024-01-19 20:38:56 +08:00
|
|
|
* Copyright (C) 2018-2024 Intel Corporation
|
2018-11-22 22:16:20 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/scratch_space_controller.h"
|
2019-02-27 18:39:32 +08:00
|
|
|
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2023-02-02 00:23:01 +08:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/memory_manager/graphics_allocation.h"
|
|
|
|
#include "shared/source/memory_manager/internal_allocation_storage.h"
|
|
|
|
#include "shared/source/memory_manager/memory_manager.h"
|
2018-11-22 22:16:20 +08:00
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2019-11-07 21:15:04 +08:00
|
|
|
ScratchSpaceController::ScratchSpaceController(uint32_t rootDeviceIndex, ExecutionEnvironment &environment, InternalAllocationStorage &allocationStorage)
|
|
|
|
: rootDeviceIndex(rootDeviceIndex), executionEnvironment(environment), csrAllocationStorage(allocationStorage) {
|
2022-11-10 21:56:53 +08:00
|
|
|
|
|
|
|
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex];
|
2022-12-08 20:22:35 +08:00
|
|
|
auto &gfxCoreHelper = rootDeviceEnvironment.getHelper<GfxCoreHelper>();
|
|
|
|
computeUnitsUsedForScratch = gfxCoreHelper.getComputeUnitsUsedForScratch(rootDeviceEnvironment);
|
2018-11-22 22:16:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ScratchSpaceController::~ScratchSpaceController() {
|
2024-01-23 18:41:31 +08:00
|
|
|
if (scratchSlot0Allocation) {
|
|
|
|
getMemoryManager()->freeGraphicsMemory(scratchSlot0Allocation);
|
2018-11-22 22:16:20 +08:00
|
|
|
}
|
2024-01-23 18:41:31 +08:00
|
|
|
if (scratchSlot1Allocation) {
|
|
|
|
getMemoryManager()->freeGraphicsMemory(scratchSlot1Allocation);
|
2019-06-28 18:42:32 +08:00
|
|
|
}
|
2018-11-22 22:16:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
MemoryManager *ScratchSpaceController::getMemoryManager() const {
|
|
|
|
UNRECOVERABLE_IF(executionEnvironment.memoryManager.get() == nullptr);
|
|
|
|
return executionEnvironment.memoryManager.get();
|
|
|
|
}
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|