From 6f84496e78c62b07e30379133bbe0418cde4b0a3 Mon Sep 17 00:00:00 2001 From: Piotr Fusik Date: Fri, 22 Mar 2019 13:23:02 +0100 Subject: [PATCH] Move duplicate code to the base class. Change-Id: I117a6e55fc51bf3ede3a69dbb8a874e71e74ddf9 Signed-off-by: Piotr Fusik --- .../aub_command_stream_receiver_hw.h | 2 -- .../aub_command_stream_receiver_hw.inl | 21 +++---------------- ...mand_stream_receiver_simulated_common_hw.h | 2 ++ ...nd_stream_receiver_simulated_common_hw.inl | 16 ++++++++++++++ .../tbx_command_stream_receiver_hw.inl | 12 +---------- .../windows/wddm_device_command_stream.inl | 2 -- 6 files changed, 22 insertions(+), 33 deletions(-) diff --git a/runtime/command_stream/aub_command_stream_receiver_hw.h b/runtime/command_stream/aub_command_stream_receiver_hw.h index d0a150de7d..bda735e091 100644 --- a/runtime/command_stream/aub_command_stream_receiver_hw.h +++ b/runtime/command_stream/aub_command_stream_receiver_hw.h @@ -10,7 +10,6 @@ #include "runtime/command_stream/aub_command_stream_receiver.h" #include "runtime/gen_common/aub_mapper.h" #include "runtime/helpers/array_count.h" -#include "runtime/memory_manager/address_mapper.h" #include "runtime/memory_manager/os_agnostic_memory_manager.h" #include "runtime/memory_manager/page_table.h" #include "runtime/memory_manager/physical_address_allocator.h" @@ -84,7 +83,6 @@ class AUBCommandStreamReceiverHw : public CommandStreamReceiverSimulatedHw::~AUBCommandStreamReceiverHw() { if (osContext) { pollForCompletion(); } - freeEngineInfo(); + this->freeEngineInfo(*gttRemap); } template @@ -98,7 +98,7 @@ bool AUBCommandStreamReceiverHw::reopenFile(const std::string &fileNa if (isFileOpen()) { if (fileName != getFileName()) { closeFile(); - freeEngineInfo(); + this->freeEngineInfo(*gttRemap); } } if (!isFileOpen()) { @@ -267,21 +267,6 @@ void AUBCommandStreamReceiverHw::initializeEngine() { DEBUG_BREAK_IF(!engineInfo.pLRCA); } -template -void AUBCommandStreamReceiverHw::freeEngineInfo() { - alignedFree(engineInfo.pLRCA); - gttRemap->unmap(engineInfo.pLRCA); - engineInfo.pLRCA = nullptr; - - alignedFree(engineInfo.pGlobalHWStatusPage); - gttRemap->unmap(engineInfo.pGlobalHWStatusPage); - engineInfo.pGlobalHWStatusPage = nullptr; - - alignedFree(engineInfo.pRingBuffer); - gttRemap->unmap(engineInfo.pRingBuffer); - engineInfo.pRingBuffer = nullptr; -} - template CommandStreamReceiver *AUBCommandStreamReceiverHw::create(const std::string &fileName, bool standalone, ExecutionEnvironment &executionEnvironment) { auto csr = new AUBCommandStreamReceiverHw(fileName, standalone, executionEnvironment); @@ -678,7 +663,7 @@ void AUBCommandStreamReceiverHw::expectMemory(const void *gfxAddress, UNRECOVERABLE_IF(offset > length); this->getAubStream()->expectMemory(physAddress, - reinterpret_cast(reinterpret_cast(srcAddress) + offset), + ptrOffset(srcAddress, offset), size, this->getAddressSpaceFromPTEBits(entryBits), compareOperation); 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 cb2ed025bf..2f5857acb4 100644 --- a/runtime/command_stream/command_stream_receiver_simulated_common_hw.h +++ b/runtime/command_stream/command_stream_receiver_simulated_common_hw.h @@ -18,6 +18,7 @@ struct AubStream; } // namespace aub_stream namespace OCLRT { +class AddressMapper; class GraphicsAllocation; class HardwareContextController; template @@ -30,6 +31,7 @@ class CommandStreamReceiverSimulatedCommonHw : public CommandStreamReceiverHw::expectMemoryNotEqual(voi AubMemDump::CmdServicesMemTraceMemoryCompare::CompareOperationValues::CompareNotEqual); } +template +void CommandStreamReceiverSimulatedCommonHw::freeEngineInfo(AddressMapper >tRemap) { + alignedFree(engineInfo.pLRCA); + gttRemap.unmap(engineInfo.pLRCA); + engineInfo.pLRCA = nullptr; + + alignedFree(engineInfo.pGlobalHWStatusPage); + gttRemap.unmap(engineInfo.pGlobalHWStatusPage); + engineInfo.pGlobalHWStatusPage = nullptr; + + alignedFree(engineInfo.pRingBuffer); + gttRemap.unmap(engineInfo.pRingBuffer); + engineInfo.pRingBuffer = nullptr; +} + } // namespace OCLRT diff --git a/runtime/command_stream/tbx_command_stream_receiver_hw.inl b/runtime/command_stream/tbx_command_stream_receiver_hw.inl index 2aa6949b0a..1644099211 100644 --- a/runtime/command_stream/tbx_command_stream_receiver_hw.inl +++ b/runtime/command_stream/tbx_command_stream_receiver_hw.inl @@ -56,17 +56,7 @@ TbxCommandStreamReceiverHw::~TbxCommandStreamReceiverHw() { tbxStream.close(); } - alignedFree(engineInfo.pLRCA); - gttRemap.unmap(engineInfo.pLRCA); - engineInfo.pLRCA = nullptr; - - alignedFree(engineInfo.pGlobalHWStatusPage); - gttRemap.unmap(engineInfo.pGlobalHWStatusPage); - engineInfo.pGlobalHWStatusPage = nullptr; - - alignedFree(engineInfo.pRingBuffer); - gttRemap.unmap(engineInfo.pRingBuffer); - engineInfo.pRingBuffer = nullptr; + this->freeEngineInfo(gttRemap); } template diff --git a/runtime/os_interface/windows/wddm_device_command_stream.inl b/runtime/os_interface/windows/wddm_device_command_stream.inl index 8bd58ce24e..0444ba5a22 100644 --- a/runtime/os_interface/windows/wddm_device_command_stream.inl +++ b/runtime/os_interface/windows/wddm_device_command_stream.inl @@ -22,8 +22,6 @@ #include "hw_cmds.h" #pragma warning(pop) -#undef max - #include "runtime/os_interface/windows/gdi_interface.h" #include "runtime/os_interface/windows/os_context_win.h" #include "runtime/os_interface/windows/os_interface.h"