1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
/*
* Copyright (C) 2019-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/aub/aub_helper.h"
#include "shared/source/aub_mem_dump/page_table_entry_bits.h"
#include "shared/source/command_stream/command_stream_receiver_simulated_common_hw.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/execution_environment/execution_environment.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/gmm_helper/gmm.h"
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/gmm_helper/resource_info.h"
#include "shared/source/helpers/aligned_memory.h"
#include "shared/source/helpers/basic_math.h"
#include "shared/source/helpers/hardware_context_controller.h"
#include "shared/source/memory_manager/address_mapper.h"
#include "shared/source/memory_manager/memory_manager.h"
#include "shared/source/os_interface/os_context.h"
#include "aubstream/aub_manager.h"
#include "aubstream/aubstream.h"
namespace NEO {
template <typename GfxFamily>
void CommandStreamReceiverSimulatedCommonHw<GfxFamily>::initAdditionalMMIO() {
if (debugManager.flags.AubDumpAddMmioRegistersList.get() != "unk") {
auto mmioList = AubHelper::getAdditionalMmioList();
for (auto &mmioPair : mmioList) {
stream->writeMMIO(mmioPair.first, mmioPair.second);
}
}
}
template <typename GfxFamily>
void CommandStreamReceiverSimulatedCommonHw<GfxFamily>::setupContext(OsContext &osContext) {
CommandStreamReceiverHw<GfxFamily>::setupContext(osContext);
auto engineType = osContext.getEngineType();
uint32_t flags = 0;
getCsTraits(engineType).setContextSaveRestoreFlags(flags);
if (osContext.isPartOfContextGroup()) {
constexpr uint32_t contextGroupBit = aub_stream::hardwareContextFlags::contextGroup;
flags |= contextGroupBit;
}
if (osContext.isHighPriority()) {
flags |= aub_stream::hardwareContextFlags::highPriority;
} else if (osContext.isLowPriority()) {
flags |= aub_stream::hardwareContextFlags::lowPriority;
}
if (debugManager.flags.AppendAubStreamContextFlags.get() != -1) {
flags |= static_cast<uint32_t>(debugManager.flags.AppendAubStreamContextFlags.get());
}
if (aubManager) {
hardwareContextController = std::make_unique<HardwareContextController>(*aubManager, osContext, flags);
}
}
template <typename GfxFamily>
bool CommandStreamReceiverSimulatedCommonHw<GfxFamily>::getParametersForMemory(GraphicsAllocation &graphicsAllocation, uint64_t &gpuAddress, void *&cpuAddress, size_t &size) const {
cpuAddress = graphicsAllocation.getUnderlyingBuffer();
gpuAddress = peekExecutionEnvironment().rootDeviceEnvironments[graphicsAllocation.getRootDeviceIndex()].get()->gmmHelper.get()->decanonize(graphicsAllocation.getGpuAddress());
size = graphicsAllocation.getUnderlyingBufferSize();
if (graphicsAllocation.isCompressionEnabled()) {
size = graphicsAllocation.getDefaultGmm()->gmmResourceInfo->getSizeAllocation();
}
if (size == 0)
return false;
if (cpuAddress == nullptr && graphicsAllocation.isAllocationLockable()) {
cpuAddress = this->getMemoryManager()->lockResource(&graphicsAllocation);
}
return true;
}
template <typename GfxFamily>
bool CommandStreamReceiverSimulatedCommonHw<GfxFamily>::expectMemoryEqual(void *gfxAddress, const void *srcAddress, size_t length) {
return this->expectMemory(gfxAddress, srcAddress, length,
AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareEqual);
}
template <typename GfxFamily>
bool CommandStreamReceiverSimulatedCommonHw<GfxFamily>::expectMemoryNotEqual(void *gfxAddress, const void *srcAddress, size_t length) {
return this->expectMemory(gfxAddress, srcAddress, length,
AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareNotEqual);
}
template <typename GfxFamily>
bool CommandStreamReceiverSimulatedCommonHw<GfxFamily>::expectMemoryCompressed(void *gfxAddress, const void *srcAddress, size_t length) {
return this->expectMemory(gfxAddress, srcAddress, length,
AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareNotEqual);
}
template <typename GfxFamily>
void CommandStreamReceiverSimulatedCommonHw<GfxFamily>::freeEngineInfo(AddressMapper >tRemap) {
alignedFree(engineInfo.pLRCA);
gttRemap.unmap(engineInfo.pLRCA);
engineInfo.pLRCA = nullptr;
alignedFree(engineInfo.pGlobalHWStatusPage);
gttRemap.unmap(engineInfo.pGlobalHWStatusPage);
engineInfo.pGlobalHWStatusPage = nullptr;
alignedFree(engineInfo.pRingBuffer);
gttRemap.unmap(engineInfo.pRingBuffer);
engineInfo.pRingBuffer = nullptr;
}
template <typename GfxFamily>
void CommandStreamReceiverSimulatedCommonHw<GfxFamily>::makeNonResident(GraphicsAllocation &gfxAllocation) {
if (gfxAllocation.isResident(osContext->getContextId())) {
dumpAllocation(gfxAllocation);
this->getEvictionAllocations().push_back(&gfxAllocation);
gfxAllocation.releaseResidencyInOsContext(this->osContext->getContextId());
}
}
template <typename GfxFamily>
uint32_t CommandStreamReceiverSimulatedCommonHw<GfxFamily>::getDeviceIndex() const {
return osContext->getDeviceBitfield().any() ? static_cast<uint32_t>(Math::log2(static_cast<uint32_t>(osContext->getDeviceBitfield().to_ulong()))) : 0u;
}
template <typename GfxFamily>
CommandStreamReceiverSimulatedCommonHw<GfxFamily>::CommandStreamReceiverSimulatedCommonHw(ExecutionEnvironment &executionEnvironment,
uint32_t rootDeviceIndex,
const DeviceBitfield deviceBitfield)
: CommandStreamReceiverHw<GfxFamily>(executionEnvironment, rootDeviceIndex, deviceBitfield),
releaseHelper(executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getReleaseHelper()) {
this->useNewResourceImplicitFlush = false;
this->useGpuIdleImplicitFlush = false;
}
template <typename GfxFamily>
CommandStreamReceiverSimulatedCommonHw<GfxFamily>::~CommandStreamReceiverSimulatedCommonHw() {
if (aubManager) {
if (hardwareContextController) {
for (auto &hardwareContext : hardwareContextController->hardwareContexts) {
aubManager->releaseHardwareContext(hardwareContext.release());
}
}
}
}
} // namespace NEO
|