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

@@ -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