Add Ult target for level_zero

Change-Id: I5b18b6f495eda302ba96287d7bd6cc0b2bbe48ac
Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
Plewka, Maciej 2020-03-15 23:03:19 -08:00 committed by sys_ocldev
parent 2dbee6d7c1
commit 2b269caca9
42 changed files with 863 additions and 67 deletions

View File

@ -920,6 +920,13 @@ configure_file(driver_version.h.in ${NEO_BUILD_DIR}/driver_version.h) # Put Driv
configure_file(lib_names.h.in ${NEO_BUILD_DIR}/lib_names.h)
hide_subdir(${NEO_RUNTIME_SUB_DIR})
if(BUILD_WITH_L0)
add_subdirectory_unique(level_zero)
endif()
add_subdirectory_unique(target_unit_tests)
add_subdirectories()
include(package.cmake)

View File

@ -0,0 +1,47 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
string(REPLACE "/" ";" unit_test_config ${unit_test_config})
list(GET unit_test_config 0 product)
list(GET unit_test_config 1 slices)
list(GET unit_test_config 2 subslices)
list(GET unit_test_config 3 eu_per_ss)
add_custom_target(run_${product}_unit_tests ALL DEPENDS unit_tests)
set_target_properties(run_${product}_unit_tests PROPERTIES FOLDER "${PLATFORM_SPECIFIC_TEST_TARGETS_FOLDER}/${product}")
if(NOT SKIP_NEO_UNIT_TESTS)
add_custom_command(
TARGET run_${product}_unit_tests
POST_BUILD
COMMAND WORKING_DIRECTORY ${TargetDir}
COMMAND echo Running igdrcl_tests ${target} ${slices}x${subslices}x${eu_per_ss} in ${TargetDir}/${product}
COMMAND $<TARGET_FILE:igdrcl_tests> --product ${product} --slices ${slices} --subslices ${subslices} --eu_per_ss ${eu_per_ss} ${GTEST_EXCEPTION_OPTIONS} --gtest_repeat=${GTEST_REPEAT} ${GTEST_SHUFFLE} ${IGDRCL_TESTS_LISTENER_OPTION} ${GTEST_FILTER_OPTION}
)
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug" AND "${IGDRCL_OPTION__BITS}" STREQUAL "64" AND appverified_allowed)
add_custom_command(
TARGET run_${product}_unit_tests
POST_BUILD
COMMAND echo copying test verify.bat file from ${OPENCL_UNIT_TEST_DIR} to ${TargetDir}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${OPENCL_UNIT_TEST_DIR}/verify.bat ${TargetDir}/verify.bat
COMMAND WORKING_DIRECTORY ${TargetDir}
COMMAND echo Running igdrcl_tests with App Verifier
COMMAND ${TargetDir}/verify.bat --product ${product} --slices ${slices} --subslices ${subslices} --eu_per_ss ${eu_per_ss} ${GTEST_EXCEPTION_OPTIONS} ${IGDRCL_TESTS_LISTENER_OPTION} ${GTEST_FILTER_OPTION}
COMMAND echo App Verifier returned: %errorLevel%
)
endif()
endif()
if(NOT SKIP_L0_UNIT_TESTS AND BUILD_WITH_L0)
add_custom_command(
TARGET run_${product}_unit_tests
POST_BUILD
COMMAND WORKING_DIRECTORY ${TargetDir}
COMMAND echo Running ze_intel_gpu_core_tests ${target} ${slices}x${subslices}x${eu_per_ss} in ${TargetDir}/${product}
COMMAND $<TARGET_FILE:ze_intel_gpu_core_tests> --product ${product} --slices ${slices} --subslices ${subslices} --eu_per_ss ${eu_per_ss} ${GTEST_EXCEPTION_OPTIONS} --gtest_repeat=${GTEST_REPEAT} ${GTEST_SHUFFLE} ${IGDRCL_TESTS_LISTENER_OPTION} ${GTEST_FILTER_OPTION}
)
endif()
add_dependencies(run_unit_tests run_${product}_unit_tests)

View File

@ -97,7 +97,7 @@ if(BUILD_WITH_L0 AND "${NEO_BITS}" STREQUAL "64")
set(SKIP_L0_UNIT_TESTS TRUE)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/${BRANCH_TYPE}/l0_tests.cmake)
if(NOT SKIP_L0_UNIT_TESTS)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${BRANCH_TYPE}/l0_tests.cmake)
endif()
@ -369,7 +369,11 @@ else()
CONFIGURATIONS Debug
)
endif()
if(NOT SKIP_L0_UNIT_TESTS)
add_subdirectory_unique(core/test)
else()
hide_subdir(core/test)
endif()
add_subdirectories()
if(UNIX)
@ -424,4 +428,7 @@ endif()
endif()
endif()
else()
set(BUILD_WITH_L0 FALSE
PARENT_SCOPE)
endif()

