Add StateComputeModeProperties to StreamProperties

Related-To: NEO-4940, NEO-4574


Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
Filip Hazubski
2021-05-18 02:46:21 +00:00
committed by Compute-Runtime-Automation
parent 3d7b1abe80
commit d693d24f27
36 changed files with 368 additions and 77 deletions

View File

@@ -6,11 +6,11 @@
*/
#include "shared/source/command_stream/preemption.h"
#include "shared/source/command_stream/stream_properties.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/unit_test/preamble/preamble_fixture.h"
#include "reg_configs_common.h"
#include "stream_properties.h"
using namespace NEO;

View File

@@ -20,6 +20,7 @@ if(TESTS_GEN12LP)
${CMAKE_CURRENT_SOURCE_DIR}/command_encoder_tests_gen12lp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/image_surface_state_tests_gen12lp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_command_encoder_gen12lp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_gen12lp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_encode_math_gen12lp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_preemption_gen12lp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/unit_test_helper_gen12lp.cpp

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_container/command_encoder.h"
#include "shared/source/command_stream/stream_properties.h"
#include "test.h"
#include "hw_cmds.h"
using namespace NEO;
using CommandEncodeGen12LpTest = ::testing::Test;
GEN12LPTEST_F(CommandEncodeGen12LpTest, whenProgrammingStateComputeModeThenProperFieldsAreSet) {
using STATE_COMPUTE_MODE = typename FamilyType::STATE_COMPUTE_MODE;
uint8_t buffer[64]{};
StateComputeModeProperties properties;
auto pLinearStream = std::make_unique<LinearStream>(buffer, sizeof(buffer));
EncodeComputeMode<FamilyType>::adjustComputeMode(*pLinearStream, nullptr, properties);
auto pScm = reinterpret_cast<STATE_COMPUTE_MODE *>(pLinearStream->getCpuBase());
EXPECT_EQ(0u, pScm->getMaskBits());
EXPECT_EQ(STATE_COMPUTE_MODE::FORCE_NON_COHERENT_FORCE_DISABLED, pScm->getForceNonCoherent());
properties.isCoherencyRequired.value = 0;
pLinearStream = std::make_unique<LinearStream>(buffer, sizeof(buffer));
EncodeComputeMode<FamilyType>::adjustComputeMode(*pLinearStream, nullptr, properties);
pScm = reinterpret_cast<STATE_COMPUTE_MODE *>(pLinearStream->getCpuBase());
EXPECT_EQ(0u, pScm->getMaskBits());
EXPECT_EQ(STATE_COMPUTE_MODE::FORCE_NON_COHERENT_FORCE_DISABLED, pScm->getForceNonCoherent());
properties.isCoherencyRequired.isDirty = true;
pLinearStream = std::make_unique<LinearStream>(buffer, sizeof(buffer));
EncodeComputeMode<FamilyType>::adjustComputeMode(*pLinearStream, nullptr, properties);
pScm = reinterpret_cast<STATE_COMPUTE_MODE *>(pLinearStream->getCpuBase());
EXPECT_EQ(FamilyType::stateComputeModeForceNonCoherentMask, pScm->getMaskBits());
EXPECT_EQ(STATE_COMPUTE_MODE::FORCE_NON_COHERENT_FORCE_GPU_NON_COHERENT, pScm->getForceNonCoherent());
}

View File

@@ -6,11 +6,11 @@
*/
#include "shared/source/command_stream/preemption.h"
#include "shared/source/command_stream/stream_properties.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/unit_test/preamble/preamble_fixture.h"
#include "reg_configs_common.h"
#include "stream_properties.h"
using namespace NEO;

View File

@@ -5,6 +5,7 @@
*
*/
#include "shared/source/command_stream/stream_properties.h"
#include "shared/source/command_stream/thread_arbitration_policy.h"
#include "shared/source/gen8/reg_configs.h"
#include "shared/source/helpers/preamble.h"
@@ -12,8 +13,6 @@
#include "opencl/test/unit_test/fixtures/platform_fixture.h"
#include "stream_properties.h"
using namespace NEO;
typedef PreambleFixture BdwSlm;

