mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 07:14:10 +08:00
Add Ult target for level_zero
Change-Id: I5b18b6f495eda302ba96287d7bd6cc0b2bbe48ac Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
2dbee6d7c1
commit
2b269caca9
9
level_zero/core/test/CMakeLists.txt
Normal file
9
level_zero/core/test/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
# Copyright (C) 2020 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
|
||||
if(NOT SKIP_L0_UNIT_TESTS)
|
||||
add_subdirectories()
|
||||
endif()
|
||||
161
level_zero/core/test/unit_tests/CMakeLists.txt
Normal file
161
level_zero/core/test/unit_tests/CMakeLists.txt
Normal 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}/..)
|
||||
15
level_zero/core/test/unit_tests/gen11/CMakeLists.txt
Normal file
15
level_zero/core/test/unit_tests/gen11/CMakeLists.txt
Normal 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()
|
||||
17
level_zero/core/test/unit_tests/gen12lp/CMakeLists.txt
Normal file
17
level_zero/core/test/unit_tests/gen12lp/CMakeLists.txt
Normal 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()
|
||||
15
level_zero/core/test/unit_tests/gen8/CMakeLists.txt
Normal file
15
level_zero/core/test/unit_tests/gen8/CMakeLists.txt
Normal 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()
|
||||
16
level_zero/core/test/unit_tests/gen9/CMakeLists.txt
Normal file
16
level_zero/core/test/unit_tests/gen9/CMakeLists.txt
Normal 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()
|
||||
202
level_zero/core/test/unit_tests/main.cpp
Normal file
202
level_zero/core/test/unit_tests/main.cpp
Normal 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
|
||||
10
level_zero/core/test/unit_tests/sources/CMakeLists.txt
Normal file
10
level_zero/core/test/unit_tests/sources/CMakeLists.txt
Normal 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
|
||||
)
|
||||
@@ -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());
|
||||
}
|
||||
Reference in New Issue
Block a user