View File

@ -0,0 +1,154 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
##
## L0 tests settings
##
if(NOT SKIP_L0_UNIT_TESTS)
# These need to be added to a project to enable platform support in ULTs
if(TESTS_GEN8)
set(COMPUTE_RUNTIME_ULT_GEN8
${NEO_SHARED_TEST_DIRECTORY}/unit_test/libult/gen8.cpp
${NEO_SHARED_TEST_DIRECTORY}/unit_test/gen8/cmd_parse_gen8.cpp
)
endif()
if(TESTS_GEN9)
set(COMPUTE_RUNTIME_ULT_GEN9
${NEO_SHARED_TEST_DIRECTORY}/unit_test/libult/gen9.cpp
${NEO_SHARED_TEST_DIRECTORY}/unit_test/gen9/cmd_parse_gen9.cpp
)
endif()
if(TESTS_GEN11)
set(COMPUTE_RUNTIME_ULT_GEN11
${NEO_SHARED_TEST_DIRECTORY}/unit_test/libult/gen11.cpp
${NEO_SHARED_TEST_DIRECTORY}/unit_test/gen11/cmd_parse_gen11.cpp
)
endif()
if(TESTS_GEN12LP)
set(COMPUTE_RUNTIME_ULT_GEN12LP
${NEO_SHARED_TEST_DIRECTORY}/unit_test/libult/gen12lp.cpp
${NEO_SHARED_TEST_DIRECTORY}/unit_test/gen12lp/cmd_parse_gen12lp.cpp
)
endif()
## ULT related settings
#Extract compute runtime COMPILE_DEFINITIONS
if(NOT SKIP_L0_UNIT_TESTS)
get_property(COMPUTE_RUNTIME_MOCKABLE_DEFINITIONS
TARGET ${NEO_MOCKABLE_LIB_NAME}
PROPERTY COMPILE_DEFINITIONS
)
endif()
#Append additional definitions
set(COMPUTE_RUNTIME_MOCKABLE_DEFINITIONS
${COMPUTE_RUNTIME_MOCKABLE_DEFINITIONS}
CL_TARGET_OPENCL_VERSION=220
CL_USE_DEPRECATED_OPENCL_1_1_APIS
CL_USE_DEPRECATED_OPENCL_1_2_APIS
CL_USE_DEPRECATED_OPENCL_2_0_APIS
)
if(WIN32)
set(COMPUTE_RUNTIME_MOCKABLE_DEFINITIONS
${COMPUTE_RUNTIME_MOCKABLE_DEFINITIONS}
WDDM_VERSION_NUMBER=23
CONST_FROM_WDK_10_0_18328_0=
)
endif()
#Extract compute runtime INCLUDE_DIRECTORIES
get_property(COMPUTE_RUNTIME_MOCKABLE_INCLUDES
TARGET ${NEO_MOCKABLE_LIB_NAME}
PROPERTY INCLUDE_DIRECTORIES
)
# Create a library that has the missing ingredients to link
add_library(compute_runtime_mockable_extra
STATIC
EXCLUDE_FROM_ALL
${NEO_SHARED_TEST_DIRECTORY}/unit_test/utilities/cpuintrinsics.cpp
${COMPUTE_RUNTIME_DIR}/opencl/source/aub/aub_stream_interface.cpp
${COMPUTE_RUNTIME_DIR}/shared/source/debug_settings/debug_settings_manager.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/abort.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/helpers/built_ins_helper.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/helpers/debug_helpers.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/helpers/test_files.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/libult/os_interface.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/libult/source_level_debugger.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/libult/source_level_debugger_library.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/mocks/mock_cif.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/mocks/mock_csr.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/mocks/mock_gmm_page_table_mngr.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/mocks/mock_compilers.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/mocks${BRANCH_SUFIX_DIR}/mock_gmm_client_context.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/mocks/mock_gmm_resource_info.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/mocks/mock_gmm_client_context_base.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/mocks/mock_program.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/mocks/mock_sip.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/utilities/debug_settings_reader_creator.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/libult/create_tbx_sockets.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/mocks/mock_deferred_deleter.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/ult_configuration.cpp
)
set_property(TARGET compute_runtime_mockable_extra APPEND_STRING PROPERTY COMPILE_FLAGS ${ASAN_FLAGS} ${TSAN_FLAGS})
set_target_properties(compute_runtime_mockable_extra PROPERTIES FOLDER ${TARGET_NAME_L0})
# These need to be added to a project to enable platform support in ULTs
#Additional includes for ULT builds
target_include_directories(compute_runtime_mockable_extra
PUBLIC
${COMPUTE_RUNTIME_MOCKABLE_INCLUDES}
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/mocks/gmm_memory
${SOURCE_LEVEL_DEBUGGER_HEADERS_DIR}
)
#Additional compile definitions for ULT builds
target_compile_definitions(compute_runtime_mockable_extra
PUBLIC
${COMPUTE_RUNTIME_MOCKABLE_DEFINITIONS}
)
target_link_libraries(compute_runtime_mockable_extra
gmock-gtest
)
if(WIN32)
target_sources(compute_runtime_mockable_extra
PRIVATE
${COMPUTE_RUNTIME_DIR}/shared/source/dll/windows/environment_variables.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/mocks/mock_gmm_memory_base.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/mocks/mock_wddm.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/mocks/mock_compilers_windows.cpp
)
target_link_libraries(compute_runtime_mockable_extra
ws2_32
)
endif()
if(UNIX)
target_sources(compute_runtime_mockable_extra
PRIVATE
${COMPUTE_RUNTIME_DIR}/opencl/source/dll/linux/allocator_helper.cpp
${COMPUTE_RUNTIME_DIR}/opencl/source/tbx/tbx_sockets_imp.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/os_interface/linux/drm_mock.cpp
)
target_link_libraries(compute_runtime_mockable_extra
dl
)
endif()
set_target_properties(compute_runtime_mockable_extra PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()

View File

@ -0,0 +1,9 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(NOT SKIP_L0_UNIT_TESTS)
add_subdirectories()
endif()

View File

@ -0,0 +1,161 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
link_libraries(${ASAN_LIBS} ${TSAN_LIBS})
set(TARGET_NAME ${TARGET_NAME_L0}_core_tests)
append_sources_from_properties(L0_CORE_ENABLERS NEO_CORE_SRCS_LINK)
append_sources_from_properties(L0_SCRS_FROM_PROPERTIES
)
add_executable(${TARGET_NAME}
${NEO_SOURCE_DIR}/level_zero/core/source/dll/disallow_deferred_deleter.cpp
${NEO_SOURCE_DIR}/level_zero/core/source/debug_manager.cpp
${NEO_SOURCE_DIR}/level_zero/core/source/debugger.cpp
${NEO_SOURCE_DIR}/level_zero/core/source/debugger/debugger_l0.cpp
${NEO_SOURCE_DIR}/level_zero/core/source/compiler_interface/default_l0_cache_config.cpp
${NEO_SOURCE_DIR}/level_zero/core/source/compiler_interface/default_cache_config.cpp
${NEO_SOURCE_DIR}/shared/test/unit_test/helpers/memory_management.h
${NEO_SOURCE_DIR}/shared/test/unit_test/helpers/memory_management.cpp
${NEO_SOURCE_DIR}/shared/test/unit_test/helpers/memory_leak_listener.h
${NEO_SOURCE_DIR}/shared/test/unit_test/helpers/memory_leak_listener.cpp
${L0_SCRS_FROM_PROPERTIES}
${L0_CORE_ENABLERS}
)
target_sources(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
)
target_sources(${TARGET_NAME} PRIVATE
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/libult/create_command_stream.cpp
)
if (UNIX)
target_sources(${TARGET_NAME} PRIVATE
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/os_interface/linux/create_drm_memory_manager.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/os_interface/linux/drm_neo_create.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/os_interface/linux/options.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/os_interface/linux/sys_calls_linux_ult.cpp
${COMPUTE_RUNTIME_DIR}/level_zero/core/source/linux/registry_path.cpp
)
else()
target_sources(${TARGET_NAME} PRIVATE
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/os_interface/windows/create_wddm_memory_manager.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/os_interface/windows/options.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/os_interface/windows/sys_calls.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/os_interface/windows/ult_dxgi_factory.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/os_interface/windows/wddm_calls.cpp
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/os_interface/windows/wddm_create.cpp
${COMPUTE_RUNTIME_DIR}/level_zero/core/source/windows/registry_path.cpp
)
endif()
set_property(TARGET ${TARGET_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS ${ASAN_FLAGS})
set_target_properties(${TARGET_NAME} PROPERTIES FOLDER ${TARGET_NAME_L0})
target_compile_definitions(${TARGET_NAME}
PUBLIC
DEFAULT_PRODUCT_FAMILY=${DEFAULT_PRODUCT_FAMILY}
ZE_MAKEDLL
)
target_include_directories(${TARGET_NAME}
BEFORE
PRIVATE
$<TARGET_PROPERTY:${TARGET_NAME_L0},SOURCE_DIR>/core
$<TARGET_PROPERTY:${TARGET_NAME_L0},SOURCE_DIR>/tools
$<TARGET_PROPERTY:${TARGET_NAME_L0},SOURCE_DIR>/../../../../instrumentation/inc/common/instrumentation/api/
$<TARGET_PROPERTY:${TARGET_NAME_L0},SOURCE_DIR>/core/os_interface
${NEO_SHARED_TEST_DIRECTORY}/unit_test/test_macros${BRANCH_DIR_SUFFIX}
)
if (UNIX)
target_include_directories(${TARGET_NAME}
BEFORE
PRIVATE
$<TARGET_PROPERTY:${TARGET_NAME_L0},SOURCE_DIR>/core/os_interface/linux
$<TARGET_PROPERTY:${TARGET_NAME_L0},SOURCE_DIR>/tools/linux
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/linux
)
target_link_libraries(${TARGET_NAME}
pthread
)
else()
target_include_directories(${TARGET_NAME}
BEFORE
PRIVATE
$<TARGET_PROPERTY:${TARGET_NAME_L0},SOURCE_DIR>/core/os_interface/windows
$<TARGET_PROPERTY:${TARGET_NAME_L0},SOURCE_DIR>/tools/windows
${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/windows
)
endif()
if (UNIX)
target_link_libraries(${TARGET_NAME}
rt
)
else()
target_link_libraries(${TARGET_NAME}
dbghelp
)
endif()
target_link_libraries(${TARGET_NAME}
${NEO_MOCKABLE_LIB_NAME}
${NEO_SHARED_MOCKABLE_LIB_NAME}
${NEO_MOCKABLE_LIB_NAME}
${NEO_SHARED_MOCKABLE_LIB_NAME}
compute_runtime_mockable_extra
${HW_LIBS_ULT}
gmock-gtest
)
if(SKIP_NEO_UNIT_TESTS)
add_subdirectory(${COMPUTE_RUNTIME_DIR}/opencl/test/unit_test/mock_gmm ${CMAKE_BINARY_DIR}/mock_gmm)
endif()
target_sources(${TARGET_NAME} PRIVATE $<TARGET_OBJECTS:mock_gmm>)
option(L0_ULT_VERBOSE "Use the default/verbose test output" OFF)
if(NOT L0_ULT_VERBOSE)
set(L0_TESTS_LISTENER_OPTION "--disable_default_listener")
else()
set(L0_TESTS_LISTENER_OPTION "--enable_default_listener")
endif()
if(L0_ULT_FILTER)
set(L0_TESTS_FILTER_OPTION "--gtest_filter=*${L0_ULT_FILTER}*")
else()
set(L0_TESTS_FILTER_OPTION "--gtest_filter=*")
endif()
if(MSVC)
set_target_properties(${TARGET_NAME}
PROPERTIES
VS_DEBUGGER_COMMAND_ARGUMENTS "${L0_TESTS_FILTER_OPTION} --gtest_catch_exceptions=0 ${L0_TESTS_LISTENER_OPTION}"
VS_DEBUGGER_WORKING_DIRECTORY "$(OutDir)"
)
set(RUN_ULT_CMD $<TARGET_FILE:${TARGET_NAME}>)
else()
set(RUN_ULT_CMD LD_LIBRARY_PATH=$<TARGET_FILE_DIR:${TARGET_NAME}> $<TARGET_FILE:${TARGET_NAME}>)
endif()
if(NOT GTEST_REPEAT)
set(GTEST_REPEAT 1 CACHE STRING "Google test iterations")
endif()
message(STATUS "GTest repeat count set to ${GTEST_REPEAT}")
if(NOT GTEST_SHUFFLE)
set(GTEST_SHUFFLE --gtest_shuffle --gtest_random_seed=0)
endif()
message(STATUS "GTest shuffle set to ${GTEST_SHUFFLE}")
add_subdirectory(sources)
create_source_tree(${TARGET_NAME} ${L0_ROOT_DIR}/..)

View File

@ -0,0 +1,15 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_GEN11)
append_sources_from_properties(HW_SOURCES_GEN11 L0_HW_SOURCES_GEN11)
target_sources(${TARGET_NAME} PRIVATE
${COMPUTE_RUNTIME_ULT_GEN11}
${HW_SOURCES_GEN11}
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
)
endif()

View File

@ -0,0 +1,17 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_GEN12LP)
append_sources_from_properties(HW_SOURCES_GEN12LP L0_HW_SOURCES_GEN12LP)
target_sources(${TARGET_NAME} PRIVATE
${COMPUTE_RUNTIME_ULT_GEN12LP}
${HW_SOURCES_GEN12LP}
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
)
add_subdirectoriesL0(${CMAKE_CURRENT_SOURCE_DIR} "*")
endif()

View File

@ -0,0 +1,15 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_GEN8)
append_sources_from_properties(HW_SOURCES_GEN8 L0_HW_SOURCES_GEN8)
target_sources(${TARGET_NAME} PRIVATE
${COMPUTE_RUNTIME_ULT_GEN8}
${HW_SOURCES_GEN8}
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
)
endif()

