From ff1d2361f3882b3102dd7dca1060f9f733f6f12b Mon Sep 17 00:00:00 2001 From: Pawel Wilma Date: Wed, 14 Mar 2018 11:07:51 +0100 Subject: [PATCH] Add patch info comments to AUB dump Collect patching information and add as comments to AUB dump. Change-Id: Ib7c903a2589d68b6e3e614c1774c7cd5a000c29f --- runtime/aub_mem_dump/aub_mem_dump.h | 5 +- runtime/command_queue/enqueue_common.h | 8 + .../aub_command_stream_receiver.cpp | 3 +- .../aub_command_stream_receiver_hw.h | 7 +- .../aub_command_stream_receiver_hw.inl | 111 ++++-- .../command_stream/command_stream_receiver.h | 4 + .../command_stream_receiver_hw.h | 9 + .../command_stream_receiver_hw.inl | 33 ++ .../tbx_command_stream_receiver.h | 2 +- runtime/helpers/CMakeLists.txt | 1 + runtime/helpers/address_patch.h | 46 +++ runtime/helpers/kernel_commands.h | 4 +- runtime/helpers/kernel_commands.inl | 12 +- runtime/helpers/state_base_address.inl | 1 - runtime/kernel/kernel.cpp | 7 +- runtime/kernel/kernel.h | 5 + runtime/mem_obj/buffer.cpp | 4 +- runtime/mem_obj/buffer.h | 3 +- runtime/mem_obj/mem_obj.h | 1 + runtime/os_interface/DebugVariables.inl | 1 + .../aub_command_stream_fixture.h | 8 +- .../command_queue/enqueue_handler_tests.cpp | 38 ++ .../aub_command_stream_receiver_tests.cpp | 335 ++++++++++++++++++ .../command_stream_receiver_hw_tests.cpp | 141 ++++++++ unit_tests/helpers/kernel_commands_tests.cpp | 62 ++++ unit_tests/mem_obj/buffer_set_arg_tests.cpp | 33 ++ unit_tests/mocks/mock_csr.h | 15 +- unit_tests/test_files/igdrcl.config | 1 + 28 files changed, 853 insertions(+), 47 deletions(-) create mode 100644 runtime/helpers/address_patch.h diff --git a/runtime/aub_mem_dump/aub_mem_dump.h b/runtime/aub_mem_dump/aub_mem_dump.h index e21c5931d6..2359aeefc5 100644 --- a/runtime/aub_mem_dump/aub_mem_dump.h +++ b/runtime/aub_mem_dump/aub_mem_dump.h @@ -121,6 +121,7 @@ struct AubStream { virtual void writeGTT(uint32_t offset, uint64_t entry) = 0; virtual void writeMMIO(uint32_t offset, uint32_t value) = 0; virtual void registerPoll(uint32_t registerOffset, uint32_t mask, uint32_t value, bool pollNotEqual, uint32_t timeoutAction) = 0; + virtual ~AubStream() = default; }; struct AubFileStream : public AubStream { @@ -134,8 +135,8 @@ struct AubFileStream : public AubStream { void writeGTT(uint32_t offset, uint64_t entry) override; void writeMMIO(uint32_t offset, uint32_t value) override; void registerPoll(uint32_t registerOffset, uint32_t mask, uint32_t value, bool pollNotEqual, uint32_t timeoutAction) override; - void expectMemory(uint64_t physAddress, const void *memory, size_t size); - void addComment(const char *message); + MOCKABLE_VIRTUAL void expectMemory(uint64_t physAddress, const void *memory, size_t size); + MOCKABLE_VIRTUAL bool addComment(const char *message); std::ofstream fileHandle; }; diff --git a/runtime/command_queue/enqueue_common.h b/runtime/command_queue/enqueue_common.h index 8a176f1dda..32f810eb1e 100644 --- a/runtime/command_queue/enqueue_common.h +++ b/runtime/command_queue/enqueue_common.h @@ -249,6 +249,14 @@ void CommandQueueHw::enqueueHandler(Surface **surfacesForResidency, blockQueue, commandType); + if (DebugManager.flags.AddPatchInfoCommentsForAUBDump.get()) { + for (auto &dispatchInfo : multiDispatchInfo) { + for (auto &patchInfoData : dispatchInfo.getKernel()->getPatchInfoDataList()) { + commandStreamReceiver.setPatchInfoData(patchInfoData); + } + } + } + commandStreamReceiver.setRequiredScratchSize(multiDispatchInfo.getRequiredScratchSize()); slmUsed = multiDispatchInfo.usesSlm(); diff --git a/runtime/command_stream/aub_command_stream_receiver.cpp b/runtime/command_stream/aub_command_stream_receiver.cpp index f7a0c4eeb5..bd38f151e1 100644 --- a/runtime/command_stream/aub_command_stream_receiver.cpp +++ b/runtime/command_stream/aub_command_stream_receiver.cpp @@ -231,7 +231,7 @@ void AubFileStream::createContext(const AubPpgttContextCreate &cmd) { fileHandle.write(reinterpret_cast(&cmd), sizeof(cmd)); } -void AubFileStream::addComment(const char *message) { +bool AubFileStream::addComment(const char *message) { using CmdServicesMemTraceComment = AubMemDump::CmdServicesMemTraceComment; CmdServicesMemTraceComment cmd; memset(&cmd, 0, sizeof(cmd)); @@ -251,6 +251,7 @@ void AubFileStream::addComment(const char *message) { uint32_t zero = 0; fileHandle.write(reinterpret_cast(&zero), sizeof(uint32_t) - remainder); } + return true; } } // namespace AubMemDump diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.h b/runtime/command_stream/aub_command_stream_receiver_hw.h index 93f263066b..596b92242c 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.h +++ b/runtime/command_stream/aub_command_stream_receiver_hw.h @@ -66,6 +66,10 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverHw { return this->memoryManager; } + bool setPatchInfoData(PatchInfoData &data) override; + + std::vector patchInfoCollection; + static const AubMemDump::LrcaHelper &getCsTraits(EngineType engineType); struct EngineInfo { @@ -79,7 +83,7 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverHw { uint32_t tailRingBuffer; } engineInfoTable[EngineType::NUM_ENGINES]; - AUBCommandStreamReceiver::AubFileStream stream; + std::unique_ptr stream; bool standalone; TypeSelector::type ppgtt; @@ -88,5 +92,6 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverHw { AddressMapper gttRemap; MOCKABLE_VIRTUAL void *flattenBatchBuffer(BatchBuffer &batchBuffer, size_t &sizeBatchBuffer); + MOCKABLE_VIRTUAL bool addPatchInfoComments(); }; } // namespace OCLRT diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.inl b/runtime/command_stream/aub_command_stream_receiver_hw.inl index 4666d4295a..fd0537d27b 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.inl +++ b/runtime/command_stream/aub_command_stream_receiver_hw.inl @@ -35,6 +35,7 @@ namespace OCLRT { template AUBCommandStreamReceiverHw::AUBCommandStreamReceiverHw(const HardwareInfo &hwInfoIn, bool standalone) : BaseClass(hwInfoIn), + stream(std::unique_ptr(new AUBCommandStreamReceiver::AubFileStream())), standalone(standalone) { this->dispatchMode = CommandStreamReceiver::DispatchMode::BatchedDispatch; if (DebugManager.flags.CsrDispatchMode.get()) { @@ -54,7 +55,7 @@ AUBCommandStreamReceiverHw::AUBCommandStreamReceiverHw(const Hardware template AUBCommandStreamReceiverHw::~AUBCommandStreamReceiverHw() { - stream.close(); + stream->close(); for (auto &engineInfo : engineInfoTable) { alignedFree(engineInfo.pLRCA); @@ -79,7 +80,7 @@ const AubMemDump::LrcaHelper &AUBCommandStreamReceiverHw::getCsTraits template void AUBCommandStreamReceiverHw::initGlobalMMIO() { for (auto &mmioPair : AUBFamilyMapper::globalMMIO) { - stream.writeMMIO(mmioPair.first, mmioPair.second); + stream->writeMMIO(mmioPair.first, mmioPair.second); } } @@ -89,7 +90,7 @@ void AUBCommandStreamReceiverHw::initEngineMMIO(EngineType engineType DEBUG_BREAK_IF(!mmioList); for (auto &mmioPair : *mmioList) { - stream.writeMMIO(mmioPair.first, mmioPair.second); + stream->writeMMIO(mmioPair.first, mmioPair.second); } } @@ -113,11 +114,11 @@ void AUBCommandStreamReceiverHw::initializeEngine(EngineType engineTy { std::ostringstream str; str << "ggtt: " << std::hex << std::showbase << engineInfo.ggttHWSP; - stream.addComment(str.str().c_str()); + stream->addComment(str.str().c_str()); } - AUB::reserveAddressGGTT(stream, engineInfo.ggttHWSP, sizeHWSP, physHWSP); - stream.writeMMIO(mmioBase + 0x2080, engineInfo.ggttHWSP); + AUB::reserveAddressGGTT(*stream, engineInfo.ggttHWSP, sizeHWSP, physHWSP); + stream->writeMMIO(mmioBase + 0x2080, engineInfo.ggttHWSP); } // Allocate the LRCA @@ -141,10 +142,10 @@ void AUBCommandStreamReceiverHw::initializeEngine(EngineType engineTy { std::ostringstream str; str << "ggtt: " << std::hex << std::showbase << engineInfo.ggttRingBuffer; - stream.addComment(str.str().c_str()); + stream->addComment(str.str().c_str()); } - AUB::reserveAddressGGTT(stream, engineInfo.ggttRingBuffer, engineInfo.sizeRingBuffer, physRingBuffer); + AUB::reserveAddressGGTT(*stream, engineInfo.ggttRingBuffer, engineInfo.sizeRingBuffer, physRingBuffer); } // Initialize the ring MMIO registers @@ -167,12 +168,12 @@ void AUBCommandStreamReceiverHw::initializeEngine(EngineType engineTy { std::ostringstream str; str << "ggtt: " << std::hex << std::showbase << engineInfo.ggttLRCA; - stream.addComment(str.str().c_str()); + stream->addComment(str.str().c_str()); } - AUB::reserveAddressGGTT(stream, engineInfo.ggttLRCA, sizeLRCA, lrcAddressPhys); + AUB::reserveAddressGGTT(*stream, engineInfo.ggttLRCA, sizeLRCA, lrcAddressPhys); AUB::addMemoryWrite( - stream, + *stream, lrcAddressPhys, pLRCABase, sizeLRCA, @@ -189,15 +190,15 @@ CommandStreamReceiver *AUBCommandStreamReceiverHw::create(const Hardw auto csr = new AUBCommandStreamReceiverHw(hwInfoIn, standalone); // Open our file - csr->stream.open(fileName.c_str()); + csr->stream->open(fileName.c_str()); - if (!csr->stream.fileHandle.is_open()) { + if (!csr->stream->fileHandle.is_open()) { // This DEBUG_BREAK_IF most probably means you are not executing aub tests with correct current directory (containing aub_out folder) // try adding _aub DEBUG_BREAK_IF(true); } // Add the file header. - csr->stream.init(AubMemDump::SteppingValues::A, AUB::Traits::device); + csr->stream->init(AubMemDump::SteppingValues::A, AUB::Traits::device); return csr; } @@ -231,14 +232,14 @@ FlushStamp AUBCommandStreamReceiverHw::flush(BatchBuffer &batchBuffer { std::ostringstream str; str << "ppgtt: " << std::hex << std::showbase << pBatchBuffer; - stream.addComment(str.str().c_str()); + stream->addComment(str.str().c_str()); } auto physBatchBuffer = ppgtt.map(reinterpret_cast(pBatchBuffer), sizeBatchBuffer); - AUB::reserveAddressPPGTT(stream, reinterpret_cast(pBatchBuffer), sizeBatchBuffer, physBatchBuffer); + AUB::reserveAddressPPGTT(*stream, reinterpret_cast(pBatchBuffer), sizeBatchBuffer, physBatchBuffer); AUB::addMemoryWrite( - stream, + *stream, physBatchBuffer, pBatchBuffer, sizeBatchBuffer, @@ -257,6 +258,9 @@ FlushStamp AUBCommandStreamReceiverHw::flush(BatchBuffer &batchBuffer } processResidency(allocationsForResidency); } + if (DebugManager.flags.AddPatchInfoCommentsForAUBDump.get()) { + addPatchInfoComments(); + } // Add a batch buffer start to the ring buffer auto previousTail = engineInfo.tailRingBuffer; @@ -282,7 +286,7 @@ FlushStamp AUBCommandStreamReceiverHw::flush(BatchBuffer &batchBuffer // write remaining ring auto physDumpStart = ggtt.map(ggttTail, sizeToWrap); AUB::addMemoryWrite( - stream, + *stream, physDumpStart, pTail, sizeToWrap, @@ -327,12 +331,12 @@ FlushStamp AUBCommandStreamReceiverHw::flush(BatchBuffer &batchBuffer { std::ostringstream str; str << "ggtt: " << std::hex << std::showbase << ggttDumpStart; - stream.addComment(str.str().c_str()); + stream->addComment(str.str().c_str()); } auto physDumpStart = ggtt.map(ggttDumpStart, dumpLength); AUB::addMemoryWrite( - stream, + *stream, physDumpStart, dumpStart, dumpLength, @@ -343,12 +347,12 @@ FlushStamp AUBCommandStreamReceiverHw::flush(BatchBuffer &batchBuffer { std::ostringstream str; str << "ggtt: " << std::hex << std::showbase << engineInfo.ggttLRCA + 0x101c; - stream.addComment(str.str().c_str()); + stream->addComment(str.str().c_str()); } auto physLRCA = ggtt.map(engineInfo.ggttLRCA, sizeof(engineInfo.tailRingBuffer)); AUB::addMemoryWrite( - stream, + *stream, physLRCA + 0x101c, &engineInfo.tailRingBuffer, sizeof(engineInfo.tailRingBuffer), @@ -402,13 +406,56 @@ void *AUBCommandStreamReceiverHw::flattenBatchBuffer(BatchBuffer &bat return flatBatchBuffer; } +template +bool AUBCommandStreamReceiverHw::addPatchInfoComments() { + std::map allocationsMap; + + std::ostringstream str; + str << "PatchInfoData" << std::endl; + for (auto &patchInfoData : this->patchInfoCollection) { + str << std::hex << patchInfoData.sourceAllocation << ";"; + str << std::hex << patchInfoData.sourceAllocationOffset << ";"; + str << std::hex << patchInfoData.sourceType << ";"; + str << std::hex << patchInfoData.targetAllocation << ";"; + str << std::hex << patchInfoData.targetAllocationOffset << ";"; + str << std::hex << patchInfoData.targetType << ";"; + str << std::endl; + + if (patchInfoData.sourceAllocation) { + allocationsMap.insert(std::pair(patchInfoData.sourceAllocation, + ppgtt.map(static_cast(patchInfoData.sourceAllocation), 1))); + } + + if (patchInfoData.targetAllocation) { + allocationsMap.insert(std::pair(patchInfoData.targetAllocation, + ppgtt.map(static_cast(patchInfoData.targetAllocation), 1))); + } + } + bool result = stream->addComment(str.str().c_str()); + this->patchInfoCollection.clear(); + if (!result) { + return false; + } + + std::ostringstream allocationStr; + allocationStr << "AllocationsList" << std::endl; + for (auto &element : allocationsMap) { + allocationStr << std::hex << element.first << ";" << element.second << std::endl; + } + result = stream->addComment(allocationStr.str().c_str()); + if (!result) { + return false; + } + return true; +} + template void AUBCommandStreamReceiverHw::submitLRCA(EngineType engineType, const typename AUBCommandStreamReceiverHw::MiContextDescriptorReg &contextDescriptor) { auto mmioBase = getCsTraits(engineType).mmioBase; - stream.writeMMIO(mmioBase + 0x2230, 0); - stream.writeMMIO(mmioBase + 0x2230, 0); - stream.writeMMIO(mmioBase + 0x2230, contextDescriptor.ulData[1]); - stream.writeMMIO(mmioBase + 0x2230, contextDescriptor.ulData[0]); + stream->writeMMIO(mmioBase + 0x2230, 0); + stream->writeMMIO(mmioBase + 0x2230, 0); + stream->writeMMIO(mmioBase + 0x2230, contextDescriptor.ulData[1]); + stream->writeMMIO(mmioBase + 0x2230, contextDescriptor.ulData[0]); } template @@ -417,7 +464,7 @@ void AUBCommandStreamReceiverHw::pollForCompletion(EngineType engineT auto mmioBase = getCsTraits(engineType).mmioBase; bool pollNotEqual = false; - this->stream.registerPoll( + this->stream->registerPoll( mmioBase + 0x2234, //EXECLIST_STATUS 0x100, 0x100, @@ -447,7 +494,7 @@ bool AUBCommandStreamReceiverHw::writeMemory(GraphicsAllocation &gfxA { std::ostringstream str; str << "ppgtt: " << std::hex << std::showbase << gpuAddress; - stream.addComment(str.str().c_str()); + stream->addComment(str.str().c_str()); } if (cpuAddress == nullptr) { @@ -457,7 +504,7 @@ bool AUBCommandStreamReceiverHw::writeMemory(GraphicsAllocation &gfxA } PageWalker walker = [&](uint64_t physAddress, size_t size, size_t offset) { - AUB::reserveAddressGGTTAndWriteMmeory(stream, static_cast(gpuAddress), cpuAddress, physAddress, size, offset); + AUB::reserveAddressGGTTAndWriteMmeory(*stream, static_cast(gpuAddress), cpuAddress, physAddress, size, offset); }; ppgtt.pageWalk(static_cast(gpuAddress), size, 0, walker); @@ -499,4 +546,10 @@ void AUBCommandStreamReceiverHw::addContextToken() { // Some simulator versions don't support adding the context token. // This hook allows specialization for those that do. } + +template +bool AUBCommandStreamReceiverHw::setPatchInfoData(PatchInfoData &data) { + patchInfoCollection.push_back(data); + return true; +} } // namespace OCLRT diff --git a/runtime/command_stream/command_stream_receiver.h b/runtime/command_stream/command_stream_receiver.h index e43a33cb2f..81d73f3269 100644 --- a/runtime/command_stream/command_stream_receiver.h +++ b/runtime/command_stream/command_stream_receiver.h @@ -26,6 +26,7 @@ #include "runtime/command_stream/submissions_aggregator.h" #include "runtime/helpers/completion_stamp.h" #include "runtime/helpers/aligned_memory.h" +#include "runtime/helpers/address_patch.h" #include "runtime/command_stream/csr_definitions.h" #include #include @@ -122,6 +123,9 @@ class CommandStreamReceiver { void setSamplerCacheFlushRequired(SamplerCacheFlushState value) { this->samplerCacheFlushRequired = value; } + // Collect patch info data + virtual bool setPatchInfoData(PatchInfoData &data) { return false; } + protected: void setDisableL3Cache(bool val) { disableL3Cache = val; diff --git a/runtime/command_stream/command_stream_receiver_hw.h b/runtime/command_stream/command_stream_receiver_hw.h index dcb8501851..73a0ecba2c 100644 --- a/runtime/command_stream/command_stream_receiver_hw.h +++ b/runtime/command_stream/command_stream_receiver_hw.h @@ -68,6 +68,15 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep) override; const HardwareInfo &peekHwInfo() const { return hwInfo; } + void collectStateBaseAddresPatchInfo( + uint64_t baseAddress, + uint64_t commandOffset, + const LinearStream &dsh, + const LinearStream &ih, + const LinearStream &ioh, + const LinearStream &ssh, + uint64_t generalStateBase); + protected: void programPreemption(LinearStream &csr, DispatchFlags &dispatchFlags, const LinearStream &ih); void programL3(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t &newL3Config); diff --git a/runtime/command_stream/command_stream_receiver_hw.inl b/runtime/command_stream/command_stream_receiver_hw.inl index f99a912f65..fa6bbacfa6 100644 --- a/runtime/command_stream/command_stream_receiver_hw.inl +++ b/runtime/command_stream/command_stream_receiver_hw.inl @@ -260,6 +260,8 @@ CompletionStamp CommandStreamReceiverHw::flushTask( GSBAFor32BitProgrammed = true; } + auto stateBaseAddressCmdOffset = commandStreamCSR.getUsed(); + StateBaseAddressHelper::programStateBaseAddress( commandStreamCSR, dsh, @@ -268,7 +270,12 @@ CompletionStamp CommandStreamReceiverHw::flushTask( ssh, newGSHbase, requiredL3Index); + latestSentStatelessMocsConfig = requiredL3Index; + + if (DebugManager.flags.AddPatchInfoCommentsForAUBDump.get()) { + collectStateBaseAddresPatchInfo(commandStream.getGpuBase(), stateBaseAddressCmdOffset, dsh, ih, ioh, ssh, newGSHbase); + } } DBG_LOG(LogTaskCounts, __FUNCTION__, "Line: ", __LINE__, "this->taskLevel", (uint32_t)this->taskLevel); @@ -638,4 +645,30 @@ template void CommandStreamReceiverHw::updateLastWaitForCompletionTimestamp() { lastWaitForCompletionTimestamp = std::chrono::high_resolution_clock::now(); } + +template +void CommandStreamReceiverHw::collectStateBaseAddresPatchInfo( + uint64_t baseAddress, + uint64_t commandOffset, + const LinearStream &dsh, + const LinearStream &ih, + const LinearStream &ioh, + const LinearStream &ssh, + uint64_t generalStateBase) { + + typedef typename GfxFamily::STATE_BASE_ADDRESS STATE_BASE_ADDRESS; + + PatchInfoData dynamicStatePatchInfo = {dsh.getGpuBase(), 0u, PatchInfoAllocationType::DynamicStateHeap, baseAddress, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::DYNAMICSTATEBASEADDRESS_BYTEOFFSET, PatchInfoAllocationType::Default}; + PatchInfoData generalStatePatchInfo = {generalStateBase, 0u, PatchInfoAllocationType::GeneralStateHeap, baseAddress, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::GENERALSTATEBASEADDRESS_BYTEOFFSET, PatchInfoAllocationType::Default}; + PatchInfoData surfaceStatePatchInfo = {ssh.getGpuBase(), 0u, PatchInfoAllocationType::SurfaceStateHeap, baseAddress, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::SURFACESTATEBASEADDRESS_BYTEOFFSET, PatchInfoAllocationType::Default}; + PatchInfoData indirectObjectPatchInfo = {ioh.getGpuBase(), 0u, PatchInfoAllocationType::IndirectObjectHeap, baseAddress, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::INDIRECTOBJECTBASEADDRESS_BYTEOFFSET, PatchInfoAllocationType::Default}; + PatchInfoData instructionPatchInfo = {ih.getGpuBase(), 0u, PatchInfoAllocationType::InstructionHeap, baseAddress, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::INSTRUCTIONBASEADDRESS_BYTEOFFSET, PatchInfoAllocationType::Default}; + + setPatchInfoData(dynamicStatePatchInfo); + setPatchInfoData(generalStatePatchInfo); + setPatchInfoData(surfaceStatePatchInfo); + setPatchInfoData(indirectObjectPatchInfo); + setPatchInfoData(instructionPatchInfo); +} + } // namespace OCLRT diff --git a/runtime/command_stream/tbx_command_stream_receiver.h b/runtime/command_stream/tbx_command_stream_receiver.h index 4ed51d8e72..7ce0c1b99d 100644 --- a/runtime/command_stream/tbx_command_stream_receiver.h +++ b/runtime/command_stream/tbx_command_stream_receiver.h @@ -40,7 +40,7 @@ class TbxStream : public AubMemDump::AubStream { public: TbxStream(); - virtual ~TbxStream(); + ~TbxStream() override; TbxStream(const TbxStream &) = delete; TbxStream &operator=(const TbxStream &) = delete; diff --git a/runtime/helpers/CMakeLists.txt b/runtime/helpers/CMakeLists.txt index 0cc27a15b9..8fa0a5d86d 100644 --- a/runtime/helpers/CMakeLists.txt +++ b/runtime/helpers/CMakeLists.txt @@ -21,6 +21,7 @@ set(RUNTIME_SRCS_HELPERS_BASE ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/abort.h + ${CMAKE_CURRENT_SOURCE_DIR}/address_patch.h ${CMAKE_CURRENT_SOURCE_DIR}/aligned_memory.h ${CMAKE_CURRENT_SOURCE_DIR}/array_count.h ${CMAKE_CURRENT_SOURCE_DIR}/base_object.cpp diff --git a/runtime/helpers/address_patch.h b/runtime/helpers/address_patch.h new file mode 100644 index 0000000000..25c7059245 --- /dev/null +++ b/runtime/helpers/address_patch.h @@ -0,0 +1,46 @@ +/* + * 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. + */ + +#pragma once +#include + +namespace OCLRT { + +enum PatchInfoAllocationType { + Default = 0, + KernelArg, + GeneralStateHeap, + DynamicStateHeap, + IndirectObjectHeap, + SurfaceStateHeap, + InstructionHeap +}; + +struct PatchInfoData { + uint64_t sourceAllocation; + uint64_t sourceAllocationOffset; + PatchInfoAllocationType sourceType; + uint64_t targetAllocation; + uint64_t targetAllocationOffset; + PatchInfoAllocationType targetType; +}; +} // namespace OCLRT \ No newline at end of file diff --git a/runtime/helpers/kernel_commands.h b/runtime/helpers/kernel_commands.h index 9171f0faf1..1cede72118 100644 --- a/runtime/helpers/kernel_commands.h +++ b/runtime/helpers/kernel_commands.h @@ -74,7 +74,7 @@ struct KernelCommandsHelper : public PerThreadDataHelper { static size_t sendCrossThreadData( IndirectHeap &indirectHeap, - const Kernel &kernel); + Kernel &kernel); static size_t pushBindingTableAndSurfaceStates(IndirectHeap &dstHeap, const KernelInfo &srcKernelInfo, const void *srcKernelSsh, size_t srcKernelSshSize, @@ -100,7 +100,7 @@ struct KernelCommandsHelper : public PerThreadDataHelper { size_t ihReservedBlockSize, IndirectHeap &ioh, IndirectHeap &ssh, - const Kernel &kernel, + Kernel &kernel, uint32_t simd, const size_t localWorkSize[3], const uint64_t offsetInterfaceDescriptorTable, diff --git a/runtime/helpers/kernel_commands.inl b/runtime/helpers/kernel_commands.inl index 39ae75a0c8..e87e5bc13d 100644 --- a/runtime/helpers/kernel_commands.inl +++ b/runtime/helpers/kernel_commands.inl @@ -26,6 +26,7 @@ #include "runtime/helpers/aligned_memory.h" #include "runtime/helpers/basic_math.h" #include "runtime/helpers/dispatch_info.h" +#include "runtime/helpers/address_patch.h" #include "runtime/helpers/ptr_math.h" #include "runtime/helpers/string.h" #include "runtime/indirect_heap/indirect_heap.h" @@ -253,7 +254,7 @@ void KernelCommandsHelper::sendMediaInterfaceDescriptorLoad( template size_t KernelCommandsHelper::sendCrossThreadData( IndirectHeap &indirectHeap, - const Kernel &kernel) { + Kernel &kernel) { typedef typename GfxFamily::GPGPU_WALKER GPGPU_WALKER; indirectHeap.align(GPGPU_WALKER::INDIRECTDATASTARTADDRESS_ALIGN_SIZE); @@ -263,6 +264,13 @@ size_t KernelCommandsHelper::sendCrossThreadData( char *pDest = static_cast(indirectHeap.getSpace(sizeCrossThreadData)); memcpy_s(pDest, sizeCrossThreadData, kernel.getCrossThreadData(), sizeCrossThreadData); + if (DebugManager.flags.AddPatchInfoCommentsForAUBDump.get()) { + for (auto &patchInfoData : kernel.getPatchInfoDataList()) { + patchInfoData.targetAllocation = indirectHeap.getGpuBase(); + patchInfoData.targetAllocationOffset += offsetCrossThreadData; + } + } + return offsetCrossThreadData; } @@ -327,7 +335,7 @@ size_t KernelCommandsHelper::sendIndirectState( size_t ihReservedBlockSize, IndirectHeap &ioh, IndirectHeap &ssh, - const Kernel &kernel, + Kernel &kernel, uint32_t simd, const size_t localWorkSize[3], const uint64_t offsetInterfaceDescriptorTable, diff --git a/runtime/helpers/state_base_address.inl b/runtime/helpers/state_base_address.inl index 56359cb99d..f367944722 100644 --- a/runtime/helpers/state_base_address.inl +++ b/runtime/helpers/state_base_address.inl @@ -25,7 +25,6 @@ #include "runtime/helpers/cache_policy.h" #include "runtime/gmm_helper/gmm_helper.h" #include "runtime/memory_manager/memory_constants.h" -#include namespace OCLRT { template diff --git a/runtime/kernel/kernel.cpp b/runtime/kernel/kernel.cpp index 7adf50fcef..91063d234c 100644 --- a/runtime/kernel/kernel.cpp +++ b/runtime/kernel/kernel.cpp @@ -1093,7 +1093,12 @@ cl_int Kernel::setArgBuffer(uint32_t argIndex, auto patchSize = kernelArgInfo.kernelArgPatchInfoVector[0].size; - buffer->setArgStateless(patchLocation, patchSize, !this->isBuiltIn); + uint64_t addressToPatch = buffer->setArgStateless(patchLocation, patchSize, !this->isBuiltIn); + + if (DebugManager.flags.AddPatchInfoCommentsForAUBDump.get()) { + PatchInfoData patchInfoData = {addressToPatch - buffer->getOffset(), buffer->getOffset(), PatchInfoAllocationType::KernelArg, reinterpret_cast(getCrossThreadData()), kernelArgInfo.kernelArgPatchInfoVector[0].crossthreadOffset, PatchInfoAllocationType::IndirectObjectHeap}; + this->patchInfoDataList.push_back(patchInfoData); + } if (requiresSshForBuffers()) { auto surfaceState = ptrOffset(getSurfaceStateHeap(), kernelArgInfo.offsetHeap); diff --git a/runtime/kernel/kernel.h b/runtime/kernel/kernel.h index b184efd2ec..d50c9704a9 100644 --- a/runtime/kernel/kernel.h +++ b/runtime/kernel/kernel.h @@ -26,6 +26,7 @@ #include "runtime/device_queue/device_queue.h" #include "runtime/helpers/base_object.h" #include "runtime/helpers/preamble.h" +#include "runtime/helpers/address_patch.h" #include "runtime/program/program.h" #include "runtime/program/kernel_info.h" #include "runtime/os_interface/debug_settings_manager.h" @@ -369,6 +370,8 @@ class Kernel : public BaseObject<_cl_kernel> { return 0; } + std::vector &getPatchInfoDataList() { return patchInfoDataList; }; + protected: struct ObjectCounts { uint32_t imageCount; @@ -476,5 +479,7 @@ class Kernel : public BaseObject<_cl_kernel> { bool usingSharedObjArgs; uint32_t patchedArgumentsNum = 0; + + std::vector patchInfoDataList; }; } // namespace OCLRT diff --git a/runtime/mem_obj/buffer.cpp b/runtime/mem_obj/buffer.cpp index f72713a13b..8bde9146aa 100644 --- a/runtime/mem_obj/buffer.cpp +++ b/runtime/mem_obj/buffer.cpp @@ -266,12 +266,14 @@ Buffer *Buffer::createSubBuffer(cl_mem_flags flags, return buffer; } -void Buffer::setArgStateless(void *memory, uint32_t patchSize, bool set32BitAddressing) { +uint64_t Buffer::setArgStateless(void *memory, uint32_t patchSize, bool set32BitAddressing) { // Subbuffers have offset that graphicsAllocation is not aware of uintptr_t addressToPatch = ((set32BitAddressing) ? static_cast(graphicsAllocation->getGpuAddressToPatch()) : static_cast(graphicsAllocation->getGpuAddress())) + this->offset; DEBUG_BREAK_IF(!(graphicsAllocation->isLocked() || (this->getCpuAddress() == reinterpret_cast(addressToPatch)) || (graphicsAllocation->gpuBaseAddress != 0) || (this->getCpuAddress() == nullptr && this->getGraphicsAllocation()->peekSharedHandle()))); patchWithRequiredSize(memory, patchSize, addressToPatch); + + return addressToPatch; } bool Buffer::bufferRectPitchSet(const size_t *bufferOrigin, diff --git a/runtime/mem_obj/buffer.h b/runtime/mem_obj/buffer.h index 898ccfb7a0..4bc5529e8a 100644 --- a/runtime/mem_obj/buffer.h +++ b/runtime/mem_obj/buffer.h @@ -89,7 +89,8 @@ class Buffer : public MemObj { BufferCreatFunc createFunction = nullptr; bool isSubBuffer(); bool isValidSubBufferOffset(size_t offset); - void setArgStateless(void *memory, uint32_t patchSize, bool set32BitAddressing = false); + uint64_t setArgStateless(void *memory, uint32_t patchSize) { return setArgStateless(memory, patchSize, false); } + uint64_t setArgStateless(void *memory, uint32_t patchSize, bool set32BitAddressing); virtual void setArgStateful(void *memory) = 0; bool bufferRectPitchSet(const size_t *bufferOrigin, const size_t *region, diff --git a/runtime/mem_obj/mem_obj.h b/runtime/mem_obj/mem_obj.h index 2556447a4a..5a0088b86f 100644 --- a/runtime/mem_obj/mem_obj.h +++ b/runtime/mem_obj/mem_obj.h @@ -122,6 +122,7 @@ class MemObj : public BaseObject<_cl_mem> { virtual size_t calculateOffsetForMapping(const MemObjOffsetArray &offset) const { return offset[0]; } size_t calculateMappedPtrLength(const MemObjSizeArray &size) const { return calculateOffsetForMapping(size); } cl_mem_object_type peekClMemObjType() const { return memObjectType; } + size_t getOffset() const { return offset; } protected: void getOsSpecificMemObjectInfo(const cl_mem_info ¶mName, size_t *srcParamSize, void **srcParam); diff --git a/runtime/os_interface/DebugVariables.inl b/runtime/os_interface/DebugVariables.inl index ab3dfb0ea1..00988ab632 100644 --- a/runtime/os_interface/DebugVariables.inl +++ b/runtime/os_interface/DebugVariables.inl @@ -62,6 +62,7 @@ DECLARE_DEBUG_VARIABLE(std::string, ProductFamilyOverride, std::string("unk"), " DECLARE_DEBUG_VARIABLE(bool, DisableAUBBufferDump, false, "Avoid dumping buffers in AUB files") DECLARE_DEBUG_VARIABLE(bool, DisableAUBImageDump, false, "Avoid dumping images in AUB files") DECLARE_DEBUG_VARIABLE(bool, FlattenBatchBufferForAUBDump, false, "Dump multi-level batch buffers to AUB as single, flat batch buffer") +DECLARE_DEBUG_VARIABLE(bool, AddPatchInfoCommentsForAUBDump, false, "Dump comments containing allocations and patching information") /*FEATURE FLAGS*/ DECLARE_DEBUG_VARIABLE(bool, EnableNV12, true, "Enables NV12 extension") DECLARE_DEBUG_VARIABLE(bool, EnablePackedYuv, true, "Enables cl_packed_yuv extension") diff --git a/unit_tests/aub_tests/command_stream/aub_command_stream_fixture.h b/unit_tests/aub_tests/command_stream/aub_command_stream_fixture.h index fd63e9f44f..59cbb087e3 100644 --- a/unit_tests/aub_tests/command_stream/aub_command_stream_fixture.h +++ b/unit_tests/aub_tests/command_stream/aub_command_stream_fixture.h @@ -52,7 +52,7 @@ class AUBCommandStreamFixture : public CommandStreamFixture { // Write our pseudo-op to the AUB file auto aubCsr = reinterpret_cast *>(pCommandStreamReceiver); - aubCsr->stream.fileHandle.write(reinterpret_cast(&header), sizeof(header)); + aubCsr->stream->fileHandle.write(reinterpret_cast(&header), sizeof(header)); } template @@ -62,9 +62,9 @@ class AUBCommandStreamFixture : public CommandStreamFixture { if (offset > length) abort(); - aubCsr->stream.expectMemory(physAddress, - reinterpret_cast(reinterpret_cast(srcAddress) + offset), - size); + aubCsr->stream->expectMemory(physAddress, + reinterpret_cast(reinterpret_cast(srcAddress) + offset), + size); }; aubCsr->ppgtt.pageWalk(reinterpret_cast(gfxAddress), length, 0, walker); diff --git a/unit_tests/command_queue/enqueue_handler_tests.cpp b/unit_tests/command_queue/enqueue_handler_tests.cpp index 5f9ac827d1..d4f27a514b 100644 --- a/unit_tests/command_queue/enqueue_handler_tests.cpp +++ b/unit_tests/command_queue/enqueue_handler_tests.cpp @@ -28,6 +28,7 @@ #include "unit_tests/mocks/mock_context.h" #include "unit_tests/mocks/mock_kernel.h" #include "unit_tests/mocks/mock_mdi.h" +#include "unit_tests/helpers/debug_manager_state_restore.h" #include "test.h" @@ -244,3 +245,40 @@ HWTEST_F(EnqueueHandlerTest, enqueueWithOutputEventRegistersEvent) { event->release(); mockCmdQ->release(); } + +HWTEST_F(EnqueueHandlerTest, givenEnqueueHandlerWhenAddPatchInfoCommentsForAUBDumpIsNotSetThenPatchInfoDataIsNotTransferredToCSR) { + int32_t tag; + auto csr = new MockCsrBase(tag); + pDevice->resetCommandStreamReceiver(csr); + + MockKernelWithInternals mockKernel(*pDevice); + auto mockCmdQ = std::unique_ptr>(new MockCommandQueueHw(context, pDevice, 0)); + + size_t gws[] = {1, 1, 1}; + + PatchInfoData patchInfoData = {0xaaaaaaaa, 0, PatchInfoAllocationType::KernelArg, 0xbbbbbbbb, 0, PatchInfoAllocationType::IndirectObjectHeap}; + mockKernel.mockKernel->getPatchInfoDataList().push_back(patchInfoData); + + EXPECT_CALL(*csr, setPatchInfoData(::testing::_)).Times(0); + mockCmdQ->enqueueKernel(mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr); +} + +HWTEST_F(EnqueueHandlerTest, givenEnqueueHandlerWhenAddPatchInfoCommentsForAUBDumpIsSetThenPatchInfoDataIsTransferredToCSR) { + DebugManagerStateRestore dbgRestore; + DebugManager.flags.AddPatchInfoCommentsForAUBDump.set(true); + + int32_t tag; + auto csr = new MockCsrBase(tag); + pDevice->resetCommandStreamReceiver(csr); + + MockKernelWithInternals mockKernel(*pDevice); + auto mockCmdQ = std::unique_ptr>(new MockCommandQueueHw(context, pDevice, 0)); + + size_t gws[] = {1, 1, 1}; + + PatchInfoData patchInfoData = {0xaaaaaaaa, 0, PatchInfoAllocationType::KernelArg, 0xbbbbbbbb, 0, PatchInfoAllocationType::IndirectObjectHeap}; + mockKernel.mockKernel->getPatchInfoDataList().push_back(patchInfoData); + + EXPECT_CALL(*csr, setPatchInfoData(::testing::_)).Times(6); + mockCmdQ->enqueueKernel(mockKernel.mockKernel, 1, nullptr, gws, nullptr, 0, nullptr, nullptr); +} diff --git a/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp b/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp index 10a6ef56a7..0e540d711d 100644 --- a/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp +++ b/unit_tests/command_stream/aub_command_stream_receiver_tests.cpp @@ -31,6 +31,10 @@ using namespace OCLRT; +using ::testing::Invoke; +using ::testing::_; +using ::testing::Return; + typedef Test AubCommandStreamReceiverTests; template @@ -50,6 +54,11 @@ struct MockAubCsr : public AUBCommandStreamReceiverHw { } MOCK_METHOD2(flattenBatchBuffer, void *(BatchBuffer &batchBuffer, size_t &sizeBatchBuffer)); + MOCK_METHOD0(addPatchInfoComments, bool(void)); +}; + +struct MockAubFileStream : public AUBCommandStreamReceiver::AubFileStream { + MOCK_METHOD1(addComment, bool(const char *message)); }; TEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenItIsCreatedWithWrongGfxCoreFamilyThenNullPointerShouldBeReturned) { @@ -528,6 +537,332 @@ HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenDispatc memoryManager->freeGraphicsMemory(chainedBatchBuffer); } +HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatchInfoCommentsForAUBDumpIsSetThenAddPatchInfoCommentsIsCalled) { + DebugManagerStateRestore dbgRestore; + DebugManager.flags.AddPatchInfoCommentsForAUBDump.set(true); + + std::unique_ptr memoryManager(nullptr); + std::unique_ptr> aubCsr(new MockAubCsr(*platformDevices[0], true)); + memoryManager.reset(aubCsr->createMemoryManager(false)); + + GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096); + ASSERT_NE(nullptr, commandBuffer); + LinearStream cs(commandBuffer); + + BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; + auto engineType = OCLRT::ENGINE_RCS; + ResidencyContainer allocationsForResidency; + aubCsr->setTagAllocation(pDevice->getTagAllocation()); + + EXPECT_CALL(*aubCsr, addPatchInfoComments()).Times(1); + aubCsr->flush(batchBuffer, engineType, &allocationsForResidency); + + memoryManager->freeGraphicsMemory(commandBuffer); +} + +HWTEST_F(AubCommandStreamReceiverTests, givenAubCommandStreamReceiverWhenAddPatchInfoCommentsForAUBDumpIsNotSetThenAddPatchInfoCommentsIsNotCalled) { + std::unique_ptr memoryManager(nullptr); + std::unique_ptr> aubCsr(new MockAubCsr(*platformDevices[0], true)); + memoryManager.reset(aubCsr->createMemoryManager(false)); + + GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096); + ASSERT_NE(nullptr, commandBuffer); + LinearStream cs(commandBuffer); + + BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; + auto engineType = OCLRT::ENGINE_RCS; + ResidencyContainer allocationsForResidency; + aubCsr->setTagAllocation(pDevice->getTagAllocation()); + + EXPECT_CALL(*aubCsr, addPatchInfoComments()).Times(0); + aubCsr->flush(batchBuffer, engineType, &allocationsForResidency); + + memoryManager->freeGraphicsMemory(commandBuffer); +} + +HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenNoPatchInfoDataObjectsThenCommentsAreEmpty) { + std::unique_ptr memoryManager(nullptr); + std::unique_ptr> aubCsr(new AUBCommandStreamReceiverHw(*platformDevices[0], true)); + memoryManager.reset(aubCsr->createMemoryManager(false)); + + GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096); + ASSERT_NE(nullptr, commandBuffer); + LinearStream cs(commandBuffer); + + BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; + + std::unique_ptr mockAubFileStream(new MockAubFileStream()); + MockAubFileStream *mockAubFileStreamPtr = static_cast(mockAubFileStream.get()); + ASSERT_NE(nullptr, mockAubFileStreamPtr); + mockAubFileStream.swap(aubCsr->stream); + + std::vector comments; + + EXPECT_CALL(*mockAubFileStreamPtr, addComment(_)).Times(2).WillRepeatedly(::testing::Invoke([&](const char *str) -> bool { + comments.push_back(std::string(str)); + return true; + })); + bool result = aubCsr->addPatchInfoComments(); + EXPECT_TRUE(result); + + ASSERT_EQ(2u, comments.size()); + + EXPECT_EQ("PatchInfoData\n", comments[0]); + EXPECT_EQ("AllocationsList\n", comments[1]); + + mockAubFileStream.swap(aubCsr->stream); + memoryManager->freeGraphicsMemory(commandBuffer); +} + +HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenFirstAddCommentsFailsThenFunctionReturnsFalse) { + std::unique_ptr memoryManager(nullptr); + std::unique_ptr> aubCsr(new AUBCommandStreamReceiverHw(*platformDevices[0], true)); + memoryManager.reset(aubCsr->createMemoryManager(false)); + + GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096); + ASSERT_NE(nullptr, commandBuffer); + LinearStream cs(commandBuffer); + + BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; + + std::unique_ptr mockAubFileStream(new MockAubFileStream()); + MockAubFileStream *mockAubFileStreamPtr = static_cast(mockAubFileStream.get()); + ASSERT_NE(nullptr, mockAubFileStreamPtr); + mockAubFileStream.swap(aubCsr->stream); + + EXPECT_CALL(*mockAubFileStreamPtr, addComment(_)).Times(1).WillOnce(Return(false)); + bool result = aubCsr->addPatchInfoComments(); + EXPECT_FALSE(result); + + mockAubFileStream.swap(aubCsr->stream); + memoryManager->freeGraphicsMemory(commandBuffer); +} + +HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenSecondAddCommentsFailsThenFunctionReturnsFalse) { + std::unique_ptr memoryManager(nullptr); + std::unique_ptr> aubCsr(new AUBCommandStreamReceiverHw(*platformDevices[0], true)); + memoryManager.reset(aubCsr->createMemoryManager(false)); + + GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096); + ASSERT_NE(nullptr, commandBuffer); + LinearStream cs(commandBuffer); + + BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; + + std::unique_ptr mockAubFileStream(new MockAubFileStream()); + MockAubFileStream *mockAubFileStreamPtr = static_cast(mockAubFileStream.get()); + ASSERT_NE(nullptr, mockAubFileStreamPtr); + mockAubFileStream.swap(aubCsr->stream); + + EXPECT_CALL(*mockAubFileStreamPtr, addComment(_)).Times(2).WillOnce(Return(true)).WillOnce(Return(false)); + bool result = aubCsr->addPatchInfoComments(); + EXPECT_FALSE(result); + + mockAubFileStream.swap(aubCsr->stream); + memoryManager->freeGraphicsMemory(commandBuffer); +} + +HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenPatchInfoDataObjectsAddedThenCommentsAreNotEmpty) { + std::unique_ptr memoryManager(nullptr); + std::unique_ptr> aubCsr(new AUBCommandStreamReceiverHw(*platformDevices[0], true)); + memoryManager.reset(aubCsr->createMemoryManager(false)); + + GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096); + ASSERT_NE(nullptr, commandBuffer); + LinearStream cs(commandBuffer); + + BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; + + std::unique_ptr mockAubFileStream(new MockAubFileStream()); + MockAubFileStream *mockAubFileStreamPtr = static_cast(mockAubFileStream.get()); + ASSERT_NE(nullptr, mockAubFileStreamPtr); + mockAubFileStream.swap(aubCsr->stream); + + PatchInfoData patchInfoData[2] = {{0xAAAAAAAA, 128u, PatchInfoAllocationType::Default, 0xBBBBBBBB, 256u, PatchInfoAllocationType::Default}, + {0xBBBBBBBB, 128u, PatchInfoAllocationType::Default, 0xDDDDDDDD, 256u, PatchInfoAllocationType::Default}}; + + EXPECT_TRUE(aubCsr->setPatchInfoData(patchInfoData[0])); + EXPECT_TRUE(aubCsr->setPatchInfoData(patchInfoData[1])); + + std::vector comments; + + EXPECT_CALL(*mockAubFileStreamPtr, addComment(_)).Times(2).WillRepeatedly(::testing::Invoke([&](const char *str) -> bool { + comments.push_back(std::string(str)); + return true; + })); + bool result = aubCsr->addPatchInfoComments(); + EXPECT_TRUE(result); + + ASSERT_EQ(2u, comments.size()); + + EXPECT_EQ("PatchInfoData", comments[0].substr(0, 13)); + EXPECT_EQ("AllocationsList", comments[1].substr(0, 15)); + + std::string line; + std::istringstream input1; + input1.str(comments[0]); + + uint32_t lineNo = 0; + while (std::getline(input1, line)) { + if (line.substr(0, 13) == "PatchInfoData") { + continue; + } + std::ostringstream ss; + ss << std::hex << patchInfoData[lineNo].sourceAllocation << ";" << patchInfoData[lineNo].sourceAllocationOffset << ";" << patchInfoData[lineNo].sourceType << ";"; + ss << patchInfoData[lineNo].targetAllocation << ";" << patchInfoData[lineNo].targetAllocationOffset << ";" << patchInfoData[lineNo].targetType << ";"; + + EXPECT_EQ(ss.str(), line); + lineNo++; + } + + std::vector expectedAddresses = {"aaaaaaaa", "bbbbbbbb", "cccccccc", "dddddddd"}; + lineNo = 0; + + std::istringstream input2; + input2.str(comments[1]); + while (std::getline(input2, line)) { + if (line.substr(0, 15) == "AllocationsList") { + continue; + } + + bool foundAddr = false; + for (auto &addr : expectedAddresses) { + if (line.substr(0, 8) == addr) { + foundAddr = true; + break; + } + } + EXPECT_TRUE(foundAddr); + EXPECT_TRUE(line.size() > 9); + lineNo++; + } + + mockAubFileStream.swap(aubCsr->stream); + memoryManager->freeGraphicsMemory(commandBuffer); +} + +HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenSourceAllocationIsNullThenDoNotAddToAllocationsList) { + std::unique_ptr memoryManager(nullptr); + std::unique_ptr> aubCsr(new AUBCommandStreamReceiverHw(*platformDevices[0], true)); + memoryManager.reset(aubCsr->createMemoryManager(false)); + + GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096); + ASSERT_NE(nullptr, commandBuffer); + LinearStream cs(commandBuffer); + + BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; + + std::unique_ptr mockAubFileStream(new MockAubFileStream()); + MockAubFileStream *mockAubFileStreamPtr = static_cast(mockAubFileStream.get()); + ASSERT_NE(nullptr, mockAubFileStreamPtr); + mockAubFileStream.swap(aubCsr->stream); + + PatchInfoData patchInfoData = {0x0, 0u, PatchInfoAllocationType::Default, 0xBBBBBBBB, 0u, PatchInfoAllocationType::Default}; + EXPECT_TRUE(aubCsr->setPatchInfoData(patchInfoData)); + + std::vector comments; + + EXPECT_CALL(*mockAubFileStreamPtr, addComment(_)).Times(2).WillRepeatedly(::testing::Invoke([&](const char *str) -> bool { + comments.push_back(std::string(str)); + return true; + })); + bool result = aubCsr->addPatchInfoComments(); + EXPECT_TRUE(result); + + ASSERT_EQ(2u, comments.size()); + + ASSERT_EQ("PatchInfoData", comments[0].substr(0, 13)); + ASSERT_EQ("AllocationsList", comments[1].substr(0, 15)); + + std::string line; + std::istringstream input; + input.str(comments[1]); + + uint32_t lineNo = 0; + + std::vector expectedAddresses = {"bbbbbbbb"}; + while (std::getline(input, line)) { + if (line.substr(0, 15) == "AllocationsList") { + continue; + } + + bool foundAddr = false; + for (auto &addr : expectedAddresses) { + if (line.substr(0, 8) == addr) { + foundAddr = true; + break; + } + } + EXPECT_TRUE(foundAddr); + EXPECT_TRUE(line.size() > 9); + lineNo++; + } + + mockAubFileStream.swap(aubCsr->stream); + memoryManager->freeGraphicsMemory(commandBuffer); +} + +HWTEST_F(AubCommandStreamReceiverTests, givenAddPatchInfoCommentsCalledWhenTargetAllocationIsNullThenDoNotAddToAllocationsList) { + std::unique_ptr memoryManager(nullptr); + std::unique_ptr> aubCsr(new AUBCommandStreamReceiverHw(*platformDevices[0], true)); + memoryManager.reset(aubCsr->createMemoryManager(false)); + + GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemory(4096, 4096); + ASSERT_NE(nullptr, commandBuffer); + LinearStream cs(commandBuffer); + + BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 128u, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs}; + + std::unique_ptr mockAubFileStream(new MockAubFileStream()); + MockAubFileStream *mockAubFileStreamPtr = static_cast(mockAubFileStream.get()); + ASSERT_NE(nullptr, mockAubFileStreamPtr); + mockAubFileStream.swap(aubCsr->stream); + + PatchInfoData patchInfoData = {0xAAAAAAAA, 0u, PatchInfoAllocationType::Default, 0x0, 0u, PatchInfoAllocationType::Default}; + EXPECT_TRUE(aubCsr->setPatchInfoData(patchInfoData)); + + std::vector comments; + + EXPECT_CALL(*mockAubFileStreamPtr, addComment(_)).Times(2).WillRepeatedly(::testing::Invoke([&](const char *str) -> bool { + comments.push_back(std::string(str)); + return true; + })); + bool result = aubCsr->addPatchInfoComments(); + EXPECT_TRUE(result); + + ASSERT_EQ(2u, comments.size()); + + ASSERT_EQ("PatchInfoData", comments[0].substr(0, 13)); + ASSERT_EQ("AllocationsList", comments[1].substr(0, 15)); + + std::string line; + std::istringstream input; + input.str(comments[1]); + + uint32_t lineNo = 0; + + std::vector expectedAddresses = {"aaaaaaaa"}; + while (std::getline(input, line)) { + if (line.substr(0, 15) == "AllocationsList") { + continue; + } + + bool foundAddr = false; + for (auto &addr : expectedAddresses) { + if (line.substr(0, 8) == addr) { + foundAddr = true; + break; + } + } + EXPECT_TRUE(foundAddr); + EXPECT_TRUE(line.size() > 9); + lineNo++; + } + + mockAubFileStream.swap(aubCsr->stream); + memoryManager->freeGraphicsMemory(commandBuffer); +} + class OsAgnosticMemoryManagerForImagesWithNoHostPtr : public OsAgnosticMemoryManager { public: GraphicsAllocation *allocateGraphicsMemoryForImage(ImageInfo &imgInfo, Gmm *gmm) override { diff --git a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp index bc19151fd1..09be71535a 100644 --- a/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_hw_tests.cpp @@ -57,6 +57,9 @@ using namespace OCLRT; +using ::testing::Invoke; +using ::testing::_; + struct UltCommandStreamReceiverTest : public DeviceFixture, public BuiltInFixture, @@ -3425,3 +3428,141 @@ HWTEST_F(CommandStreamReceiverFlushTaskTests, givenDispatchFlagsWithThrottleSetT EXPECT_EQ(cmdBuffer->batchBuffer.throttle, QueueThrottle::HIGH); } + +HWTEST_F(CommandStreamReceiverFlushTaskTests, givenMockCommandStreamerWhenAddPatchInfoCommentsForAUBDumpIsNotSetThenAddPatchInfoDataIsNotCollected) { + + CommandQueueHw commandQueue(nullptr, pDevice, 0); + auto &commandStream = commandQueue.getCS(4096u); + + int32_t tag; + auto mockCsr = new MockCsrBase(tag); + pDevice->resetCommandStreamReceiver(mockCsr); + + DispatchFlags dispatchFlags; + dispatchFlags.throttle = QueueThrottle::MEDIUM; + + EXPECT_CALL(*mockCsr, setPatchInfoData(_)).Times(0); + + mockCsr->flushTask(commandStream, + 0, + dsh, + ih, + ioh, + ssh, + taskLevel, + dispatchFlags); +} + +HWTEST_F(CommandStreamReceiverFlushTaskTests, givenMockCommandStreamerWhenAddPatchInfoCommentsForAUBDumpIsSetThenAddPatchInfoDataIsCollected) { + DebugManagerStateRestore dbgRestore; + DebugManager.flags.AddPatchInfoCommentsForAUBDump.set(true); + + CommandQueueHw commandQueue(nullptr, pDevice, 0); + auto &commandStream = commandQueue.getCS(4096u); + + int32_t tag; + auto mockCsr = new MockCsrBase(tag); + pDevice->resetCommandStreamReceiver(mockCsr); + + DispatchFlags dispatchFlags; + dispatchFlags.throttle = QueueThrottle::MEDIUM; + + std::vector patchInfoDataVector; + EXPECT_CALL(*mockCsr, setPatchInfoData(_)).Times(5).WillRepeatedly(Invoke([&](PatchInfoData &data) { + patchInfoDataVector.push_back(data); + return true; + })); + + mockCsr->flushTask(commandStream, + 0, + dsh, + ih, + ioh, + ssh, + taskLevel, + dispatchFlags); + + EXPECT_EQ(5u, patchInfoDataVector.size()); + + for (auto &patchInfoData : patchInfoDataVector) { + uint64_t expectedAddress = 0u; + switch (patchInfoData.sourceType) { + case PatchInfoAllocationType::DynamicStateHeap: + expectedAddress = dsh.getGpuBase(); + break; + case PatchInfoAllocationType::SurfaceStateHeap: + expectedAddress = ssh.getGpuBase(); + break; + case PatchInfoAllocationType::IndirectObjectHeap: + expectedAddress = ioh.getGpuBase(); + break; + case PatchInfoAllocationType::InstructionHeap: + expectedAddress = ih.getGpuBase(); + break; + default: + expectedAddress = 0u; + } + EXPECT_EQ(expectedAddress, patchInfoData.sourceAllocation); + EXPECT_EQ(0u, patchInfoData.sourceAllocationOffset); + EXPECT_EQ(commandStream.getGpuBase(), patchInfoData.targetAllocation); + EXPECT_EQ(PatchInfoAllocationType::Default, patchInfoData.targetType); + EXPECT_NE(commandStream.getGpuBase(), patchInfoData.targetAllocationOffset); + } +} + +HWTEST_F(CommandStreamReceiverFlushTaskTests, givenNonAubCsrWhenSetPatchInfoDataIsCalledThenNoDataIsCollected) { + std::unique_ptr> mockCsr(new MockCsrHw2(*platformDevices[0])); + PatchInfoData patchInfoData = {0u, 0u, PatchInfoAllocationType::Default, 0u, 0u, PatchInfoAllocationType::Default}; + EXPECT_FALSE(mockCsr->setPatchInfoData(patchInfoData)); +} + +HWTEST_F(CommandStreamReceiverFlushTaskTests, givenMockCsrWhenCollectStateBaseAddresPatchInfoIsCalledThenAppropriateAddressesAreTaken) { + typedef typename FamilyType::STATE_BASE_ADDRESS STATE_BASE_ADDRESS; + + int32_t tag; + std::unique_ptr> mockCsr(new MockCsrBase(tag)); + + std::vector patchInfoDataVector; + EXPECT_CALL(*mockCsr, setPatchInfoData(_)).Times(5).WillRepeatedly(Invoke([&](PatchInfoData &data) { + patchInfoDataVector.push_back(data); + return true; + })); + + uint64_t baseAddress = 0xabcdef; + uint64_t commandOffset = 0xa; + uint64_t generalStateBase = 0xff; + + mockCsr->collectStateBaseAddresPatchInfo(baseAddress, commandOffset, dsh, ih, ioh, ssh, generalStateBase); + + ASSERT_EQ(patchInfoDataVector.size(), 5u); + PatchInfoData dshPatch = patchInfoDataVector[0]; + PatchInfoData gshPatch = patchInfoDataVector[1]; + PatchInfoData sshPatch = patchInfoDataVector[2]; + PatchInfoData iohPatch = patchInfoDataVector[3]; + PatchInfoData ihPatch = patchInfoDataVector[4]; + + for (auto &patch : patchInfoDataVector) { + EXPECT_EQ(patch.targetAllocation, baseAddress); + EXPECT_EQ(patch.sourceAllocationOffset, 0u); + } + + //DSH + EXPECT_EQ(dshPatch.sourceAllocation, dsh.getGpuBase()); + EXPECT_EQ(dshPatch.targetAllocationOffset, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::DYNAMICSTATEBASEADDRESS_BYTEOFFSET); + + //IH + EXPECT_EQ(ihPatch.sourceAllocation, ih.getGpuBase()); + EXPECT_EQ(ihPatch.targetAllocationOffset, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::INSTRUCTIONBASEADDRESS_BYTEOFFSET); + + //IOH + EXPECT_EQ(iohPatch.sourceAllocation, ioh.getGpuBase()); + EXPECT_EQ(iohPatch.targetAllocationOffset, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::INDIRECTOBJECTBASEADDRESS_BYTEOFFSET); + + //SSH + EXPECT_EQ(sshPatch.sourceAllocation, ssh.getGpuBase()); + EXPECT_EQ(sshPatch.targetAllocationOffset, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::SURFACESTATEBASEADDRESS_BYTEOFFSET); + + //GSH + EXPECT_EQ(gshPatch.sourceAllocation, generalStateBase); + EXPECT_EQ(gshPatch.targetAllocationOffset, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::GENERALSTATEBASEADDRESS_BYTEOFFSET); +} diff --git a/unit_tests/helpers/kernel_commands_tests.cpp b/unit_tests/helpers/kernel_commands_tests.cpp index f37a83eccd..3bfdd2e0c5 100644 --- a/unit_tests/helpers/kernel_commands_tests.cpp +++ b/unit_tests/helpers/kernel_commands_tests.cpp @@ -30,6 +30,7 @@ #include "unit_tests/fixtures/device_fixture.h" #include "unit_tests/fixtures/image_fixture.h" #include "unit_tests/fixtures/execution_model_kernel_fixture.h" +#include "unit_tests/helpers/debug_manager_state_restore.h" #include "unit_tests/indirect_heap/indirect_heap_fixture.h" #include "unit_tests/fixtures/built_in_fixture.h" #include "unit_tests/mocks/mock_kernel.h" @@ -211,6 +212,67 @@ HWTEST_F(KernelCommandsTest, sendCrossThreadDataResourceUsage) { EXPECT_EQ(kernel->getCrossThreadDataSize(), usedAfter - usedBefore); } +HWTEST_F(KernelCommandsTest, givenSendCrossThreadDataWhenWhenAddPatchInfoCommentsForAUBDumpIsNotSetThenAddPatchInfoDataOffsetsAreNotMoved) { + CommandQueueHw cmdQ(pContext, pDevice, 0); + + MockContext context; + MockProgram program(&context, false); + std::unique_ptr kernelInfo(KernelInfo::create()); + std::unique_ptr kernel(new MockKernel(&program, *kernelInfo, *pDevice)); + + auto &indirectHeap = cmdQ.getIndirectHeap(IndirectHeap::INDIRECT_OBJECT, 8192); + + PatchInfoData patchInfoData = {0xaaaaaaaa, 0, PatchInfoAllocationType::KernelArg, 0xbbbbbbbb, 0, PatchInfoAllocationType::IndirectObjectHeap}; + kernel->getPatchInfoDataList().push_back(patchInfoData); + + KernelCommandsHelper::sendCrossThreadData( + indirectHeap, + *kernel); + + ASSERT_EQ(1u, kernel->getPatchInfoDataList().size()); + EXPECT_EQ(0xaaaaaaaa, kernel->getPatchInfoDataList()[0].sourceAllocation); + EXPECT_EQ(0u, kernel->getPatchInfoDataList()[0].sourceAllocationOffset); + EXPECT_EQ(PatchInfoAllocationType::KernelArg, kernel->getPatchInfoDataList()[0].sourceType); + EXPECT_EQ(0xbbbbbbbb, kernel->getPatchInfoDataList()[0].targetAllocation); + EXPECT_EQ(0u, kernel->getPatchInfoDataList()[0].targetAllocationOffset); + EXPECT_EQ(PatchInfoAllocationType::IndirectObjectHeap, kernel->getPatchInfoDataList()[0].targetType); +} + +HWTEST_F(KernelCommandsTest, givenSendCrossThreadDataWhenWhenAddPatchInfoCommentsForAUBDumpIsSetThenAddPatchInfoDataOffsetsAreMoved) { + DebugManagerStateRestore dbgRestore; + DebugManager.flags.AddPatchInfoCommentsForAUBDump.set(true); + + CommandQueueHw cmdQ(pContext, pDevice, 0); + + MockContext context; + MockProgram program(&context, false); + std::unique_ptr kernelInfo(KernelInfo::create()); + std::unique_ptr kernel(new MockKernel(&program, *kernelInfo, *pDevice)); + + auto &indirectHeap = cmdQ.getIndirectHeap(IndirectHeap::INDIRECT_OBJECT, 8192); + indirectHeap.getSpace(128u); + + PatchInfoData patchInfoData = {0xaaaaaaaa, 0, PatchInfoAllocationType::KernelArg, 0xbbbbbbbb, 0, PatchInfoAllocationType::IndirectObjectHeap}; + kernel->getPatchInfoDataList().push_back(patchInfoData); + + auto offsetCrossThreadData = KernelCommandsHelper::sendCrossThreadData( + indirectHeap, + *kernel); + + ASSERT_NE(0u, offsetCrossThreadData); + EXPECT_EQ(128u, offsetCrossThreadData); + + ASSERT_EQ(1u, kernel->getPatchInfoDataList().size()); + EXPECT_EQ(0xaaaaaaaa, kernel->getPatchInfoDataList()[0].sourceAllocation); + EXPECT_EQ(0u, kernel->getPatchInfoDataList()[0].sourceAllocationOffset); + EXPECT_EQ(PatchInfoAllocationType::KernelArg, kernel->getPatchInfoDataList()[0].sourceType); + EXPECT_NE(0xbbbbbbbb, kernel->getPatchInfoDataList()[0].targetAllocation); + EXPECT_EQ(indirectHeap.getGpuBase(), kernel->getPatchInfoDataList()[0].targetAllocation); + EXPECT_NE(0u, kernel->getPatchInfoDataList()[0].targetAllocationOffset); + EXPECT_EQ(offsetCrossThreadData, kernel->getPatchInfoDataList()[0].targetAllocationOffset); + EXPECT_EQ(PatchInfoAllocationType::IndirectObjectHeap, kernel->getPatchInfoDataList()[0].targetType); +} + HWTEST_F(KernelCommandsTest, sendIndirectStateResourceUsage) { typedef typename FamilyType::INTERFACE_DESCRIPTOR_DATA INTERFACE_DESCRIPTOR_DATA; diff --git a/unit_tests/mem_obj/buffer_set_arg_tests.cpp b/unit_tests/mem_obj/buffer_set_arg_tests.cpp index 6805a55fff..f84c04f7dd 100644 --- a/unit_tests/mem_obj/buffer_set_arg_tests.cpp +++ b/unit_tests/mem_obj/buffer_set_arg_tests.cpp @@ -29,6 +29,7 @@ #include "unit_tests/fixtures/buffer_fixture.h" #include "unit_tests/mocks/mock_kernel.h" #include "unit_tests/mocks/mock_program.h" +#include "unit_tests/helpers/debug_manager_state_restore.h" #include "gtest/gtest.h" using namespace OCLRT; @@ -245,3 +246,35 @@ TEST_F(BufferSetArgTest, getKernelArgShouldReturnBuffer) { EXPECT_EQ(memObj, pKernel->getKernelArg(0)); } + +TEST_F(BufferSetArgTest, givenKernelArgBufferWhenAddPathInfoDataIsSetThenPatchInfoDataIsCollected) { + DebugManagerStateRestore dbgRestore; + DebugManager.flags.AddPatchInfoCommentsForAUBDump.set(true); + cl_mem memObj = buffer; + + retVal = pKernel->setArg( + 0, + sizeof(memObj), + &memObj); + + ASSERT_EQ(CL_SUCCESS, retVal); + ASSERT_EQ(1u, pKernel->getPatchInfoDataList().size()); + + EXPECT_EQ(PatchInfoAllocationType::KernelArg, pKernel->getPatchInfoDataList()[0].sourceType); + EXPECT_EQ(PatchInfoAllocationType::IndirectObjectHeap, pKernel->getPatchInfoDataList()[0].targetType); + EXPECT_EQ(buffer->getGraphicsAllocation()->getGpuAddressToPatch(), pKernel->getPatchInfoDataList()[0].sourceAllocation); + EXPECT_EQ(reinterpret_cast(pKernel->getCrossThreadData()), pKernel->getPatchInfoDataList()[0].targetAllocation); + EXPECT_EQ(0u, pKernel->getPatchInfoDataList()[0].sourceAllocationOffset); +} + +TEST_F(BufferSetArgTest, givenKernelArgBufferWhenAddPathInfoDataIsNotSetThenPatchInfoDataIsNotCollected) { + cl_mem memObj = buffer; + + retVal = pKernel->setArg( + 0, + sizeof(memObj), + &memObj); + + ASSERT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(0u, pKernel->getPatchInfoDataList().size()); +} diff --git a/unit_tests/mocks/mock_csr.h b/unit_tests/mocks/mock_csr.h index 8efdbf7ea2..0a81dbdfe2 100644 --- a/unit_tests/mocks/mock_csr.h +++ b/unit_tests/mocks/mock_csr.h @@ -28,8 +28,14 @@ #include "runtime/helpers/flush_stamp.h" #include "runtime/helpers/string.h" #include "unit_tests/libult/ult_command_stream_receiver.h" +#include "gmock/gmock.h" #include +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Winconsistent-missing-override" +#endif + using namespace OCLRT; template @@ -83,6 +89,8 @@ class MockCsrBase : public UltCommandStreamReceiver { processEvictionCalled = true; } + MOCK_METHOD1(setPatchInfoData, bool(PatchInfoData &)); + ResidencyContainer madeResidentGfxAllocations; ResidencyContainer madeNonResidentGfxAllocations; int32_t *executionStamp; @@ -141,7 +149,8 @@ class MockCsr : public MockCsrBase { }; template -struct MockCsrHw2 : public CommandStreamReceiverHw { +class MockCsrHw2 : public CommandStreamReceiverHw { + public: using CommandStreamReceiverHw::flushStamp; using CommandStreamReceiver::commandStream; using CommandStreamReceiver::dispatchMode; @@ -250,3 +259,7 @@ class MockCommandStreamReceiver : public CommandStreamReceiver { instructionHeapReserveredData.data(), instructionHeapReserveredData.size()); } }; + +#if defined(__clang__) +#pragma clang diagnostic pop +#endif diff --git a/unit_tests/test_files/igdrcl.config b/unit_tests/test_files/igdrcl.config index 8566212d23..3b3c9d4c77 100644 --- a/unit_tests/test_files/igdrcl.config +++ b/unit_tests/test_files/igdrcl.config @@ -62,3 +62,4 @@ OverrideThreadArbitrationPolicy = -1 PrintDriverDiagnostics = -1 FlattenBatchBufferForAUBDump = false PrintDispatchParameters = false +AddPatchInfoCommentsForAUBDump = false