diff --git a/runtime/aub/aub_helper.cpp b/runtime/aub/aub_helper.cpp index 43c1361e47..19daa0368c 100644 --- a/runtime/aub/aub_helper.cpp +++ b/runtime/aub/aub_helper.cpp @@ -21,4 +21,8 @@ uint64_t AubHelper::getPTEntryBits(uint64_t pdEntryBits) { void AubHelper::checkPTEAddress(uint64_t address) { } +uint32_t AubHelper::getMemType(uint32_t addressSpace) { + return 0; +} + } // namespace OCLRT diff --git a/runtime/aub/aub_helper.h b/runtime/aub/aub_helper.h index 5585af2d22..950bb61104 100644 --- a/runtime/aub/aub_helper.h +++ b/runtime/aub/aub_helper.h @@ -27,6 +27,7 @@ class AubHelper : public NonCopyableOrMovableClass { static int getMemTrace(uint64_t pdEntryBits); static uint64_t getPTEntryBits(uint64_t pdEntryBits); static void checkPTEAddress(uint64_t address); + static uint32_t getMemType(uint32_t addressSpace); virtual int getDataHintForPml4Entry() const = 0; virtual int getDataHintForPdpEntry() const = 0; diff --git a/runtime/aub_mem_dump/aub_mem_dump.h b/runtime/aub_mem_dump/aub_mem_dump.h index e12a8fe332..0b4d5a6eb9 100644 --- a/runtime/aub_mem_dump/aub_mem_dump.h +++ b/runtime/aub_mem_dump/aub_mem_dump.h @@ -104,7 +104,7 @@ struct AubStream { virtual void writeMemoryWriteHeader(uint64_t physAddress, size_t size, uint32_t addressSpace) { return writeMemoryWriteHeader(physAddress, size, addressSpace, CmdServicesMemTraceMemoryWrite::DataTypeHintValues::TraceNotype); } - virtual void writePTE(uint64_t physAddress, uint64_t entry) = 0; + virtual void writePTE(uint64_t physAddress, uint64_t entry, uint32_t addressSpace) = 0; virtual void writeGTT(uint32_t offset, uint64_t entry) = 0; void writeMMIO(uint32_t offset, uint32_t value); virtual void registerPoll(uint32_t registerOffset, uint32_t mask, uint32_t value, bool pollNotEqual, uint32_t timeoutAction) = 0; @@ -121,7 +121,7 @@ struct AubFileStream : public AubStream { void createContext(const AubPpgttContextCreate &cmd) override; void writeMemory(uint64_t physAddress, const void *memory, size_t size, uint32_t addressSpace, uint32_t hint) override; void writeMemoryWriteHeader(uint64_t physAddress, size_t size, uint32_t addressSpace, uint32_t hint) override; - void writePTE(uint64_t physAddress, uint64_t entry) override; + void writePTE(uint64_t physAddress, uint64_t entry, uint32_t addressSpace) override; void writeGTT(uint32_t offset, uint64_t entry) override; void writeMMIOImpl(uint32_t offset, uint32_t value) override; void registerPoll(uint32_t registerOffset, uint32_t mask, uint32_t value, bool pollNotEqual, uint32_t timeoutAction) override; diff --git a/runtime/aub_mem_dump/aub_mem_dump.inl b/runtime/aub_mem_dump/aub_mem_dump.inl index a0c4f9ed4f..4b669e0133 100644 --- a/runtime/aub_mem_dump/aub_mem_dump.inl +++ b/runtime/aub_mem_dump/aub_mem_dump.inl @@ -157,19 +157,20 @@ uint64_t AubPageTableHelper32::reserveAddressPPGTT(typename Traits::Stre // Process the PD entries bool writePDE = true; if (writePDE) { - auto start_address = BaseClass::getPDEAddress(startPDE); + auto startAddress = BaseClass::getPDEAddress(startPDE); + auto addressSpace = aubHelper.getMemTraceForPdEntry(); + auto hint = aubHelper.getDataHintForPdEntry(); - stream.writeMemoryWriteHeader(start_address, numPDEs * sizeof(uint64_t), - aubHelper.getMemTraceForPdEntry(), - aubHelper.getDataHintForPdEntry()); + stream.writeMemoryWriteHeader(startAddress, numPDEs * sizeof(uint64_t), + addressSpace, hint); auto currPDE = startPDE; auto physPage = BaseClass::getPTEAddress(startPTE) & g_pageMask; while (currPDE <= endPDE) { auto pde = physPage | OCLRT::AubHelper::getPTEntryBits(additionalBits); - stream.writePTE(start_address, pde); - start_address += sizeof(pde); + stream.writePTE(startAddress, pde, addressSpace); + startAddress += sizeof(pde); physPage += 4096; currPDE++; @@ -179,19 +180,20 @@ uint64_t AubPageTableHelper32::reserveAddressPPGTT(typename Traits::Stre // Process the PT entries bool writePTE = true; if (writePTE) { - auto start_address = BaseClass::getPTEAddress(startPTE); + auto startAddress = BaseClass::getPTEAddress(startPTE); + auto addressSpace = aubHelper.getMemTraceForPtEntry(); + auto hint = aubHelper.getDataHintForPtEntry(); - stream.writeMemoryWriteHeader(start_address, numPTEs * sizeof(uint64_t), - aubHelper.getMemTraceForPtEntry(), - aubHelper.getDataHintForPtEntry()); + stream.writeMemoryWriteHeader(startAddress, numPTEs * sizeof(uint64_t), + addressSpace, hint); auto currPTE = startPTE; auto physPage = physAddress & g_pageMask; while (currPTE <= endPTE) { auto pte = physPage | additionalBits; - stream.writePTE(start_address, pte); - start_address += sizeof(pte); + stream.writePTE(startAddress, pte, addressSpace); + startAddress += sizeof(pte); physPage += 4096; currPTE++; @@ -227,19 +229,20 @@ uint64_t AubPageTableHelper64::reserveAddressPPGTT(typename Traits::Stre // Process the PML4 entries bool writePML4 = true; if (writePML4) { - auto start_address = getPML4Address(startPML4); + auto startAddress = getPML4Address(startPML4); + auto addressSpace = aubHelper.getMemTraceForPml4Entry(); + auto hint = aubHelper.getDataHintForPml4Entry(); - stream.writeMemoryWriteHeader(start_address, numPML4s * sizeof(uint64_t), - aubHelper.getMemTraceForPml4Entry(), - aubHelper.getDataHintForPml4Entry()); + stream.writeMemoryWriteHeader(startAddress, numPML4s * sizeof(uint64_t), + addressSpace, hint); auto currPML4 = startPML4; auto physPage = BaseClass::getPDPAddress(startPDP) & g_pageMask; while (currPML4 <= endPML4) { auto pml4 = physPage | OCLRT::AubHelper::getPTEntryBits(additionalBits); - stream.writePTE(start_address, pml4); - start_address += sizeof(pml4); + stream.writePTE(startAddress, pml4, addressSpace); + startAddress += sizeof(pml4); physPage += 4096; currPML4++; @@ -249,19 +252,20 @@ uint64_t AubPageTableHelper64::reserveAddressPPGTT(typename Traits::Stre // Process the PDP entries bool writePDPE = true; if (writePDPE) { - auto start_address = BaseClass::getPDPAddress(startPDP); + auto startAddress = BaseClass::getPDPAddress(startPDP); + auto addressSpace = aubHelper.getMemTraceForPdpEntry(); + auto hint = aubHelper.getDataHintForPdpEntry(); - stream.writeMemoryWriteHeader(start_address, numPDPs * sizeof(uint64_t), - aubHelper.getMemTraceForPdpEntry(), - aubHelper.getDataHintForPdpEntry()); + stream.writeMemoryWriteHeader(startAddress, numPDPs * sizeof(uint64_t), + addressSpace, hint); auto currPDP = startPDP; auto physPage = BaseClass::getPDEAddress(startPDE) & g_pageMask; while (currPDP <= endPDP) { auto pdp = physPage | OCLRT::AubHelper::getPTEntryBits(additionalBits); - stream.writePTE(start_address, pdp); - start_address += sizeof(pdp); + stream.writePTE(startAddress, pdp, addressSpace); + startAddress += sizeof(pdp); physPage += 4096; currPDP++; @@ -271,19 +275,20 @@ uint64_t AubPageTableHelper64::reserveAddressPPGTT(typename Traits::Stre // Process the PD entries bool writePDE = true; if (writePDE) { - auto start_address = BaseClass::getPDEAddress(startPDE); + auto startAddress = BaseClass::getPDEAddress(startPDE); + auto addressSpace = aubHelper.getMemTraceForPdEntry(); + auto hint = aubHelper.getDataHintForPdEntry(); - stream.writeMemoryWriteHeader(start_address, numPDEs * sizeof(uint64_t), - aubHelper.getMemTraceForPdEntry(), - aubHelper.getDataHintForPdEntry()); + stream.writeMemoryWriteHeader(startAddress, numPDEs * sizeof(uint64_t), + addressSpace, hint); auto currPDE = startPDE; auto physPage = BaseClass::getPTEAddress(startPTE) & g_pageMask; while (currPDE <= endPDE) { auto pde = physPage | OCLRT::AubHelper::getPTEntryBits(additionalBits); - stream.writePTE(start_address, pde); - start_address += sizeof(pde); + stream.writePTE(startAddress, pde, addressSpace); + startAddress += sizeof(pde); physPage += 4096; currPDE++; @@ -293,20 +298,21 @@ uint64_t AubPageTableHelper64::reserveAddressPPGTT(typename Traits::Stre // Process the PT entries bool writePTE = true; if (writePTE) { - auto start_address = BaseClass::getPTEAddress(startPTE); + auto startAddress = BaseClass::getPTEAddress(startPTE); + auto addressSpace = aubHelper.getMemTraceForPtEntry(); + auto hint = aubHelper.getDataHintForPtEntry(); - stream.writeMemoryWriteHeader(start_address, numPTEs * sizeof(uint64_t), - aubHelper.getMemTraceForPtEntry(), - aubHelper.getDataHintForPtEntry()); + stream.writeMemoryWriteHeader(startAddress, numPTEs * sizeof(uint64_t), + addressSpace, hint); auto currPTE = startPTE; auto physPage = physAddress & g_pageMask; while (currPTE <= endPTE) { auto pte = physPage | additionalBits; - stream.writePTE(start_address, pte); - start_address += sizeof(pte); - OCLRT::AubHelper::checkPTEAddress(start_address); + stream.writePTE(startAddress, pte, addressSpace); + startAddress += sizeof(pte); + OCLRT::AubHelper::checkPTEAddress(startAddress); physPage += 4096; currPTE++; diff --git a/runtime/command_stream/aub_command_stream_receiver.cpp b/runtime/command_stream/aub_command_stream_receiver.cpp index 64ec4e207c..f0ddaaa6b4 100644 --- a/runtime/command_stream/aub_command_stream_receiver.cpp +++ b/runtime/command_stream/aub_command_stream_receiver.cpp @@ -140,7 +140,7 @@ void AubFileStream::writeGTT(uint32_t gttOffset, uint64_t entry) { write(reinterpret_cast(&entry), sizeof(entry)); } -void AubFileStream::writePTE(uint64_t physAddress, uint64_t entry) { +void AubFileStream::writePTE(uint64_t physAddress, uint64_t entry, uint32_t addressSpace) { write(reinterpret_cast(&entry), sizeof(entry)); } diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.h b/runtime/command_stream/aub_command_stream_receiver_hw.h index fcb42bc55e..a2596ac33e 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.h +++ b/runtime/command_stream/aub_command_stream_receiver_hw.h @@ -53,7 +53,6 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw::getEngineIndex(EngineType engineTy return getEngineIndexFromInstance(engineType); } -template -void AUBCommandStreamReceiverHw::initGlobalMMIO() { - for (auto &mmioPair : AUBFamilyMapper::globalMMIO) { - stream->writeMMIO(mmioPair.first, mmioPair.second); - } -} - template void AUBCommandStreamReceiverHw::initEngineMMIO(EngineInstanceT engineInstance) { auto mmioList = AUBFamilyMapper::perEngineMMIO[engineInstance.type]; @@ -182,7 +175,7 @@ void AUBCommandStreamReceiverHw::initializeEngine(size_t engineIndex) auto mmioBase = getCsTraits(engineInstance).mmioBase; auto &engineInfo = engineInfoTable[engineIndex]; - initGlobalMMIO(); + this->initGlobalMMIO(); initEngineMMIO(engineInstance); this->initAdditionalMMIO(); @@ -812,9 +805,4 @@ template uint32_t AUBCommandStreamReceiverHw::getMemoryBankForGtt() const { return MemoryBanks::getBank(this->deviceIndex); } - -template -PhysicalAddressAllocator *CommandStreamReceiverSimulatedCommonHw::createPhysicalAddressAllocator() { - return new PhysicalAddressAllocator(); -} } // namespace OCLRT diff --git a/runtime/command_stream/command_stream_receiver_simulated_common_hw.h b/runtime/command_stream/command_stream_receiver_simulated_common_hw.h index 679aca4076..ca529ded02 100644 --- a/runtime/command_stream/command_stream_receiver_simulated_common_hw.h +++ b/runtime/command_stream/command_stream_receiver_simulated_common_hw.h @@ -24,6 +24,7 @@ class CommandStreamReceiverSimulatedCommonHw : public CommandStreamReceiverHw +void CommandStreamReceiverSimulatedCommonHw::initGlobalMMIO() { + for (auto &mmioPair : AUBFamilyMapper::globalMMIO) { + stream->writeMMIO(mmioPair.first, mmioPair.second); + } +} + template void CommandStreamReceiverSimulatedCommonHw::initAdditionalMMIO() { auto newOffset = static_cast(DebugManager.flags.AubDumpAddMmioRegister.get()); @@ -16,4 +26,10 @@ void CommandStreamReceiverSimulatedCommonHw::initAdditionalMMIO() { stream->writeMMIO(newOffset, value); } } + +template +PhysicalAddressAllocator *CommandStreamReceiverSimulatedCommonHw::createPhysicalAddressAllocator() { + return new PhysicalAddressAllocator(); +} + } // namespace OCLRT diff --git a/runtime/command_stream/tbx_command_stream_receiver.h b/runtime/command_stream/tbx_command_stream_receiver.h index 81e4026fd6..5cdec48e5f 100644 --- a/runtime/command_stream/tbx_command_stream_receiver.h +++ b/runtime/command_stream/tbx_command_stream_receiver.h @@ -22,6 +22,7 @@ class TbxSockets; class ExecutionEnvironment; class TbxStream : public AubMemDump::AubStream { + protected: TbxSockets *socket = nullptr; public: @@ -37,7 +38,7 @@ class TbxStream : public AubMemDump::AubStream { void writeMemory(uint64_t physAddress, const void *memory, size_t size, uint32_t addressSpace, uint32_t hint) override; void writeMemoryWriteHeader(uint64_t physAddress, size_t size, uint32_t addressSpace, uint32_t hint) override; void writeGTT(uint32_t gttOffset, uint64_t entry) override; - void writePTE(uint64_t physAddress, uint64_t entry) override; + void writePTE(uint64_t physAddress, uint64_t entry, uint32_t addressSpace) override; void writeMMIOImpl(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 readMemory(uint64_t physAddress, void *memory, size_t size); diff --git a/runtime/command_stream/tbx_command_stream_receiver_hw.h b/runtime/command_stream/tbx_command_stream_receiver_hw.h index 312b713e49..a8f4a9cbe7 100644 --- a/runtime/command_stream/tbx_command_stream_receiver_hw.h +++ b/runtime/command_stream/tbx_command_stream_receiver_hw.h @@ -45,7 +45,6 @@ class TbxCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw::getCsTraits return *AUBFamilyMapper::csTraits[engineType]; } -template -void TbxCommandStreamReceiverHw::initGlobalMMIO() { - for (auto &mmioPair : AUBFamilyMapper::globalMMIO) { - tbxStream.writeMMIO(mmioPair.first, mmioPair.second); - } -} - template void TbxCommandStreamReceiverHw::initEngineMMIO(EngineType engineType) { auto mmioList = AUBFamilyMapper::perEngineMMIO[engineType]; @@ -96,7 +89,7 @@ void TbxCommandStreamReceiverHw::initializeEngine(EngineType engineTy auto mmioBase = getCsTraits(engineType).mmioBase; auto &engineInfo = engineInfoTable[engineType]; - initGlobalMMIO(); + this->initGlobalMMIO(); initEngineMMIO(engineType); this->initAdditionalMMIO(); diff --git a/runtime/command_stream/tbx_stream.cpp b/runtime/command_stream/tbx_stream.cpp index f0debff6b9..4424351218 100644 --- a/runtime/command_stream/tbx_stream.cpp +++ b/runtime/command_stream/tbx_stream.cpp @@ -5,6 +5,7 @@ * */ +#include "runtime/aub/aub_helper.h" #include "runtime/command_stream/tbx_command_stream_receiver.h" #include "runtime/helpers/debug_helpers.h" #include "runtime/os_interface/debug_settings_manager.h" @@ -36,15 +37,17 @@ bool TbxStream::init(uint32_t stepping, uint32_t device) { } void TbxStream::writeMemory(uint64_t addr, const void *memory, size_t size, uint32_t addressSpace, uint32_t hint) { - socket->writeMemory(addr, memory, size); + uint32_t type = AubHelper::getMemType(addressSpace); + socket->writeMemory(addr, memory, size, type); } void TbxStream::writeGTT(uint32_t gttOffset, uint64_t entry) { socket->writeGTT(gttOffset, entry); } -void TbxStream::writePTE(uint64_t physAddress, uint64_t entry) { - socket->writeMemory(physAddress, &entry, sizeof(entry)); +void TbxStream::writePTE(uint64_t physAddress, uint64_t entry, uint32_t addressSpace) { + uint32_t type = AubHelper::getMemType(addressSpace); + socket->writeMemory(physAddress, &entry, sizeof(entry), type); } void TbxStream::writeMemoryWriteHeader(uint64_t physAddress, size_t size, uint32_t addressSpace, uint32_t hint) { diff --git a/runtime/enable_gens.cmake b/runtime/enable_gens.cmake index 528f41c395..ecdd1be212 100644 --- a/runtime/enable_gens.cmake +++ b/runtime/enable_gens.cmake @@ -32,6 +32,7 @@ set(RUNTIME_SRCS_GENX_CPP_BASE buffer command_queue command_stream_receiver_hw + command_stream_receiver_simulated_common_hw device_queue experimental_command_buffer gpgpu_walker diff --git a/runtime/gen10/aub_command_stream_receiver_gen10.cpp b/runtime/gen10/aub_command_stream_receiver_gen10.cpp index 5c17df1392..47581bb397 100644 --- a/runtime/gen10/aub_command_stream_receiver_gen10.cpp +++ b/runtime/gen10/aub_command_stream_receiver_gen10.cpp @@ -7,7 +7,6 @@ #include "runtime/command_stream/aub_command_stream_receiver_hw.h" #include "runtime/command_stream/aub_command_stream_receiver_hw.inl" -#include "runtime/command_stream/command_stream_receiver_simulated_common_hw.inl" #include "runtime/helpers/base_object.h" #include "runtime/helpers/array_count.h" @@ -24,5 +23,4 @@ void populateFactoryTable>() { } template class AUBCommandStreamReceiverHw; -template class CommandStreamReceiverSimulatedCommonHw; } // namespace OCLRT diff --git a/runtime/gen10/command_stream_receiver_simulated_common_hw_gen10.cpp b/runtime/gen10/command_stream_receiver_simulated_common_hw_gen10.cpp new file mode 100644 index 0000000000..8caba740ab --- /dev/null +++ b/runtime/gen10/command_stream_receiver_simulated_common_hw_gen10.cpp @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "runtime/command_stream/command_stream_receiver_simulated_common_hw.inl" + +namespace OCLRT { +typedef CNLFamily Family; + +template class CommandStreamReceiverSimulatedCommonHw; +} // namespace OCLRT diff --git a/runtime/gen8/aub_command_stream_receiver_gen8.cpp b/runtime/gen8/aub_command_stream_receiver_gen8.cpp index de4481b45f..c0d7cee078 100644 --- a/runtime/gen8/aub_command_stream_receiver_gen8.cpp +++ b/runtime/gen8/aub_command_stream_receiver_gen8.cpp @@ -7,7 +7,6 @@ #include "runtime/command_stream/aub_command_stream_receiver_hw.h" #include "runtime/command_stream/aub_command_stream_receiver_hw.inl" -#include "runtime/command_stream/command_stream_receiver_simulated_common_hw.inl" #include "runtime/helpers/base_object.h" #include "runtime/helpers/array_count.h" @@ -24,5 +23,4 @@ void populateFactoryTable>() { } template class AUBCommandStreamReceiverHw; -template class CommandStreamReceiverSimulatedCommonHw; } // namespace OCLRT diff --git a/runtime/gen8/command_stream_receiver_simulated_common_hw_gen8.cpp b/runtime/gen8/command_stream_receiver_simulated_common_hw_gen8.cpp new file mode 100644 index 0000000000..6e56342b44 --- /dev/null +++ b/runtime/gen8/command_stream_receiver_simulated_common_hw_gen8.cpp @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "runtime/command_stream/command_stream_receiver_simulated_common_hw.inl" + +namespace OCLRT { +typedef BDWFamily Family; + +template class CommandStreamReceiverSimulatedCommonHw; +} // namespace OCLRT diff --git a/runtime/gen9/aub_command_stream_receiver_gen9.cpp b/runtime/gen9/aub_command_stream_receiver_gen9.cpp index d3528e9e44..5a164567b0 100644 --- a/runtime/gen9/aub_command_stream_receiver_gen9.cpp +++ b/runtime/gen9/aub_command_stream_receiver_gen9.cpp @@ -7,7 +7,6 @@ #include "runtime/command_stream/aub_command_stream_receiver_hw.h" #include "runtime/command_stream/aub_command_stream_receiver_hw.inl" -#include "runtime/command_stream/command_stream_receiver_simulated_common_hw.inl" #include "runtime/helpers/base_object.h" #include "runtime/helpers/array_count.h" @@ -24,5 +23,4 @@ void populateFactoryTable>() { } template class AUBCommandStreamReceiverHw; -template class CommandStreamReceiverSimulatedCommonHw; } // namespace OCLRT diff --git a/runtime/gen9/command_stream_receiver_simulated_common_hw_gen9.cpp b/runtime/gen9/command_stream_receiver_simulated_common_hw_gen9.cpp new file mode 100644 index 0000000000..d8d2902dbd --- /dev/null +++ b/runtime/gen9/command_stream_receiver_simulated_common_hw_gen9.cpp @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "runtime/command_stream/command_stream_receiver_simulated_common_hw.inl" + +namespace OCLRT { +typedef SKLFamily Family; + +template class CommandStreamReceiverSimulatedCommonHw; +} // namespace OCLRT diff --git a/runtime/tbx/tbx_sockets.h b/runtime/tbx/tbx_sockets.h index 60d04ae344..5e1d7efe5a 100644 --- a/runtime/tbx/tbx_sockets.h +++ b/runtime/tbx/tbx_sockets.h @@ -1,24 +1,10 @@ /* -* Copyright (c) 2017, 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. -*/ + * Copyright (C) 2017-2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + #pragma once #include @@ -36,7 +22,7 @@ class TbxSockets { virtual bool writeGTT(uint32_t offset, uint64_t entry) = 0; virtual bool readMemory(uint64_t addr, void *memory, size_t size) = 0; - virtual bool writeMemory(uint64_t addr, const void *memory, size_t size) = 0; + virtual bool writeMemory(uint64_t addr, const void *memory, size_t size, uint32_t type) = 0; virtual bool readMMIO(uint32_t offset, uint32_t *value) = 0; virtual bool writeMMIO(uint32_t offset, uint32_t value) = 0; diff --git a/runtime/tbx/tbx_sockets_imp.cpp b/runtime/tbx/tbx_sockets_imp.cpp index d98ea03683..5f6d86ae1c 100644 --- a/runtime/tbx/tbx_sockets_imp.cpp +++ b/runtime/tbx/tbx_sockets_imp.cpp @@ -224,7 +224,7 @@ bool TbxSocketsImp::readMemory(uint64_t addrOffset, void *data, size_t size) { return success; } -bool TbxSocketsImp::writeMemory(uint64_t physAddr, const void *data, size_t size) { +bool TbxSocketsImp::writeMemory(uint64_t physAddr, const void *data, size_t size, uint32_t type) { HAS_MSG cmd; memset(&cmd, 0, sizeof(cmd)); cmd.hdr.msg_type = HAS_WRITE_DATA_REQ_TYPE; @@ -238,6 +238,7 @@ bool TbxSocketsImp::writeMemory(uint64_t physAddr, const void *data, size_t size cmd.u.write_req.take_ownership = 0; cmd.u.write_req.frontdoor = 0; cmd.u.write_req.cacheline_disable = cmd.u.write_req.frontdoor; + cmd.u.write_req.memory_type = type; bool success; do { diff --git a/runtime/tbx/tbx_sockets_imp.h b/runtime/tbx/tbx_sockets_imp.h index 0b88bbf360..cd8cd83682 100644 --- a/runtime/tbx/tbx_sockets_imp.h +++ b/runtime/tbx/tbx_sockets_imp.h @@ -23,7 +23,7 @@ class TbxSocketsImp : public TbxSockets { bool writeGTT(uint32_t gttOffset, uint64_t entry) override; bool readMemory(uint64_t offset, void *data, size_t size) override; - bool writeMemory(uint64_t offset, const void *data, size_t size) override; + bool writeMemory(uint64_t offset, const void *data, size_t size, uint32_t type) override; bool readMMIO(uint32_t offset, uint32_t *data) override; bool writeMMIO(uint32_t offset, uint32_t data) override; diff --git a/unit_tests/command_stream/CMakeLists.txt b/unit_tests/command_stream/CMakeLists.txt index e641b79143..d0215f7d57 100644 --- a/unit_tests/command_stream/CMakeLists.txt +++ b/unit_tests/command_stream/CMakeLists.txt @@ -26,6 +26,7 @@ set(IGDRCL_SRCS_tests_command_stream ${CMAKE_CURRENT_SOURCE_DIR}/tbx_command_stream_fixture.cpp ${CMAKE_CURRENT_SOURCE_DIR}/tbx_command_stream_fixture.h ${CMAKE_CURRENT_SOURCE_DIR}/tbx_command_stream_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/tbx_stream_tests.cpp ) target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_command_stream}) add_subdirectories() diff --git a/unit_tests/command_stream/tbx_stream_tests.cpp b/unit_tests/command_stream/tbx_stream_tests.cpp new file mode 100644 index 0000000000..d7f115b247 --- /dev/null +++ b/unit_tests/command_stream/tbx_stream_tests.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "runtime/command_stream/tbx_command_stream_receiver_hw.h" +#include "unit_tests/mocks/mock_tbx_sockets.h" +#include "unit_tests/mocks/mock_tbx_stream.h" + +#include "gtest/gtest.h" + +using namespace OCLRT; + +TEST(TbxStreamTests, givenTbxStreamWhenWriteMemoryIsCalledThenTypeIsZero) { + std::unique_ptr mockTbxStream(new MockTbxStream()); + MockTbxStream *mockTbxStreamPtr = static_cast(mockTbxStream.get()); + + MockTbxSockets *mockTbxSocket = new MockTbxSockets(); + mockTbxStreamPtr->socket = mockTbxSocket; + + mockTbxStream->writeMemory(0, nullptr, 0, 0, 0); + EXPECT_EQ(0u, mockTbxSocket->typeCapturedFromWriteMemory); + + mockTbxStream->writePTE(0, 0, 0); + EXPECT_EQ(0u, mockTbxSocket->typeCapturedFromWriteMemory); +} diff --git a/unit_tests/mocks/CMakeLists.txt b/unit_tests/mocks/CMakeLists.txt index 26bd95f790..8644228d2d 100644 --- a/unit_tests/mocks/CMakeLists.txt +++ b/unit_tests/mocks/CMakeLists.txt @@ -11,6 +11,7 @@ set(IGDRCL_SRCS_tests_mocks ${CMAKE_CURRENT_SOURCE_DIR}/mock_async_event_handler.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_csr.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_file_stream.h + ${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_stream.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_aub_subcapture_manager.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_block_kernel_manager.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_buffer.h @@ -58,6 +59,7 @@ set(IGDRCL_SRCS_tests_mocks ${CMAKE_CURRENT_SOURCE_DIR}/mock_sip.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_source_level_debugger.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_submissions_aggregator.h + ${CMAKE_CURRENT_SOURCE_DIR}/mock_tbx_stream.h ) if(WIN32) diff --git a/unit_tests/mocks/mock_aub_stream.h b/unit_tests/mocks/mock_aub_stream.h new file mode 100644 index 0000000000..c6c691c8b1 --- /dev/null +++ b/unit_tests/mocks/mock_aub_stream.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#include "runtime/aub_mem_dump/aub_mem_dump.h" +#include "runtime/gen_common/aub_mapper_base.h" + +namespace OCLRT { + +struct MockAubStreamMockMmioWrite : AubMemDump::AubStream { + void open(const char *filePath) override{}; + void close() override{}; + bool init(uint32_t stepping, uint32_t device) override { return true; }; + void writeMemory(uint64_t physAddress, const void *memory, size_t sizeToDumpThisIteration, uint32_t addressSpace, uint32_t hint) override{}; + void writeMemoryWriteHeader(uint64_t physAddress, size_t size, uint32_t addressSpace, uint32_t hint) override{}; + void writePTE(uint64_t physAddress, uint64_t entry, uint32_t addressSpace) override{}; + void writeGTT(uint32_t offset, uint64_t entry) override{}; + void registerPoll(uint32_t registerOffset, uint32_t mask, uint32_t value, bool pollNotEqual, uint32_t timeoutAction) override{}; + + void writeMMIOImpl(uint32_t offset, uint32_t value) override { + mmioList.push_back(std::make_pair(offset, value)); + } + bool isOnMmioList(const MMIOPair &mmio) { + bool mmioFound = false; + for (auto &mmioPair : mmioList) { + if (mmioPair.first == mmio.first && mmioPair.second == mmio.second) { + mmioFound = true; + break; + } + } + return mmioFound; + } + + std::vector> mmioList; +}; +} // namespace OCLRT diff --git a/unit_tests/mocks/mock_tbx_sockets.h b/unit_tests/mocks/mock_tbx_sockets.h index 76e4809b57..595c822463 100644 --- a/unit_tests/mocks/mock_tbx_sockets.h +++ b/unit_tests/mocks/mock_tbx_sockets.h @@ -21,9 +21,14 @@ class MockTbxSockets : public TbxSockets { bool writeGTT(uint32_t gttOffset, uint64_t entry) override { return true; }; bool readMemory(uint64_t offset, void *data, size_t size) override { return true; }; - bool writeMemory(uint64_t offset, const void *data, size_t size) override { return true; }; + bool writeMemory(uint64_t offset, const void *data, size_t size, uint32_t type) override { + typeCapturedFromWriteMemory = type; + return true; + }; bool readMMIO(uint32_t offset, uint32_t *data) override { return true; }; bool writeMMIO(uint32_t offset, uint32_t data) override { return true; }; + + uint32_t typeCapturedFromWriteMemory = 0; }; } // namespace OCLRT diff --git a/unit_tests/mocks/mock_tbx_stream.h b/unit_tests/mocks/mock_tbx_stream.h new file mode 100644 index 0000000000..26b3edc29b --- /dev/null +++ b/unit_tests/mocks/mock_tbx_stream.h @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2018 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#pragma once + +#include "runtime/command_stream/tbx_command_stream_receiver.h" + +namespace OCLRT { + +struct MockTbxStream : public TbxCommandStreamReceiver::TbxStream { + using TbxCommandStreamReceiver::TbxStream::socket; +}; +} // namespace OCLRT