View File

@ -0,0 +1,16 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_GEN9)
append_sources_from_properties(HW_SOURCES_GEN9 L0_HW_SOURCES_GEN9)
target_sources(${TARGET_NAME} PRIVATE
${COMPUTE_RUNTIME_ULT_GEN9}
${HW_SOURCES_GEN9}
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
add_subdirectoriesL0(${CMAKE_CURRENT_SOURCE_DIR} "*")
endif()

View File

@ -0,0 +1,202 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/helpers/hw_info.h"
#include "shared/source/os_interface/hw_info_config.h"
#include "shared/test/unit_test/helpers/default_hw_info.inl"
#include "shared/test/unit_test/helpers/memory_leak_listener.h"
#include "shared/test/unit_test/helpers/ult_hw_config.inl"
#include "opencl/source/program/kernel_info.h"
#include "opencl/source/utilities/logger.h"
#include "opencl/test/unit_test/custom_event_listener.h"
#include "opencl/test/unit_test/mocks/mock_gmm_client_context.h"
#include "opencl/test/unit_test/mocks/mock_sip.h"
#include "gmock/gmock.h"
#include "igfxfmid.h"
#include <fstream>
#include <mutex>
#include <sstream>
#include <thread>
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winconsistent-missing-override"
#endif
#ifdef WIN32
const char *fSeparator = "\\";
#else
const char *fSeparator = "/";
#endif
TEST(Should, pass) { EXPECT_TRUE(true); }
namespace L0 {
namespace ult {
::testing::Environment *environment = nullptr;
}
} // namespace L0
using namespace L0::ult;
PRODUCT_FAMILY productFamily = IGFX_SKYLAKE;
GFXCORE_FAMILY renderCoreFamily = IGFX_GEN9_CORE;
namespace NEO {
extern const HardwareInfo *hardwareInfoTable[IGFX_MAX_PRODUCT];
namespace MockSipData {
extern std::unique_ptr<MockSipKernel> mockSipKernel;
}
} // namespace NEO
std::string getRunPath(char *argv0) {
std::string res(argv0);
auto pos = res.rfind(fSeparator);
if (pos != std::string::npos)
res = res.substr(0, pos);
if (res == "." || pos == std::string::npos) {
#if defined(__linux__)
res = getcwd(nullptr, 0);
#else
res = _getcwd(nullptr, 0);
#endif
}
return res;
}
std::thread::id tempThreadID;
void applyWorkarounds() {
NEO::platformsImpl.reserve(1);
{
std::ofstream f;
const std::string fileName("_tmp_");
f.open(fileName, std::ofstream::binary);
f.close();
}
{
std::mutex mtx;
std::unique_lock<std::mutex> stateLock(mtx);
}
{
std::stringstream ss("1");
int val;
ss >> val;
}
{
class BaseClass {
public:
int method(int param) { return 1; }
};
class MockClass : public BaseClass {
public:
MOCK_METHOD1(method, int(int param));
};
::testing::NiceMock<MockClass> mockObj;
EXPECT_CALL(mockObj, method(::testing::_))
.Times(1);
mockObj.method(2);
}
//intialize rand
srand(static_cast<unsigned int>(time(nullptr)));
//Create at least on thread to prevent false memory leaks in tests using threads
std::thread t([&]() {
});
tempThreadID = t.get_id();
t.join();
}
int main(int argc, char **argv) {
bool useDefaultListener = false;
applyWorkarounds();
testing::InitGoogleMock(&argc, argv);
for (int i = 1; i < argc; ++i) {
if (!strcmp("--product", argv[i])) {
++i;
if (i < argc) {
if (::isdigit(argv[i][0])) {
int productValue = atoi(argv[i]);
if (productValue > 0 && productValue < IGFX_MAX_PRODUCT &&
NEO::hardwarePrefix[productValue] != nullptr) {
::productFamily = static_cast<PRODUCT_FAMILY>(productValue);
} else {
::productFamily = IGFX_UNKNOWN;
}
} else {
::productFamily = IGFX_UNKNOWN;
for (int j = 0; j < IGFX_MAX_PRODUCT; j++) {
if (NEO::hardwarePrefix[j] == nullptr)
continue;
if (strcmp(NEO::hardwarePrefix[j], argv[i]) == 0) {
::productFamily = static_cast<PRODUCT_FAMILY>(j);
break;
}
}
}
if (::productFamily == IGFX_UNKNOWN) {
std::cout << "unknown or unsupported product family has been set: " << argv[i]
<< std::endl;
return -1;
} else {
std::cout << "product family: " << NEO::hardwarePrefix[::productFamily] << " ("
<< ::productFamily << ")" << std::endl;
}
}
}
if (!strcmp("--disable_default_listener", argv[i])) {
useDefaultListener = false;
} else if (!strcmp("--enable_default_listener", argv[i])) {
useDefaultListener = true;
}
}
auto &listeners = ::testing::UnitTest::GetInstance()->listeners();
if (useDefaultListener == false) {
auto defaultListener = listeners.default_result_printer();
auto customEventListener = new CCustomEventListener(defaultListener, NEO::hardwarePrefix[::productFamily]);
listeners.Release(defaultListener);
listeners.Append(customEventListener);
}
listeners.Append(new NEO::MemoryLeakListener);
NEO::GmmHelper::createGmmContextWrapperFunc =
NEO::GmmClientContextBase::create<NEO::MockGmmClientContext>;
if (environment) {
::testing::AddGlobalTestEnvironment(environment);
}
PLATFORM platform;
auto hardwareInfo = NEO::hardwareInfoTable[productFamily];
if (!hardwareInfo) {
return -1;
}
platform = hardwareInfo->platform;
NEO::useKernelDescriptor = true;
NEO::MockSipData::mockSipKernel.reset(new NEO::MockSipKernel());
return RUN_ALL_TESTS();
}
#if defined(__clang__)
#pragma clang diagnostic pop
#endif

View File

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

View File

@ -0,0 +1,16 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/deferred_deleter_helper.h"
#include "gtest/gtest.h"
using namespace NEO;
TEST(DeferredDeleterHelper, GivenDefferedDeleterHelperWhenCheckIFDeferrDeleterIsEnabledThenFalseIsReturned) {
EXPECT_FALSE(isDeferredDeleterEnabled());
}

View File

@ -7,7 +7,7 @@
project(igdrcl_tests)
set(OPENCL_TEST_PROJECTS_FOLDER "opencl runtime")
set(OPENCL_PLATFORM_SPECIFIC_TEST_TARGETS_FOLDER "${OPENCL_TEST_PROJECTS_FOLDER}/test platforms")
set(PLATFORM_SPECIFIC_TEST_TARGETS_FOLDER "${OPENCL_TEST_PROJECTS_FOLDER}/test platforms")
set(OPENCL_UNIT_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR})
# disable optimizations for ults
@ -181,7 +181,7 @@ function(neo_copy_test_files target product)
DEPENDS ${NEO_SOURCE_DIR}/opencl/test/unit_test/test_files
)
add_dependencies(${target} copy_compiler_files)
set_target_properties(${target} PROPERTIES FOLDER "${OPENCL_PLATFORM_SPECIFIC_TEST_TARGETS_FOLDER}/${product}")
set_target_properties(${target} PROPERTIES FOLDER "${PLATFORM_SPECIFIC_TEST_TARGETS_FOLDER}/${product}")
endfunction()
add_dependencies(unit_tests
@ -470,7 +470,7 @@ macro(macro_for_each_gen)
endif()
endif()
add_custom_target(prepare_test_kernels_${family_name_with_type} DEPENDS ${kernels_to_compile_${family_name_with_type}} copy_compiler_files)
set_target_properties(prepare_test_kernels_${family_name_with_type} PROPERTIES FOLDER "${OPENCL_PLATFORM_SPECIFIC_TEST_TARGETS_FOLDER}/${family_name_with_type}")
set_target_properties(prepare_test_kernels_${family_name_with_type} PROPERTIES FOLDER "${PLATFORM_SPECIFIC_TEST_TARGETS_FOLDER}/${family_name_with_type}")
add_dependencies(prepare_test_kernels prepare_test_kernels_${family_name_with_type})
endif()
endforeach()

View File

@ -12,7 +12,7 @@ list(GET aub_test_config 3 eu_per_ss)
add_custom_target(run_${product}_aub_tests ALL DEPENDS copy_test_files_${product} prepare_test_kernels)
add_dependencies(run_aub_tests run_${product}_aub_tests)
set_target_properties(run_${product}_aub_tests PROPERTIES FOLDER "${OPENCL_PLATFORM_SPECIFIC_TEST_TARGETS_FOLDER}/${product}")
set_target_properties(run_${product}_aub_tests PROPERTIES FOLDER "${PLATFORM_SPECIFIC_TEST_TARGETS_FOLDER}/${product}")
if(WIN32)
add_dependencies(run_${product}_aub_tests mock_gdi)

View File

@ -1,36 +0,0 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
string(REPLACE "/" ";" unit_test_config ${unit_test_config})
list(GET unit_test_config 0 product)
list(GET unit_test_config 1 slices)
list(GET unit_test_config 2 subslices)
list(GET unit_test_config 3 eu_per_ss)
add_custom_target(run_${product}_unit_tests ALL DEPENDS unit_tests)
neo_copy_test_files(copy_test_files_${product} ${product})
add_dependencies(unit_tests copy_test_files_${product})
set_target_properties(run_${product}_unit_tests PROPERTIES FOLDER "${OPENCL_PLATFORM_SPECIFIC_TEST_TARGETS_FOLDER}/${product}")
add_custom_command(
TARGET run_${product}_unit_tests
POST_BUILD
COMMAND WORKING_DIRECTORY ${TargetDir}
COMMAND echo Running igdrcl_tests ${target} ${slices}x${subslices}x${eu_per_ss} in ${TargetDir}/${product}
COMMAND $<TARGET_FILE:igdrcl_tests> --product ${product} --slices ${slices} --subslices ${subslices} --eu_per_ss ${eu_per_ss} ${GTEST_EXCEPTION_OPTIONS} --gtest_repeat=${GTEST_REPEAT} ${GTEST_SHUFFLE} ${IGDRCL_TESTS_LISTENER_OPTION} ${GTEST_FILTER_OPTION}
)
add_dependencies(run_unit_tests run_${product}_unit_tests)
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug" AND "${IGDRCL_OPTION__BITS}" STREQUAL "64" AND appverified_allowed)
add_custom_command(
TARGET run_${product}_unit_tests
POST_BUILD
COMMAND echo copying test verify.bat file from ${OPENCL_UNIT_TEST_DIR} to ${TargetDir}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${OPENCL_UNIT_TEST_DIR}/verify.bat ${TargetDir}/verify.bat
COMMAND WORKING_DIRECTORY ${TargetDir}
COMMAND echo Running igdrcl_tests with App Verifier
COMMAND ${TargetDir}/verify.bat --product ${product} --slices ${slices} --subslices ${subslices} --eu_per_ss ${eu_per_ss} ${GTEST_EXCEPTION_OPTIONS} ${IGDRCL_TESTS_LISTENER_OPTION} ${GTEST_FILTER_OPTION}
COMMAND echo App Verifier returned: %errorLevel%
)
endif()

View File

@ -12,6 +12,6 @@ if(TESTS_EHL)
)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen11_ehl})
add_subdirectories()
set(unit_test_config "ehl/1/4/8")
include(${OPENCL_UNIT_TEST_DIR}/cmake/run_ult_target.cmake)
neo_copy_test_files(copy_test_files_ehl ehl)
add_dependencies(unit_tests copy_test_files_ehl)
endif()