View File

@@ -6,6 +6,7 @@
*/
#include "shared/source/command_stream/preemption.h"
#include "shared/source/command_stream/stream_properties.h"
#include "shared/source/command_stream/thread_arbitration_policy.h"
#include "shared/source/gen9/reg_configs.h"
#include "shared/source/helpers/preamble.h"
@@ -13,8 +14,6 @@
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "shared/test/unit_test/preamble/preamble_fixture.h"
#include "stream_properties.h"
using namespace NEO;
typedef PreambleFixture SklSlm;

View File

@@ -0,0 +1,13 @@
#
# Copyright (C) 2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/stream_properties_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/stream_properties_tests_common.cpp
${CMAKE_CURRENT_SOURCE_DIR}/stream_properties_tests_common.h
)
add_subdirectories()

View File

@@ -0,0 +1,19 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/command_stream/stream_properties.h"
#include "shared/test/unit_test/command_stream/stream_properties_tests_common.h"
namespace NEO {
std::vector<StreamProperty *> getAllStateComputeModeProperties(StateComputeModeProperties &properties) {
std::vector<StreamProperty *> allProperties;
allProperties.push_back(&properties.isCoherencyRequired);
return allProperties;
}
} // namespace NEO

View File

@@ -0,0 +1,75 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/unit_test/command_stream/stream_properties_tests_common.h"
#include "shared/source/command_stream/stream_properties.h"
#include "shared/test/common/helpers/debug_manager_state_restore.h"
#include "test.h"
using namespace NEO;
TEST(StreamPropertiesTests, whenPropertyValueIsChangedThenProperStateIsSet) {
NEO::StreamProperty streamProperty;
EXPECT_EQ(-1, streamProperty.value);
EXPECT_FALSE(streamProperty.isDirty);
streamProperty.set(-1);
EXPECT_EQ(-1, streamProperty.value);
EXPECT_FALSE(streamProperty.isDirty);
int32_t valuesToTest[] = {0, 1};
for (auto valueToTest : valuesToTest) {
streamProperty.set(valueToTest);
EXPECT_EQ(valueToTest, streamProperty.value);
EXPECT_TRUE(streamProperty.isDirty);
streamProperty.isDirty = false;
streamProperty.set(valueToTest);
EXPECT_EQ(valueToTest, streamProperty.value);
EXPECT_FALSE(streamProperty.isDirty);
streamProperty.set(-1);
EXPECT_EQ(valueToTest, streamProperty.value);
EXPECT_FALSE(streamProperty.isDirty);
}
}
TEST(StreamPropertiesTests, whenSettingStateComputeModePropertiesThenCorrectValuesAreSet) {
StreamProperties properties;
for (auto requiresCoherency : ::testing::Bool()) {
properties.setStateComputeModeProperties(requiresCoherency, 0u, false, false, false);
EXPECT_EQ(requiresCoherency, properties.stateComputeMode.isCoherencyRequired.value);
}
}
TEST(StreamPropertiesTests, givenVariousStatesOfThePropertiesWhenIsStateComputeModeDirtyIsQueriedThenCorrectValueIsReturned) {
struct MockStateComputeModeProperties : StateComputeModeProperties {
using StateComputeModeProperties::clearIsDirty;
};
MockStateComputeModeProperties properties;
EXPECT_FALSE(properties.isDirty());
for (auto pProperty : getAllStateComputeModeProperties(properties)) {
pProperty->isDirty = true;
EXPECT_TRUE(properties.isDirty());
pProperty->isDirty = false;
EXPECT_FALSE(properties.isDirty());
}
for (auto pProperty : getAllStateComputeModeProperties(properties)) {
pProperty->isDirty = true;
}
EXPECT_TRUE(properties.isDirty());
properties.clearIsDirty();
for (auto pProperty : getAllStateComputeModeProperties(properties)) {
EXPECT_FALSE(pProperty->isDirty);
}
EXPECT_FALSE(properties.isDirty());
}

View File

