Refactor waitOnCompletionFence method in DrmMemoryManager

get completion address and value from command stream receiver

Related-To: NEO-6643

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2022-03-30 12:40:09 +00:00
committed by Compute-Runtime-Automation
parent e32f624bf4
commit 9d502dea25
9 changed files with 59 additions and 35 deletions

View File

@@ -64,6 +64,13 @@ struct CommandStreamReceiverTest : public DeviceFixture,
InternalAllocationStorage *internalAllocationStorage;
};
TEST_F(CommandStreamReceiverTest, givenOsAgnosticCsrWhenGettingCompletionValueOrAddressThenZeroIsReturned) {
EXPECT_EQ(0u, commandStreamReceiver->getCompletionAddress());
MockGraphicsAllocation allocation{};
EXPECT_EQ(0u, commandStreamReceiver->getCompletionValue(allocation));
}
HWTEST_F(CommandStreamReceiverTest, WhenCreatingCsrThenDefaultValuesAreSet) {
auto &csr = pDevice->getUltCommandStreamReceiver<FamilyType>();
EXPECT_EQ(0u, csr.peekTaskLevel());

View File

@@ -9,7 +9,7 @@ set(NEO_CORE_OS_INTERFACE_TESTS_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests_linux.cpp
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests_linux.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_bind_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream_l0_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_command_stream_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_engine_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_mock_impl.h
${CMAKE_CURRENT_SOURCE_DIR}/drm_query_topology_upstream_tests.cpp

View File

@@ -17,6 +17,7 @@
#include "shared/test/common/libult/linux/drm_mock.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/mocks/mock_graphics_allocation.h"
#include "shared/test/common/os_interface/linux/device_command_stream_fixture.h"
#include "shared/test/common/test_macros/test.h"
@@ -28,7 +29,7 @@ extern ApiSpecificConfig::ApiType apiTypeForUlts;
} //namespace NEO
using namespace NEO;
class DrmCommandStreamTestL0 : public ::testing::Test {
class DrmCommandStreamTest : public ::testing::Test {
public:
template <typename GfxFamily>
void SetUpT() {
@@ -89,13 +90,26 @@ class DrmCommandStreamTestL0 : public ::testing::Test {
};
template <typename GfxFamily>
struct MockDrmCsrL0 : public DrmCommandStreamReceiver<GfxFamily> {
struct MockDrmCsr : public DrmCommandStreamReceiver<GfxFamily> {
using DrmCommandStreamReceiver<GfxFamily>::DrmCommandStreamReceiver;
using DrmCommandStreamReceiver<GfxFamily>::dispatchMode;
};
HWTEST_TEMPLATED_F(DrmCommandStreamTestL0, givenL0ApiConfigWhenCreatingDrmCsrThenEnableImmediateDispatch) {
HWTEST_TEMPLATED_F(DrmCommandStreamTest, givenL0ApiConfigWhenCreatingDrmCsrThenEnableImmediateDispatch) {
VariableBackup<ApiSpecificConfig::ApiType> backup(&apiTypeForUlts, ApiSpecificConfig::L0);
MockDrmCsrL0<FamilyType> csr(executionEnvironment, 0, 1, gemCloseWorkerMode::gemCloseWorkerInactive);
MockDrmCsr<FamilyType> csr(executionEnvironment, 0, 1, gemCloseWorkerMode::gemCloseWorkerInactive);
EXPECT_EQ(DispatchMode::ImmediateDispatch, csr.dispatchMode);
}
HWTEST_TEMPLATED_F(DrmCommandStreamTest, whenGettingCompletionValueThenTaskCountOfAllocationIsReturned) {
MockGraphicsAllocation allocation{};
uint32_t expectedValue = 0x1234;
allocation.updateTaskCount(expectedValue, osContext->getContextId());
EXPECT_EQ(expectedValue, csr->getCompletionValue(allocation));
}
HWTEST_TEMPLATED_F(DrmCommandStreamTest, whenGettingCompletionAddressThenOffsettedTagAddressIsReturned) {
uint64_t tagAddress = castToUint64(const_cast<uint32_t *>(csr->getTagAddress()));
auto expectedAddress = tagAddress + Drm::completionFenceOffset;
EXPECT_EQ(expectedAddress, csr->getCompletionAddress());
}