View File

@ -14,7 +14,6 @@ if(TESTS_ICLLP)
)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen11_icllp})
add_subdirectories()
set(appverified_allowed ${APPVERIFIER_ALLOWED})
set(unit_test_config "icllp/1/8/8")
include(${OPENCL_UNIT_TEST_DIR}/cmake/run_ult_target.cmake)
neo_copy_test_files(copy_test_files_icllp icllp)
add_dependencies(unit_tests copy_test_files_icllp)
endif()

View File

@ -12,6 +12,6 @@ if(TESTS_LKF)
)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen11_lkf})
add_subdirectories()
set(unit_test_config "lkf/1/8/8")
include(${OPENCL_UNIT_TEST_DIR}/cmake/run_ult_target.cmake)
neo_copy_test_files(copy_test_files_lkf lkf)
add_dependencies(unit_tests copy_test_files_lkf)
endif()

View File

@ -13,7 +13,6 @@ if(TESTS_TGLLP)
)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen12lp_tgllp})
add_subdirectories()
set(appverified_allowed ${APPVERIFIER_ALLOWED})
set(unit_test_config "tgllp/1/6/16")
include(${OPENCL_UNIT_TEST_DIR}/cmake/run_ult_target.cmake)
neo_copy_test_files(copy_test_files_tgllp tgllp)
add_dependencies(unit_tests copy_test_files_tgllp)
endif()