@@ -0,0 +1,19 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <vector>
namespace NEO {
struct StateComputeModeProperties;
struct StreamProperty;
std::vector<StreamProperty *> getAllStateComputeModeProperties(StateComputeModeProperties &properties);
} // namespace NEO

View File

@@ -43,7 +43,7 @@ TEST_F(CommandEncodeStatesTest, givenCommandConatinerCreatedWithMaxNumAggregateI
delete cmdContainer;
}
HWTEST_F(CommandEncodeStatesTest, givenenDispatchInterfaceWhenDispatchKernelThenWalkerCommandProgrammed) {
HWTEST_F(CommandEncodeStatesTest, givenDispatchInterfaceWhenDispatchKernelThenWalkerCommandProgrammed) {
uint32_t dims[] = {2, 1, 1};
std::unique_ptr<MockDispatchKernelEncoder> dispatchInterface(new MockDispatchKernelEncoder());
bool requiresUncachedMocs = false;
@@ -629,13 +629,8 @@ HWCMDTEST_F(IGFX_GEN8_CORE, CommandEncodeStatesTest, givenCleanHeapsAndSlmNotCha
GenCmdList commands;
CmdParse<FamilyType>::parseCommandBuffer(commands, ptrOffset(cmdContainer->getCommandStream()->getCpuBase(), 0), cmdContainer->getCommandStream()->getUsed());
if (MemorySynchronizationCommands<FamilyType>::isPipeControlPriorToPipelineSelectWArequired(pDevice->getHardwareInfo())) {
auto itorPC = findAll<PIPE_CONTROL *>(commands.begin(), commands.end());
EXPECT_EQ(2u, itorPC.size());
} else {
auto itorPC = find<PIPE_CONTROL *>(commands.begin(), commands.end());
ASSERT_EQ(itorPC, commands.end());
}
auto itorPC = find<PIPE_CONTROL *>(commands.begin(), commands.end());
ASSERT_EQ(itorPC, commands.end());
}
HWCMDTEST_F(IGFX_GEN8_CORE, CommandEncodeStatesTest, givenCleanHeapsAndSlmNotChangedAndUncachedMocsRequestedThenSBAIsProgrammedAndMocsAreSet) {

View File

@@ -284,3 +284,17 @@ HWTEST_F(CommandEncodeStatesTest, givenAnUnalignedDstPtrThenCorrectAlignedPtrAnd
EXPECT_TRUE((ptr & (NEO::EncodeSurfaceState<FamilyType>::getSurfaceBaseAddressAlignment() - 1)) == 0x0u);
EXPECT_NE(0u, offset);
}
HWCMDTEST_F(IGFX_GEN8_CORE, CommandEncodeStatesTest, whenAdjustPipelineSelectIsCalledThenNothingHappens) {
using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT;
auto initialUsed = cmdContainer->getCommandStream()->getUsed();
NEO::EncodeComputeMode<FamilyType>::adjustPipelineSelect(*cmdContainer, descriptor);
EXPECT_EQ(initialUsed, cmdContainer->getCommandStream()->getUsed());
}
HWTEST2_F(CommandEncodeStatesTest, whenAdjustStateComputeModeIsCalledThenNothingHappens, IsAtMostGen11) {
using PIPELINE_SELECT = typename FamilyType::PIPELINE_SELECT;
auto initialUsed = cmdContainer->getCommandStream()->getUsed();
NEO::EncodeStates<FamilyType>::adjustStateComputeMode(*cmdContainer->getCommandStream(), 0, nullptr, false, false, false, false);
EXPECT_EQ(initialUsed, cmdContainer->getCommandStream()->getUsed());
}

View File

@@ -6,6 +6,7 @@
*/
#include "shared/source/command_stream/preemption.h"
#include "shared/source/command_stream/stream_properties.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/gen_common/reg_configs_common.h"
#include "shared/source/helpers/flat_batch_buffer_helper_hw.h"
@@ -18,7 +19,6 @@
#include "test.h"
#include "stream_properties.h"
#include <gtest/gtest.h>
#include <algorithm>