diff --git a/runtime/aub/CMakeLists.txt b/runtime/aub/CMakeLists.txt index 1cc00fc102..20626cd3e4 100644 --- a/runtime/aub/CMakeLists.txt +++ b/runtime/aub/CMakeLists.txt @@ -22,6 +22,7 @@ set(RUNTIME_SRCS_AUB ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/aub_helper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/aub_helper.h + ${CMAKE_CURRENT_SOURCE_DIR}/aub_helper.inl ) target_sources(${NEO_STATIC_LIB_NAME} PRIVATE ${RUNTIME_SRCS_AUB}) set_property(GLOBAL PROPERTY RUNTIME_SRCS_AUB ${RUNTIME_SRCS_AUB}) diff --git a/runtime/aub/aub_helper.cpp b/runtime/aub/aub_helper.cpp index 9c5853a5f7..52849c65c2 100644 --- a/runtime/aub/aub_helper.cpp +++ b/runtime/aub/aub_helper.cpp @@ -32,5 +32,4 @@ int AubHelper::getMemTrace(uint64_t pdEntryBits) { uint64_t AubHelper::getPTEntryBits(uint64_t pdEntryBits) { return pdEntryBits; } - } // namespace OCLRT diff --git a/runtime/aub/aub_helper.h b/runtime/aub/aub_helper.h index 331785e684..25d8fafa7c 100644 --- a/runtime/aub/aub_helper.h +++ b/runtime/aub/aub_helper.h @@ -39,5 +39,37 @@ class AubHelper { } static int getMemTrace(uint64_t pdEntryBits); static uint64_t getPTEntryBits(uint64_t pdEntryBits); + + virtual int getDataHintForPml4Entry() const = 0; + virtual int getDataHintForPdpEntry() const = 0; + virtual int getDataHintForPdEntry() const = 0; + virtual int getDataHintForPtEntry() const = 0; + + virtual int getMemTraceForPml4Entry() const = 0; + virtual int getMemTraceForPdpEntry() const = 0; + virtual int getMemTraceForPdEntry() const = 0; + virtual int getMemTraceForPtEntry() const = 0; }; + +template +class AubHelperHw : public AubHelper { + public: + AubHelperHw(bool localMemoryEnabled) : localMemoryEnabled(localMemoryEnabled){}; + ~AubHelperHw() = default; + AubHelperHw(AubHelperHw &) = delete; + + int getDataHintForPml4Entry() const override; + int getDataHintForPdpEntry() const override; + int getDataHintForPdEntry() const override; + int getDataHintForPtEntry() const override; + + int getMemTraceForPml4Entry() const override; + int getMemTraceForPdpEntry() const override; + int getMemTraceForPdEntry() const override; + int getMemTraceForPtEntry() const override; + + protected: + bool localMemoryEnabled; +}; + } // namespace OCLRT diff --git a/runtime/aub/aub_helper.inl b/runtime/aub/aub_helper.inl new file mode 100644 index 0000000000..ec94e81c24 --- /dev/null +++ b/runtime/aub/aub_helper.inl @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2018, Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "runtime/aub_mem_dump/aub_mem_dump.h" + +namespace OCLRT { + +template +int AubHelperHw::getDataHintForPml4Entry() const { + return AubMemDump::DataTypeHintValues::TraceNotype; +} +template +int AubHelperHw::getDataHintForPdpEntry() const { + return AubMemDump::DataTypeHintValues::TraceNotype; +} +template +int AubHelperHw::getDataHintForPdEntry() const { + return AubMemDump::DataTypeHintValues::TraceNotype; +} +template +int AubHelperHw::getDataHintForPtEntry() const { + return AubMemDump::DataTypeHintValues::TraceNotype; +} + +template +int AubHelperHw::getMemTraceForPml4Entry() const { + if (localMemoryEnabled) { + return AubMemDump::AddressSpaceValues::TraceLocal; + } + return AubMemDump::AddressSpaceValues::TracePml4Entry; +} + +template +int AubHelperHw::getMemTraceForPdpEntry() const { + if (localMemoryEnabled) { + return AubMemDump::AddressSpaceValues::TraceLocal; + } + return AubMemDump::AddressSpaceValues::TracePhysicalPdpEntry; +} + +template +int AubHelperHw::getMemTraceForPdEntry() const { + if (localMemoryEnabled) { + return AubMemDump::AddressSpaceValues::TraceLocal; + } + return AubMemDump::AddressSpaceValues::TracePpgttPdEntry; +} + +template +int AubHelperHw::getMemTraceForPtEntry() const { + if (localMemoryEnabled) { + return AubMemDump::AddressSpaceValues::TraceLocal; + } + return AubMemDump::AddressSpaceValues::TracePpgttEntry; +} + +} // namespace OCLRT diff --git a/runtime/aub_mem_dump/aub_mem_dump.h b/runtime/aub_mem_dump/aub_mem_dump.h index 55f07dea4a..f0199018db 100644 --- a/runtime/aub_mem_dump/aub_mem_dump.h +++ b/runtime/aub_mem_dump/aub_mem_dump.h @@ -31,6 +31,10 @@ #include "runtime/aub_mem_dump/aub_data.h" +namespace OCLRT { +class AubHelper; +} + namespace AubMemDump { #include "aub_services.h" @@ -248,7 +252,9 @@ struct AubPageTableHelper32 : public AubPageTableHelper, PageTableTraits typedef AubPageTableHelper BaseClass; static void createContext(typename Traits::Stream &stream, uint32_t context); - static uint64_t reserveAddressPPGTT(typename Traits::Stream &stream, uintptr_t gfxAddress, size_t blockSize, uint64_t physAddress, uint64_t additionalBits); + static uint64_t reserveAddressPPGTT(typename Traits::Stream &stream, uintptr_t gfxAddress, + size_t blockSize, uint64_t physAddress, + uint64_t additionalBits, const OCLRT::AubHelper &aubHelper); static void fixupLRC(uint8_t *pLrc); }; @@ -262,7 +268,9 @@ struct AubPageTableHelper64 : public AubPageTableHelper, PageTableTraits } static void createContext(typename Traits::Stream &stream, uint32_t context); - static uint64_t reserveAddressPPGTT(typename Traits::Stream &stream, uintptr_t gfxAddress, size_t blockSize, uint64_t physAddress, uint64_t additionalBits); + static uint64_t reserveAddressPPGTT(typename Traits::Stream &stream, uintptr_t gfxAddress, + size_t blockSize, uint64_t physAddress, + uint64_t additionalBits, const OCLRT::AubHelper &aubHelper); static void fixupLRC(uint8_t *pLrc); }; @@ -296,7 +304,9 @@ struct AubDump : public TypeSelector, AubPageTabl static void addMemoryWrite(Stream &stream, uint64_t addr, const void *memory, size_t blockSize, int addressSpace, int hint = DataTypeHintValues::TraceNotype); static uint64_t reserveAddressGGTT(Stream &stream, uint32_t addr, size_t size, uint64_t physStart, AubGTTData data); static uint64_t reserveAddressGGTT(Stream &stream, const void *memory, size_t size, uint64_t physStart, AubGTTData data); - static void reserveAddressGGTTAndWriteMmeory(Stream &stream, uintptr_t gfxAddress, const void *memory, uint64_t physAddress, size_t size, size_t offset, uint64_t additionalBits); + static void reserveAddressGGTTAndWriteMmeory(Stream &stream, uintptr_t gfxAddress, const void *memory, uint64_t physAddress, + size_t size, size_t offset, uint64_t additionalBits, const OCLRT::AubHelper &aubHelper); + static void setGttEntry(MiGttEntry &entry, uint64_t address, AubGTTData data); private: diff --git a/runtime/aub_mem_dump/aub_mem_dump.inl b/runtime/aub_mem_dump/aub_mem_dump.inl index dd6e350d42..6aed2c2d4d 100644 --- a/runtime/aub_mem_dump/aub_mem_dump.inl +++ b/runtime/aub_mem_dump/aub_mem_dump.inl @@ -130,11 +130,14 @@ uint64_t AubDump::reserveAddressGGTT(typename Traits::Stream &stream, co } template -void AubDump::reserveAddressGGTTAndWriteMmeory(typename Traits::Stream &stream, uintptr_t gfxAddress, const void *memory, uint64_t physAddress, size_t size, size_t offset, uint64_t additionalBits) { +void AubDump::reserveAddressGGTTAndWriteMmeory(typename Traits::Stream &stream, uintptr_t gfxAddress, + const void *memory, uint64_t physAddress, + size_t size, size_t offset, + uint64_t additionalBits, const OCLRT::AubHelper &aubHelper) { auto vmAddr = (gfxAddress + offset) & ~(MemoryConstants::pageSize - 1); auto pAddr = physAddress & ~(MemoryConstants::pageSize - 1); - AubDump::reserveAddressPPGTT(stream, vmAddr, MemoryConstants::pageSize, pAddr, additionalBits); + AubDump::reserveAddressPPGTT(stream, vmAddr, MemoryConstants::pageSize, pAddr, additionalBits, aubHelper); int hint = OCLRT::AubHelper::getMemTrace(additionalBits); @@ -152,7 +155,9 @@ void AubDump::setGttEntry(MiGttEntry &entry, uint64_t address, AubGTTDat } template -uint64_t AubPageTableHelper32::reserveAddressPPGTT(typename Traits::Stream &stream, uintptr_t gfxAddress, size_t blockSize, uint64_t physAddress, uint64_t additionalBits) { +uint64_t AubPageTableHelper32::reserveAddressPPGTT(typename Traits::Stream &stream, uintptr_t gfxAddress, + size_t blockSize, uint64_t physAddress, + uint64_t additionalBits, const OCLRT::AubHelper &aubHelper) { auto startAddress = gfxAddress; auto endAddress = gfxAddress + blockSize - 1; @@ -169,7 +174,9 @@ uint64_t AubPageTableHelper32::reserveAddressPPGTT(typename Traits::Stre if (writePDE) { auto start_address = BaseClass::getPDEAddress(startPDE); - stream.writeMemoryWriteHeader(start_address, numPDEs * sizeof(uint64_t), AddressSpaceValues::TracePpgttPdEntry); + stream.writeMemoryWriteHeader(start_address, numPDEs * sizeof(uint64_t), + aubHelper.getMemTraceForPdEntry(), + aubHelper.getDataHintForPdEntry()); auto currPDE = startPDE; auto physPage = BaseClass::getPTEAddress(startPTE) & g_pageMask; @@ -189,7 +196,9 @@ uint64_t AubPageTableHelper32::reserveAddressPPGTT(typename Traits::Stre if (writePTE) { auto start_address = BaseClass::getPTEAddress(startPTE); - stream.writeMemoryWriteHeader(start_address, numPTEs * sizeof(uint64_t), AddressSpaceValues::TracePpgttEntry); + stream.writeMemoryWriteHeader(start_address, numPTEs * sizeof(uint64_t), + aubHelper.getMemTraceForPtEntry(), + aubHelper.getDataHintForPtEntry()); auto currPTE = startPTE; auto physPage = physAddress & g_pageMask; @@ -208,7 +217,9 @@ uint64_t AubPageTableHelper32::reserveAddressPPGTT(typename Traits::Stre } template -uint64_t AubPageTableHelper64::reserveAddressPPGTT(typename Traits::Stream &stream, uintptr_t gfxAddress, size_t blockSize, uint64_t physAddress, uint64_t additionalBits) { +uint64_t AubPageTableHelper64::reserveAddressPPGTT(typename Traits::Stream &stream, uintptr_t gfxAddress, + size_t blockSize, uint64_t physAddress, + uint64_t additionalBits, const OCLRT::AubHelper &aubHelper) { auto startAddress = gfxAddress; auto endAddress = gfxAddress + blockSize - 1; @@ -233,7 +244,9 @@ uint64_t AubPageTableHelper64::reserveAddressPPGTT(typename Traits::Stre if (writePML4) { auto start_address = getPML4Address(startPML4); - stream.writeMemoryWriteHeader(start_address, numPML4s * sizeof(uint64_t), AddressSpaceValues::TracePml4Entry); + stream.writeMemoryWriteHeader(start_address, numPML4s * sizeof(uint64_t), + aubHelper.getMemTraceForPml4Entry(), + aubHelper.getDataHintForPml4Entry()); auto currPML4 = startPML4; auto physPage = BaseClass::getPDPAddress(startPDP) & g_pageMask; @@ -253,7 +266,9 @@ uint64_t AubPageTableHelper64::reserveAddressPPGTT(typename Traits::Stre if (writePDPE) { auto start_address = BaseClass::getPDPAddress(startPDP); - stream.writeMemoryWriteHeader(start_address, numPDPs * sizeof(uint64_t), AddressSpaceValues::TracePhysicalPdpEntry); + stream.writeMemoryWriteHeader(start_address, numPDPs * sizeof(uint64_t), + aubHelper.getMemTraceForPdpEntry(), + aubHelper.getDataHintForPdpEntry()); auto currPDP = startPDP; auto physPage = BaseClass::getPDEAddress(startPDE) & g_pageMask; @@ -273,7 +288,9 @@ uint64_t AubPageTableHelper64::reserveAddressPPGTT(typename Traits::Stre if (writePDE) { auto start_address = BaseClass::getPDEAddress(startPDE); - stream.writeMemoryWriteHeader(start_address, numPDEs * sizeof(uint64_t), AddressSpaceValues::TracePpgttPdEntry); + stream.writeMemoryWriteHeader(start_address, numPDEs * sizeof(uint64_t), + aubHelper.getMemTraceForPdEntry(), + aubHelper.getDataHintForPdEntry()); auto currPDE = startPDE; auto physPage = BaseClass::getPTEAddress(startPTE) & g_pageMask; @@ -293,7 +310,9 @@ uint64_t AubPageTableHelper64::reserveAddressPPGTT(typename Traits::Stre if (writePTE) { auto start_address = BaseClass::getPTEAddress(startPTE); - stream.writeMemoryWriteHeader(start_address, numPTEs * sizeof(uint64_t), AddressSpaceValues::TracePpgttEntry); + stream.writeMemoryWriteHeader(start_address, numPTEs * sizeof(uint64_t), + aubHelper.getMemTraceForPtEntry(), + aubHelper.getDataHintForPtEntry()); auto currPTE = startPTE; auto physPage = physAddress & g_pageMask; diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.inl b/runtime/command_stream/aub_command_stream_receiver_hw.inl index 9acbafebd2..17ac52fbdc 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.inl +++ b/runtime/command_stream/aub_command_stream_receiver_hw.inl @@ -29,6 +29,7 @@ #include "runtime/gmm_helper/resource_info.h" #include "runtime/helpers/aligned_memory.h" #include "runtime/helpers/debug_helpers.h" +#include "runtime/helpers/debug_helpers.h" #include "runtime/helpers/ptr_math.h" #include "runtime/helpers/string.h" #include "runtime/memory_manager/graphics_allocation.h" @@ -294,8 +295,10 @@ FlushStamp AUBCommandStreamReceiverHw::flush(BatchBuffer &batchBuffer } auto physBatchBuffer = ppgtt->map(static_cast(batchBufferGpuAddress), sizeBatchBuffer, PageTableHelper::getMemoryBankIndex(*batchBuffer.commandBufferAllocation)); + AubHelperHw aubHelperHw(this->localMemoryEnabled); AUB::reserveAddressPPGTT(*stream, static_cast(batchBufferGpuAddress), sizeBatchBuffer, physBatchBuffer, - getPPGTTAdditionalBits(batchBuffer.commandBufferAllocation)); + getPPGTTAdditionalBits(batchBuffer.commandBufferAllocation), + aubHelperHw); AUB::addMemoryWrite( *stream, @@ -559,8 +562,11 @@ bool AUBCommandStreamReceiverHw::writeMemory(GraphicsAllocation &gfxA gfxAllocation.setLocked(true); } + AubHelperHw aubHelperHw(this->localMemoryEnabled); + PageWalker walker = [&](uint64_t physAddress, size_t size, size_t offset) { - AUB::reserveAddressGGTTAndWriteMmeory(*stream, static_cast(gpuAddress), cpuAddress, physAddress, size, offset, getPPGTTAdditionalBits(&gfxAllocation)); + AUB::reserveAddressGGTTAndWriteMmeory(*stream, static_cast(gpuAddress), cpuAddress, physAddress, size, offset, getPPGTTAdditionalBits(&gfxAllocation), + aubHelperHw); }; ppgtt->pageWalk(static_cast(gpuAddress), size, 0, walker, PageTableHelper::getMemoryBankIndex(gfxAllocation)); @@ -654,6 +660,7 @@ void AUBCommandStreamReceiverHw::addGUCStartMessage(uint64_t batchBuf typedef typename GfxFamily::MI_BATCH_BUFFER_START MI_BATCH_BUFFER_START; auto bufferSize = sizeof(uint32_t) + sizeof(MI_BATCH_BUFFER_START); + AubHelperHw aubHelperHw(this->localMemoryEnabled); std::unique_ptr> buffer(this->getMemoryManager()->alignedMallocWrapper(bufferSize, MemoryConstants::pageSize), [&](void *ptr) { this->getMemoryManager()->alignedFreeWrapper(ptr); }); LinearStream linearStream(buffer.get(), bufferSize); @@ -668,7 +675,9 @@ void AUBCommandStreamReceiverHw::addGUCStartMessage(uint64_t batchBuf miBatchBufferStart->setAddressSpaceIndicator(MI_BATCH_BUFFER_START::ADDRESS_SPACE_INDICATOR_PPGTT); auto physBufferAddres = ppgtt->map(reinterpret_cast(buffer.get()), bufferSize, PageTableHelper::memoryBankNotSpecified); - AUB::reserveAddressPPGTT(*stream, reinterpret_cast(buffer.get()), bufferSize, physBufferAddres, getPPGTTAdditionalBits(linearStream.getGraphicsAllocation())); + AUB::reserveAddressPPGTT(*stream, reinterpret_cast(buffer.get()), bufferSize, physBufferAddres, + getPPGTTAdditionalBits(linearStream.getGraphicsAllocation()), + aubHelperHw); AUB::addMemoryWrite( *stream, diff --git a/runtime/command_stream/command_stream_receiver_hw.h b/runtime/command_stream/command_stream_receiver_hw.h index 5ea62c1a4c..caeef87e05 100644 --- a/runtime/command_stream/command_stream_receiver_hw.h +++ b/runtime/command_stream/command_stream_receiver_hw.h @@ -113,6 +113,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { const HardwareInfo &hwInfo; CsrSizeRequestFlags csrSizeRequestFlags = {}; + const bool localMemoryEnabled; }; } // namespace OCLRT diff --git a/runtime/command_stream/command_stream_receiver_hw.inl b/runtime/command_stream/command_stream_receiver_hw.inl index 2aa323776b..3d0329545f 100644 --- a/runtime/command_stream/command_stream_receiver_hw.inl +++ b/runtime/command_stream/command_stream_receiver_hw.inl @@ -27,6 +27,7 @@ #include "runtime/gtpin/gtpin_notify.h" #include "runtime/helpers/cache_policy.h" #include "runtime/helpers/flat_batch_buffer_helper_hw.h" +#include "runtime/helpers/hw_helper.h" #include "runtime/helpers/preamble.h" #include "runtime/helpers/ptr_math.h" #include "runtime/helpers/state_base_address.h" @@ -47,7 +48,8 @@ size_t CommandStreamReceiverHw::getSshHeapSize() { template CommandStreamReceiverHw::CommandStreamReceiverHw(const HardwareInfo &hwInfoIn, ExecutionEnvironment &executionEnvironment) - : CommandStreamReceiver(executionEnvironment), hwInfo(hwInfoIn) { + : CommandStreamReceiver(executionEnvironment), hwInfo(hwInfoIn), + localMemoryEnabled(HwHelper::get(hwInfo.pPlatform->eRenderCoreFamily).isLocalMemoryEnabled(hwInfo)) { requiredThreadArbitrationPolicy = PreambleHelper::getDefaultThreadArbitrationPolicy(); resetKmdNotifyHelper(new KmdNotifyHelper(&(hwInfoIn.capabilityTable.kmdNotifyProperties))); flatBatchBufferHelper.reset(new FlatBatchBufferHelperHw(this->memoryManager)); diff --git a/runtime/command_stream/tbx_command_stream_receiver_hw.inl b/runtime/command_stream/tbx_command_stream_receiver_hw.inl index c2bc3d3ed6..129c1a0126 100644 --- a/runtime/command_stream/tbx_command_stream_receiver_hw.inl +++ b/runtime/command_stream/tbx_command_stream_receiver_hw.inl @@ -21,9 +21,11 @@ */ #include "hw_cmds.h" +#include "runtime/aub/aub_helper.h" #include "runtime/aub_mem_dump/page_table_entry_bits.h" #include "runtime/helpers/aligned_memory.h" #include "runtime/helpers/debug_helpers.h" +#include "runtime/helpers/hw_helper.h" #include "runtime/helpers/ptr_math.h" #include "runtime/memory_manager/graphics_allocation.h" #include "runtime/command_stream/command_stream_receiver_with_aub_dump.h" @@ -209,7 +211,11 @@ FlushStamp TbxCommandStreamReceiverHw::flush(BatchBuffer &batchBuffer auto sizeBatchBuffer = currentOffset - batchBuffer.startOffset; { auto physBatchBuffer = ppgtt->map(reinterpret_cast(pBatchBuffer), sizeBatchBuffer, PageTableHelper::getMemoryBankIndex(*batchBuffer.commandBufferAllocation)); - AUB::reserveAddressPPGTT(stream, reinterpret_cast(pBatchBuffer), sizeBatchBuffer, physBatchBuffer, getPPGTTAdditionalBits(batchBuffer.commandBufferAllocation)); + + AubHelperHw aubHelperHw(this->localMemoryEnabled); + AUB::reserveAddressPPGTT(stream, reinterpret_cast(pBatchBuffer), sizeBatchBuffer, physBatchBuffer, + getPPGTTAdditionalBits(batchBuffer.commandBufferAllocation), + aubHelperHw); AUB::addMemoryWrite( stream, @@ -359,8 +365,11 @@ bool TbxCommandStreamReceiverHw::writeMemory(GraphicsAllocation &gfxA if (size == 0) return false; + AubHelperHw aubHelperHw(this->localMemoryEnabled); + PageWalker walker = [&](uint64_t physAddress, size_t size, size_t offset) { - AUB::reserveAddressGGTTAndWriteMmeory(stream, static_cast(gpuAddress), cpuAddress, physAddress, size, offset, getPPGTTAdditionalBits(&gfxAllocation)); + AUB::reserveAddressGGTTAndWriteMmeory(stream, static_cast(gpuAddress), cpuAddress, physAddress, size, offset, getPPGTTAdditionalBits(&gfxAllocation), + aubHelperHw); }; ppgtt->pageWalk(static_cast(gpuAddress), size, 0, walker, PageTableHelper::getMemoryBankIndex(gfxAllocation)); diff --git a/runtime/gen10/hw_helper_gen10.cpp b/runtime/gen10/hw_helper_gen10.cpp index a659773e88..a4e1159ffc 100644 --- a/runtime/gen10/hw_helper_gen10.cpp +++ b/runtime/gen10/hw_helper_gen10.cpp @@ -20,6 +20,8 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include "runtime/aub/aub_helper.h" +#include "runtime/aub/aub_helper.inl" #include "runtime/helpers/hw_helper.h" #include "runtime/helpers/hw_helper_common.inl" #include "runtime/helpers/flat_batch_buffer_helper_hw.inl" @@ -42,6 +44,7 @@ bool HwHelperHw::setupPreemptionRegisters(HardwareInfo *pHwInfo, bool en return pHwInfo->capabilityTable.whitelistedRegisters.csChicken1_0x2580; } +template class AubHelperHw; template class HwHelperHw; template class FlatBatchBufferHelperHw; } // namespace OCLRT diff --git a/runtime/gen8/hw_helper_gen8.cpp b/runtime/gen8/hw_helper_gen8.cpp index 739e0fe92f..d15d3afa98 100644 --- a/runtime/gen8/hw_helper_gen8.cpp +++ b/runtime/gen8/hw_helper_gen8.cpp @@ -20,6 +20,8 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include "runtime/aub/aub_helper.h" +#include "runtime/aub/aub_helper.inl" #include "runtime/helpers/hw_helper.h" #include "runtime/helpers/hw_helper_common.inl" #include "runtime/helpers/flat_batch_buffer_helper_hw.inl" @@ -41,6 +43,7 @@ void HwHelperHw::setupHardwareCapabilities(HardwareCapabilities *caps, c caps->isStatelesToStatefullWithOffsetSupported = false; } +template class AubHelperHw; template class HwHelperHw; template class FlatBatchBufferHelperHw; } // namespace OCLRT diff --git a/runtime/gen9/hw_helper_gen9.cpp b/runtime/gen9/hw_helper_gen9.cpp index a9e0ff89cc..34e402033f 100644 --- a/runtime/gen9/hw_helper_gen9.cpp +++ b/runtime/gen9/hw_helper_gen9.cpp @@ -20,6 +20,8 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include "runtime/aub/aub_helper.h" +#include "runtime/aub/aub_helper.inl" #include "runtime/helpers/hw_helper.h" #include "runtime/helpers/hw_helper_common.inl" #include "runtime/helpers/flat_batch_buffer_helper_hw.inl" @@ -41,6 +43,7 @@ SipKernelType HwHelperHw::getSipKernelType(bool debuggingActive) { return SipKernelType::DbgCsrLocal; } +template class AubHelperHw; template class HwHelperHw; template class FlatBatchBufferHelperHw; } // namespace OCLRT diff --git a/runtime/helpers/hw_helper.h b/runtime/helpers/hw_helper.h index 8cc816958a..80c1a7e24b 100644 --- a/runtime/helpers/hw_helper.h +++ b/runtime/helpers/hw_helper.h @@ -46,10 +46,10 @@ class HwHelper { virtual void setupHardwareCapabilities(HardwareCapabilities *caps, const HardwareInfo &hwInfo) = 0; virtual SipKernelType getSipKernelType(bool debuggingActive) = 0; virtual uint32_t getConfigureAddressSpaceMode() = 0; + virtual bool isLocalMemoryEnabled(const HardwareInfo &hwInfo) = 0; protected: HwHelper(){}; - virtual bool isLocalMemoryEnabled(const HardwareInfo &hwInfo) = 0; }; template diff --git a/runtime/helpers/hw_helper_common.inl b/runtime/helpers/hw_helper_common.inl index 49f805b514..dee35c2c1f 100644 --- a/runtime/helpers/hw_helper_common.inl +++ b/runtime/helpers/hw_helper_common.inl @@ -20,6 +20,7 @@ * OTHER DEALINGS IN THE SOFTWARE. */ +#include "runtime/aub_mem_dump/aub_mem_dump.h" #include "runtime/helpers/hw_helper.h" #include "runtime/helpers/hw_info.h" #include "runtime/memory_manager/memory_constants.h" @@ -78,5 +79,4 @@ template size_t HwHelperHw::getMaxBarrierRegisterPerSlice() const { return 32; } - } // namespace OCLRT diff --git a/unit_tests/aub/aub_helper_tests.cpp b/unit_tests/aub/aub_helper_tests.cpp index 222e79447f..4c0e9916c5 100644 --- a/unit_tests/aub/aub_helper_tests.cpp +++ b/unit_tests/aub/aub_helper_tests.cpp @@ -24,6 +24,8 @@ #include "runtime/aub/aub_helper.h" #include "runtime/aub_mem_dump/aub_mem_dump.h" #include "runtime/aub_mem_dump/page_table_entry_bits.h" +#include "unit_tests/fixtures/device_fixture.h" +#include "test.h" using namespace OCLRT; @@ -39,3 +41,77 @@ TEST(AubHelper, WhenGetPTEntryBitsIsCalledThenEntryBitsAreNotMasked) { uint64_t maskedEntryBits = AubHelper::getPTEntryBits(entryBits); EXPECT_EQ(entryBits, maskedEntryBits); } + +typedef Test AubHelperHwTest; + +HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetDataHintForPml4EntryIsCalledThenTraceNotypeIsReturned) { + AubHelperHw aubHelper(false); + int dataHint = aubHelper.getDataHintForPml4Entry(); + EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceNotype, dataHint); +} + +HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetDataHintForPdpEntryIsCalledThenTraceNotypeIsReturned) { + AubHelperHw aubHelper(false); + int dataHint = aubHelper.getDataHintForPdpEntry(); + EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceNotype, dataHint); +} + +HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetDataHintForPdEntryIsCalledThenTraceNotypeIsReturned) { + AubHelperHw aubHelper(false); + int dataHint = aubHelper.getDataHintForPdEntry(); + EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceNotype, dataHint); +} + +HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetDataHintForPtEntryIsCalledThenTraceNotypeIsReturned) { + AubHelperHw aubHelper(false); + int dataHint = aubHelper.getDataHintForPtEntry(); + EXPECT_EQ(AubMemDump::DataTypeHintValues::TraceNotype, dataHint); +} + +HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetMemTraceForPml4EntryIsCalledThenTracePml4EntryIsReturned) { + AubHelperHw aubHelper(false); + int addressSpace = aubHelper.getMemTraceForPml4Entry(); + EXPECT_EQ(AubMemDump::AddressSpaceValues::TracePml4Entry, addressSpace); +} + +HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetMemTraceForPdpEntryIsCalledThenTracePhysicalPdpEntryIsReturned) { + AubHelperHw aubHelper(false); + int addressSpace = aubHelper.getMemTraceForPdpEntry(); + EXPECT_EQ(AubMemDump::AddressSpaceValues::TracePhysicalPdpEntry, addressSpace); +} + +HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetMemTraceForPd4EntryIsCalledThenTracePpgttPdEntryIsReturned) { + AubHelperHw aubHelper(false); + int addressSpace = aubHelper.getMemTraceForPdEntry(); + EXPECT_EQ(AubMemDump::AddressSpaceValues::TracePpgttPdEntry, addressSpace); +} + +HWTEST_F(AubHelperHwTest, GivenDisabledLocalMemoryWhenGetMemTraceForPtEntryIsCalledThenTracePpgttEntryIsReturned) { + AubHelperHw aubHelper(false); + int addressSpace = aubHelper.getMemTraceForPtEntry(); + EXPECT_EQ(AubMemDump::AddressSpaceValues::TracePpgttEntry, addressSpace); +} + +HWTEST_F(AubHelperHwTest, GivenEnabledLocalMemoryWhenGetMemTraceForPml4EntryIsCalledThenTraceNonlocalIsReturned) { + AubHelperHw aubHelper(true); + int addressSpace = aubHelper.getMemTraceForPml4Entry(); + EXPECT_EQ(AubMemDump::AddressSpaceValues::TraceLocal, addressSpace); +} + +HWTEST_F(AubHelperHwTest, GivenEnabledLocalMemoryWhenGetMemTraceForPdpEntryIsCalledThenTraceNonlocalIsReturned) { + AubHelperHw aubHelper(true); + int addressSpace = aubHelper.getMemTraceForPdpEntry(); + EXPECT_EQ(AubMemDump::AddressSpaceValues::TraceLocal, addressSpace); +} + +HWTEST_F(AubHelperHwTest, GivenEnabledLocalMemoryWhenGetMemTraceForPd4EntryIsCalledThenTraceNonlocalIsReturned) { + AubHelperHw aubHelper(true); + int addressSpace = aubHelper.getMemTraceForPdEntry(); + EXPECT_EQ(AubMemDump::AddressSpaceValues::TraceLocal, addressSpace); +} + +HWTEST_F(AubHelperHwTest, GivenEnabledLocalMemoryWhenGetMemTraceForPtEntryIsCalledThenTraceNonlocalIsReturned) { + AubHelperHw aubHelper(true); + int addressSpace = aubHelper.getMemTraceForPtEntry(); + EXPECT_EQ(AubMemDump::AddressSpaceValues::TraceLocal, addressSpace); +} diff --git a/unit_tests/aub_tests/command_stream/aub_mem_dump_tests.cpp b/unit_tests/aub_tests/command_stream/aub_mem_dump_tests.cpp index b8c57a7123..b3c576249a 100644 --- a/unit_tests/aub_tests/command_stream/aub_mem_dump_tests.cpp +++ b/unit_tests/aub_tests/command_stream/aub_mem_dump_tests.cpp @@ -21,6 +21,8 @@ */ #include "aub_mem_dump_tests.h" +#include "runtime/aub/aub_helper.h" +#include "runtime/helpers/hw_helper.h" #include "unit_tests/fixtures/device_fixture.h" using OCLRT::AUBCommandStreamReceiver; @@ -92,7 +94,9 @@ HWTEST_F(AubMemDumpTests, reserveMaxAddress) { auto gAddress = static_cast(-1) - 4096; auto pAddress = static_cast(gAddress) & 0xFFFFFFFF; - AUB::reserveAddressPPGTT(aubFile, gAddress, 4096, pAddress, 7); + + OCLRT::AubHelperHw aubHelperHw(pDevice->getHardwareCapabilities().localMemorySupported); + AUB::reserveAddressPPGTT(aubFile, gAddress, 4096, pAddress, 7, aubHelperHw); aubFile.fileHandle.close(); } @@ -112,7 +116,9 @@ HWTEST_F(AubMemDumpTests, writeVerifyOneBytePPGTT) { uint8_t byte = 0xbf; auto gAddress = reinterpret_cast(&byte); uint64_t physAddress = reinterpret_cast(&byte) & 0xFFFFFFFF; - AUB::reserveAddressPPGTT(aubFile, gAddress, sizeof(byte), physAddress, 7); + + OCLRT::AubHelperHw aubHelperHw(false); + AUB::reserveAddressPPGTT(aubFile, gAddress, sizeof(byte), physAddress, 7, aubHelperHw); AUB::addMemoryWrite(aubFile, physAddress, &byte, sizeof(byte), AubMemDump::AddressSpaceValues::TraceNonlocal); aubFile.expectMemory(physAddress, &byte, sizeof(byte)); @@ -156,7 +162,9 @@ HWTEST_F(AubMemDumpTests, writeVerifySevenBytesPPGTT) { uint8_t bytes[] = {0, 1, 2, 3, 4, 5, 6}; auto gAddress = reinterpret_cast(bytes); auto physAddress = reinterpret_cast(bytes) & 0xFFFFFFFF; - AUB::reserveAddressPPGTT(aubFile, gAddress, sizeof(bytes), physAddress, 7); + + OCLRT::AubHelperHw aubHelperHw(false); + AUB::reserveAddressPPGTT(aubFile, gAddress, sizeof(bytes), physAddress, 7, aubHelperHw); AUB::addMemoryWrite(aubFile, physAddress, bytes, sizeof(bytes), AubMemDump::AddressSpaceValues::TraceNonlocal); aubFile.expectMemory(physAddress, bytes, sizeof(bytes)); diff --git a/unit_tests/aub_tests/gen10/batch_buffer/aub_batch_buffer_tests_gen10.h b/unit_tests/aub_tests/gen10/batch_buffer/aub_batch_buffer_tests_gen10.h index 2861c595f3..d4758baeca 100644 --- a/unit_tests/aub_tests/gen10/batch_buffer/aub_batch_buffer_tests_gen10.h +++ b/unit_tests/aub_tests/gen10/batch_buffer/aub_batch_buffer_tests_gen10.h @@ -21,6 +21,7 @@ */ #pragma once +#include "runtime/aub/aub_helper.h" #include "unit_tests/aub_tests/command_stream/aub_mem_dump_tests.h" template @@ -66,7 +67,10 @@ void setupAUBWithBatchBuffer(const OCLRT::Device *pDevice, OCLRT::EngineType eng const auto sizeBatchBuffer = 0x1000; auto gpuBatchBuffer = static_cast(gpuBatchBufferAddr); physAddress += sizeBatchBuffer; - AUB::reserveAddressPPGTT(aubFile, gpuBatchBuffer, sizeBatchBuffer, physBatchBuffer, 7); + + OCLRT::AubHelperHw aubHelperHw(false); + + AUB::reserveAddressPPGTT(aubFile, gpuBatchBuffer, sizeBatchBuffer, physBatchBuffer, 7, aubHelperHw); uint8_t batchBuffer[sizeBatchBuffer]; auto noop = MI_NOOP::sInit(); diff --git a/unit_tests/aub_tests/gen9/batch_buffer/aub_batch_buffer_tests.h b/unit_tests/aub_tests/gen9/batch_buffer/aub_batch_buffer_tests.h index 50429b10a7..4a18b010a5 100644 --- a/unit_tests/aub_tests/gen9/batch_buffer/aub_batch_buffer_tests.h +++ b/unit_tests/aub_tests/gen9/batch_buffer/aub_batch_buffer_tests.h @@ -21,6 +21,7 @@ */ #pragma once +#include "runtime/aub/aub_helper.h" #include "unit_tests/aub_tests/command_stream/aub_mem_dump_tests.h" template @@ -67,7 +68,10 @@ void setupAUBWithBatchBuffer(const OCLRT::Device *pDevice, OCLRT::EngineType eng const auto sizeBatchBuffer = 0x1000; auto gpuBatchBuffer = static_cast(gpuBatchBufferAddr); physAddress += sizeBatchBuffer; - AUB::reserveAddressPPGTT(aubFile, gpuBatchBuffer, sizeBatchBuffer, physBatchBuffer, 7); + + OCLRT::AubHelperHw aubHelperHw(false); + + AUB::reserveAddressPPGTT(aubFile, gpuBatchBuffer, sizeBatchBuffer, physBatchBuffer, 7, aubHelperHw); uint8_t batchBuffer[sizeBatchBuffer]; auto noop = MI_NOOP::sInit();