Add AIL functionality

Signed-off-by: Kamil Diedrich <kamil.diedrich@intel.com>
This commit is contained in:
Kamil Diedrich
2021-07-21 08:47:43 +00:00
committed by Compute-Runtime-Automation
parent ab73b61b77
commit 2afb785bba
29 changed files with 396 additions and 18 deletions

View File

@@ -10,8 +10,6 @@ set(TARGET_NAME ${TARGET_NAME_L0}_core_tests)
include(gen_kernel.cmake)
append_sources_from_properties(L0_CORE_ENABLERS NEO_CORE_SRCS_LINK)
function(ADD_SUPPORTED_TEST_PRODUCT_FAMILIES_DEFINITION)
set(L0_TESTED_PRODUCT_FAMILIES ${ALL_TESTED_PRODUCT_FAMILY})
string(REPLACE ";" "," L0_TESTED_PRODUCT_FAMILIES "${L0_TESTED_PRODUCT_FAMILIES}")
@@ -24,7 +22,6 @@ add_executable(${TARGET_NAME}
${NEO_SOURCE_DIR}/level_zero/core/source/dll/disallow_deferred_deleter.cpp
${NEO_SOURCE_DIR}/shared/test/common/mocks/ult_device_factory.cpp
${NEO_SOURCE_DIR}/shared/test/common/mocks/ult_device_factory.h
${L0_CORE_ENABLERS}
${NEO_SOURCE_DIR}/opencl/test/unit_test/global_environment.cpp
${NEO_SOURCE_DIR}/level_zero/tools/test/unit_tests/sources/debug/debug_session_helper.cpp
${NEO_SOURCE_DIR}/opencl/test/unit_test/helpers/kernel_binary_helper_hash_value.cpp

View File

@@ -8,8 +8,6 @@ link_libraries(${ASAN_LIBS} ${TSAN_LIBS})
set(TARGET_NAME ${TARGET_NAME_L0}_exp_tests)
append_sources_from_properties(L0_CORE_ENABLERS NEO_CORE_SRCS_LINK)
function(ADD_SUPPORTED_TEST_PRODUCT_FAMILIES_DEFINITION)
set(L0_TESTED_PRODUCT_FAMILIES ${ALL_TESTED_PRODUCT_FAMILY})
string(REPLACE ";" "," L0_TESTED_PRODUCT_FAMILIES
@@ -27,7 +25,6 @@ add_executable(
${NEO_SOURCE_DIR}/level_zero/core/source/dll/disallow_deferred_deleter.cpp
${NEO_SOURCE_DIR}/shared/test/common/mocks/ult_device_factory.cpp
${NEO_SOURCE_DIR}/shared/test/common/mocks/ult_device_factory.h
${L0_CORE_ENABLERS}
${NEO_SOURCE_DIR}/opencl/test/unit_test/global_environment.cpp
${NEO_SOURCE_DIR}/opencl/test/unit_test/helpers/kernel_binary_helper_hash_value.cpp
${NEO_SOURCE_DIR}/level_zero/core/test/unit_tests/sources/builtin/create_ult_builtin_functions_lib.cpp

View File

@@ -8,8 +8,6 @@ link_libraries(${ASAN_LIBS} ${TSAN_LIBS})
set(TARGET_NAME ${TARGET_NAME_L0}_tools_tests)
append_sources_from_properties(L0_CORE_ENABLERS NEO_CORE_SRCS_LINK)
function(ADD_SUPPORTED_TEST_PRODUCT_FAMILIES_DEFINITION)
set(L0_TESTED_PRODUCT_FAMILIES ${ALL_TESTED_PRODUCT_FAMILY})
string(REPLACE ";" "," L0_TESTED_PRODUCT_FAMILIES "${L0_TESTED_PRODUCT_FAMILIES}")
@@ -22,7 +20,6 @@ add_executable(${TARGET_NAME}
${NEO_SOURCE_DIR}/level_zero/core/source/dll/disallow_deferred_deleter.cpp
${NEO_SOURCE_DIR}/shared/test/common/mocks/ult_device_factory.cpp
${NEO_SOURCE_DIR}/shared/test/common/mocks/ult_device_factory.h
${L0_CORE_ENABLERS}
)
target_sources(${TARGET_NAME} PRIVATE

View File

@@ -5,6 +5,7 @@
*
*/
#include "shared/source/ail/ail_configuration.h"
#include "shared/source/aub/aub_center.h"
#include "shared/source/built_ins/built_ins.h"
#include "shared/source/command_stream/preemption.h"
@@ -273,4 +274,4 @@ TEST(ClExecutionEnvironment, WhenExecutionEnvironmentIsDeletedThenAsyncEventHand
TEST(ClExecutionEnvironment, WhenExecutionEnvironmentIsCreatedThenAsyncEventHandlerIsCreated) {
auto executionEnvironment = std::make_unique<ClExecutionEnvironment>();
EXPECT_NE(nullptr, executionEnvironment->getAsyncEventsHandler());
}
}

View File

@@ -17,6 +17,7 @@ if(TESTS_DG1)
${CMAKE_CURRENT_SOURCE_DIR}/hw_info_tests_dg1.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_hw_info_config_dg1.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_device_caps_dg1.cpp
${CMAKE_CURRENT_SOURCE_DIR}/execution_environment_tests_dg1.cpp
)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_dg1})
add_subdirectories()

View File

@@ -0,0 +1,37 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/ail/ail_configuration.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "shared/test/unit_test/utilities/destructor_counted.h"
#include "test.h"
namespace NEO {
using RootDeviceEnvironmentTests = ::testing::Test;
HWTEST2_F(RootDeviceEnvironmentTests, givenRootDeviceEnvironmentWhenAILInitProcessExecutableNameReturnsFailedThenInitAilConfigurationReturnsFail, IsDG1) {
MockExecutionEnvironment executionEnvironment;
executionEnvironment.rootDeviceEnvironments[0]->setHwInfo(defaultHwInfo.get());
auto rootDeviceEnvironment = static_cast<MockRootDeviceEnvironment *>(executionEnvironment.rootDeviceEnvironments[0].get());
class AILDG1 : public AILConfigurationHw<productFamily> {
public:
bool initProcessExecutableName() override {
return false;
}
};
VariableBackup<AILConfiguration *> ailConfiguration(&ailConfigurationTable[productFamily]);
AILDG1 ailDg1;
ailConfigurationTable[productFamily] = &ailDg1;
EXPECT_EQ(false, rootDeviceEnvironment->initAilConfiguration());
}
} // namespace NEO

View File

@@ -42,6 +42,7 @@ int fstatFuncRetVal = 0;
uint32_t preadFuncCalled = 0u;
uint32_t mmapFuncCalled = 0u;
uint32_t munmapFuncCalled = 0u;
bool isInvalidAILTest = false;
int close(int fileDescriptor) {
closeFuncCalled++;
@@ -108,6 +109,15 @@ int access(const char *pathName, int mode) {
}
int readlink(const char *path, char *buf, size_t bufsize) {
if (isInvalidAILTest) {
return -1;
}
if (strcmp(path, "/proc/self/exe") == 0) {
strcpy_s(buf, sizeof("/proc/self/exe/tests"), "/proc/self/exe/tests");
return sizeof("/proc/self/exe/tests");
}
if (strcmp(path, "/sys/dev/char/226:128") != 0) {
return -1;
}

View File

@@ -48,9 +48,6 @@ BOOL getModuleHandle(DWORD dwFlags, LPCWSTR lpModuleName, HMODULE *phModule) {
return TRUE;
}
DWORD getModuleFileName(HMODULE hModule, LPWSTR lpFilename, DWORD nSize) {
if (hModule != handleValue) {
return FALSE;
}
lstrcpyW(lpFilename, currentLibraryPath);
return TRUE;
}

View File

@@ -78,6 +78,10 @@ class NoCompilerInterfaceRootDeviceEnvironment : public RootDeviceEnvironment {
CompilerInterface *getCompilerInterface() override {
return nullptr;
}
bool initAilConfiguration() override {
return true;
}
};
class FailingGenBinaryProgram : public MockProgram {
@@ -2734,6 +2738,10 @@ struct SpecializationConstantRootDeviceEnvironemnt : public RootDeviceEnvironmen
CompilerInterface *getCompilerInterface() override {
return compilerInterface.get();
}
bool initAilConfiguration() override {
return true;
}
};
struct setProgramSpecializationConstantTests : public ::testing::Test {

View File

@@ -91,6 +91,7 @@ endmacro()
apply_macro_for_each_gen("SUPPORTED")
append_sources_from_properties(CORE_SOURCES
NEO_CORE_AIL
NEO_CORE_AUB
NEO_CORE_AUB_MEM_DUMP
NEO_CORE_BUILT_INS
@@ -138,6 +139,7 @@ if(WIN32)
NEO_CORE_SRCS_HELPERS_WINDOWS
NEO_CORE_UTILITIES_WINDOWS
NEO_CORE_EXECUTION_ENVIRONMENT_WINDOWS
NEO_CORE_AIL_WINDOWS
)
else()
append_sources_from_properties(CORE_SOURCES
@@ -146,6 +148,7 @@ else()
NEO_CORE_PAGE_FAULT_MANAGER_LINUX
NEO_CORE_UTILITIES_LINUX
NEO_CORE_EXECUTION_ENVIRONMENT_LINUX
NEO_CORE_AIL_LINUX
)
if(NOT DISABLE_WDDM_LINUX)
append_sources_from_properties(CORE_SOURCES

View File

@@ -0,0 +1,15 @@
#
# Copyright (C) 2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(NEO_CORE_AIL
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/ail_configuration.h
${CMAKE_CURRENT_SOURCE_DIR}/ail_configuration.inl
${CMAKE_CURRENT_SOURCE_DIR}/ail_configuration.cpp
)
set_property(GLOBAL PROPERTY NEO_CORE_AIL ${NEO_CORE_AIL})
add_subdirectories()

View File

@@ -0,0 +1,26 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/ail/ail_configuration.h"
#include <map>
#include <string_view>
namespace NEO {
std::map<std::string_view, std::vector<AILEnumeration>> applicationMap = {};
AILConfiguration *ailConfigurationTable[IGFX_MAX_PRODUCT] = {};
AILConfiguration *AILConfiguration::get(PRODUCT_FAMILY productFamily) {
return ailConfigurationTable[productFamily];
}
void AILConfiguration::apply(RuntimeCapabilityTable &runtimeCapabilityTable) {
applyExt(runtimeCapabilityTable);
}
} // namespace NEO

View File

@@ -0,0 +1,53 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/hw_info.h"
#include <string>
#pragma once
namespace NEO {
enum class AILEnumeration : uint32_t {
AIL_MAX_OPTIONS_COUNT
};
class AILConfiguration {
public:
AILConfiguration() = default;
MOCKABLE_VIRTUAL bool initProcessExecutableName();
static AILConfiguration *get(PRODUCT_FAMILY productFamily);
virtual void apply(RuntimeCapabilityTable &runtimeCapabilityTable);
protected:
virtual void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) = 0;
std::string processName;
};
extern AILConfiguration *ailConfigurationTable[IGFX_MAX_PRODUCT];
template <PRODUCT_FAMILY Product>
class AILConfigurationHw : public AILConfiguration {
public:
static AILConfigurationHw<Product> &get() {
static AILConfigurationHw<Product> ailConfiguration;
return ailConfiguration;
}
void applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) override;
};
template <PRODUCT_FAMILY product>
struct EnableAIL {
EnableAIL() {
ailConfigurationTable[product] = &AILConfigurationHw<product>::get();
}
};
} // namespace NEO

View File

@@ -0,0 +1,20 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/ail/ail_configuration.h"
#include <map>
#include <string_view>
namespace NEO {
extern std::map<std::string_view, std::vector<AILEnumeration>> applicationMapHW;
template <PRODUCT_FAMILY Product>
void AILConfigurationHw<Product>::applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) {
}
} // namespace NEO

View File

@@ -0,0 +1,13 @@
#
# Copyright (C) 2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(NEO_CORE_AIL_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/ail_configuration_linux.cpp
)
set_property(GLOBAL PROPERTY NEO_CORE_AIL_LINUX ${NEO_CORE_AIL_LINUX})
add_subdirectories()

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/ail/ail_configuration.h"
#include "shared/source/os_interface/linux/sys_calls.h"
#include <string_view>
namespace NEO {
bool AILConfiguration::initProcessExecutableName() {
char path[512] = {0};
int result = SysCalls::readlink("/proc/self/exe", path, sizeof(path) - 1);
if (result == -1) {
return false;
}
path[result] = '\0';
std::string_view pathView(path);
auto lastPosition = pathView.find_last_of("/");
pathView.remove_prefix(lastPosition + 1u);
processName = pathView;
return true;
}
} // namespace NEO

