From b0de2a11d289abb265cc1204d610d81875c60d27 Mon Sep 17 00:00:00 2001 From: "Dunajski, Bartosz" Date: Tue, 27 Nov 2018 14:26:19 +0100 Subject: [PATCH] Set OsContext as reference Change-Id: I3b682fabde9c2ddb2c33a95aef77bf6ce400a21f Signed-off-by: Dunajski, Bartosz --- runtime/command_stream/command_stream_receiver.h | 2 +- runtime/device/device.cpp | 2 +- runtime/os_interface/linux/drm_engine_mapper.h | 2 -- runtime/os_interface/windows/wddm_engine_mapper.h | 3 --- .../command_stream_receiver_with_aub_dump_tests.cpp | 4 ++-- unit_tests/fixtures/ult_command_stream_receiver_fixture.h | 2 +- unit_tests/mocks/mock_aub_csr.h | 2 +- unit_tests/mocks/mock_device.cpp | 2 +- unit_tests/os_interface/linux/drm_command_stream_tests.cpp | 4 ++-- .../os_interface/windows/device_command_stream_tests.cpp | 4 ++-- 10 files changed, 11 insertions(+), 16 deletions(-) diff --git a/runtime/command_stream/command_stream_receiver.h b/runtime/command_stream/command_stream_receiver.h index 481fe3b19c..41754cb2af 100644 --- a/runtime/command_stream/command_stream_receiver.h +++ b/runtime/command_stream/command_stream_receiver.h @@ -161,7 +161,7 @@ class CommandStreamReceiver { InternalAllocationStorage *getInternalAllocationStorage() const { return internalAllocationStorage.get(); } bool createAllocationForHostSurface(HostPtrSurface &surface, Device &device, bool requiresL3Flush); virtual size_t getPreferredTagPoolSize() const { return 512; } - void setOsContext(OsContext *osContext) { this->osContext = osContext; } + void setOsContext(OsContext &osContext) { this->osContext = &osContext; } OsContext &getOsContext() const { return *osContext; } TagAllocator *getEventTsAllocator(); diff --git a/runtime/device/device.cpp b/runtime/device/device.cpp index 02f16ed9b4..f0e438a3a6 100644 --- a/runtime/device/device.cpp +++ b/runtime/device/device.cpp @@ -119,7 +119,7 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) { auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext({getChosenEngineType(*pHwInfo), 0}); auto commandStreamReceiver = executionEnvironment->commandStreamReceivers[outDevice.getDeviceIndex()][deviceCsrIndex].get(); - commandStreamReceiver->setOsContext(osContext); + commandStreamReceiver->setOsContext(*osContext); if (!commandStreamReceiver->initializeTagAllocation()) { return false; } diff --git a/runtime/os_interface/linux/drm_engine_mapper.h b/runtime/os_interface/linux/drm_engine_mapper.h index 284a52eba9..75146d4a31 100644 --- a/runtime/os_interface/linux/drm_engine_mapper.h +++ b/runtime/os_interface/linux/drm_engine_mapper.h @@ -9,8 +9,6 @@ #include "engine_node.h" -#include - namespace OCLRT { class DrmEngineMapper { diff --git a/runtime/os_interface/windows/wddm_engine_mapper.h b/runtime/os_interface/windows/wddm_engine_mapper.h index aed9117ff0..4b9bf264a8 100644 --- a/runtime/os_interface/windows/wddm_engine_mapper.h +++ b/runtime/os_interface/windows/wddm_engine_mapper.h @@ -8,11 +8,8 @@ #pragma once #include "engine_node.h" -#include "runtime/helpers/hw_info.h" #include "runtime/os_interface/windows/wddm/wddm.h" -#include - namespace OCLRT { class WddmEngineMapper { diff --git a/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp b/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp index 4aff7b5069..a3f279dd9b 100644 --- a/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp +++ b/unit_tests/command_stream/command_stream_receiver_with_aub_dump_tests.cpp @@ -111,9 +111,9 @@ struct CommandStreamReceiverWithAubDumpTest : public ::testing::TestWithParamcreateAndRegisterOsContext(getChosenEngineType(DEFAULT_TEST_PLATFORM::hwInfo)); - csrWithAubDump->setOsContext(osContext); + csrWithAubDump->setOsContext(*osContext); if (csrWithAubDump->aubCSR) { - csrWithAubDump->aubCSR->setOsContext(osContext); + csrWithAubDump->aubCSR->setOsContext(*osContext); } } diff --git a/unit_tests/fixtures/ult_command_stream_receiver_fixture.h b/unit_tests/fixtures/ult_command_stream_receiver_fixture.h index 47a12c545a..2119f306ee 100644 --- a/unit_tests/fixtures/ult_command_stream_receiver_fixture.h +++ b/unit_tests/fixtures/ult_command_stream_receiver_fixture.h @@ -55,7 +55,7 @@ struct UltCommandStreamReceiverTest graphicsAllocation = new MockGraphicsAllocation(sshBuffer, sizeStream); ssh.replaceGraphicsAllocation(graphicsAllocation); - pDevice->getCommandStreamReceiver().setOsContext(pDevice->getEngine(0).osContext); + pDevice->getCommandStreamReceiver().setOsContext(*pDevice->getEngine(0).osContext); } void TearDown() override { diff --git a/unit_tests/mocks/mock_aub_csr.h b/unit_tests/mocks/mock_aub_csr.h index dbf69ae979..b06f661412 100644 --- a/unit_tests/mocks/mock_aub_csr.h +++ b/unit_tests/mocks/mock_aub_csr.h @@ -136,7 +136,7 @@ std::unique_ptr getEnvironment(bool createTagAllocation } auto osContext = executionEnvironment->memoryManager->createAndRegisterOsContext(getChosenEngineType(*platformDevices[0])); - executionEnvironment->commandStreamReceivers[0][0]->setOsContext(osContext); + executionEnvironment->commandStreamReceivers[0][0]->setOsContext(*osContext); std::unique_ptr aubExecutionEnvironment(new AubExecutionEnvironment); if (allocateCommandBuffer) { diff --git a/unit_tests/mocks/mock_device.cpp b/unit_tests/mocks/mock_device.cpp index 715972ffe8..ed5d94149f 100644 --- a/unit_tests/mocks/mock_device.cpp +++ b/unit_tests/mocks/mock_device.cpp @@ -50,7 +50,7 @@ void MockDevice::resetCommandStreamReceiver(CommandStreamReceiver *newCsr) { executionEnvironment->commandStreamReceivers[getDeviceIndex()][0]->initializeTagAllocation(); executionEnvironment->commandStreamReceivers[getDeviceIndex()][0]->setPreemptionCsrAllocation(preemptionAllocation); this->engines[0].commandStreamReceiver = newCsr; - this->engines[0].commandStreamReceiver->setOsContext(this->engines[0].osContext); + this->engines[0].commandStreamReceiver->setOsContext(*this->engines[0].osContext); UNRECOVERABLE_IF(getDeviceIndex() != 0u); this->tagAddress = executionEnvironment->commandStreamReceivers[getDeviceIndex()][0]->getTagAddress(); } diff --git a/unit_tests/os_interface/linux/drm_command_stream_tests.cpp b/unit_tests/os_interface/linux/drm_command_stream_tests.cpp index bbde1af0c7..4635ec5877 100644 --- a/unit_tests/os_interface/linux/drm_command_stream_tests.cpp +++ b/unit_tests/os_interface/linux/drm_command_stream_tests.cpp @@ -48,7 +48,7 @@ class DrmCommandStreamFixture { ASSERT_NE(nullptr, csr); executionEnvironment.commandStreamReceivers.resize(1); executionEnvironment.commandStreamReceivers[0][0].reset(csr); - csr->setOsContext(osContext.get()); + csr->setOsContext(*osContext); // Memory manager creates pinBB with ioctl, expect one call EXPECT_CALL(*mock, ioctl(::testing::_, ::testing::_)) @@ -677,7 +677,7 @@ class DrmCommandStreamEnhancedFixture tCsr = new TestedDrmCommandStreamReceiver(*executionEnvironment); csr = tCsr; - csr->setOsContext(osContext.get()); + csr->setOsContext(*osContext); ASSERT_NE(nullptr, csr); mm = reinterpret_cast(csr->createMemoryManager(false, false)); ASSERT_NE(nullptr, mm); diff --git a/unit_tests/os_interface/windows/device_command_stream_tests.cpp b/unit_tests/os_interface/windows/device_command_stream_tests.cpp index f04678bcc8..d9b18ba3eb 100644 --- a/unit_tests/os_interface/windows/device_command_stream_tests.cpp +++ b/unit_tests/os_interface/windows/device_command_stream_tests.cpp @@ -254,7 +254,7 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOf executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false)); executionEnvironment->commandStreamReceivers[0][0]->overrideDispatchPolicy(DispatchMode::ImmediateDispatch); OsContext osContext(executionEnvironment->osInterface.get(), 0u, gpgpuEngineInstances[0]); - executionEnvironment->commandStreamReceivers[0][0]->setOsContext(&osContext); + executionEnvironment->commandStreamReceivers[0][0]->setOsContext(osContext); auto commandBuffer = executionEnvironment->memoryManager->allocateGraphicsMemory(4096); LinearStream cs(commandBuffer); @@ -279,7 +279,7 @@ TEST(WddmPreemptionHeaderTests, givenWddmCommandStreamReceiverWhenPreemptionIsOn executionEnvironment->memoryManager.reset(executionEnvironment->commandStreamReceivers[0][0]->createMemoryManager(false, false)); executionEnvironment->commandStreamReceivers[0][0]->overrideDispatchPolicy(DispatchMode::ImmediateDispatch); OsContext osContext(executionEnvironment->osInterface.get(), 0u, gpgpuEngineInstances[0]); - executionEnvironment->commandStreamReceivers[0][0]->setOsContext(&osContext); + executionEnvironment->commandStreamReceivers[0][0]->setOsContext(osContext); auto commandBuffer = executionEnvironment->memoryManager->allocateGraphicsMemory(4096); LinearStream cs(commandBuffer);