ResourceTag refactor

Signed-off-by: Daria Hinz <daria.hinz@intel.com>
Related-To: NEO-6099
This commit is contained in:
Daria Hinz
2021-07-28 11:19:13 +00:00
committed by Compute-Runtime-Automation
parent 6e64c24df3
commit 25c44bd6d3
11 changed files with 18 additions and 114 deletions

View File

@@ -10,6 +10,6 @@
using namespace NEO; using namespace NEO;
void Gmm::applyAppResource(StorageInfo &storageInfo) {}
void Gmm::applyExtraMemoryFlags(const StorageInfo &storageInfo) {} void Gmm::applyExtraMemoryFlags(const StorageInfo &storageInfo) {}
bool Gmm::extraMemoryFlagsRequired() { return false; } bool Gmm::extraMemoryFlagsRequired() { return false; }
void Gmm::applyAppResource(StorageInfo &storageInfo) {}

View File

@@ -1,7 +0,0 @@
#
# Copyright (C) 2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
add_subdirectories()

View File

@@ -12,6 +12,7 @@ set(NEO_CORE_HELPERS
${CMAKE_CURRENT_SOURCE_DIR}/aligned_memory.h ${CMAKE_CURRENT_SOURCE_DIR}/aligned_memory.h
${CMAKE_CURRENT_SOURCE_DIR}/app_resource_defines.h ${CMAKE_CURRENT_SOURCE_DIR}/app_resource_defines.h
${CMAKE_CURRENT_SOURCE_DIR}/app_resource_helper.h ${CMAKE_CURRENT_SOURCE_DIR}/app_resource_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/app_resource_helper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/api_specific_config.h ${CMAKE_CURRENT_SOURCE_DIR}/api_specific_config.h
${CMAKE_CURRENT_SOURCE_DIR}/array_count.h ${CMAKE_CURRENT_SOURCE_DIR}/array_count.h
${CMAKE_CURRENT_SOURCE_DIR}/aux_translation.h ${CMAKE_CURRENT_SOURCE_DIR}/aux_translation.h
@@ -141,16 +142,6 @@ if(SUPPORT_XEHP_AND_LATER)
) )
endif() endif()
if(WIN32)
list(APPEND NEO_CORE_HELPERS
${CMAKE_CURRENT_SOURCE_DIR}/windows/app_resource_helper.cpp
)
else()
list(APPEND NEO_CORE_HELPERS
${CMAKE_CURRENT_SOURCE_DIR}/linux/app_resource_helper.cpp
)
endif()
set(NEO_CORE_HELPERS_GMM_CALLBACKS_WINDOWS set(NEO_CORE_HELPERS_GMM_CALLBACKS_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/windows/gmm_callbacks.cpp ${CMAKE_CURRENT_SOURCE_DIR}/windows/gmm_callbacks.cpp
${CMAKE_CURRENT_SOURCE_DIR}/windows/gmm_callbacks.h ${CMAKE_CURRENT_SOURCE_DIR}/windows/gmm_callbacks.h

View File

@@ -11,17 +11,19 @@
namespace NEO { namespace NEO {
namespace AppResourceDefines { namespace AppResourceDefines {
#if defined(_DEBUG) || (_RELEASE_INTERNAL)
constexpr bool resourceTagSupport = true;
#else
constexpr bool resourceTagSupport = false;
#endif
template <typename TMemberSource, typename = int> template <typename TMemberSource, typename = int>
static constexpr bool has_ResourceTag = false; static constexpr bool has_ResourceTag = false;
#if defined(_DEBUG) || (_RELEASE_INTERNAL)
template <typename TMemberSource> template <typename TMemberSource>
static constexpr bool has_ResourceTag<TMemberSource, decltype((void)TMemberSource::ResourceTag, int{})> = true; static constexpr bool has_ResourceTag<TMemberSource, decltype((void)TMemberSource::ResourceTag, int{})> = true;
constexpr bool resourceTagSupport = true;
#else
constexpr bool resourceTagSupport = false;
template <typename TMemberSource>
static constexpr bool has_ResourceTag<TMemberSource, decltype((void)TMemberSource::ResourceTag, int{})> = false;
#endif
constexpr uint32_t maxStrLen = 8u; constexpr uint32_t maxStrLen = 8u;
} // namespace AppResourceDefines } // namespace AppResourceDefines

View File

@@ -14,11 +14,9 @@
namespace NEO { namespace NEO {
void AppResourceHelper::copyResourceTagStr(char *dst, GraphicsAllocation::AllocationType type, size_t size) { void AppResourceHelper::copyResourceTagStr(char *dst, GraphicsAllocation::AllocationType type, size_t size) {
if constexpr (AppResourceDefines::resourceTagSupport) { if (DebugManager.flags.EnableResourceTags.get()) {
if (DebugManager.flags.EnableResourceTags.get()) { auto tag = getResourceTagStr(type);
auto tag = getResourceTagStr(type); strcpy_s(dst, size, tag);
strcpy_s(dst, size, tag);
}
} }
} }

View File

@@ -1,15 +0,0 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/app_resource_helper.h"
namespace NEO {
void AppResourceHelper::copyResourceTagStr(char *dst, GraphicsAllocation::AllocationType type, size_t size) {}
const char *AppResourceHelper::getResourceTagStr(GraphicsAllocation::AllocationType type) { return ""; }
} // namespace NEO

View File

@@ -6,6 +6,7 @@
set(IGDRCL_SRCS_tests_helpers set(IGDRCL_SRCS_tests_helpers
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/app_resource_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/array_count_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/array_count_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/basic_math_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/basic_math_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/bit_helpers_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/bit_helpers_tests.cpp

View File

@@ -20,37 +20,28 @@
#include "test.h" #include "test.h"
using MockExecutionEnvironmentGmmTest = Test<NEO::MockExecutionEnvironmentGmmFixture>; using MockExecutionEnvironmentTagTest = Test<NEO::MockExecutionEnvironmentGmmFixture>;
using namespace NEO; using namespace NEO;
struct GmmAppResourceWinTests : public MockExecutionEnvironmentGmmTest { struct AppResourceTests : public MockExecutionEnvironmentTagTest {
void SetUp() override { void SetUp() override {
MockExecutionEnvironmentGmmFixture::SetUp(); MockExecutionEnvironmentGmmFixture::SetUp();
rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get(); rootDeviceEnvironment = executionEnvironment->rootDeviceEnvironments[0].get();
localPlatformDevice = rootDeviceEnvironment->getMutableHardwareInfo(); localPlatformDevice = rootDeviceEnvironment->getMutableHardwareInfo();
} }
template <typename TGMM_RESCREATE_PARAMS>
static auto getResourceTagGMM(TGMM_RESCREATE_PARAMS &src) {
if constexpr (AppResourceDefines::has_ResourceTag<std::decay_t<decltype(src)>>) {
return &src.ResourceTag;
} else {
return nullptr;
}
}
RootDeviceEnvironment *rootDeviceEnvironment = nullptr; RootDeviceEnvironment *rootDeviceEnvironment = nullptr;
HardwareInfo *localPlatformDevice = nullptr; HardwareInfo *localPlatformDevice = nullptr;
const DeviceBitfield singleTileMask{static_cast<uint32_t>(1u << 2)}; const DeviceBitfield singleTileMask{static_cast<uint32_t>(1u << 2)};
}; };
TEST_F(GmmAppResourceWinTests, givenIncorrectGraphicsAllocationTypeWhenGettingResourceTagThenNOTFOUNDIsReturned) { TEST_F(AppResourceTests, givenIncorrectGraphicsAllocationTypeWhenGettingResourceTagThenNOTFOUNDIsReturned) {
auto tag = AppResourceHelper::getResourceTagStr(static_cast<GraphicsAllocation::AllocationType>(999)); auto tag = AppResourceHelper::getResourceTagStr(static_cast<GraphicsAllocation::AllocationType>(999));
EXPECT_STREQ(tag, "NOTFOUND"); EXPECT_STREQ(tag, "NOTFOUND");
} }
TEST_F(GmmAppResourceWinTests, givenGraphicsAllocationTypeWhenGettingResourceTagThenForEveryDefinedTypeProperTagExist) { TEST_F(AppResourceTests, givenGraphicsAllocationTypeWhenGettingResourceTagThenForEveryDefinedTypeProperTagExist) {
auto firstTypeIdx = static_cast<int>(GraphicsAllocation::AllocationType::UNKNOWN); auto firstTypeIdx = static_cast<int>(GraphicsAllocation::AllocationType::UNKNOWN);
auto lastTypeIdx = static_cast<int>(GraphicsAllocation::AllocationType::COUNT); auto lastTypeIdx = static_cast<int>(GraphicsAllocation::AllocationType::COUNT);
@@ -63,30 +54,6 @@ TEST_F(GmmAppResourceWinTests, givenGraphicsAllocationTypeWhenGettingResourceTag
} }
} }
TEST_F(GmmAppResourceWinTests, givenStorageInfoCreatedFromPropertiesWhenEnableResourceTagsThenGmmResourceTagIsSet) {
if (!AppResourceDefines::resourceTagSupport) {
GTEST_SKIP();
}
DebugManagerStateRestore restorer;
MockMemoryManager mockMemoryManager(*executionEnvironment);
auto firstTypeIdx = static_cast<int>(GraphicsAllocation::AllocationType::UNKNOWN);
auto lastTypeIdx = static_cast<int>(GraphicsAllocation::AllocationType::COUNT);
DebugManager.flags.EnableResourceTags.set(true);
for (int typeIdx = firstTypeIdx; typeIdx != lastTypeIdx; typeIdx++) {
auto allocationType = static_cast<GraphicsAllocation::AllocationType>(typeIdx);
AllocationProperties properties{mockRootDeviceIndex, false, 1u, allocationType, false, singleTileMask};
auto storageInfo = mockMemoryManager.createStorageInfoFromProperties(properties);
auto expectedSize = (AppResourceDefines::maxStrLen + 1) * sizeof(char);
EXPECT_EQ(expectedSize, sizeof(storageInfo.resourceTag));
auto tag = AppResourceHelper::getResourceTagStr(properties.allocationType);
EXPECT_STREQ(storageInfo.resourceTag, tag);
}
}
struct AllocationTypeTagTestCase { struct AllocationTypeTagTestCase {
GraphicsAllocation::AllocationType type; GraphicsAllocation::AllocationType type;
const char *str; const char *str;
@@ -143,9 +110,6 @@ AllocationTypeTagTestCase allocationTypeTagValues[static_cast<int>(GraphicsAlloc
class AllocationTypeTagString : public ::testing::TestWithParam<AllocationTypeTagTestCase> {}; class AllocationTypeTagString : public ::testing::TestWithParam<AllocationTypeTagTestCase> {};
TEST_P(AllocationTypeTagString, givenGraphicsAllocationTypeWhenCopyTagToStorageInfoThenCorrectTagIsReturned) { TEST_P(AllocationTypeTagString, givenGraphicsAllocationTypeWhenCopyTagToStorageInfoThenCorrectTagIsReturned) {
if (!AppResourceDefines::resourceTagSupport) {
GTEST_SKIP();
}
DebugManagerStateRestore restorer; DebugManagerStateRestore restorer;
StorageInfo storageInfo = {}; StorageInfo storageInfo = {};
auto input = GetParam(); auto input = GetParam();

View File

@@ -6,7 +6,6 @@
set(NEO_CORE_OS_INTERFACE_TESTS_LINUX set(NEO_CORE_OS_INTERFACE_TESTS_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/app_resource_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_query_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}drm_query_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/drm_special_heap_test.cpp ${CMAKE_CURRENT_SOURCE_DIR}/drm_special_heap_test.cpp
) )

View File

@@ -1,28 +0,0 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/app_resource_helper.h"
#include "shared/test/common/mocks/mock_graphics_allocation.h"
#include "shared/test/common/mocks/mock_memory_manager.h"
#include "test.h"
using namespace NEO;
TEST(AppResourceLinuxTests, givenGraphicsAllocationTypeWhenCreatingStorageInfoFromPropertiesThenResourceTagAlwaysEmpty) {
MockMemoryManager mockMemoryManager;
const DeviceBitfield singleTileMask{static_cast<uint32_t>(1u << 2)};
auto allocationType = GraphicsAllocation::AllocationType::BUFFER;
AllocationProperties properties{mockRootDeviceIndex, false, 1u, allocationType, false, singleTileMask};
auto tag = AppResourceHelper::getResourceTagStr(properties.allocationType);
EXPECT_STREQ("", tag);
auto storageInfo = mockMemoryManager.createStorageInfoFromProperties(properties);
EXPECT_STREQ(tag, storageInfo.resourceTag);
}

View File

@@ -9,7 +9,6 @@ set(NEO_CORE_OS_INTERFACE_TESTS_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/adapter_info_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/adapter_info_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/adapter_info_tests.h ${CMAKE_CURRENT_SOURCE_DIR}/adapter_info_tests.h
${CMAKE_CURRENT_SOURCE_DIR}/gdi_interface_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gdi_interface_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gmm_app_resource_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/gmm_helper_tests_win.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gmm_helper_tests_win.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_gdi_interface.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mock_gdi_interface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_gdi_interface.h ${CMAKE_CURRENT_SOURCE_DIR}/mock_gdi_interface.h