View File

@@ -0,0 +1,13 @@
#
# Copyright (C) 2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(NEO_CORE_AIL_WINDOWS
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/ail_configuration_windows.cpp
)
set_property(GLOBAL PROPERTY NEO_CORE_AIL_WINDOWS ${NEO_CORE_AIL_WINDOWS})
add_subdirectories()

View File

@@ -0,0 +1,24 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/ail/ail_configuration.h"
#include "shared/source/os_interface/windows/sys_calls.h"
namespace NEO {
bool AILConfiguration::initProcessExecutableName() {
const DWORD length = MAX_PATH;
WCHAR processFilenameW[length];
char processFilename[length] = "";
auto status = SysCalls::getModuleFileName(nullptr, processFilenameW, MAX_PATH);
if (status != 0) {
std::wcstombs(processFilename, processFilenameW, MAX_PATH);
}
return status;
}
} // namespace NEO

View File

@@ -7,6 +7,7 @@
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/ail/ail_configuration.h"
#include "shared/source/aub/aub_center.h"
#include "shared/source/built_ins/built_ins.h"
#include "shared/source/compiler_interface/compiler_interface.h"
@@ -67,6 +68,23 @@ GmmClientContext *RootDeviceEnvironment::getGmmClientContext() const {
return gmmHelper->getClientContext();
}
bool RootDeviceEnvironment::initAilConfiguration() {
auto ailConfiguration = AILConfiguration::get(hwInfo->platform.eProductFamily);
if (ailConfiguration == nullptr) {
return true;
}
auto result = ailConfiguration->initProcessExecutableName();
if (result != true) {
return false;
}
ailConfiguration->apply(hwInfo->capabilityTable);
return true;
}
void RootDeviceEnvironment::initGmm() {
if (!gmmHelper) {
gmmHelper.reset(new GmmHelper(osInterface.get(), getHardwareInfo()));

View File

@@ -52,6 +52,7 @@ struct RootDeviceEnvironment {
bool initOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, uint32_t rootDeviceIndex);
void initGmm();
void initDebugger();
MOCKABLE_VIRTUAL bool initAilConfiguration();
GmmHelper *getGmmHelper() const;
GmmClientContext *getGmmClientContext() const;
MOCKABLE_VIRTUAL CompilerInterface *getCompilerInterface();

View File

@@ -5,9 +5,12 @@
*
*/
#include "shared/source/ail/ail_configuration.h"
#include "shared/source/ail/ail_configuration.inl"
#include "shared/source/gen12lp/hw_cmds.h"
#include "shared/source/helpers/hw_helper.h"
#include <map>
namespace NEO {
extern HwHelper *hwHelperFactory[IGFX_MAX_CORE];
@@ -22,4 +25,22 @@ struct EnableCoreGen12LP {
};
static EnableCoreGen12LP enable;
extern AILConfiguration *ailConfigurationTable[IGFX_MAX_PRODUCT];
#ifdef SUPPORT_DG1
std::map<std::string_view, std::vector<AILEnumeration>> applicationMapDG1 = {};
template <>
void AILConfigurationHw<IGFX_DG1>::applyExt(RuntimeCapabilityTable &runtimeCapabilityTable) {
}
static EnableAIL<IGFX_DG1> enableDG1;
#endif
#ifdef SUPPORT_TGLLP
std::map<std::string_view, std::vector<AILEnumeration>> applicationMapTGLLP = {};
static EnableAIL<IGFX_TIGERLAKE_LP> enableTgllp;
#endif
} // namespace NEO

View File

@@ -52,6 +52,10 @@ bool initDrmOsInterface(std::unique_ptr<HwDeviceId> &&hwDeviceId, uint32_t rootD
return false;
}
dstMemoryOpsHandler = DrmMemoryOperationsHandler::create(*drm, rootDeviceIndex);
[[maybe_unused]] bool result = rootDeviceEnv->initAilConfiguration();
DEBUG_BREAK_IF(!result);
return true;
}

View File

@@ -112,6 +112,9 @@ bool Wddm::init() {
rootDeviceEnvironment.initGmm();
this->rootDeviceEnvironment.getGmmClientContext()->setHandleAllocator(this->hwDeviceId->getUmKmDataTranslator()->createGmmHandleAllocator());
[[maybe_unused]] bool result = rootDeviceEnvironment.initAilConfiguration();
DEBUG_BREAK_IF(!result);
if (WddmVersion::WDDM_2_3 == getWddmVersion()) {
wddmInterface = std::make_unique<WddmInterface23>(*this);
} else {

View File

@@ -40,14 +40,11 @@ if(NOT SKIP_UNIT_TESTS)
ADD_SUPPORTED_TEST_PRODUCT_FAMILIES_DEFINITION()
link_libraries(${ASAN_LIBS} ${TSAN_LIBS})
append_sources_from_properties(CORE_ENABLERS NEO_CORE_SRCS_LINK)
add_executable(${TARGET_NAME}
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_mode.h
${CMAKE_CURRENT_SOURCE_DIR}/tests_configuration.h
${CORE_ENABLERS}
${NEO_SOURCE_DIR}/opencl/source/compiler_interface/default_cache_config.cpp
${NEO_SOURCE_DIR}/opencl/test/unit_test/global_environment.cpp
${NEO_SOURCE_DIR}/opencl/test/unit_test/helpers/kernel_binary_helper_hash_value.cpp

View File

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

View File

@@ -0,0 +1,23 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/ail/ail_configuration.h"
#include "shared/test/common/helpers/unit_test_helper.h"
#include "test.h"
namespace NEO {
using IsSKL = IsProduct<IGFX_SKYLAKE>;
using AILTests = ::testing::Test;
HWTEST2_F(AILTests, givenUninitializedTemplateWhenGetAILConfigurationThenNullptrIsReturned, IsSKL) {
auto ailConfiguration = AILConfiguration::get(productFamily);
ASSERT_EQ(nullptr, ailConfiguration);
}
} // namespace NEO

View File

@@ -0,0 +1,19 @@
#
# Copyright (C) 2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(NEO_CORE_AIL_TESTS_LINUX
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/ail_linux_tests.cpp
)
set_property(GLOBAL PROPERTY NEO_CORE_AIL_TESTS_LINUX ${NEO_CORE_AIL_TESTS_LINUX})
if(UNIX)
target_sources(${TARGET_NAME} PRIVATE
${NEO_CORE_AIL_TESTS_LINUX}
)
endif()
add_subdirectories()

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/ail/ail_configuration.h"
#include "shared/test/common/helpers/unit_test_helper.h"
#include "shared/test/common/helpers/variable_backup.h"
#include "test.h"
namespace NEO {
using AILTests = ::testing::Test;
namespace SysCalls {
extern bool isInvalidAILTest;
}
HWTEST2_F(AILTests, givenValidPathWhenAILinitProcessExecutableNameThenSuccessIsReturned, IsDG1) {
AILConfigurationHw<productFamily> ail;
EXPECT_EQ(ail.initProcessExecutableName(), true);
}
HWTEST2_F(AILTests, givenInvalidPathWhenAILinitProcessExecutableNameThenFailIsReturned, IsDG1) {
VariableBackup<bool> isAILTestBackup(&SysCalls::isInvalidAILTest);
SysCalls::isInvalidAILTest = true;
AILConfigurationHw<productFamily> ail;
EXPECT_EQ(ail.initProcessExecutableName(), false);
}
} // namespace NEO

View File

@@ -19,6 +19,8 @@
#include "shared/test/common/mocks/windows/mock_wddm_direct_submission.h"
#include "shared/test/common/os_interface/windows/wddm_fixture.h"
using namespace NEO;
struct WddmDirectSubmissionFixture : public WddmFixture {
void SetUp() override {
WddmFixture::SetUp();
@@ -40,8 +42,6 @@ struct WddmDirectSubmissionFixture : public WddmFixture {
using WddmDirectSubmissionTest = WddmDirectSubmissionFixture;
using namespace NEO;
HWTEST_F(WddmDirectSubmissionTest, givenWddmWhenDirectIsInitializedAndStartedThenExpectProperCommandsDispatched) {
std::unique_ptr<MockWddmDirectSubmission<FamilyType, RenderDispatcher<FamilyType>>> wddmDirectSubmission =
std::make_unique<MockWddmDirectSubmission<FamilyType, RenderDispatcher<FamilyType>>>(*device.get(),