Use ImmediateDispatch mode for L0 command queues
Related-To: LOCI-1988 Signed-off-by: Aravind Gopalakrishnan <aravind.gopalakrishnan@intel.com>
This commit is contained in:
parent
ec40b6562e
commit
e29a85ebb3
|
@ -47,6 +47,9 @@ CommandStreamReceiver::CommandStreamReceiver(ExecutionEnvironment &executionEnvi
|
|||
|
||||
latestSentStatelessMocsConfig = CacheSettings::unknownMocs;
|
||||
submissionAggregator.reset(new SubmissionAggregator());
|
||||
if (ApiSpecificConfig::getApiType() == ApiSpecificConfig::L0) {
|
||||
this->dispatchMode = DispatchMode::ImmediateDispatch;
|
||||
}
|
||||
if (DebugManager.flags.CsrDispatchMode.get()) {
|
||||
this->dispatchMode = (DispatchMode)DebugManager.flags.CsrDispatchMode.get();
|
||||
}
|
||||
|
|
|
@ -57,6 +57,10 @@ DrmCommandStreamReceiver<GfxFamily>::DrmCommandStreamReceiver(ExecutionEnvironme
|
|||
|
||||
this->dispatchMode = localMemoryEnabled ? DispatchMode::BatchedDispatch : DispatchMode::ImmediateDispatch;
|
||||
|
||||
if (ApiSpecificConfig::getApiType() == ApiSpecificConfig::L0) {
|
||||
this->dispatchMode = DispatchMode::ImmediateDispatch;
|
||||
}
|
||||
|
||||
if (DebugManager.flags.CsrDispatchMode.get()) {
|
||||
this->dispatchMode = static_cast<DispatchMode>(DebugManager.flags.CsrDispatchMode.get());
|
||||
}
|
||||
|
|
|
@ -54,6 +54,10 @@ WddmCommandStreamReceiver<GfxFamily>::WddmCommandStreamReceiver(ExecutionEnviron
|
|||
|
||||
this->dispatchMode = DispatchMode::BatchedDispatch;
|
||||
|
||||
if (ApiSpecificConfig::getApiType() == ApiSpecificConfig::L0) {
|
||||
this->dispatchMode = DispatchMode::ImmediateDispatch;
|
||||
}
|
||||
|
||||
if (DebugManager.flags.CsrDispatchMode.get()) {
|
||||
this->dispatchMode = (DispatchMode)DebugManager.flags.CsrDispatchMode.get();
|
||||
}
|
||||
|
|
|
@ -206,6 +206,12 @@ HWTEST_F(CommandStreamReceiverTest, givenDefaultCommandStreamReceiverThenDefault
|
|||
EXPECT_EQ(DispatchMode::ImmediateDispatch, csr.dispatchMode);
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverTest, givenL0CommandStreamReceiverThenDefaultDispatchingPolicyIsImmediateSubmission) {
|
||||
VariableBackup<ApiSpecificConfig::ApiType> backup(&apiTypeForUlts, ApiSpecificConfig::L0);
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
EXPECT_EQ(DispatchMode::ImmediateDispatch, csr.dispatchMode);
|
||||
}
|
||||
|
||||
HWTEST_F(CommandStreamReceiverTest, givenCsrWhenGetIndirectHeapIsCalledThenHeapIsReturned) {
|
||||
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
|
||||
auto &heap = csr.getIndirectHeap(IndirectHeap::DYNAMIC_STATE, 10u);
|
||||
|
|
|
@ -10,6 +10,7 @@ set(NEO_CORE_OS_INTERFACE_TESTS_LINUX
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/drm_special_heap_test.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_uuid_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/os_context_linux_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream_l0_tests.cpp
|
||||
)
|
||||
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_OS_INTERFACE_TESTS_LINUX ${NEO_CORE_OS_INTERFACE_TESTS_LINUX})
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/helpers/api_specific_config.h"
|
||||
#include "shared/source/os_interface/linux/drm_command_stream.h"
|
||||
#include "shared/source/os_interface/linux/drm_memory_operations_handler.h"
|
||||
#include "shared/source/os_interface/linux/os_context_linux.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
#include "shared/test/common/helpers/engine_descriptor_helper.h"
|
||||
#include "shared/test/common/helpers/variable_backup.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_command_stream_receiver.h"
|
||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||
#include "shared/test/common/os_interface/linux/device_command_stream_fixture.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
#include "drm/i915_drm.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
namespace NEO {
|
||||
extern ApiSpecificConfig::ApiType apiTypeForUlts;
|
||||
} //namespace NEO
|
||||
using namespace NEO;
|
||||
|
||||
class DrmCommandStreamTestL0 : public ::testing::Test {
|
||||
public:
|
||||
template <typename GfxFamily>
|
||||
void SetUpT() {
|
||||
|
||||
//make sure this is disabled, we don't want to test this now
|
||||
DebugManager.flags.EnableForcePin.set(false);
|
||||
|
||||
mock = new ::testing::NiceMock<DrmMockImpl>(mockFd, *executionEnvironment.rootDeviceEnvironments[0]);
|
||||
|
||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
|
||||
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u);
|
||||
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo();
|
||||
mock->createVirtualMemoryAddressSpace(HwHelper::getSubDevicesCount(hwInfo));
|
||||
osContext = std::make_unique<OsContextLinux>(*mock, 0u,
|
||||
EngineDescriptorHelper::getDefaultDescriptor(HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0],
|
||||
PreemptionHelper::getDefaultPreemptionMode(*hwInfo)));
|
||||
osContext->ensureContextInitialized();
|
||||
|
||||
csr = new DrmCommandStreamReceiver<GfxFamily>(executionEnvironment, 0, 1, gemCloseWorkerMode::gemCloseWorkerActive);
|
||||
ASSERT_NE(nullptr, csr);
|
||||
csr->setupContext(*osContext);
|
||||
|
||||
// Memory manager creates pinBB with ioctl, expect one call
|
||||
EXPECT_CALL(*mock, ioctl(::testing::_, ::testing::_))
|
||||
.Times(1);
|
||||
memoryManager = new DrmMemoryManager(gemCloseWorkerMode::gemCloseWorkerActive,
|
||||
DebugManager.flags.EnableForcePin.get(),
|
||||
true,
|
||||
executionEnvironment);
|
||||
executionEnvironment.memoryManager.reset(memoryManager);
|
||||
::testing::Mock::VerifyAndClearExpectations(mock);
|
||||
|
||||
//assert we have memory manager
|
||||
ASSERT_NE(nullptr, memoryManager);
|
||||
}
|
||||
|
||||
template <typename GfxFamily>
|
||||
void TearDownT() {
|
||||
memoryManager->waitForDeletions();
|
||||
memoryManager->peekGemCloseWorker()->close(true);
|
||||
delete csr;
|
||||
::testing::Mock::VerifyAndClearExpectations(mock);
|
||||
// Memory manager closes pinBB with ioctl, expect one call
|
||||
EXPECT_CALL(*mock, ioctl(::testing::_, ::testing::_))
|
||||
.Times(::testing::AtLeast(1));
|
||||
}
|
||||
|
||||
CommandStreamReceiver *csr = nullptr;
|
||||
DrmMemoryManager *memoryManager = nullptr;
|
||||
::testing::NiceMock<DrmMockImpl> *mock;
|
||||
const int mockFd = 33;
|
||||
static const uint64_t alignment = MemoryConstants::allocationAlignment;
|
||||
DebugManagerStateRestore dbgState;
|
||||
MockExecutionEnvironment executionEnvironment;
|
||||
std::unique_ptr<OsContextLinux> osContext;
|
||||
};
|
||||
|
||||
template <typename GfxFamily>
|
||||
struct MockDrmCsrL0 : public DrmCommandStreamReceiver<GfxFamily> {
|
||||
using DrmCommandStreamReceiver<GfxFamily>::DrmCommandStreamReceiver;
|
||||
using DrmCommandStreamReceiver<GfxFamily>::dispatchMode;
|
||||
};
|
||||
|
||||
HWTEST_TEMPLATED_F(DrmCommandStreamTestL0, givenL0ApiConfigWhenCreatingDrmCsrThenEnableImmediateDispatch) {
|
||||
VariableBackup<ApiSpecificConfig::ApiType> backup(&apiTypeForUlts, ApiSpecificConfig::L0);
|
||||
MockDrmCsrL0<FamilyType> csr(executionEnvironment, 0, 1, gemCloseWorkerMode::gemCloseWorkerInactive);
|
||||
EXPECT_EQ(DispatchMode::ImmediateDispatch, csr.dispatchMode);
|
||||
}
|
|
@ -15,6 +15,7 @@ set(NEO_CORE_OS_INTERFACE_TESTS_WINDOWS
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_special_heap_test.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_shared_allocations_test.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wddm_command_stream_l0_tests.cpp
|
||||
)
|
||||
|
||||
set_property(GLOBAL PROPERTY NEO_CORE_OS_INTERFACE_TESTS_WINDOWS ${NEO_CORE_OS_INTERFACE_TESTS_WINDOWS})
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* Copyright (C) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/command_stream/command_stream_receiver.h"
|
||||
#include "shared/source/command_stream/command_stream_receiver_with_aub_dump.h"
|
||||
#include "shared/source/command_stream/device_command_stream.h"
|
||||
#include "shared/source/command_stream/linear_stream.h"
|
||||
#include "shared/source/command_stream/preemption.h"
|
||||
#include "shared/source/direct_submission/dispatchers/render_dispatcher.h"
|
||||
#include "shared/source/direct_submission/windows/wddm_direct_submission.h"
|
||||
#include "shared/source/helpers/api_specific_config.h"
|
||||
#include "shared/source/helpers/flush_stamp.h"
|
||||
#include "shared/source/helpers/windows/gmm_callbacks.h"
|
||||
#include "shared/source/memory_manager/internal_allocation_storage.h"
|
||||
#include "shared/source/memory_manager/memory_manager.h"
|
||||
#include "shared/source/os_interface/os_interface.h"
|
||||
#include "shared/source/os_interface/windows/os_context_win.h"
|
||||
#include "shared/source/os_interface/windows/wddm_device_command_stream.h"
|
||||
#include "shared/source/os_interface/windows/wddm_memory_manager.h"
|
||||
#include "shared/source/os_interface/windows/wddm_memory_operations_handler.h"
|
||||
#include "shared/source/os_interface/windows/wddm_residency_controller.h"
|
||||
#include "shared/test/common/helpers/execution_environment_helper.h"
|
||||
#include "shared/test/common/mocks/mock_builtins.h"
|
||||
#include "shared/test/common/mocks/mock_device.h"
|
||||
#include "shared/test/common/mocks/mock_gmm_page_table_mngr.h"
|
||||
#include "shared/test/common/mocks/mock_graphics_allocation.h"
|
||||
#include "shared/test/common/mocks/mock_io_functions.h"
|
||||
#include "shared/test/common/mocks/mock_submissions_aggregator.h"
|
||||
#include "shared/test/common/mocks/mock_wddm_interface23.h"
|
||||
#include "shared/test/common/mocks/windows/mock_gdi_interface.h"
|
||||
#include "shared/test/common/mocks/windows/mock_wddm_direct_submission.h"
|
||||
#include "shared/test/common/os_interface/windows/mock_wddm_memory_manager.h"
|
||||
#include "shared/test/common/os_interface/windows/wddm_fixture.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
namespace NEO {
|
||||
extern ApiSpecificConfig::ApiType apiTypeForUlts;
|
||||
} //namespace NEO
|
||||
using namespace NEO;
|
||||
|
||||
template <typename GfxFamily>
|
||||
struct MockWddmCsrL0 : public WddmCommandStreamReceiver<GfxFamily> {
|
||||
using CommandStreamReceiver::clearColorAllocation;
|
||||
using CommandStreamReceiver::commandStream;
|
||||
using CommandStreamReceiver::dispatchMode;
|
||||
using CommandStreamReceiver::getCS;
|
||||
using CommandStreamReceiver::globalFenceAllocation;
|
||||
using CommandStreamReceiver::useGpuIdleImplicitFlush;
|
||||
using CommandStreamReceiver::useNewResourceImplicitFlush;
|
||||
using CommandStreamReceiverHw<GfxFamily>::blitterDirectSubmission;
|
||||
using CommandStreamReceiverHw<GfxFamily>::directSubmission;
|
||||
using WddmCommandStreamReceiver<GfxFamily>::commandBufferHeader;
|
||||
using WddmCommandStreamReceiver<GfxFamily>::initDirectSubmission;
|
||||
using WddmCommandStreamReceiver<GfxFamily>::WddmCommandStreamReceiver;
|
||||
|
||||
void overrideDispatchPolicy(DispatchMode overrideValue) {
|
||||
this->dispatchMode = overrideValue;
|
||||
}
|
||||
|
||||
SubmissionAggregator *peekSubmissionAggregator() {
|
||||
return this->submissionAggregator.get();
|
||||
}
|
||||
|
||||
void overrideSubmissionAggregator(SubmissionAggregator *newSubmissionsAggregator) {
|
||||
this->submissionAggregator.reset(newSubmissionsAggregator);
|
||||
}
|
||||
|
||||
void overrideRecorededCommandBuffer(Device &device) {
|
||||
recordedCommandBuffer = std::unique_ptr<CommandBuffer>(new CommandBuffer(device));
|
||||
}
|
||||
|
||||
bool initDirectSubmission(Device &device, OsContext &osContext) override {
|
||||
if (callParentInitDirectSubmission) {
|
||||
return WddmCommandStreamReceiver<GfxFamily>::initDirectSubmission(device, osContext);
|
||||
}
|
||||
bool ret = true;
|
||||
if (DebugManager.flags.EnableDirectSubmission.get() == 1) {
|
||||
if (!initBlitterDirectSubmission) {
|
||||
directSubmission = std::make_unique<
|
||||
MockWddmDirectSubmission<GfxFamily, RenderDispatcher<GfxFamily>>>(device, osContext);
|
||||
ret = directSubmission->initialize(true, false);
|
||||
this->dispatchMode = DispatchMode::ImmediateDispatch;
|
||||
} else {
|
||||
blitterDirectSubmission = std::make_unique<
|
||||
MockWddmDirectSubmission<GfxFamily, BlitterDispatcher<GfxFamily>>>(device, osContext);
|
||||
blitterDirectSubmission->initialize(true, false);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int flushCalledCount = 0;
|
||||
std::unique_ptr<CommandBuffer> recordedCommandBuffer = nullptr;
|
||||
|
||||
bool callParentInitDirectSubmission = true;
|
||||
bool initBlitterDirectSubmission = false;
|
||||
};
|
||||
|
||||
using WddmSimpleTestL0 = ::testing::Test;
|
||||
HWTEST_F(WddmSimpleTestL0, givenL0ApiAndDefaultWddmCsrWhenItIsCreatedThenImmediateDispatchIsTurnedOn) {
|
||||
VariableBackup<ApiSpecificConfig::ApiType> backup(&apiTypeForUlts, ApiSpecificConfig::L0);
|
||||
HardwareInfo *hwInfo = nullptr;
|
||||
ExecutionEnvironment *executionEnvironment = getExecutionEnvironmentImpl(hwInfo, 1);
|
||||
std::unique_ptr<MockDevice> device(Device::create<MockDevice>(executionEnvironment, 0u));
|
||||
{
|
||||
std::unique_ptr<MockWddmCsrL0<FamilyType>> mockCsr(new MockWddmCsrL0<FamilyType>(*executionEnvironment, 0, 1));
|
||||
EXPECT_EQ(DispatchMode::ImmediateDispatch, mockCsr->dispatchMode);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue