mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 14:55:24 +08:00
Add StateComputeModeProperties to StreamProperties
Related-To: NEO-4940, NEO-4574 Signed-off-by: Filip Hazubski <filip.hazubski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
3d7b1abe80
commit
d693d24f27
13
shared/test/unit_test/command_stream/CMakeLists.txt
Normal file
13
shared/test/unit_test/command_stream/CMakeLists.txt
Normal 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()
|
||||
@@ -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
|
||||
@@ -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());
|
||||
}
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user