diff --git a/runtime/command_queue/enqueue_common.h b/runtime/command_queue/enqueue_common.h index c2e77ffe09..a62d6385ce 100644 --- a/runtime/command_queue/enqueue_common.h +++ b/runtime/command_queue/enqueue_common.h @@ -242,7 +242,7 @@ void CommandQueueHw::enqueueHandler(Surface **surfacesForResidency, } TimestampPacket *timestampPacket = nullptr; - if (device->peekCommandStreamReceiver()->peekTimestampPacketWriteEnabled()) { + if (device->getCommandStreamReceiver().peekTimestampPacketWriteEnabled()) { obtainNewTimestampPacketNode(); timestampPacket = timestampPacketNode->tag; } diff --git a/runtime/command_queue/gpgpu_walker.h b/runtime/command_queue/gpgpu_walker.h index 4381a9e050..ac6a97e2f8 100644 --- a/runtime/command_queue/gpgpu_walker.h +++ b/runtime/command_queue/gpgpu_walker.h @@ -295,7 +295,7 @@ LinearStream &getCommandStream(CommandQueue &commandQueue, cl_uint numEventsInWa SchedulerKernel &scheduler = commandQueue.getDevice().getExecutionEnvironment()->getBuiltIns()->getSchedulerKernel(parentKernel->getContext()); expectedSizeCS += EnqueueOperation::getSizeRequiredCS(eventType, reserveProfilingCmdsSpace, reservePerfCounterCmdsSpace, commandQueue, &scheduler); } - if (commandQueue.getDevice().peekCommandStreamReceiver()->peekTimestampPacketWriteEnabled()) { + if (commandQueue.getDevice().getCommandStreamReceiver().peekTimestampPacketWriteEnabled()) { expectedSizeCS += EnqueueOperation::getSizeRequiredForTimestampPacketWrite(); expectedSizeCS += numEventsInWaitList * sizeof(typename GfxFamily::MI_SEMAPHORE_WAIT); } diff --git a/runtime/command_queue/gpgpu_walker.inl b/runtime/command_queue/gpgpu_walker.inl index e2ab0c9538..842400adc2 100644 --- a/runtime/command_queue/gpgpu_walker.inl +++ b/runtime/command_queue/gpgpu_walker.inl @@ -494,7 +494,7 @@ void GpgpuWalkerHelper::dispatchWalker( ssh = &getIndirectHeap(commandQueue, multiDispatchInfo); } - if (commandQueue.getDevice().peekCommandStreamReceiver()->peekTimestampPacketWriteEnabled()) { + if (commandQueue.getDevice().getCommandStreamReceiver().peekTimestampPacketWriteEnabled()) { GpgpuWalkerHelper::dispatchOnDeviceWaitlistSemaphores(commandStream, commandQueue.getDevice(), numEventsInWaitList, eventWaitList); } diff --git a/runtime/device/device.cpp b/runtime/device/device.cpp index a3d8980f7f..9acd7d3c07 100644 --- a/runtime/device/device.cpp +++ b/runtime/device/device.cpp @@ -134,19 +134,19 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) { outDevice.osContext = new OsContext(executionEnvironment->osInterface.get()); executionEnvironment->memoryManager->registerOsContext(outDevice.osContext); - CommandStreamReceiver *commandStreamReceiver = executionEnvironment->commandStreamReceiver.get(); - if (!commandStreamReceiver->initializeTagAllocation()) { + outDevice.commandStreamReceiver = executionEnvironment->commandStreamReceiver.get(); + if (!outDevice.commandStreamReceiver->initializeTagAllocation()) { return false; } - executionEnvironment->memoryManager->csr = commandStreamReceiver; + executionEnvironment->memoryManager->csr = outDevice.commandStreamReceiver; auto pDevice = &outDevice; if (!pDevice->osTime) { - pDevice->osTime = OSTime::create(commandStreamReceiver->getOSInterface()); + pDevice->osTime = OSTime::create(outDevice.commandStreamReceiver->getOSInterface()); } - pDevice->driverInfo.reset(DriverInfo::create(commandStreamReceiver->getOSInterface())); - pDevice->tagAddress = reinterpret_cast(commandStreamReceiver->getTagAllocation()->getUnderlyingBuffer()); + pDevice->driverInfo.reset(DriverInfo::create(outDevice.commandStreamReceiver->getOSInterface())); + pDevice->tagAddress = reinterpret_cast(outDevice.commandStreamReceiver->getTagAllocation()->getUnderlyingBuffer()); pDevice->initializeCaps(); @@ -158,8 +158,8 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) { } uint32_t deviceHandle = 0; - if (commandStreamReceiver->getOSInterface()) { - deviceHandle = commandStreamReceiver->getOSInterface()->getDeviceHandle(); + if (outDevice.commandStreamReceiver->getOSInterface()) { + deviceHandle = outDevice.commandStreamReceiver->getOSInterface()->getDeviceHandle(); } if (pDevice->deviceInfo.sourceLevelDebuggerActive) { @@ -176,14 +176,14 @@ bool Device::createDeviceImpl(const HardwareInfo *pHwInfo, Device &outDevice) { if (!pDevice->preemptionAllocation) { return false; } - commandStreamReceiver->setPreemptionCsrAllocation(pDevice->preemptionAllocation); + outDevice.commandStreamReceiver->setPreemptionCsrAllocation(pDevice->preemptionAllocation); auto sipType = SipKernel::getSipKernelType(pHwInfo->pPlatform->eRenderCoreFamily, pDevice->isSourceLevelDebuggerActive()); initSipKernel(sipType, *pDevice); } if (DebugManager.flags.EnableExperimentalCommandBuffer.get() > 0) { - commandStreamReceiver->setExperimentalCmdBuffer( - std::unique_ptr(new ExperimentalCommandBuffer(commandStreamReceiver, pDevice->getDeviceInfo().profilingTimerResolution))); + outDevice.commandStreamReceiver->setExperimentalCmdBuffer( + std::unique_ptr(new ExperimentalCommandBuffer(outDevice.commandStreamReceiver, pDevice->getDeviceInfo().profilingTimerResolution))); } return true; diff --git a/runtime/device/device.h b/runtime/device/device.h index a6b70da446..cbdd695100 100644 --- a/runtime/device/device.h +++ b/runtime/device/device.h @@ -88,7 +88,6 @@ class Device : public BaseObject<_cl_device_id> { } CommandStreamReceiver &getCommandStreamReceiver(); - CommandStreamReceiver *peekCommandStreamReceiver(); volatile uint32_t *getTagAddress() const; @@ -179,6 +178,7 @@ class Device : public BaseObject<_cl_device_id> { PreemptionMode preemptionMode; EngineType engineType; ExecutionEnvironment *executionEnvironment = nullptr; + CommandStreamReceiver *commandStreamReceiver = nullptr; }; template @@ -190,11 +190,7 @@ inline void Device::getCap(const void *&src, } inline CommandStreamReceiver &Device::getCommandStreamReceiver() { - return *executionEnvironment->commandStreamReceiver; -} - -inline CommandStreamReceiver *Device::peekCommandStreamReceiver() { - return executionEnvironment->commandStreamReceiver.get(); + return *this->commandStreamReceiver; } inline volatile uint32_t *Device::getTagAddress() const { diff --git a/unit_tests/device/device_tests.cpp b/unit_tests/device/device_tests.cpp index af7dc6461c..5e043d073a 100644 --- a/unit_tests/device/device_tests.cpp +++ b/unit_tests/device/device_tests.cpp @@ -51,10 +51,6 @@ TEST_F(DeviceTest, getCommandStreamReceiver) { EXPECT_NE(nullptr, &pDevice->getCommandStreamReceiver()); } -TEST_F(DeviceTest, givenDeviceWhenPeekCommandStreamReceiverIsCalledThenCommandStreamReceiverIsReturned) { - EXPECT_NE(nullptr, pDevice->peekCommandStreamReceiver()); -} - TEST_F(DeviceTest, getSupportedClVersion) { auto version = pDevice->getSupportedClVersion(); auto version2 = pDevice->getHardwareInfo().capabilityTable.clVersionSupport; diff --git a/unit_tests/mocks/mock_device.cpp b/unit_tests/mocks/mock_device.cpp index 0380ad00d1..874c05cef3 100644 --- a/unit_tests/mocks/mock_device.cpp +++ b/unit_tests/mocks/mock_device.cpp @@ -36,8 +36,8 @@ MockDevice::MockDevice(const HardwareInfo &hwInfo) executionEnvironment->commandStreamReceiver.reset(commandStreamReceiver); commandStreamReceiver->setMemoryManager(this->mockMemoryManager.get()); this->executionEnvironment->memoryManager = std::move(this->mockMemoryManager); + this->commandStreamReceiver = commandStreamReceiver; } - OCLRT::MockDevice::MockDevice(const HardwareInfo &hwInfo, ExecutionEnvironment *executionEnvironment) : Device(hwInfo, executionEnvironment) { this->mockMemoryManager.reset(new OsAgnosticMemoryManager(false, this->getHardwareCapabilities().localMemorySupported)); @@ -76,6 +76,7 @@ void MockDevice::resetCommandStreamReceiver(CommandStreamReceiver *newCsr) { executionEnvironment->commandStreamReceiver->initializeTagAllocation(); executionEnvironment->commandStreamReceiver->setPreemptionCsrAllocation(preemptionAllocation); executionEnvironment->memoryManager->csr = executionEnvironment->commandStreamReceiver.get(); + this->commandStreamReceiver = newCsr; this->tagAddress = executionEnvironment->commandStreamReceiver->getTagAddress(); }