View File

@ -13,7 +13,6 @@ if(TESTS_BDW)
)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen8_bdw})
add_subdirectories()
set(appverified_allowed ${APPVERIFIER_ALLOWED})
set(unit_test_config "bdw/1/3/8")
include(${OPENCL_UNIT_TEST_DIR}/cmake/run_ult_target.cmake)
neo_copy_test_files(copy_test_files_bdw bdw)
add_dependencies(unit_tests copy_test_files_bdw)
endif()

View File

@ -13,6 +13,6 @@ if(TESTS_BXT)
)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen9_bxt})
add_subdirectories()
set(unit_test_config "bxt/1/3/6")
include(${OPENCL_UNIT_TEST_DIR}/cmake/run_ult_target.cmake)
neo_copy_test_files(copy_test_files_bxt bxt)
add_dependencies(unit_tests copy_test_files_bxt)
endif()

View File

@ -12,6 +12,6 @@ if(TESTS_CFL)
)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen9_cfl})
add_subdirectories()
set(unit_test_config "cfl/1/3/6")
include(${OPENCL_UNIT_TEST_DIR}/cmake/run_ult_target.cmake)
neo_copy_test_files(copy_test_files_cfl cfl)
add_dependencies(unit_tests copy_test_files_cfl)
endif()

View File

