2018-11-22 22:16:20 +08:00
|
|
|
/*
|
2022-11-10 21:56:53 +08:00
|
|
|
* Copyright (C) 2018-2022 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"
|
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
|
|
|
#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];
|
|
|
|
auto &coreHelper = rootDeviceEnvironment.getHelper<CoreHelper>();
|
|
|
|
computeUnitsUsedForScratch = coreHelper.getComputeUnitsUsedForScratch(rootDeviceEnvironment);
|
2018-11-22 22:16:20 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ScratchSpaceController::~ScratchSpaceController() {
|
|
|
|
if (scratchAllocation) {
|
|
|
|
getMemoryManager()->freeGraphicsMemory(scratchAllocation);
|
|
|
|
}
|
2019-06-28 18:42:32 +08:00
|
|
|
if (privateScratchAllocation) {
|
|
|
|
getMemoryManager()->freeGraphicsMemory(privateScratchAllocation);
|
|
|
|
}
|
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
|