2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2025-01-15 13:44:10 +00:00
|
|
|
* Copyright (C) 2018-2025 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-19 20:54:29 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/command_stream/command_stream_receiver.h"
|
2019-02-27 11:39:32 +01:00
|
|
|
|
2020-02-24 13:10:44 +01:00
|
|
|
#include "shared/source/built_ins/built_ins.h"
|
2021-08-03 11:42:37 +00:00
|
|
|
#include "shared/source/command_container/implicit_scaling.h"
|
2023-01-17 17:04:14 +00:00
|
|
|
#include "shared/source/command_stream/aub_subcapture_status.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/command_stream/preemption.h"
|
|
|
|
|
#include "shared/source/command_stream/scratch_space_controller.h"
|
2022-12-22 11:31:28 +00:00
|
|
|
#include "shared/source/command_stream/submission_status.h"
|
2023-01-17 17:04:14 +00:00
|
|
|
#include "shared/source/command_stream/submissions_aggregator.h"
|
2022-12-06 07:32:34 +00:00
|
|
|
#include "shared/source/command_stream/tag_allocation_layout.h"
|
2022-03-09 12:36:51 +00:00
|
|
|
#include "shared/source/debug_settings/debug_settings_manager.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/device/device.h"
|
2021-10-29 11:54:52 +00:00
|
|
|
#include "shared/source/direct_submission/direct_submission_controller.h"
|
2022-12-29 12:27:52 +00:00
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/execution_environment/root_device_environment.h"
|
2022-06-27 14:58:29 +00:00
|
|
|
#include "shared/source/gmm_helper/cache_settings_helper.h"
|
2021-09-29 15:59:41 +00:00
|
|
|
#include "shared/source/gmm_helper/page_table_mngr.h"
|
2021-12-03 17:48:12 +00:00
|
|
|
#include "shared/source/helpers/api_specific_config.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/array_count.h"
|
2023-11-23 13:58:58 +00:00
|
|
|
#include "shared/source/helpers/compiler_product_helper.h"
|
2023-01-17 17:04:14 +00:00
|
|
|
#include "shared/source/helpers/flat_batch_buffer_helper.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/flush_stamp.h"
|
2023-02-01 16:23:01 +00:00
|
|
|
#include "shared/source/helpers/gfx_core_helper.h"
|
2021-02-06 14:38:55 +00:00
|
|
|
#include "shared/source/helpers/pause_on_gpu_properties.h"
|
2022-04-25 14:54:13 +00:00
|
|
|
#include "shared/source/helpers/ray_tracing_helper.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/helpers/string.h"
|
|
|
|
|
#include "shared/source/helpers/timestamp_packet.h"
|
2022-12-07 11:51:44 +00:00
|
|
|
#include "shared/source/memory_manager/allocation_properties.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/memory_manager/internal_allocation_storage.h"
|
|
|
|
|
#include "shared/source/memory_manager/memory_manager.h"
|
|
|
|
|
#include "shared/source/memory_manager/surface.h"
|
|
|
|
|
#include "shared/source/os_interface/os_context.h"
|
|
|
|
|
#include "shared/source/os_interface/os_interface.h"
|
2022-12-22 11:31:28 +00:00
|
|
|
#include "shared/source/os_interface/os_thread.h"
|
2023-03-10 12:28:11 +00:00
|
|
|
#include "shared/source/os_interface/product_helper.h"
|
2022-02-11 16:28:08 +00:00
|
|
|
#include "shared/source/os_interface/sys_calls_common.h"
|
2022-07-24 04:21:16 +00:00
|
|
|
#include "shared/source/utilities/hw_timestamps.h"
|
|
|
|
|
#include "shared/source/utilities/perf_counter.h"
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/utilities/tag_allocator.h"
|
2021-03-30 18:11:00 +00:00
|
|
|
#include "shared/source/utilities/wait_util.h"
|
2020-02-24 10:22:30 +01:00
|
|
|
|
2024-10-01 12:41:04 +00:00
|
|
|
#include <array>
|
2023-01-17 17:04:14 +00:00
|
|
|
#include <iostream>
|
|
|
|
|
|
2022-12-01 19:42:57 +00:00
|
|
|
namespace AubMemDump {
|
|
|
|
|
#include "aub_services.h"
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2020-02-19 16:32:40 +01:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
// Global table of CommandStreamReceiver factories for HW and tests
|
|
|
|
|
CommandStreamReceiverCreateFunc commandStreamReceiverFactory[2 * IGFX_MAX_CORE] = {};
|
|
|
|
|
|
2020-10-29 15:33:35 +01:00
|
|
|
CommandStreamReceiver::CommandStreamReceiver(ExecutionEnvironment &executionEnvironment,
|
|
|
|
|
uint32_t rootDeviceIndex,
|
|
|
|
|
const DeviceBitfield deviceBitfield)
|
2020-10-28 16:08:37 +01:00
|
|
|
: executionEnvironment(executionEnvironment), rootDeviceIndex(rootDeviceIndex), deviceBitfield(deviceBitfield) {
|
2022-04-06 13:59:23 +00:00
|
|
|
residencyAllocations.reserve(startingResidencyContainerSize);
|
2018-09-13 15:49:38 +02:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
latestSentStatelessMocsConfig = CacheSettings::unknownMocs;
|
|
|
|
|
submissionAggregator.reset(new SubmissionAggregator());
|
2022-01-20 21:20:56 +00:00
|
|
|
if (ApiSpecificConfig::getApiType() == ApiSpecificConfig::L0) {
|
2023-12-13 09:17:24 +00:00
|
|
|
this->dispatchMode = DispatchMode::immediateDispatch;
|
2022-01-20 21:20:56 +00:00
|
|
|
}
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.CsrDispatchMode.get()) {
|
|
|
|
|
this->dispatchMode = (DispatchMode)debugManager.flags.CsrDispatchMode.get();
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
flushStamp.reset(new FlushStampTracker(true));
|
2023-12-13 16:09:52 +00:00
|
|
|
for (int i = 0; i < IndirectHeap::Type::numTypes; ++i) {
|
2018-04-26 10:01:01 +02:00
|
|
|
indirectHeap[i] = nullptr;
|
|
|
|
|
}
|
2018-10-22 15:17:32 +02:00
|
|
|
internalAllocationStorage = std::make_unique<InternalAllocationStorage>(*this);
|
2022-01-11 19:41:57 +00:00
|
|
|
const auto &hwInfo = peekHwInfo();
|
2021-11-17 19:51:43 +00:00
|
|
|
uint32_t subDeviceCount = static_cast<uint32_t>(deviceBitfield.count());
|
2022-12-09 14:37:32 +00:00
|
|
|
auto &gfxCoreHelper = getGfxCoreHelper();
|
2023-01-30 00:09:45 +00:00
|
|
|
auto &rootDeviceEnvironment = peekRootDeviceEnvironment();
|
|
|
|
|
bool platformImplicitScaling = gfxCoreHelper.platformSupportsImplicitScaling(rootDeviceEnvironment);
|
2022-01-11 19:41:57 +00:00
|
|
|
if (NEO::ImplicitScalingHelper::isImplicitScalingEnabled(deviceBitfield, platformImplicitScaling) &&
|
2021-11-17 19:51:43 +00:00
|
|
|
subDeviceCount > 1 &&
|
2023-11-30 08:32:25 +00:00
|
|
|
debugManager.flags.EnableStaticPartitioning.get() != 0) {
|
2021-11-17 19:51:43 +00:00
|
|
|
this->activePartitions = subDeviceCount;
|
2021-02-16 17:04:00 +00:00
|
|
|
this->staticWorkPartitioningEnabled = true;
|
|
|
|
|
}
|
2023-03-09 23:12:09 +00:00
|
|
|
this->streamProperties.initSupport(rootDeviceEnvironment);
|
2022-12-15 12:13:57 +00:00
|
|
|
auto &productHelper = getProductHelper();
|
|
|
|
|
productHelper.fillFrontEndPropertiesSupportStructure(feSupportFlags, hwInfo);
|
|
|
|
|
productHelper.fillPipelineSelectPropertiesSupportStructure(pipelineSupportFlags, hwInfo);
|
2023-02-02 18:57:24 +00:00
|
|
|
productHelper.fillStateBaseAddressPropertiesSupportStructure(sbaSupportFlags);
|
2023-02-22 21:30:40 +00:00
|
|
|
this->doubleSbaWa = productHelper.isAdditionalStateBaseAddressWARequired(hwInfo);
|
2023-02-24 16:55:21 +00:00
|
|
|
this->l1CachePolicyData.init(productHelper);
|
2023-09-25 07:58:39 +00:00
|
|
|
|
|
|
|
|
registeredClients.reserve(16);
|
2023-11-23 13:58:58 +00:00
|
|
|
|
|
|
|
|
auto &compilerProductHelper = rootDeviceEnvironment.getHelper<CompilerProductHelper>();
|
|
|
|
|
this->heaplessModeEnabled = compilerProductHelper.isHeaplessModeEnabled();
|
2024-08-22 10:25:49 +00:00
|
|
|
this->evictionAllocations.reserve(2 * MemoryConstants::kiloByte);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CommandStreamReceiver::~CommandStreamReceiver() {
|
2020-06-17 11:31:08 +02:00
|
|
|
if (userPauseConfirmation) {
|
2020-11-06 13:01:29 +01:00
|
|
|
{
|
|
|
|
|
std::unique_lock<SpinLock> lock{debugPauseStateLock};
|
|
|
|
|
*debugPauseStateAddress = DebugPauseState::terminate;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-17 11:31:08 +02:00
|
|
|
userPauseConfirmation->join();
|
2020-04-30 17:12:01 +02:00
|
|
|
}
|
|
|
|
|
|
2023-12-13 16:09:52 +00:00
|
|
|
for (int i = 0; i < IndirectHeap::Type::numTypes; ++i) {
|
2018-04-26 10:01:01 +02:00
|
|
|
if (indirectHeap[i] != nullptr) {
|
|
|
|
|
auto allocation = indirectHeap[i]->getGraphicsAllocation();
|
|
|
|
|
if (allocation != nullptr) {
|
2018-10-24 14:25:04 +02:00
|
|
|
internalAllocationStorage->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
|
2018-04-26 10:01:01 +02:00
|
|
|
}
|
|
|
|
|
delete indirectHeap[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
cleanupResources();
|
2018-10-09 11:50:58 +02:00
|
|
|
|
2018-10-29 12:26:58 +00:00
|
|
|
internalAllocationStorage->cleanAllocationList(-1, REUSABLE_ALLOCATION);
|
|
|
|
|
internalAllocationStorage->cleanAllocationList(-1, TEMPORARY_ALLOCATION);
|
2023-10-27 16:43:33 +00:00
|
|
|
internalAllocationStorage->cleanAllocationList(-1, DEFERRED_DEALLOCATION);
|
2019-09-02 13:23:25 +02:00
|
|
|
getMemoryManager()->unregisterEngineForCsr(this);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2022-01-07 14:53:31 +00:00
|
|
|
SubmissionStatus CommandStreamReceiver::submitBatchBuffer(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) {
|
2020-02-18 13:51:01 +01:00
|
|
|
this->latestSentTaskCount = taskCount + 1;
|
|
|
|
|
|
2022-01-07 14:53:31 +00:00
|
|
|
SubmissionStatus retVal = this->flush(batchBuffer, allocationsForResidency);
|
2022-05-27 03:58:07 +00:00
|
|
|
|
2023-12-13 09:17:24 +00:00
|
|
|
if (retVal != NEO::SubmissionStatus::success) {
|
2022-05-27 03:58:07 +00:00
|
|
|
return retVal;
|
|
|
|
|
}
|
2021-10-28 09:21:44 +00:00
|
|
|
if (!isUpdateTagFromWaitEnabled()) {
|
|
|
|
|
this->latestFlushedTaskCount = taskCount + 1;
|
|
|
|
|
}
|
2020-02-18 13:51:01 +01:00
|
|
|
taskCount++;
|
|
|
|
|
|
2022-01-07 14:53:31 +00:00
|
|
|
return retVal;
|
2020-02-18 13:51:01 +01:00
|
|
|
}
|
|
|
|
|
|
2021-05-14 16:46:50 +00:00
|
|
|
void CommandStreamReceiver::makeResident(MultiGraphicsAllocation &gfxAllocation) {
|
|
|
|
|
makeResident(*gfxAllocation.getGraphicsAllocation(rootDeviceIndex));
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
void CommandStreamReceiver::makeResident(GraphicsAllocation &gfxAllocation) {
|
2018-11-07 08:33:55 +00:00
|
|
|
auto submissionTaskCount = this->taskCount + 1;
|
2024-07-29 16:10:10 +00:00
|
|
|
|
|
|
|
|
gfxAllocation.updateTaskCount(submissionTaskCount, osContext->getContextId());
|
|
|
|
|
|
2018-12-18 13:02:08 +00:00
|
|
|
if (gfxAllocation.isResidencyTaskCountBelow(submissionTaskCount, osContext->getContextId())) {
|
2022-02-08 12:14:24 +00:00
|
|
|
auto pushAllocations = true;
|
|
|
|
|
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.MakeEachAllocationResident.get() != -1) {
|
|
|
|
|
pushAllocations = !debugManager.flags.MakeEachAllocationResident.get();
|
2022-02-08 12:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pushAllocations) {
|
|
|
|
|
this->getResidencyAllocations().push_back(&gfxAllocation);
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-13 09:17:24 +00:00
|
|
|
if (this->dispatchMode == DispatchMode::batchedDispatch) {
|
2024-07-30 06:31:25 +00:00
|
|
|
checkForNewResources(submissionTaskCount, gfxAllocation.getTaskCount(osContext->getContextId()), gfxAllocation);
|
2022-10-10 18:57:10 +00:00
|
|
|
if (!gfxAllocation.isResident(osContext->getContextId())) {
|
|
|
|
|
this->totalMemoryUsed += gfxAllocation.getUnderlyingBufferSize();
|
|
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
}
|
2024-07-29 16:10:10 +00:00
|
|
|
|
2018-12-03 10:05:36 +01:00
|
|
|
gfxAllocation.updateResidencyTaskCount(submissionTaskCount, osContext->getContextId());
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2018-11-26 14:04:52 +01:00
|
|
|
void CommandStreamReceiver::processEviction() {
|
2018-09-14 13:48:02 +02:00
|
|
|
this->getEvictionAllocations().clear();
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CommandStreamReceiver::makeNonResident(GraphicsAllocation &gfxAllocation) {
|
2018-12-03 10:05:36 +01:00
|
|
|
if (gfxAllocation.isResident(osContext->getContextId())) {
|
2024-07-13 14:02:01 +00:00
|
|
|
if (gfxAllocation.peekEvictable() && !gfxAllocation.isAlwaysResident(osContext->getContextId())) {
|
2024-08-22 10:25:49 +00:00
|
|
|
this->addToEvictionContainer(gfxAllocation);
|
2018-04-12 10:05:35 +02:00
|
|
|
} else {
|
|
|
|
|
gfxAllocation.setEvictable(true);
|
|
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2022-01-25 13:24:45 +00:00
|
|
|
if (!gfxAllocation.isAlwaysResident(this->osContext->getContextId())) {
|
|
|
|
|
gfxAllocation.releaseResidencyInOsContext(this->osContext->getContextId());
|
|
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2022-05-27 03:58:07 +00:00
|
|
|
void CommandStreamReceiver::makeSurfacePackNonResident(ResidencyContainer &allocationsForResidency, bool clearAllocations) {
|
2018-09-25 13:13:14 +02:00
|
|
|
for (auto &surface : allocationsForResidency) {
|
2017-12-21 00:45:38 +01:00
|
|
|
this->makeNonResident(*surface);
|
|
|
|
|
}
|
2022-05-27 03:58:07 +00:00
|
|
|
if (clearAllocations) {
|
|
|
|
|
allocationsForResidency.clear();
|
|
|
|
|
}
|
2018-11-26 14:04:52 +01:00
|
|
|
this->processEviction();
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2024-08-22 10:25:49 +00:00
|
|
|
SubmissionStatus CommandStreamReceiver::processResidency(ResidencyContainer &allocationsForResidency, uint32_t handleId) {
|
2023-12-13 09:17:24 +00:00
|
|
|
return SubmissionStatus::success;
|
2022-12-22 11:31:28 +00:00
|
|
|
}
|
|
|
|
|
|
2018-02-08 22:52:58 +01:00
|
|
|
void CommandStreamReceiver::makeResidentHostPtrAllocation(GraphicsAllocation *gfxAllocation) {
|
|
|
|
|
makeResident(*gfxAllocation);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
WaitStatus CommandStreamReceiver::waitForTaskCount(TaskCountType requiredTaskCount) {
|
2021-10-19 19:28:05 +00:00
|
|
|
auto address = getTagAddress();
|
2022-05-17 15:23:15 +00:00
|
|
|
if (!skipResourceCleanup() && address) {
|
2022-04-12 16:07:22 +00:00
|
|
|
this->downloadTagAllocation(requiredTaskCount);
|
2024-08-06 12:54:11 +00:00
|
|
|
return baseWaitFunction(address, WaitParams{false, false, false, 0}, requiredTaskCount);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
2022-02-22 12:51:29 +00:00
|
|
|
|
2023-12-01 09:12:59 +00:00
|
|
|
return WaitStatus::ready;
|
2021-10-21 01:29:53 +02:00
|
|
|
}
|
|
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
WaitStatus CommandStreamReceiver::waitForTaskCountAndCleanAllocationList(TaskCountType requiredTaskCount, uint32_t allocationUsage) {
|
2023-12-01 09:12:59 +00:00
|
|
|
WaitStatus waitStatus{WaitStatus::ready};
|
2021-11-17 15:31:39 +00:00
|
|
|
auto &list = allocationUsage == TEMPORARY_ALLOCATION ? internalAllocationStorage->getTemporaryAllocations() : internalAllocationStorage->getAllocationsForReuse();
|
|
|
|
|
if (!list.peekIsEmpty()) {
|
2022-02-22 12:51:29 +00:00
|
|
|
waitStatus = this->CommandStreamReceiver::waitForTaskCount(requiredTaskCount);
|
2021-11-17 15:31:39 +00:00
|
|
|
}
|
2018-11-02 10:01:56 +01:00
|
|
|
internalAllocationStorage->cleanAllocationList(requiredTaskCount, allocationUsage);
|
2023-10-27 16:43:33 +00:00
|
|
|
if (allocationUsage == TEMPORARY_ALLOCATION) {
|
|
|
|
|
internalAllocationStorage->cleanAllocationList(requiredTaskCount, DEFERRED_DEALLOCATION);
|
|
|
|
|
}
|
2022-02-22 12:51:29 +00:00
|
|
|
|
|
|
|
|
return waitStatus;
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
WaitStatus CommandStreamReceiver::waitForTaskCountAndCleanTemporaryAllocationList(TaskCountType requiredTaskCount) {
|
2022-02-22 12:51:29 +00:00
|
|
|
return waitForTaskCountAndCleanAllocationList(requiredTaskCount, TEMPORARY_ALLOCATION);
|
|
|
|
|
}
|
2019-12-17 10:35:25 +01:00
|
|
|
|
2019-02-20 10:31:32 +01:00
|
|
|
void CommandStreamReceiver::ensureCommandBufferAllocation(LinearStream &commandStream, size_t minimumRequiredSize, size_t additionalAllocationSize) {
|
|
|
|
|
if (commandStream.getAvailableSpace() >= minimumRequiredSize) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-09 12:33:43 +00:00
|
|
|
auto alignment = MemoryConstants::pageSize64k;
|
|
|
|
|
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.ForceCommandBufferAlignment.get() != -1) {
|
|
|
|
|
alignment = debugManager.flags.ForceCommandBufferAlignment.get() * MemoryConstants::kiloByte;
|
2022-02-09 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const auto allocationSize = alignUp(minimumRequiredSize + additionalAllocationSize, alignment);
|
2023-12-11 14:24:36 +00:00
|
|
|
constexpr static auto allocationType = AllocationType::commandBuffer;
|
2019-02-20 10:31:32 +01:00
|
|
|
auto allocation = this->getInternalAllocationStorage()->obtainReusableAllocation(allocationSize, allocationType).release();
|
|
|
|
|
if (allocation == nullptr) {
|
2019-11-07 14:15:04 +01:00
|
|
|
const AllocationProperties commandStreamAllocationProperties{rootDeviceIndex, true, allocationSize, allocationType,
|
2019-12-10 12:16:07 +01:00
|
|
|
isMultiOsContextCapable(), false, osContext->getDeviceBitfield()};
|
2019-02-20 10:31:32 +01:00
|
|
|
allocation = this->getMemoryManager()->allocateGraphicsMemoryWithProperties(commandStreamAllocationProperties);
|
|
|
|
|
}
|
|
|
|
|
DEBUG_BREAK_IF(allocation == nullptr);
|
|
|
|
|
|
|
|
|
|
if (commandStream.getGraphicsAllocation() != nullptr) {
|
|
|
|
|
getInternalAllocationStorage()->storeAllocation(std::unique_ptr<GraphicsAllocation>(commandStream.getGraphicsAllocation()), REUSABLE_ALLOCATION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commandStream.replaceBuffer(allocation->getUnderlyingBuffer(), allocationSize - additionalAllocationSize);
|
|
|
|
|
commandStream.replaceGraphicsAllocation(allocation);
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-17 12:14:15 +00:00
|
|
|
void CommandStreamReceiver::preallocateAllocation(AllocationType type, size_t size) {
|
|
|
|
|
const AllocationProperties commandStreamAllocationProperties{rootDeviceIndex, true, size, type,
|
2023-10-27 15:54:45 +00:00
|
|
|
isMultiOsContextCapable(), false, deviceBitfield};
|
|
|
|
|
auto allocation = this->getMemoryManager()->allocateGraphicsMemoryWithProperties(commandStreamAllocationProperties);
|
2023-11-08 12:44:01 +00:00
|
|
|
if (allocation) {
|
|
|
|
|
getInternalAllocationStorage()->storeAllocation(std::unique_ptr<GraphicsAllocation>(allocation), REUSABLE_ALLOCATION);
|
|
|
|
|
this->makeResident(*allocation);
|
|
|
|
|
}
|
2023-10-27 15:54:45 +00:00
|
|
|
}
|
|
|
|
|
|
2023-11-17 12:14:15 +00:00
|
|
|
void CommandStreamReceiver::preallocateCommandBuffer() {
|
2023-12-11 14:24:36 +00:00
|
|
|
preallocateAllocation(AllocationType::commandBuffer, MemoryConstants::pageSize64k);
|
2023-11-17 12:14:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CommandStreamReceiver::preallocateInternalHeap() {
|
2023-12-11 14:24:36 +00:00
|
|
|
preallocateAllocation(AllocationType::internalHeap, MemoryConstants::pageSize64k);
|
2023-11-17 12:14:15 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-13 15:53:33 +00:00
|
|
|
void CommandStreamReceiver::fillReusableAllocationsList() {
|
2022-12-09 14:37:32 +00:00
|
|
|
auto &gfxCoreHelper = getGfxCoreHelper();
|
|
|
|
|
auto amountToFill = gfxCoreHelper.getAmountOfAllocationsToFill();
|
2022-10-13 15:53:33 +00:00
|
|
|
for (auto i = 0u; i < amountToFill; i++) {
|
2023-10-27 15:54:45 +00:00
|
|
|
preallocateCommandBuffer();
|
|
|
|
|
}
|
2023-11-17 12:14:15 +00:00
|
|
|
|
|
|
|
|
auto internalHeapsToFill = getProductHelper().getInternalHeapsPreallocated();
|
|
|
|
|
for (auto i = 0u; i < internalHeapsToFill; i++) {
|
|
|
|
|
preallocateInternalHeap();
|
|
|
|
|
}
|
2023-10-27 15:54:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CommandStreamReceiver::requestPreallocation() {
|
|
|
|
|
auto preallocationsPerQueue = getProductHelper().getCommandBuffersPreallocatedPerCommandQueue();
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.SetAmountOfReusableAllocationsPerCmdQueue.get() != -1) {
|
|
|
|
|
preallocationsPerQueue = debugManager.flags.SetAmountOfReusableAllocationsPerCmdQueue.get();
|
2023-10-27 15:54:45 +00:00
|
|
|
}
|
|
|
|
|
auto lock = obtainUniqueOwnership();
|
|
|
|
|
requestedPreallocationsAmount += preallocationsPerQueue;
|
|
|
|
|
const int64_t amountToPreallocate = static_cast<int64_t>(requestedPreallocationsAmount.load()) - preallocatedAmount;
|
|
|
|
|
DEBUG_BREAK_IF(amountToPreallocate > preallocationsPerQueue);
|
|
|
|
|
if (amountToPreallocate > 0) {
|
|
|
|
|
for (auto i = 0u; i < amountToPreallocate; i++) {
|
|
|
|
|
preallocateCommandBuffer();
|
|
|
|
|
}
|
|
|
|
|
preallocatedAmount += static_cast<uint32_t>(amountToPreallocate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CommandStreamReceiver::releasePreallocationRequest() {
|
|
|
|
|
auto preallocationsPerQueue = getProductHelper().getCommandBuffersPreallocatedPerCommandQueue();
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.SetAmountOfReusableAllocationsPerCmdQueue.get() != -1) {
|
|
|
|
|
preallocationsPerQueue = debugManager.flags.SetAmountOfReusableAllocationsPerCmdQueue.get();
|
2022-10-13 15:53:33 +00:00
|
|
|
}
|
2023-10-27 15:54:45 +00:00
|
|
|
DEBUG_BREAK_IF(preallocationsPerQueue > requestedPreallocationsAmount);
|
|
|
|
|
requestedPreallocationsAmount -= preallocationsPerQueue;
|
2022-10-13 15:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
2024-06-17 10:43:53 +00:00
|
|
|
uint8_t CommandStreamReceiver::getUmdPowerHintValue() const {
|
|
|
|
|
return this->osContext ? this->osContext->getUmdPowerHintValue() : 0u;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-15 13:44:10 +00:00
|
|
|
bool CommandStreamReceiver::initializeResources(bool allocateInterrupt, const PreemptionMode preemptionMode) {
|
2022-11-03 15:25:30 +00:00
|
|
|
if (!resourcesInitialized) {
|
|
|
|
|
auto lock = obtainUniqueOwnership();
|
|
|
|
|
if (!resourcesInitialized) {
|
2024-06-06 15:23:40 +00:00
|
|
|
if (!osContext->ensureContextInitialized(allocateInterrupt)) {
|
2023-02-11 22:03:06 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
2025-01-15 13:44:10 +00:00
|
|
|
if (preemptionMode == NEO::PreemptionMode::MidThread &&
|
|
|
|
|
!this->getPreemptionAllocation()) {
|
|
|
|
|
this->createPreemptionAllocation();
|
|
|
|
|
}
|
2022-11-03 15:25:30 +00:00
|
|
|
this->fillReusableAllocationsList();
|
|
|
|
|
this->resourcesInitialized = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-11 22:03:06 +00:00
|
|
|
|
|
|
|
|
return true;
|
2022-11-03 15:25:30 +00:00
|
|
|
}
|
|
|
|
|
|
2018-10-11 11:19:49 +02:00
|
|
|
MemoryManager *CommandStreamReceiver::getMemoryManager() const {
|
|
|
|
|
DEBUG_BREAK_IF(!executionEnvironment.memoryManager);
|
|
|
|
|
return executionEnvironment.memoryManager.get();
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LinearStream &CommandStreamReceiver::getCS(size_t minRequiredSize) {
|
2019-02-20 10:31:32 +01:00
|
|
|
constexpr static auto additionalAllocationSize = MemoryConstants::cacheLineSize + CSRequirements::csOverfetchSize;
|
|
|
|
|
ensureCommandBufferAllocation(this->commandStream, minRequiredSize, additionalAllocationSize);
|
2017-12-21 00:45:38 +01:00
|
|
|
return commandStream;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-03 13:24:53 +01:00
|
|
|
OSInterface *CommandStreamReceiver::getOSInterface() const {
|
|
|
|
|
return executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->osInterface.get();
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-28 09:05:59 +00:00
|
|
|
GmmHelper *CommandStreamReceiver::peekGmmHelper() const {
|
|
|
|
|
return executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->gmmHelper.get();
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-19 10:37:39 +00:00
|
|
|
uint64_t CommandStreamReceiver::getWorkPartitionAllocationGpuAddress() const {
|
|
|
|
|
if (isStaticWorkPartitioningEnabled()) {
|
|
|
|
|
return getWorkPartitionAllocation()->getGpuAddress();
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-19 15:15:51 +01:00
|
|
|
bool CommandStreamReceiver::isRcs() const {
|
|
|
|
|
return this->osContext->getEngineType() == aub_stream::ENGINE_RCS;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-19 22:58:46 +01:00
|
|
|
bool CommandStreamReceiver::skipResourceCleanup() const {
|
2022-10-26 11:31:37 +00:00
|
|
|
return ((this->getOSInterface() && this->getOSInterface()->getDriverModel() && this->getOSInterface()->getDriverModel()->skipResourceCleanup()) || forceSkipResourceCleanupRequired);
|
2021-11-19 22:58:46 +01:00
|
|
|
}
|
|
|
|
|
|
2022-01-20 16:56:19 +00:00
|
|
|
bool CommandStreamReceiver::isGpuHangDetected() const {
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.DisableGpuHangDetection.get()) {
|
2022-03-09 12:36:51 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-04 16:03:36 +00:00
|
|
|
return this->osContext && this->getOSInterface() && this->getOSInterface()->getDriverModel() && this->getOSInterface()->getDriverModel()->isGpuHangDetected(*osContext);
|
2022-01-20 16:56:19 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
void CommandStreamReceiver::cleanupResources() {
|
2018-01-12 16:41:45 +01:00
|
|
|
waitForTaskCountAndCleanAllocationList(this->latestFlushedTaskCount, TEMPORARY_ALLOCATION);
|
|
|
|
|
waitForTaskCountAndCleanAllocationList(this->latestFlushedTaskCount, REUSABLE_ALLOCATION);
|
|
|
|
|
|
2018-03-21 12:58:30 +01:00
|
|
|
if (debugSurface) {
|
2018-10-11 11:19:49 +02:00
|
|
|
getMemoryManager()->freeGraphicsMemory(debugSurface);
|
2018-03-21 12:58:30 +01:00
|
|
|
debugSurface = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-05 11:03:38 +01:00
|
|
|
if (commandStream.getCpuBase()) {
|
2018-10-11 11:19:49 +02:00
|
|
|
getMemoryManager()->freeGraphicsMemory(commandStream.getGraphicsAllocation());
|
2017-12-21 00:45:38 +01:00
|
|
|
commandStream.replaceGraphicsAllocation(nullptr);
|
|
|
|
|
commandStream.replaceBuffer(nullptr, 0);
|
|
|
|
|
}
|
2018-07-13 14:11:04 +02:00
|
|
|
|
2021-02-25 09:38:48 +01:00
|
|
|
if (tagsMultiAllocation) {
|
2022-03-29 15:31:51 +00:00
|
|
|
// Null tag address to prevent waiting for tag update when freeing it
|
2021-05-12 08:35:07 +00:00
|
|
|
tagAllocation = nullptr;
|
|
|
|
|
tagAddress = nullptr;
|
2021-05-27 12:23:40 +00:00
|
|
|
DEBUG_BREAK_IF(tagAllocation != nullptr);
|
|
|
|
|
DEBUG_BREAK_IF(tagAddress != nullptr);
|
|
|
|
|
|
2021-02-25 09:38:48 +01:00
|
|
|
for (auto graphicsAllocation : tagsMultiAllocation->getGraphicsAllocations()) {
|
|
|
|
|
getMemoryManager()->freeGraphicsMemory(graphicsAllocation);
|
|
|
|
|
}
|
|
|
|
|
delete tagsMultiAllocation;
|
|
|
|
|
tagsMultiAllocation = nullptr;
|
2018-07-13 14:11:04 +02:00
|
|
|
}
|
2019-06-27 21:33:05 +02:00
|
|
|
|
2020-02-05 20:00:08 +01:00
|
|
|
if (globalFenceAllocation) {
|
|
|
|
|
getMemoryManager()->freeGraphicsMemory(globalFenceAllocation);
|
|
|
|
|
globalFenceAllocation = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-27 21:33:05 +02:00
|
|
|
if (preemptionAllocation) {
|
|
|
|
|
getMemoryManager()->freeGraphicsMemory(preemptionAllocation);
|
|
|
|
|
preemptionAllocation = nullptr;
|
|
|
|
|
}
|
2019-09-04 16:44:27 +02:00
|
|
|
|
|
|
|
|
if (perDssBackedBuffer) {
|
|
|
|
|
getMemoryManager()->freeGraphicsMemory(perDssBackedBuffer);
|
|
|
|
|
perDssBackedBuffer = nullptr;
|
|
|
|
|
}
|
2020-11-18 23:58:42 +00:00
|
|
|
|
|
|
|
|
if (clearColorAllocation) {
|
|
|
|
|
getMemoryManager()->freeGraphicsMemory(clearColorAllocation);
|
|
|
|
|
clearColorAllocation = nullptr;
|
|
|
|
|
}
|
2021-02-16 17:04:00 +00:00
|
|
|
|
|
|
|
|
if (workPartitionAllocation) {
|
|
|
|
|
getMemoryManager()->freeGraphicsMemory(workPartitionAllocation);
|
|
|
|
|
workPartitionAllocation = nullptr;
|
|
|
|
|
}
|
2022-08-03 11:54:08 +00:00
|
|
|
|
2023-03-06 20:33:50 +00:00
|
|
|
if (globalStatelessHeapAllocation) {
|
|
|
|
|
getMemoryManager()->freeGraphicsMemory(globalStatelessHeapAllocation);
|
|
|
|
|
globalStatelessHeapAllocation = nullptr;
|
|
|
|
|
}
|
2023-08-10 15:40:21 +00:00
|
|
|
for (auto &alloc : ownedPrivateAllocations) {
|
|
|
|
|
getMemoryManager()->freeGraphicsMemory(alloc.second);
|
|
|
|
|
}
|
|
|
|
|
ownedPrivateAllocations.clear();
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
WaitStatus CommandStreamReceiver::waitForCompletionWithTimeout(const WaitParams ¶ms, TaskCountType taskCountToWait) {
|
2023-11-30 08:32:25 +00:00
|
|
|
bool printWaitForCompletion = debugManager.flags.LogWaitingForCompletion.get();
|
2022-04-21 17:41:33 +00:00
|
|
|
if (printWaitForCompletion) {
|
|
|
|
|
printTagAddressContent(taskCountToWait, params.waitTimeout, true);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
TaskCountType latestSentTaskCount = this->latestFlushedTaskCount;
|
2017-12-21 00:45:38 +01:00
|
|
|
if (latestSentTaskCount < taskCountToWait) {
|
2019-11-24 14:50:41 +01:00
|
|
|
if (!this->flushBatchedSubmissions()) {
|
2022-01-20 16:56:19 +00:00
|
|
|
const auto isGpuHang{isGpuHangDetected()};
|
2023-12-01 09:12:59 +00:00
|
|
|
return isGpuHang ? WaitStatus::gpuHang : WaitStatus::notReady;
|
2019-11-24 14:50:41 +01:00
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2022-04-21 17:41:33 +00:00
|
|
|
auto retCode = baseWaitFunction(getTagAddress(), params, taskCountToWait);
|
|
|
|
|
if (printWaitForCompletion) {
|
|
|
|
|
printTagAddressContent(taskCountToWait, params.waitTimeout, false);
|
|
|
|
|
}
|
|
|
|
|
return retCode;
|
2021-10-07 18:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
2022-09-19 10:20:14 +00:00
|
|
|
bool CommandStreamReceiver::checkGpuHangDetected(TimeType currentTime, TimeType &lastHangCheckTime) const {
|
|
|
|
|
std::chrono::microseconds elapsedTimeSinceGpuHangCheck = std::chrono::duration_cast<std::chrono::microseconds>(currentTime - lastHangCheckTime);
|
|
|
|
|
|
|
|
|
|
if (elapsedTimeSinceGpuHangCheck.count() >= gpuHangCheckPeriod.count()) {
|
|
|
|
|
lastHangCheckTime = currentTime;
|
|
|
|
|
if (isGpuHangDetected()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
WaitStatus CommandStreamReceiver::baseWaitFunction(volatile TagAddressType *pollAddress, const WaitParams ¶ms, TaskCountType taskCountToWait) {
|
2022-01-20 16:56:19 +00:00
|
|
|
std::chrono::high_resolution_clock::time_point waitStartTime, lastHangCheckTime, currentTime;
|
2021-10-07 18:09:36 +00:00
|
|
|
int64_t timeDiff = 0;
|
|
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
TaskCountType latestSentTaskCount = this->latestFlushedTaskCount;
|
2021-10-28 09:21:44 +00:00
|
|
|
if (latestSentTaskCount < taskCountToWait) {
|
2023-12-13 09:17:24 +00:00
|
|
|
if (this->flushTagUpdate() != NEO::SubmissionStatus::success) {
|
2023-12-01 09:12:59 +00:00
|
|
|
return WaitStatus::notReady;
|
2023-03-15 15:10:06 +00:00
|
|
|
}
|
2021-10-28 09:21:44 +00:00
|
|
|
}
|
2022-11-22 13:53:59 +00:00
|
|
|
volatile TagAddressType *partitionAddress = pollAddress;
|
2021-10-28 09:21:44 +00:00
|
|
|
|
2022-01-20 16:56:19 +00:00
|
|
|
waitStartTime = std::chrono::high_resolution_clock::now();
|
|
|
|
|
lastHangCheckTime = waitStartTime;
|
2021-09-17 13:05:26 +00:00
|
|
|
for (uint32_t i = 0; i < activePartitions; i++) {
|
2022-03-23 14:36:07 +00:00
|
|
|
while (*partitionAddress < taskCountToWait && timeDiff <= params.waitTimeout) {
|
2022-04-19 11:43:40 +00:00
|
|
|
this->downloadTagAllocation(taskCountToWait);
|
|
|
|
|
|
2022-03-23 14:36:07 +00:00
|
|
|
if (!params.indefinitelyPoll && WaitUtils::waitFunction(partitionAddress, taskCountToWait)) {
|
2021-09-06 22:29:47 +00:00
|
|
|
break;
|
|
|
|
|
}
|
2019-02-21 10:27:31 +01:00
|
|
|
|
2022-01-20 16:56:19 +00:00
|
|
|
currentTime = std::chrono::high_resolution_clock::now();
|
2022-09-19 10:20:14 +00:00
|
|
|
if (checkGpuHangDetected(currentTime, lastHangCheckTime)) {
|
2023-12-01 09:12:59 +00:00
|
|
|
return WaitStatus::gpuHang;
|
2022-01-20 16:56:19 +00:00
|
|
|
}
|
|
|
|
|
|
2022-03-23 14:36:07 +00:00
|
|
|
if (params.enableTimeout) {
|
2022-01-20 16:56:19 +00:00
|
|
|
timeDiff = std::chrono::duration_cast<std::chrono::microseconds>(currentTime - waitStartTime).count();
|
2021-09-06 22:29:47 +00:00
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
2021-09-06 22:29:47 +00:00
|
|
|
|
2023-06-06 15:11:09 +00:00
|
|
|
partitionAddress = ptrOffset(partitionAddress, this->immWritePostSyncWriteOffset);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
2021-09-03 11:42:31 +00:00
|
|
|
|
2022-03-17 09:43:17 +00:00
|
|
|
partitionAddress = pollAddress;
|
|
|
|
|
for (uint32_t i = 0; i < activePartitions; i++) {
|
|
|
|
|
if (*partitionAddress < taskCountToWait) {
|
2023-12-01 09:12:59 +00:00
|
|
|
return WaitStatus::notReady;
|
2022-03-17 09:43:17 +00:00
|
|
|
}
|
2023-06-06 15:11:09 +00:00
|
|
|
partitionAddress = ptrOffset(partitionAddress, this->immWritePostSyncWriteOffset);
|
2022-03-17 09:43:17 +00:00
|
|
|
}
|
|
|
|
|
|
2023-12-01 09:12:59 +00:00
|
|
|
return WaitStatus::ready;
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CommandStreamReceiver::setTagAllocation(GraphicsAllocation *allocation) {
|
|
|
|
|
this->tagAllocation = allocation;
|
2019-07-22 21:28:59 +02:00
|
|
|
UNRECOVERABLE_IF(allocation == nullptr);
|
2022-11-22 13:53:59 +00:00
|
|
|
this->tagAddress = reinterpret_cast<TagAddressType *>(allocation->getUnderlyingBuffer());
|
2020-04-30 17:12:01 +02:00
|
|
|
this->debugPauseStateAddress = reinterpret_cast<DebugPauseState *>(
|
2022-12-06 07:32:34 +00:00
|
|
|
reinterpret_cast<uint8_t *>(allocation->getUnderlyingBuffer()) + TagAllocationLayout::debugPauseStateAddressOffset);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-11 14:23:53 +00:00
|
|
|
MultiGraphicsAllocation &CommandStreamReceiver::createTagsMultiAllocation() {
|
2022-04-07 13:09:40 +00:00
|
|
|
RootDeviceIndicesContainer rootDeviceIndices;
|
2021-02-25 09:38:48 +01:00
|
|
|
|
2023-06-12 13:52:45 +00:00
|
|
|
rootDeviceIndices.pushUnique(rootDeviceIndex);
|
2021-02-25 09:38:48 +01:00
|
|
|
|
2023-01-13 10:36:23 +00:00
|
|
|
auto maxRootDeviceIndex = static_cast<uint32_t>(this->executionEnvironment.rootDeviceEnvironments.size() - 1);
|
2021-02-25 09:38:48 +01:00
|
|
|
auto allocations = new MultiGraphicsAllocation(maxRootDeviceIndex);
|
|
|
|
|
|
2023-12-11 14:24:36 +00:00
|
|
|
AllocationProperties unifiedMemoryProperties{rootDeviceIndex, MemoryConstants::pageSize, AllocationType::tagBuffer, systemMemoryBitfield};
|
2021-02-25 09:38:48 +01:00
|
|
|
|
2021-03-11 14:23:53 +00:00
|
|
|
this->getMemoryManager()->createMultiGraphicsAllocationInSystemMemoryPool(rootDeviceIndices, unifiedMemoryProperties, *allocations);
|
2021-02-25 09:38:48 +01:00
|
|
|
return *allocations;
|
|
|
|
|
}
|
2023-01-13 10:36:23 +00:00
|
|
|
bool CommandStreamReceiver::ensureTagAllocationForRootDeviceIndex(uint32_t rootDeviceIndex) {
|
|
|
|
|
UNRECOVERABLE_IF(!tagsMultiAllocation);
|
|
|
|
|
if (rootDeviceIndex >= tagsMultiAllocation->getGraphicsAllocations().size()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (tagsMultiAllocation->getGraphicsAllocation(rootDeviceIndex)) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2023-12-11 14:24:36 +00:00
|
|
|
AllocationProperties allocationProperties{rootDeviceIndex, MemoryConstants::pageSize, AllocationType::tagBuffer, systemMemoryBitfield};
|
2023-01-13 10:36:23 +00:00
|
|
|
allocationProperties.flags.allocateMemory = false;
|
|
|
|
|
auto graphicsAllocation = this->getMemoryManager()->createGraphicsAllocationFromExistingStorage(allocationProperties, tagAllocation->getUnderlyingBuffer(), *tagsMultiAllocation);
|
|
|
|
|
if (!graphicsAllocation) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
tagsMultiAllocation->addAllocation(graphicsAllocation);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2021-02-25 09:38:48 +01:00
|
|
|
|
2019-07-10 07:57:54 +02:00
|
|
|
FlushStamp CommandStreamReceiver::obtainCurrentFlushStamp() const {
|
|
|
|
|
return flushStamp->peekStamp();
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-23 10:41:31 +00:00
|
|
|
void CommandStreamReceiver::setRequiredScratchSizes(uint32_t newRequiredScratchSlot0Size, uint32_t newRequiredScratchSlot1Size) {
|
|
|
|
|
if (newRequiredScratchSlot0Size > requiredScratchSlot0Size) {
|
|
|
|
|
requiredScratchSlot0Size = newRequiredScratchSlot0Size;
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
2024-01-23 10:41:31 +00:00
|
|
|
if (newRequiredScratchSlot1Size > requiredScratchSlot1Size) {
|
|
|
|
|
requiredScratchSlot1Size = newRequiredScratchSlot1Size;
|
2019-06-28 09:37:04 +02:00
|
|
|
}
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
2018-01-08 15:58:02 +01:00
|
|
|
|
2018-11-22 15:16:20 +01:00
|
|
|
GraphicsAllocation *CommandStreamReceiver::getScratchAllocation() {
|
2024-01-23 10:41:31 +00:00
|
|
|
return scratchSpaceController->getScratchSpaceSlot0Allocation();
|
2018-11-22 15:16:20 +01:00
|
|
|
}
|
|
|
|
|
|
2023-01-17 17:04:14 +00:00
|
|
|
void CommandStreamReceiver::overwriteFlatBatchBufferHelper(FlatBatchBufferHelper *newHelper) {
|
|
|
|
|
flatBatchBufferHelper.reset(newHelper);
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-12 20:33:03 +02:00
|
|
|
void CommandStreamReceiver::initProgrammingFlags() {
|
|
|
|
|
isPreambleSent = false;
|
2023-04-28 09:38:31 +00:00
|
|
|
gsbaFor32BitProgrammed = false;
|
2019-04-26 17:04:03 +02:00
|
|
|
bindingTableBaseAddressRequired = true;
|
2018-06-12 20:33:03 +02:00
|
|
|
mediaVfeStateDirty = true;
|
|
|
|
|
lastVmeSubslicesConfig = false;
|
2023-03-10 13:20:23 +00:00
|
|
|
stateComputeModeDirty = true;
|
2018-06-12 20:33:03 +02:00
|
|
|
|
|
|
|
|
lastSentL3Config = 0;
|
|
|
|
|
lastMediaSamplerConfig = -1;
|
|
|
|
|
lastPreemptionMode = PreemptionMode::Initial;
|
2023-02-02 18:57:24 +00:00
|
|
|
|
2023-02-10 17:54:13 +00:00
|
|
|
latestSentStatelessMocsConfig = CacheSettings::unknownMocs;
|
2023-02-02 18:57:24 +00:00
|
|
|
this->streamProperties.stateBaseAddress.statelessMocs = {};
|
2018-06-12 20:33:03 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-03 09:57:27 +02:00
|
|
|
void CommandStreamReceiver::programForAubSubCapture(bool wasActiveInPreviousEnqueue, bool isActive) {
|
|
|
|
|
if (!wasActiveInPreviousEnqueue && isActive) {
|
|
|
|
|
// force CSR reprogramming upon subcapture activation
|
|
|
|
|
this->initProgrammingFlags();
|
|
|
|
|
}
|
|
|
|
|
if (wasActiveInPreviousEnqueue && !isActive) {
|
|
|
|
|
// flush BB upon subcapture deactivation
|
|
|
|
|
this->flushBatchedSubmissions();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-11 11:19:21 +02:00
|
|
|
ResidencyContainer &CommandStreamReceiver::getResidencyAllocations() {
|
2018-09-13 15:49:38 +02:00
|
|
|
return this->residencyAllocations;
|
2018-09-11 11:19:21 +02:00
|
|
|
}
|
|
|
|
|
|
2018-09-12 10:44:35 +02:00
|
|
|
ResidencyContainer &CommandStreamReceiver::getEvictionAllocations() {
|
2018-09-13 15:49:38 +02:00
|
|
|
return this->evictionAllocations;
|
2018-09-12 10:44:35 +02:00
|
|
|
}
|
2023-09-04 09:42:02 +00:00
|
|
|
PrivateAllocsToReuseContainer &CommandStreamReceiver::getOwnedPrivateAllocations() {
|
2023-08-10 15:40:21 +00:00
|
|
|
return this->ownedPrivateAllocations;
|
|
|
|
|
}
|
2018-09-12 10:44:35 +02:00
|
|
|
|
2021-09-22 19:25:21 +00:00
|
|
|
AubSubCaptureStatus CommandStreamReceiver::checkAndActivateAubSubCapture(const std::string &kernelName) { return {false, false}; }
|
2018-06-12 20:33:03 +02:00
|
|
|
|
2019-04-01 09:33:19 +02:00
|
|
|
void CommandStreamReceiver::addAubComment(const char *comment) {}
|
|
|
|
|
|
2024-05-06 09:27:41 +00:00
|
|
|
bool CommandStreamReceiver::isTlbFlushRequiredForStateCacheFlush() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-29 15:31:51 +00:00
|
|
|
void CommandStreamReceiver::downloadAllocation(GraphicsAllocation &gfxAllocation) {
|
|
|
|
|
if (this->downloadAllocationImpl) {
|
|
|
|
|
this->downloadAllocationImpl(gfxAllocation);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-29 11:54:52 +00:00
|
|
|
void CommandStreamReceiver::startControllingDirectSubmissions() {
|
|
|
|
|
auto controller = this->executionEnvironment.directSubmissionController.get();
|
|
|
|
|
if (controller) {
|
2024-03-22 11:18:35 +00:00
|
|
|
controller->setTimeoutParamsForPlatform(this->getProductHelper());
|
2021-10-29 11:54:52 +00:00
|
|
|
controller->startControlling();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-06 16:13:06 +00:00
|
|
|
bool CommandStreamReceiver::enqueueWaitForPagingFence(uint64_t pagingFenceValue) {
|
|
|
|
|
auto controller = this->executionEnvironment.directSubmissionController.get();
|
|
|
|
|
if (this->isAnyDirectSubmissionEnabled() && controller) {
|
|
|
|
|
controller->enqueueWaitForPagingFence(this, pagingFenceValue);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-29 15:38:06 +00:00
|
|
|
void CommandStreamReceiver::drainPagingFenceQueue() {
|
|
|
|
|
auto controller = this->executionEnvironment.directSubmissionController.get();
|
|
|
|
|
if (this->isAnyDirectSubmissionEnabled() && controller) {
|
|
|
|
|
controller->drainPagingFenceQueue();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-21 12:58:30 +01:00
|
|
|
GraphicsAllocation *CommandStreamReceiver::allocateDebugSurface(size_t size) {
|
|
|
|
|
UNRECOVERABLE_IF(debugSurface != nullptr);
|
2024-05-06 19:17:52 +00:00
|
|
|
if (primaryCsr) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
2023-12-11 14:24:36 +00:00
|
|
|
debugSurface = getMemoryManager()->allocateGraphicsMemoryWithProperties({rootDeviceIndex, size, AllocationType::debugContextSaveArea, getOsContext().getDeviceBitfield()});
|
2018-03-21 12:58:30 +01:00
|
|
|
return debugSurface;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-02 18:57:24 +00:00
|
|
|
void *CommandStreamReceiver::getIndirectHeapCurrentPtr(IndirectHeapType heapType) const {
|
|
|
|
|
auto heap = indirectHeap[heapType];
|
|
|
|
|
if (heap) {
|
|
|
|
|
return heap->getSpace(0);
|
|
|
|
|
}
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-26 10:01:01 +02:00
|
|
|
IndirectHeap &CommandStreamReceiver::getIndirectHeap(IndirectHeap::Type heapType,
|
|
|
|
|
size_t minRequiredSize) {
|
2018-08-13 09:27:49 +02:00
|
|
|
DEBUG_BREAK_IF(static_cast<uint32_t>(heapType) >= arrayCount(indirectHeap));
|
2018-04-26 10:01:01 +02:00
|
|
|
auto &heap = indirectHeap[heapType];
|
|
|
|
|
GraphicsAllocation *heapMemory = nullptr;
|
|
|
|
|
|
|
|
|
|
if (heap)
|
|
|
|
|
heapMemory = heap->getGraphicsAllocation();
|
|
|
|
|
|
|
|
|
|
if (heap && heap->getAvailableSpace() < minRequiredSize && heapMemory) {
|
2018-10-24 14:25:04 +02:00
|
|
|
internalAllocationStorage->storeAllocation(std::unique_ptr<GraphicsAllocation>(heapMemory), REUSABLE_ALLOCATION);
|
2018-04-26 10:01:01 +02:00
|
|
|
heapMemory = nullptr;
|
2023-02-07 17:23:45 +00:00
|
|
|
this->heapStorageRequiresRecyclingTag = true;
|
2024-09-05 14:13:40 +00:00
|
|
|
|
|
|
|
|
if (this->peekRootDeviceEnvironment().getProductHelper().isDcFlushMitigated()) {
|
|
|
|
|
this->registerDcFlushForDcMitigation();
|
|
|
|
|
}
|
2018-04-26 10:01:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!heapMemory) {
|
|
|
|
|
allocateHeapMemory(heapType, minRequiredSize, heap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return *heap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CommandStreamReceiver::allocateHeapMemory(IndirectHeap::Type heapType,
|
|
|
|
|
size_t minRequiredSize, IndirectHeap *&indirectHeap) {
|
|
|
|
|
size_t reservedSize = 0;
|
2023-03-16 00:12:49 +00:00
|
|
|
auto finalHeapSize = HeapSize::getDefaultHeapSize(HeapSize::defaultHeapSize);
|
2023-12-13 16:09:52 +00:00
|
|
|
if (IndirectHeap::Type::surfaceState == heapType) {
|
2018-08-29 13:39:27 +02:00
|
|
|
finalHeapSize = defaultSshSize;
|
|
|
|
|
}
|
2024-09-18 11:20:14 +00:00
|
|
|
bool requireInternalHeap = IndirectHeap::Type::indirectObject == heapType ? canUse4GbHeaps() : false;
|
2018-04-26 10:01:01 +02:00
|
|
|
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.AddPatchInfoCommentsForAUBDump.get()) {
|
2018-04-26 10:01:01 +02:00
|
|
|
requireInternalHeap = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
minRequiredSize += reservedSize;
|
|
|
|
|
|
|
|
|
|
finalHeapSize = alignUp(std::max(finalHeapSize, minRequiredSize), MemoryConstants::pageSize);
|
2023-12-11 14:24:36 +00:00
|
|
|
auto allocationType = AllocationType::linearStream;
|
2019-02-01 13:49:24 +01:00
|
|
|
if (requireInternalHeap) {
|
2023-12-11 14:24:36 +00:00
|
|
|
allocationType = AllocationType::internalHeap;
|
2019-02-01 13:49:24 +01:00
|
|
|
}
|
|
|
|
|
auto heapMemory = internalAllocationStorage->obtainReusableAllocation(finalHeapSize, allocationType).release();
|
2018-04-26 10:01:01 +02:00
|
|
|
|
|
|
|
|
if (!heapMemory) {
|
2019-11-07 14:15:04 +01:00
|
|
|
heapMemory = getMemoryManager()->allocateGraphicsMemoryWithProperties({rootDeviceIndex, true, finalHeapSize, allocationType,
|
2019-12-10 12:16:07 +01:00
|
|
|
isMultiOsContextCapable(), false, osContext->getDeviceBitfield()});
|
2018-04-26 10:01:01 +02:00
|
|
|
} else {
|
|
|
|
|
finalHeapSize = std::max(heapMemory->getUnderlyingBufferSize(), finalHeapSize);
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-13 16:09:52 +00:00
|
|
|
if (IndirectHeap::Type::surfaceState == heapType) {
|
2018-08-29 13:39:27 +02:00
|
|
|
DEBUG_BREAK_IF(minRequiredSize > defaultSshSize - MemoryConstants::pageSize);
|
|
|
|
|
finalHeapSize = defaultSshSize - MemoryConstants::pageSize;
|
2018-04-26 10:01:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (indirectHeap) {
|
|
|
|
|
indirectHeap->replaceBuffer(heapMemory->getUnderlyingBuffer(), finalHeapSize);
|
|
|
|
|
indirectHeap->replaceGraphicsAllocation(heapMemory);
|
|
|
|
|
} else {
|
|
|
|
|
indirectHeap = new IndirectHeap(heapMemory, requireInternalHeap);
|
|
|
|
|
indirectHeap->overrideMaxSize(finalHeapSize);
|
|
|
|
|
}
|
2018-11-22 15:16:20 +01:00
|
|
|
scratchSpaceController->reserveHeap(heapType, indirectHeap);
|
2018-04-26 10:01:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CommandStreamReceiver::releaseIndirectHeap(IndirectHeap::Type heapType) {
|
2018-08-13 09:27:49 +02:00
|
|
|
DEBUG_BREAK_IF(static_cast<uint32_t>(heapType) >= arrayCount(indirectHeap));
|
2018-04-26 10:01:01 +02:00
|
|
|
auto &heap = indirectHeap[heapType];
|
|
|
|
|
|
|
|
|
|
if (heap) {
|
|
|
|
|
auto heapMemory = heap->getGraphicsAllocation();
|
|
|
|
|
if (heapMemory != nullptr)
|
2018-10-24 14:25:04 +02:00
|
|
|
internalAllocationStorage->storeAllocation(std::unique_ptr<GraphicsAllocation>(heapMemory), REUSABLE_ALLOCATION);
|
2018-04-26 10:01:01 +02:00
|
|
|
heap->replaceBuffer(nullptr, 0);
|
|
|
|
|
heap->replaceGraphicsAllocation(nullptr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-17 11:31:08 +02:00
|
|
|
void *CommandStreamReceiver::asyncDebugBreakConfirmation(void *arg) {
|
|
|
|
|
auto self = reinterpret_cast<CommandStreamReceiver *>(arg);
|
|
|
|
|
|
2020-11-06 13:01:29 +01:00
|
|
|
do {
|
2021-02-06 14:38:55 +00:00
|
|
|
auto debugPauseStateValue = DebugPauseState::waitingForUserStartConfirmation;
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.PauseOnGpuMode.get() != PauseOnGpuProperties::PauseMode::AfterWorkload) {
|
2021-02-06 14:38:55 +00:00
|
|
|
do {
|
|
|
|
|
{
|
|
|
|
|
std::unique_lock<SpinLock> lock{self->debugPauseStateLock};
|
|
|
|
|
debugPauseStateValue = *self->debugPauseStateAddress;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (debugPauseStateValue == DebugPauseState::terminate) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
std::this_thread::yield();
|
|
|
|
|
} while (debugPauseStateValue != DebugPauseState::waitingForUserStartConfirmation);
|
|
|
|
|
std::cout << "Debug break: Press enter to start workload" << std::endl;
|
|
|
|
|
self->debugConfirmationFunction();
|
|
|
|
|
debugPauseStateValue = DebugPauseState::hasUserStartConfirmation;
|
|
|
|
|
{
|
|
|
|
|
std::unique_lock<SpinLock> lock{self->debugPauseStateLock};
|
|
|
|
|
*self->debugPauseStateAddress = debugPauseStateValue;
|
|
|
|
|
}
|
2021-02-12 11:49:34 +01:00
|
|
|
}
|
|
|
|
|
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.PauseOnGpuMode.get() != PauseOnGpuProperties::PauseMode::BeforeWorkload) {
|
2021-02-06 14:38:55 +00:00
|
|
|
do {
|
|
|
|
|
{
|
|
|
|
|
std::unique_lock<SpinLock> lock{self->debugPauseStateLock};
|
|
|
|
|
debugPauseStateValue = *self->debugPauseStateAddress;
|
|
|
|
|
}
|
|
|
|
|
if (debugPauseStateValue == DebugPauseState::terminate) {
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
std::this_thread::yield();
|
|
|
|
|
} while (debugPauseStateValue != DebugPauseState::waitingForUserEndConfirmation);
|
|
|
|
|
|
|
|
|
|
std::cout << "Debug break: Workload ended, press enter to continue" << std::endl;
|
|
|
|
|
self->debugConfirmationFunction();
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
std::unique_lock<SpinLock> lock{self->debugPauseStateLock};
|
|
|
|
|
*self->debugPauseStateAddress = DebugPauseState::hasUserEndConfirmation;
|
|
|
|
|
}
|
2021-02-12 11:49:34 +01:00
|
|
|
}
|
2023-11-30 08:32:25 +00:00
|
|
|
} while (debugManager.flags.PauseOnEnqueue.get() == PauseOnGpuProperties::DebugFlagValues::OnEachEnqueue || debugManager.flags.PauseOnBlitCopy.get() == PauseOnGpuProperties::DebugFlagValues::OnEachEnqueue);
|
2020-06-17 11:31:08 +02:00
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-16 17:11:43 +02:00
|
|
|
bool CommandStreamReceiver::initializeTagAllocation() {
|
2021-03-11 14:23:53 +00:00
|
|
|
this->tagsMultiAllocation = &this->createTagsMultiAllocation();
|
2021-02-25 09:38:48 +01:00
|
|
|
|
|
|
|
|
auto tagAllocation = tagsMultiAllocation->getGraphicsAllocation(rootDeviceIndex);
|
2018-07-16 17:11:43 +02:00
|
|
|
if (!tagAllocation) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this->setTagAllocation(tagAllocation);
|
2023-11-30 08:32:25 +00:00
|
|
|
auto initValue = debugManager.flags.EnableNullHardware.get() ? static_cast<uint32_t>(-1) : initialHardwareTag;
|
2021-10-07 18:09:36 +00:00
|
|
|
auto tagAddress = this->tagAddress;
|
2022-12-06 07:32:34 +00:00
|
|
|
auto completionFence = reinterpret_cast<TaskCountType *>(getCompletionAddress());
|
|
|
|
|
UNRECOVERABLE_IF(!completionFence);
|
2021-10-07 18:09:36 +00:00
|
|
|
uint32_t subDevices = static_cast<uint32_t>(this->deviceBitfield.count());
|
|
|
|
|
for (uint32_t i = 0; i < subDevices; i++) {
|
|
|
|
|
*tagAddress = initValue;
|
2023-06-06 15:11:09 +00:00
|
|
|
tagAddress = ptrOffset(tagAddress, this->immWritePostSyncWriteOffset);
|
2022-12-06 07:32:34 +00:00
|
|
|
*completionFence = 0;
|
2023-06-06 15:11:09 +00:00
|
|
|
completionFence = ptrOffset(completionFence, this->immWritePostSyncWriteOffset);
|
2021-10-07 18:09:36 +00:00
|
|
|
}
|
2023-11-30 08:32:25 +00:00
|
|
|
*this->debugPauseStateAddress = debugManager.flags.EnableNullHardware.get() ? DebugPauseState::disabled : DebugPauseState::waitingForFirstSemaphore;
|
2020-04-30 17:12:01 +02:00
|
|
|
|
2023-11-30 08:32:25 +00:00
|
|
|
PRINT_DEBUG_STRING(debugManager.flags.PrintTagAllocationAddress.get(), stdout,
|
2020-09-25 09:49:10 +02:00
|
|
|
"\nCreated tag allocation %p for engine %u\n",
|
|
|
|
|
this->tagAddress, static_cast<uint32_t>(osContext->getEngineType()));
|
|
|
|
|
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.PauseOnEnqueue.get() != -1 || debugManager.flags.PauseOnBlitCopy.get() != -1) {
|
2024-08-21 14:19:13 +00:00
|
|
|
userPauseConfirmation = Thread::createFunc(CommandStreamReceiver::asyncDebugBreakConfirmation, reinterpret_cast<void *>(this));
|
2020-04-30 17:12:01 +02:00
|
|
|
}
|
2018-07-31 14:27:26 +02:00
|
|
|
|
2023-02-06 10:12:34 +00:00
|
|
|
this->barrierCountTagAddress = ptrOffset(this->tagAddress, TagAllocationLayout::barrierCountOffset);
|
|
|
|
|
|
2018-07-16 17:11:43 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-16 17:04:00 +00:00
|
|
|
bool CommandStreamReceiver::createWorkPartitionAllocation(const Device &device) {
|
|
|
|
|
if (!staticWorkPartitioningEnabled) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2021-08-31 16:49:46 +00:00
|
|
|
UNRECOVERABLE_IF(device.getNumGenericSubDevices() < 2);
|
2021-02-16 17:04:00 +00:00
|
|
|
|
2023-12-11 14:24:36 +00:00
|
|
|
AllocationProperties properties{this->rootDeviceIndex, true, 4096u, AllocationType::workPartitionSurface, true, false, deviceBitfield};
|
2021-02-16 17:04:00 +00:00
|
|
|
this->workPartitionAllocation = getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
|
|
|
|
if (this->workPartitionAllocation == nullptr) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-10 18:32:25 +00:00
|
|
|
uint32_t logicalId = 0;
|
2024-10-01 12:41:04 +00:00
|
|
|
auto copySrc = std::make_unique<std::array<uint32_t, 2>>();
|
2021-02-16 17:04:00 +00:00
|
|
|
for (uint32_t deviceIndex = 0; deviceIndex < deviceBitfield.size(); deviceIndex++) {
|
|
|
|
|
if (!deviceBitfield.test(deviceIndex)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-01 12:41:04 +00:00
|
|
|
*copySrc = {logicalId++, deviceIndex};
|
2021-02-16 17:04:00 +00:00
|
|
|
DeviceBitfield copyBitfield{};
|
|
|
|
|
copyBitfield.set(deviceIndex);
|
2024-10-01 12:41:04 +00:00
|
|
|
auto copySuccess = MemoryTransferHelper::transferMemoryToAllocationBanks(device, workPartitionAllocation, 0, copySrc.get(), 2 * sizeof(uint32_t), copyBitfield);
|
2021-02-16 17:04:00 +00:00
|
|
|
|
2021-10-21 11:16:19 +00:00
|
|
|
if (!copySuccess) {
|
2021-02-16 17:04:00 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-05 20:00:08 +01:00
|
|
|
bool CommandStreamReceiver::createGlobalFenceAllocation() {
|
2022-12-09 14:37:32 +00:00
|
|
|
auto &gfxCoreHelper = getGfxCoreHelper();
|
|
|
|
|
auto &hwInfo = peekHwInfo();
|
2022-12-08 12:22:35 +00:00
|
|
|
if (!gfxCoreHelper.isFenceAllocationRequired(hwInfo)) {
|
2020-02-05 20:00:08 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
2020-02-13 13:28:21 +01:00
|
|
|
|
2020-02-05 20:00:08 +01:00
|
|
|
DEBUG_BREAK_IF(this->globalFenceAllocation != nullptr);
|
2023-12-11 14:24:36 +00:00
|
|
|
this->globalFenceAllocation = getMemoryManager()->allocateGraphicsMemoryWithProperties({rootDeviceIndex, MemoryConstants::pageSize, AllocationType::globalFence, osContext->getDeviceBitfield()});
|
2020-02-05 20:00:08 +01:00
|
|
|
return this->globalFenceAllocation != nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-27 21:33:05 +02:00
|
|
|
bool CommandStreamReceiver::createPreemptionAllocation() {
|
2024-10-08 11:48:13 +00:00
|
|
|
auto &rootDeviceEnvironment = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex];
|
|
|
|
|
if (EngineHelpers::isBcs(osContext->getEngineType()) || rootDeviceEnvironment->debugger.get()) {
|
2024-01-18 14:21:34 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
2024-10-08 11:48:13 +00:00
|
|
|
auto hwInfo = rootDeviceEnvironment->getHardwareInfo();
|
2022-12-09 14:37:32 +00:00
|
|
|
auto &gfxCoreHelper = getGfxCoreHelper();
|
2021-04-16 14:14:03 +02:00
|
|
|
size_t preemptionSurfaceSize = hwInfo->capabilityTable.requiredPreemptionSurfaceSize;
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.OverrideCsrAllocationSize.get() > 0) {
|
|
|
|
|
preemptionSurfaceSize = debugManager.flags.OverrideCsrAllocationSize.get();
|
2021-04-16 14:14:03 +02:00
|
|
|
}
|
2023-12-11 14:24:36 +00:00
|
|
|
AllocationProperties properties{rootDeviceIndex, true, preemptionSurfaceSize, AllocationType::preemption, isMultiOsContextCapable(), false, deviceBitfield};
|
2021-11-25 09:31:14 +00:00
|
|
|
properties.flags.uncacheable = hwInfo->workaroundTable.flags.waCSRUncachable;
|
2022-12-09 14:37:32 +00:00
|
|
|
properties.alignment = gfxCoreHelper.getPreemptionAllocationAlignment();
|
2019-06-27 21:33:05 +02:00
|
|
|
this->preemptionAllocation = getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
|
|
|
|
return this->preemptionAllocation != nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-06 14:55:04 +02:00
|
|
|
std::unique_lock<CommandStreamReceiver::MutexType> CommandStreamReceiver::obtainUniqueOwnership() {
|
|
|
|
|
return std::unique_lock<CommandStreamReceiver::MutexType>(this->ownershipMutex);
|
|
|
|
|
}
|
2021-10-06 19:34:44 +02:00
|
|
|
std::unique_lock<CommandStreamReceiver::MutexType> CommandStreamReceiver::obtainHostPtrSurfaceCreationLock() {
|
|
|
|
|
return std::unique_lock<CommandStreamReceiver::MutexType>(this->hostPtrSurfaceCreationMutex);
|
|
|
|
|
}
|
2018-10-29 12:26:58 +00:00
|
|
|
AllocationsList &CommandStreamReceiver::getTemporaryAllocations() { return internalAllocationStorage->getTemporaryAllocations(); }
|
|
|
|
|
AllocationsList &CommandStreamReceiver::getAllocationsForReuse() { return internalAllocationStorage->getAllocationsForReuse(); }
|
2022-07-13 15:05:42 +00:00
|
|
|
AllocationsList &CommandStreamReceiver::getDeferredAllocations() { return internalAllocationStorage->getDeferredAllocations(); }
|
2018-08-06 14:55:04 +02:00
|
|
|
|
2019-03-12 12:00:41 +01:00
|
|
|
bool CommandStreamReceiver::createAllocationForHostSurface(HostPtrSurface &surface, bool requiresL3Flush) {
|
2021-10-06 19:34:44 +02:00
|
|
|
std::unique_lock<decltype(hostPtrSurfaceCreationMutex)> lock = this->obtainHostPtrSurfaceCreationLock();
|
2023-12-11 14:24:36 +00:00
|
|
|
auto allocation = internalAllocationStorage->obtainTemporaryAllocationWithPtr(surface.getSurfaceSize(), surface.getMemoryPointer(), AllocationType::externalHostPtr);
|
2020-04-15 13:39:09 +02:00
|
|
|
|
|
|
|
|
if (allocation == nullptr) {
|
|
|
|
|
auto memoryManager = getMemoryManager();
|
|
|
|
|
AllocationProperties properties{rootDeviceIndex,
|
|
|
|
|
false, // allocateMemory
|
2023-12-11 14:24:36 +00:00
|
|
|
surface.getSurfaceSize(), AllocationType::externalHostPtr,
|
2020-04-15 13:39:09 +02:00
|
|
|
false, // isMultiStorageAllocation
|
|
|
|
|
osContext->getDeviceBitfield()};
|
|
|
|
|
properties.flags.flushL3RequiredForRead = properties.flags.flushL3RequiredForWrite = requiresL3Flush;
|
|
|
|
|
allocation.reset(memoryManager->allocateGraphicsMemoryWithProperties(properties, surface.getMemoryPointer()));
|
|
|
|
|
if (allocation == nullptr && surface.peekIsPtrCopyAllowed()) {
|
|
|
|
|
// Try with no host pointer allocation and copy
|
2020-09-30 22:21:42 -07:00
|
|
|
allocation.reset(memoryManager->allocateInternalGraphicsMemoryWithHostCopy(rootDeviceIndex,
|
|
|
|
|
internalAllocationStorage->getDeviceBitfield(),
|
|
|
|
|
surface.getMemoryPointer(),
|
|
|
|
|
surface.getSurfaceSize()));
|
2018-10-29 10:38:53 +01:00
|
|
|
}
|
|
|
|
|
}
|
2020-04-15 13:39:09 +02:00
|
|
|
|
2018-10-29 10:38:53 +01:00
|
|
|
if (allocation == nullptr) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2022-05-05 12:01:59 +00:00
|
|
|
allocation->hostPtrTaskCountAssignment++;
|
|
|
|
|
allocation->updateTaskCount(0u, osContext->getContextId());
|
2020-04-15 13:39:09 +02:00
|
|
|
surface.setAllocation(allocation.get());
|
|
|
|
|
internalAllocationStorage->storeAllocation(std::move(allocation), TEMPORARY_ALLOCATION);
|
2018-10-29 10:38:53 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-24 18:21:13 +00:00
|
|
|
TagAllocatorBase *CommandStreamReceiver::getEventTsAllocator() {
|
2018-11-27 13:07:41 +01:00
|
|
|
if (profilingTimeStampAllocator.get() == nullptr) {
|
2022-04-07 13:09:40 +00:00
|
|
|
RootDeviceIndicesContainer rootDeviceIndices = {rootDeviceIndex};
|
2021-05-12 18:48:41 +00:00
|
|
|
profilingTimeStampAllocator = std::make_unique<TagAllocator<HwTimeStamps>>(rootDeviceIndices, getMemoryManager(), getPreferredTagPoolSize(), MemoryConstants::cacheLineSize,
|
2024-12-16 11:01:27 +00:00
|
|
|
sizeof(HwTimeStamps), 0, false, true, osContext->getDeviceBitfield());
|
2018-11-27 13:07:41 +01:00
|
|
|
}
|
|
|
|
|
return profilingTimeStampAllocator.get();
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-24 18:21:13 +00:00
|
|
|
TagAllocatorBase *CommandStreamReceiver::getEventPerfCountAllocator(const uint32_t tagSize) {
|
2018-11-27 13:07:41 +01:00
|
|
|
if (perfCounterAllocator.get() == nullptr) {
|
2022-04-07 13:09:40 +00:00
|
|
|
RootDeviceIndicesContainer rootDeviceIndices = {rootDeviceIndex};
|
2019-12-02 08:37:42 +01:00
|
|
|
perfCounterAllocator = std::make_unique<TagAllocator<HwPerfCounter>>(
|
2024-12-16 11:01:27 +00:00
|
|
|
rootDeviceIndices, getMemoryManager(), getPreferredTagPoolSize(), MemoryConstants::cacheLineSize, tagSize, 0, false, true, osContext->getDeviceBitfield());
|
2018-11-27 13:07:41 +01:00
|
|
|
}
|
|
|
|
|
return perfCounterAllocator.get();
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-03 10:52:12 +01:00
|
|
|
size_t CommandStreamReceiver::getPreferredTagPoolSize() const {
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.DisableTimestampPacketOptimizations.get()) {
|
2020-02-03 10:52:12 +01:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-26 17:03:23 +02:00
|
|
|
return 2048;
|
2020-02-03 10:52:12 +01:00
|
|
|
}
|
|
|
|
|
|
2020-03-19 13:48:13 +01:00
|
|
|
bool CommandStreamReceiver::expectMemory(const void *gfxAddress, const void *srcAddress,
|
|
|
|
|
size_t length, uint32_t compareOperation) {
|
2019-03-28 18:28:23 +01:00
|
|
|
auto isMemoryEqual = (memcmp(gfxAddress, srcAddress, length) == 0);
|
2019-12-27 11:32:12 +01:00
|
|
|
auto isEqualMemoryExpected = (compareOperation == AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareEqual);
|
2019-03-28 18:28:23 +01:00
|
|
|
|
2020-03-19 13:48:13 +01:00
|
|
|
return (isMemoryEqual == isEqualMemoryExpected);
|
2018-11-28 15:32:13 +01:00
|
|
|
}
|
|
|
|
|
|
2021-10-06 12:42:30 +00:00
|
|
|
bool CommandStreamReceiver::needsPageTableManager() const {
|
2020-02-12 11:27:28 +01:00
|
|
|
auto hwInfo = executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
|
2022-12-15 12:13:57 +00:00
|
|
|
auto &productHelper = getProductHelper();
|
2021-09-29 15:59:41 +00:00
|
|
|
|
|
|
|
|
if (pageTableManager.get() != nullptr) {
|
2019-12-27 11:32:12 +01:00
|
|
|
return false;
|
|
|
|
|
}
|
2022-12-15 12:13:57 +00:00
|
|
|
return productHelper.isPageTableManagerSupported(*hwInfo);
|
2019-12-27 11:32:12 +01:00
|
|
|
}
|
|
|
|
|
|
2020-04-30 13:24:34 +02:00
|
|
|
void CommandStreamReceiver::printDeviceIndex() {
|
2023-11-30 08:32:25 +00:00
|
|
|
if (debugManager.flags.PrintDeviceAndEngineIdOnSubmission.get()) {
|
2022-02-11 16:28:08 +00:00
|
|
|
printf("%u: Submission to RootDevice Index: %u, Sub-Devices Mask: %lu, EngineId: %u (%s, %s)\n",
|
|
|
|
|
SysCalls::getProcessId(),
|
2021-06-22 16:07:47 +00:00
|
|
|
this->getRootDeviceIndex(),
|
|
|
|
|
this->osContext->getDeviceBitfield().to_ulong(),
|
|
|
|
|
this->osContext->getEngineType(),
|
|
|
|
|
EngineHelpers::engineTypeToString(this->osContext->getEngineType()).c_str(),
|
|
|
|
|
EngineHelpers::engineUsageToString(this->osContext->getEngineUsage()).c_str());
|
2020-04-30 13:24:34 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-30 06:31:25 +00:00
|
|
|
void CommandStreamReceiver::checkForNewResources(TaskCountType submittedTaskCount, TaskCountType allocationTaskCount, GraphicsAllocation &gfxAllocation) {
|
|
|
|
|
if (useNewResourceImplicitFlush) {
|
|
|
|
|
if (allocationTaskCount == GraphicsAllocation::objectNotUsed && !GraphicsAllocation::isIsaAllocationType(gfxAllocation.getAllocationType())) {
|
|
|
|
|
newResources = true;
|
|
|
|
|
if (debugManager.flags.ProvideVerboseImplicitFlush.get()) {
|
|
|
|
|
printf("New resource detected of type %llu\n", static_cast<unsigned long long>(gfxAllocation.getAllocationType()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-22 16:29:34 +02:00
|
|
|
bool CommandStreamReceiver::checkImplicitFlushForGpuIdle() {
|
|
|
|
|
if (useGpuIdleImplicitFlush) {
|
2023-01-16 13:58:53 +00:00
|
|
|
if (this->taskCount == *getTagAddress()) {
|
2020-09-22 16:29:34 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
void CommandStreamReceiver::downloadTagAllocation(TaskCountType taskCountToWait) {
|
2022-03-29 15:31:51 +00:00
|
|
|
if (this->getTagAllocation()) {
|
2022-04-12 16:07:22 +00:00
|
|
|
if (taskCountToWait && taskCountToWait <= this->peekLatestFlushedTaskCount()) {
|
|
|
|
|
this->downloadAllocation(*this->getTagAllocation());
|
|
|
|
|
}
|
2022-03-29 15:31:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
bool CommandStreamReceiver::testTaskCountReady(volatile TagAddressType *pollAddress, TaskCountType taskCountToWait) {
|
2022-04-12 16:07:22 +00:00
|
|
|
this->downloadTagAllocation(taskCountToWait);
|
2021-10-12 22:08:25 +00:00
|
|
|
for (uint32_t i = 0; i < activePartitions; i++) {
|
2022-03-17 09:43:17 +00:00
|
|
|
if (!WaitUtils::waitFunction(pollAddress, taskCountToWait)) {
|
2021-10-12 22:08:25 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-06 15:11:09 +00:00
|
|
|
pollAddress = ptrOffset(pollAddress, this->immWritePostSyncWriteOffset);
|
2021-10-12 22:08:25 +00:00
|
|
|
}
|
2023-07-25 08:51:03 +00:00
|
|
|
|
2024-08-22 14:04:53 +00:00
|
|
|
downloadAllocations(true);
|
2023-07-25 08:51:03 +00:00
|
|
|
|
2021-10-12 22:08:25 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-11 19:41:57 +00:00
|
|
|
const HardwareInfo &CommandStreamReceiver::peekHwInfo() const {
|
2022-04-19 14:44:06 +00:00
|
|
|
return *peekRootDeviceEnvironment().getHardwareInfo();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const RootDeviceEnvironment &CommandStreamReceiver::peekRootDeviceEnvironment() const {
|
|
|
|
|
return *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex];
|
2022-01-11 19:41:57 +00:00
|
|
|
}
|
|
|
|
|
|
2022-12-09 14:37:32 +00:00
|
|
|
const GfxCoreHelper &CommandStreamReceiver::getGfxCoreHelper() const {
|
|
|
|
|
return peekRootDeviceEnvironment().getHelper<GfxCoreHelper>();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-15 12:13:57 +00:00
|
|
|
const ProductHelper &CommandStreamReceiver::getProductHelper() const {
|
|
|
|
|
return peekRootDeviceEnvironment().getHelper<ProductHelper>();
|
|
|
|
|
}
|
|
|
|
|
|
2023-05-12 14:49:39 +00:00
|
|
|
const ReleaseHelper *CommandStreamReceiver::getReleaseHelper() const {
|
|
|
|
|
return peekRootDeviceEnvironment().getReleaseHelper();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
TaskCountType CommandStreamReceiver::getCompletionValue(const GraphicsAllocation &gfxAllocation) {
|
2022-04-26 13:29:31 +00:00
|
|
|
if (completionFenceValuePointer) {
|
|
|
|
|
return *completionFenceValuePointer;
|
|
|
|
|
}
|
2022-04-20 11:26:46 +00:00
|
|
|
auto osContextId = osContext->getContextId();
|
|
|
|
|
return gfxAllocation.getTaskCount(osContextId);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-25 14:54:13 +00:00
|
|
|
bool CommandStreamReceiver::createPerDssBackedBuffer(Device &device) {
|
|
|
|
|
UNRECOVERABLE_IF(perDssBackedBuffer != nullptr);
|
|
|
|
|
auto size = RayTracingHelper::getTotalMemoryBackedFifoSize(device);
|
|
|
|
|
|
2023-12-11 14:24:36 +00:00
|
|
|
perDssBackedBuffer = getMemoryManager()->allocateGraphicsMemoryWithProperties({rootDeviceIndex, size, AllocationType::buffer, device.getDeviceBitfield()});
|
2022-04-25 14:54:13 +00:00
|
|
|
|
|
|
|
|
return perDssBackedBuffer != nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
void CommandStreamReceiver::printTagAddressContent(TaskCountType taskCountToWait, int64_t waitTimeout, bool start) {
|
2024-09-25 18:04:23 +00:00
|
|
|
if (getType() == NEO::CommandStreamReceiverType::aub) {
|
|
|
|
|
if (start) {
|
|
|
|
|
PRINT_DEBUG_STRING(true, stdout, "\nAub dump wait for task count %llu", taskCountToWait);
|
|
|
|
|
} else {
|
|
|
|
|
PRINT_DEBUG_STRING(true, stdout, "\nAub dump wait completed.");
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-04-21 17:41:33 +00:00
|
|
|
auto postSyncAddress = getTagAddress();
|
|
|
|
|
if (start) {
|
|
|
|
|
PRINT_DEBUG_STRING(true, stdout,
|
2022-11-29 09:35:05 +00:00
|
|
|
"\nWaiting for task count %llu at location %p with timeout %llx. Current value:",
|
2022-04-21 17:41:33 +00:00
|
|
|
taskCountToWait, postSyncAddress, waitTimeout);
|
|
|
|
|
} else {
|
|
|
|
|
PRINT_DEBUG_STRING(true, stdout,
|
|
|
|
|
"%s", "\nWaiting completed. Current value:");
|
|
|
|
|
}
|
2024-09-25 18:04:23 +00:00
|
|
|
|
2022-04-21 17:41:33 +00:00
|
|
|
for (uint32_t i = 0; i < activePartitions; i++) {
|
|
|
|
|
PRINT_DEBUG_STRING(true, stdout, " %u", *postSyncAddress);
|
2023-06-06 15:11:09 +00:00
|
|
|
postSyncAddress = ptrOffset(postSyncAddress, this->immWritePostSyncWriteOffset);
|
2022-04-21 17:41:33 +00:00
|
|
|
}
|
|
|
|
|
PRINT_DEBUG_STRING(true, stdout, "%s", "\n");
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-22 11:31:28 +00:00
|
|
|
bool CommandStreamReceiver::isTbxMode() const {
|
2024-04-09 12:43:12 +00:00
|
|
|
return (getType() == NEO::CommandStreamReceiverType::tbx || getType() == NEO::CommandStreamReceiverType::tbxWithAub);
|
2022-12-22 11:31:28 +00:00
|
|
|
}
|
|
|
|
|
|
2022-11-22 13:53:59 +00:00
|
|
|
TaskCountType CompletionStamp::getTaskCountFromSubmissionStatusError(SubmissionStatus status) {
|
2022-11-04 17:02:46 +00:00
|
|
|
switch (status) {
|
2023-12-13 09:17:24 +00:00
|
|
|
case SubmissionStatus::outOfHostMemory:
|
2022-11-04 17:02:46 +00:00
|
|
|
return CompletionStamp::outOfHostMemory;
|
2023-12-13 09:17:24 +00:00
|
|
|
case SubmissionStatus::outOfMemory:
|
2022-11-04 17:02:46 +00:00
|
|
|
return CompletionStamp::outOfDeviceMemory;
|
2023-12-13 09:17:24 +00:00
|
|
|
case SubmissionStatus::failed:
|
2023-03-13 02:56:47 +00:00
|
|
|
return CompletionStamp::failed;
|
2023-12-13 09:17:24 +00:00
|
|
|
case SubmissionStatus::unsupported:
|
2023-06-28 18:05:36 +00:00
|
|
|
return CompletionStamp::unsupported;
|
2022-11-04 17:02:46 +00:00
|
|
|
default:
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-06 10:12:34 +00:00
|
|
|
uint64_t CommandStreamReceiver::getBarrierCountGpuAddress() const { return ptrOffset(this->tagAllocation->getGpuAddress(), TagAllocationLayout::barrierCountOffset); }
|
2022-12-06 07:32:34 +00:00
|
|
|
uint64_t CommandStreamReceiver::getDebugPauseStateGPUAddress() const { return tagAllocation->getGpuAddress() + TagAllocationLayout::debugPauseStateAddressOffset; }
|
|
|
|
|
uint64_t CommandStreamReceiver::getCompletionAddress() const {
|
|
|
|
|
uint64_t completionFenceAddress = castToUint64(const_cast<TagAddressType *>(tagAddress));
|
|
|
|
|
if (completionFenceAddress == 0) {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
completionFenceAddress += TagAllocationLayout::completionFenceOffset;
|
|
|
|
|
return completionFenceAddress;
|
|
|
|
|
}
|
2023-01-17 17:04:14 +00:00
|
|
|
|
2023-03-06 20:33:50 +00:00
|
|
|
void CommandStreamReceiver::createGlobalStatelessHeap() {
|
|
|
|
|
if (this->globalStatelessHeapAllocation == nullptr) {
|
|
|
|
|
auto lock = obtainUniqueOwnership();
|
|
|
|
|
if (this->globalStatelessHeapAllocation == nullptr) {
|
|
|
|
|
constexpr size_t heapSize = 16 * MemoryConstants::kiloByte;
|
2023-12-11 14:24:36 +00:00
|
|
|
constexpr AllocationType allocationType = AllocationType::linearStream;
|
2023-03-06 20:33:50 +00:00
|
|
|
|
|
|
|
|
AllocationProperties properties{rootDeviceIndex, true, heapSize, allocationType,
|
|
|
|
|
isMultiOsContextCapable(), false, osContext->getDeviceBitfield()};
|
|
|
|
|
|
|
|
|
|
this->globalStatelessHeapAllocation = getMemoryManager()->allocateGraphicsMemoryWithProperties(properties);
|
|
|
|
|
|
|
|
|
|
this->globalStatelessHeap = std::make_unique<IndirectHeap>(this->globalStatelessHeapAllocation);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-30 20:03:12 +00:00
|
|
|
bool CommandStreamReceiver::isRayTracingStateProgramingNeeded(Device &device) const {
|
|
|
|
|
return device.getRTMemoryBackedBuffer() && getBtdCommandDirty();
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-25 07:58:39 +00:00
|
|
|
void CommandStreamReceiver::registerClient(void *client) {
|
|
|
|
|
std::unique_lock<MutexType> lock(registeredClientsMutex);
|
|
|
|
|
auto element = std::find(registeredClients.begin(), registeredClients.end(), client);
|
|
|
|
|
if (element == registeredClients.end()) {
|
|
|
|
|
registeredClients.push_back(client);
|
|
|
|
|
numClients++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CommandStreamReceiver::unregisterClient(void *client) {
|
|
|
|
|
std::unique_lock<MutexType> lock(registeredClientsMutex);
|
|
|
|
|
|
|
|
|
|
auto element = std::find(registeredClients.begin(), registeredClients.end(), client);
|
|
|
|
|
if (element != registeredClients.end()) {
|
|
|
|
|
registeredClients.erase(element);
|
|
|
|
|
numClients--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-01 19:44:16 +00:00
|
|
|
void CommandStreamReceiver::ensurePrimaryCsrInitialized(Device &device) {
|
|
|
|
|
auto csrToInitialize = primaryCsr ? primaryCsr : this;
|
|
|
|
|
csrToInitialize->initializeDeviceWithFirstSubmission(device);
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-22 10:25:49 +00:00
|
|
|
void CommandStreamReceiver::addToEvictionContainer(GraphicsAllocation &gfxAllocation) {
|
|
|
|
|
this->getEvictionAllocations().push_back(&gfxAllocation);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-17 17:04:14 +00:00
|
|
|
std::function<void()> CommandStreamReceiver::debugConfirmationFunction = []() { std::cin.get(); };
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|