@ -12,6 +12,6 @@ if(TESTS_GLK)
)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen9_glk})
add_subdirectories()
set(unit_test_config "glk/1/3/6")
include(${OPENCL_UNIT_TEST_DIR}/cmake/run_ult_target.cmake)
neo_copy_test_files(copy_test_files_glk glk)
add_dependencies(unit_tests copy_test_files_glk)
endif()

View File

@ -12,6 +12,6 @@ if(TESTS_KBL)
)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen9_kbl})
add_subdirectories()
set(unit_test_config "kbl/1/3/6")
include(${OPENCL_UNIT_TEST_DIR}/cmake/run_ult_target.cmake)
neo_copy_test_files(copy_test_files_kbl kbl)
add_dependencies(unit_tests copy_test_files_kbl)
endif()

View File

@ -18,7 +18,6 @@ if(TESTS_SKL)
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_gen9_skl})
add_subdirectories()
set(appverified_allowed ${APPVERIFIER_ALLOWED})
set(unit_test_config "skl/1/3/8")
include(${OPENCL_UNIT_TEST_DIR}/cmake/run_ult_target.cmake)
neo_copy_test_files(copy_test_files_skl skl)
add_dependencies(unit_tests copy_test_files_skl)
endif()

View File

@ -16,7 +16,7 @@ if(NOT WIN32)
endif()
add_dependencies(run_mt_unit_tests run_${product}_mt_unit_tests)
set_target_properties(run_${product}_mt_unit_tests PROPERTIES FOLDER "${OPENCL_PLATFORM_SPECIFIC_TEST_TARGETS_FOLDER}/${product}")
set_target_properties(run_${product}_mt_unit_tests PROPERTIES FOLDER "${PLATFORM_SPECIFIC_TEST_TARGETS_FOLDER}/${product}")
add_custom_command(
TARGET run_${product}_mt_unit_tests

View File

@ -0,0 +1,20 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
set(BUILT_IN_KERNEL_DIR "${NEO_SOURCE_DIR}/shared/source/built_ins")
set(PLATFORM_SPECIFIC_TEST_TARGETS_FOLDER ult_product_targets)
if(NOT TARGET run_unit_tests)
add_custom_target(run_unit_tests ALL)
set_target_properties(run_unit_tests PROPERTIES FOLDER ${PLATFORM_SPECIFIC_TEST_TARGETS_FOLDER})
endif()
if(NOT TARGET unit_tests)
add_custom_target(unit_tests ALL)
set_target_properties(unit_tests PROPERTIES FOLDER ${PLATFORM_SPECIFIC_TEST_TARGETS_FOLDER})
endif()
add_subdirectories()

View File

@ -0,0 +1,9 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_GEN11)
add_subdirectories()
endif()

