2018-11-22 22:16:20 +08:00
|
|
|
/*
|
2020-01-21 18:00:03 +08:00
|
|
|
* Copyright (C) 2018-2020 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) {
|
2020-02-12 18:27:28 +08:00
|
|
|
auto hwInfo = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
|
2019-05-08 22:00:24 +08:00
|
|
|
auto &hwHelper = HwHelper::get(hwInfo->platform.eRenderCoreFamily);
|
2019-03-29 07:49:23 +08:00
|
|
|
computeUnitsUsedForScratch = hwHelper.getComputeUnitsUsedForScratch(hwInfo);
|
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
|