Files
compute-runtime/shared/source/command_stream/scratch_space_controller.cpp
Kamil Kopryk 05aea7ebc8 Move hwHelper ownership to RootDeviceEnvironment 3/n
Related-To: NEO-6853
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>

Use RootDeviceEnvironment getHelper<CoreHelper> for
- getComputeUnitsUsedForScratch
- getPitchAlignmentForImage
2022-11-15 10:22:48 +01:00

40 lines
1.5 KiB
C++

/*
* Copyright (C) 2018-2022 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_stream/scratch_space_controller.h"
#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"
namespace NEO {
ScratchSpaceController::ScratchSpaceController(uint32_t rootDeviceIndex, ExecutionEnvironment &environment, InternalAllocationStorage &allocationStorage)
: rootDeviceIndex(rootDeviceIndex), executionEnvironment(environment), csrAllocationStorage(allocationStorage) {
auto &rootDeviceEnvironment = *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex];
auto &coreHelper = rootDeviceEnvironment.getHelper<CoreHelper>();
computeUnitsUsedForScratch = coreHelper.getComputeUnitsUsedForScratch(rootDeviceEnvironment);
}
ScratchSpaceController::~ScratchSpaceController() {
if (scratchAllocation) {
getMemoryManager()->freeGraphicsMemory(scratchAllocation);
}
if (privateScratchAllocation) {
getMemoryManager()->freeGraphicsMemory(privateScratchAllocation);
}
}
MemoryManager *ScratchSpaceController::getMemoryManager() const {
UNRECOVERABLE_IF(executionEnvironment.memoryManager.get() == nullptr);
return executionEnvironment.memoryManager.get();
}
} // namespace NEO