View File

@ -0,0 +1,10 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_EHL)
set(unit_test_config "ehl/1/4/8")
include(${NEO_SOURCE_DIR}/cmake/run_ult_target.cmake)
endif()

View File

@ -0,0 +1,11 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_ICLLP)
set(unit_test_config "icllp/1/8/8")
set(appverified_allowed ${APPVERIFIER_ALLOWED})
include(${NEO_SOURCE_DIR}/cmake/run_ult_target.cmake)
endif()

View File

@ -0,0 +1,10 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_LKF)
set(unit_test_config "lkf/1/8/8")
include(${NEO_SOURCE_DIR}/cmake/run_ult_target.cmake)
endif()

View File

@ -0,0 +1,9 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_GEN12LP)
add_subdirectories()
endif()

View File

@ -0,0 +1,11 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_TGLLP)
set(unit_test_config "tgllp/1/6/16")
set(appverified_allowed ${APPVERIFIER_ALLOWED})
include(${NEO_SOURCE_DIR}/cmake/run_ult_target.cmake)
endif()

View File

@ -0,0 +1,9 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_GEN8)
add_subdirectories()
endif()

View File

@ -0,0 +1,11 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_BDW)
set(unit_test_config "bdw/1/3/8")
set(appverified_allowed ${APPVERIFIER_ALLOWED})
include(${NEO_SOURCE_DIR}/cmake/run_ult_target.cmake)
endif()

View File

@ -0,0 +1,9 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_GEN9)
add_subdirectories()
endif()

View File

@ -0,0 +1,10 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_BXT)
set(unit_test_config "bxt/1/3/6")
include(${NEO_SOURCE_DIR}/cmake/run_ult_target.cmake)
endif()

View File

@ -0,0 +1,10 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_CFL)
set(unit_test_config "cfl/1/3/6")
include(${NEO_SOURCE_DIR}/cmake/run_ult_target.cmake)
endif()

View File

@ -0,0 +1,10 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_GLK)
set(unit_test_config "glk/1/3/6")
include(${NEO_SOURCE_DIR}/cmake/run_ult_target.cmake)
endif()

View File

@ -0,0 +1,10 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_KBL)
set(unit_test_config "kbl/1/3/6")
include(${NEO_SOURCE_DIR}/cmake/run_ult_target.cmake)
endif()

View File

@ -0,0 +1,11 @@
#
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
if(TESTS_SKL)
set(unit_test_config "skl/1/3/8")
set(appverified_allowed ${APPVERIFIER_ALLOWED})
include(${NEO_SOURCE_DIR}/cmake/run_ult_target.cmake)
endif()