diff --git a/opencl/test/unit_test/linux/main_linux_dll.cpp b/opencl/test/unit_test/linux/main_linux_dll.cpp index b687f92970..365247808e 100644 --- a/opencl/test/unit_test/linux/main_linux_dll.cpp +++ b/opencl/test/unit_test/linux/main_linux_dll.cpp @@ -49,6 +49,7 @@ extern const DeviceDescriptor deviceDescriptorTable[]; NEO::OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo, uint64_t gpuAddressSpace) { return nullptr; } +void setupExternalDependencies() {} using namespace NEO; diff --git a/opencl/test/unit_test/windows/CMakeLists.txt b/opencl/test/unit_test/windows/CMakeLists.txt index 92c2112222..38fb50f71b 100644 --- a/opencl/test/unit_test/windows/CMakeLists.txt +++ b/opencl/test/unit_test/windows/CMakeLists.txt @@ -31,6 +31,7 @@ if(WIN32) ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/windows/create_wddm_memory_manager.cpp ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/windows/mock_environment_variables.cpp ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/windows/options.cpp + ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/setup_external_dependencies_drm_or_wddm.cpp ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/windows/sys_calls.cpp ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/windows/wddm_calls.cpp ${NEO_SHARED_TEST_DIRECTORY}/common/test_macros/test_checks_shared.cpp diff --git a/shared/source/os_interface/windows/wddm/um_km_data_translator.cpp b/shared/source/os_interface/windows/wddm/um_km_data_translator.cpp index 4782633a03..81a60b0de9 100644 --- a/shared/source/os_interface/windows/wddm/um_km_data_translator.cpp +++ b/shared/source/os_interface/windows/wddm/um_km_data_translator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -16,7 +16,7 @@ size_t UmKmDataTranslator::getSizeForAdapterInfoInternalRepresentation() { } bool UmKmDataTranslator::translateAdapterInfoFromInternalRepresentation(ADAPTER_INFO_KMD &dst, const void *src, size_t srcSize) { - return (0 == memcpy_s(&dst, sizeof(ADAPTER_INFO), src, srcSize)); + return (0 == memcpy_s(&dst, sizeof(ADAPTER_INFO_KMD), src, srcSize)); } size_t UmKmDataTranslator::getSizeForCreateContextDataInternalRepresentation() { diff --git a/shared/test/common/libult/CMakeLists.txt b/shared/test/common/libult/CMakeLists.txt index b36670448c..5dfec653f9 100644 --- a/shared/test/common/libult/CMakeLists.txt +++ b/shared/test/common/libult/CMakeLists.txt @@ -182,7 +182,8 @@ set(neo_libult_SRCS_LINUX ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/linux/create_drm_memory_manager.cpp ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/linux/drm_memory_manager_fixture.cpp ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/linux/drm_neo_create.cpp - ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/linux/options_${DRIVER_MODEL}.cpp + ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/linux/options.cpp + ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/setup_external_dependencies_${DRIVER_MODEL}.cpp ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/linux/sys_calls_linux_ult.cpp ) @@ -193,6 +194,7 @@ set(neo_libult_SRCS_WINDOWS ${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_direct_submission_controller_enabled.cpp ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/windows/create_wddm_memory_manager.cpp ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/windows/options.cpp + ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/setup_external_dependencies_drm_or_wddm.cpp ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/windows/sys_calls.cpp ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/windows/wddm_calls.cpp ${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/windows/mock_environment_variables.cpp diff --git a/shared/test/common/libult/global_environment.cpp b/shared/test/common/libult/global_environment.cpp index b80c012ba7..764fbe5c6d 100644 --- a/shared/test/common/libult/global_environment.cpp +++ b/shared/test/common/libult/global_environment.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -22,6 +22,7 @@ void TestEnvironment::SetUp() { fclPushDebugVars(fclDefaultDebugVars); igcPushDebugVars(igcDefaultDebugVars); if (libraryOS == nullptr) { + setupExternalDependencies(); libraryOS = setAdapterInfo(&hwInfoDefaultDebugVars.platform, &hwInfoDefaultDebugVars.gtSystemInfo, hwInfoDefaultDebugVars.capabilityTable.gpuAddressSpace); diff --git a/shared/test/common/libult/global_environment.h b/shared/test/common/libult/global_environment.h index 1d7392273e..81e12b4e3d 100644 --- a/shared/test/common/libult/global_environment.h +++ b/shared/test/common/libult/global_environment.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018-2021 Intel Corporation + * Copyright (C) 2018-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -15,6 +15,7 @@ using namespace NEO; OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo, uint64_t gpuAddressSpace); +void setupExternalDependencies(); class TestEnvironment : public ::testing::Environment { public: diff --git a/shared/test/common/os_interface/linux/options_drm.cpp b/shared/test/common/os_interface/linux/options.cpp similarity index 83% rename from shared/test/common/os_interface/linux/options_drm.cpp rename to shared/test/common/os_interface/linux/options.cpp index b1475b88fd..23e33edd73 100644 --- a/shared/test/common/os_interface/linux/options_drm.cpp +++ b/shared/test/common/os_interface/linux/options.cpp @@ -5,8 +5,6 @@ * */ -#include "shared/source/os_interface/os_library.h" - #include "common/gtsysinfo.h" #include "igfxfmid.h" #include "test_files_setup.h" @@ -29,7 +27,3 @@ const char *sysFsPciPathPrefix = NEO_SHARED_TEST_FILES_DIR "/linux/devices/"; const char *pciDevicesDirectory = NEO_SHARED_TEST_FILES_DIR "/linux/by-path"; const char *sysFsProcPathPrefix = NEO_SHARED_TEST_FILES_DIR "/linux/proc/"; } // namespace Os - -NEO::OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo, uint64_t gpuAddressSpace) { - return nullptr; -} diff --git a/shared/test/common/os_interface/linux/options_drm_or_wddm.cpp b/shared/test/common/os_interface/linux/options_drm_or_wddm.cpp deleted file mode 100644 index 3ee8a3200f..0000000000 --- a/shared/test/common/os_interface/linux/options_drm_or_wddm.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2018-2022 Intel Corporation - * - * SPDX-License-Identifier: MIT - * - */ - -#include "shared/test/common/mock_gdi/mock_os_library.h" - -#include "common/gtsysinfo.h" -#include "igfxfmid.h" -#include "test_files_setup.h" - -namespace Os { -/////////////////////////////////////////////////////////////////////////////// -// These options determine the Linux specific behavior for -// the runtime unit tests -/////////////////////////////////////////////////////////////////////////////// -#if defined(__linux__) -const char *frontEndDllName = "_invalidFCL"; -const char *igcDllName = "_invalidIGC"; -const char *libvaDllName = nullptr; -const char *testDllName = "libtest_dynamic_lib.so"; -const char *metricsLibraryDllName = ""; -const char *gdiDllName = ""; -const char *dxcoreDllName = ""; -#endif -const char *sysFsPciPathPrefix = NEO_SHARED_TEST_FILES_DIR "/linux/devices/"; -const char *pciDevicesDirectory = NEO_SHARED_TEST_FILES_DIR "/linux/by-path"; -const char *sysFsProcPathPrefix = NEO_SHARED_TEST_FILES_DIR "/linux/proc/"; -} // namespace Os - -NEO::OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo, uint64_t gpuAddressSpace) { - NEO::OsLibrary *mockGdiDll; - mockGdiDll = NEO::MockOsLibrary::load(""); - - typedef void (*pfSetAdapterInfo)(const void *, const void *, uint64_t); - pfSetAdapterInfo setAdapterInfo = reinterpret_cast(mockGdiDll->getProcAddress("mockSetAdapterInfo")); - - setAdapterInfo(platform, gtSystemInfo, gpuAddressSpace); - - return mockGdiDll; -} diff --git a/shared/test/common/os_interface/setup_external_dependencies_drm.cpp b/shared/test/common/os_interface/setup_external_dependencies_drm.cpp new file mode 100644 index 0000000000..44dfe5450a --- /dev/null +++ b/shared/test/common/os_interface/setup_external_dependencies_drm.cpp @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2018-2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/os_interface/os_library.h" + +#include "common/gtsysinfo.h" +#include "igfxfmid.h" + +NEO::OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo, uint64_t gpuAddressSpace) { + return nullptr; +} +void setupExternalDependencies() {} \ No newline at end of file diff --git a/shared/test/common/os_interface/setup_external_dependencies_drm_or_wddm.cpp b/shared/test/common/os_interface/setup_external_dependencies_drm_or_wddm.cpp new file mode 100644 index 0000000000..14180843e3 --- /dev/null +++ b/shared/test/common/os_interface/setup_external_dependencies_drm_or_wddm.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2018-2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/test/common/mock_gdi/mock_os_library.h" + +#include "common/gtsysinfo.h" +#include "igfxfmid.h" + +namespace NEO { +extern const char *wslComputeHelperLibNameToLoad; +} + +void setupExternalDependencies() { + NEO::wslComputeHelperLibNameToLoad = ""; +} + +NEO::OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo, uint64_t gpuAddressSpace) { + NEO::OsLibrary *mockGdiDll; + mockGdiDll = NEO::MockOsLibrary::load(""); + + typedef void (*pfSetAdapterInfo)(const void *, const void *, uint64_t); + pfSetAdapterInfo setAdapterInfo = reinterpret_cast(mockGdiDll->getProcAddress("mockSetAdapterInfo")); + + setAdapterInfo(platform, gtSystemInfo, gpuAddressSpace); + + return mockGdiDll; +} diff --git a/shared/test/common/os_interface/windows/options.cpp b/shared/test/common/os_interface/windows/options.cpp index 225d224848..d779149aea 100644 --- a/shared/test/common/os_interface/windows/options.cpp +++ b/shared/test/common/os_interface/windows/options.cpp @@ -5,8 +5,6 @@ * */ -#include "shared/test/common/mock_gdi/mock_os_library.h" - #include "common/gtsysinfo.h" #include "igfxfmid.h" @@ -22,15 +20,3 @@ const char *dxcoreDllName = ""; const char *testDllName = "test_dynamic_lib.dll"; const char *metricsLibraryDllName = ""; } // namespace Os - -NEO::OsLibrary *setAdapterInfo(const PLATFORM *platform, const GT_SYSTEM_INFO *gtSystemInfo, uint64_t gpuAddressSpace) { - NEO::OsLibrary *mockGdiDll; - mockGdiDll = NEO::MockOsLibrary::load(""); - - typedef void (*pfSetAdapterInfo)(const void *, const void *, uint64_t); - pfSetAdapterInfo setAdapterInfo = reinterpret_cast(mockGdiDll->getProcAddress("mockSetAdapterInfo")); - - setAdapterInfo(platform, gtSystemInfo, gpuAddressSpace); - - return mockGdiDll; -} diff --git a/shared/test/unit_test/os_interface/windows/CMakeLists.txt b/shared/test/unit_test/os_interface/windows/CMakeLists.txt index 5aec726415..fcce35fb76 100644 --- a/shared/test/unit_test/os_interface/windows/CMakeLists.txt +++ b/shared/test/unit_test/os_interface/windows/CMakeLists.txt @@ -11,6 +11,7 @@ if(WIN32) ${CMAKE_CURRENT_SOURCE_DIR}/adapter_info_tests.h ${CMAKE_CURRENT_SOURCE_DIR}/deferrable_deletion_win_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/wddm_adapter_luid_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/gmm_helper_tests_win.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_win_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_info_config_win_tests.h @@ -20,8 +21,7 @@ if(WIN32) ${CMAKE_CURRENT_SOURCE_DIR}/os_library_win_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/self_lib_win.cpp ${CMAKE_CURRENT_SOURCE_DIR}/um_km_data_translator_tests.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/wddm_address_space_tests.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/wddm_adapter_luid_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/wddm_address_space_windows_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_command_stream_l0_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_mapper_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_special_heap_test.cpp @@ -32,6 +32,8 @@ endif() if(WIN32 OR(UNIX AND NOT DISABLE_WDDM_LINUX)) target_sources(neo_shared_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/gdi_interface_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/wddm_address_space_tests.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/wddm_mapper_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_preemption_tests.cpp ${CMAKE_CURRENT_SOURCE_DIR}/wddm_shared_allocations_test.cpp diff --git a/shared/test/unit_test/os_interface/windows/wddm_address_space_tests.cpp b/shared/test/unit_test/os_interface/windows/wddm_address_space_tests.cpp index ea65d4ebaa..01e03584c0 100644 --- a/shared/test/unit_test/os_interface/windows/wddm_address_space_tests.cpp +++ b/shared/test/unit_test/os_interface/windows/wddm_address_space_tests.cpp @@ -141,19 +141,3 @@ TEST(WddmReserveAddressTest, givenWddmWhenFirstIsInvalidSecondNullThenReturnSeco EXPECT_FALSE(ret); EXPECT_EQ(expectedReserve, reinterpret_cast(reserve)); } - -using WddmTests = WddmTestWithMockGdiDll; - -TEST_F(WddmTests, whenInitializingWddmThenSetMinAddressToCorrectValue) { - constexpr static uintptr_t mockedInternalGpuVaRange = 0x9876u; - auto gmmMemory = new MockGmmMemoryBase(wddm->rootDeviceEnvironment.getGmmClientContext()); - gmmMemory->overrideInternalGpuVaRangeLimit(mockedInternalGpuVaRange); - wddm->gmmMemory.reset(gmmMemory); - - ASSERT_EQ(0u, wddm->getWddmMinAddress()); - wddm->init(); - - const bool obtainFromGmm = defaultHwInfo->platform.eRenderCoreFamily == IGFX_GEN12LP_CORE; - const auto expectedMinAddress = obtainFromGmm ? mockedInternalGpuVaRange : windowsMinAddress; - ASSERT_EQ(expectedMinAddress, wddm->getWddmMinAddress()); -} diff --git a/shared/test/unit_test/os_interface/windows/wddm_address_space_windows_tests.cpp b/shared/test/unit_test/os_interface/windows/wddm_address_space_windows_tests.cpp new file mode 100644 index 0000000000..8d00c06134 --- /dev/null +++ b/shared/test/unit_test/os_interface/windows/wddm_address_space_windows_tests.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2022 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_stream/preemption.h" +#include "shared/source/execution_environment/root_device_environment.h" +#include "shared/test/common/mocks/mock_execution_environment.h" +#include "shared/test/common/mocks/mock_wddm.h" +#include "shared/test/common/os_interface/windows/wddm_fixture.h" +#include "shared/test/common/test_macros/hw_test.h" + +using namespace NEO; + +using WddmTests = WddmTestWithMockGdiDll; + +TEST_F(WddmTests, whenInitializingWddmThenSetMinAddressToCorrectValue) { + constexpr static uintptr_t mockedInternalGpuVaRange = 0x9876u; + auto gmmMemory = new MockGmmMemoryBase(wddm->rootDeviceEnvironment.getGmmClientContext()); + gmmMemory->overrideInternalGpuVaRangeLimit(mockedInternalGpuVaRange); + wddm->gmmMemory.reset(gmmMemory); + + ASSERT_EQ(0u, wddm->getWddmMinAddress()); + wddm->init(); + + const bool obtainFromGmm = defaultHwInfo->platform.eRenderCoreFamily == IGFX_GEN12LP_CORE; + const auto expectedMinAddress = obtainFromGmm ? mockedInternalGpuVaRange : windowsMinAddress; + ASSERT_EQ(expectedMinAddress, wddm->getWddmMinAddress()); +} diff --git a/shared/wsl_compute_helper/source/wsl_compute_helper.h b/shared/wsl_compute_helper/source/wsl_compute_helper.h index fc5d26fcc7..dd6228b756 100644 --- a/shared/wsl_compute_helper/source/wsl_compute_helper.h +++ b/shared/wsl_compute_helper/source/wsl_compute_helper.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Intel Corporation + * Copyright (C) 2021-2022 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -14,7 +14,7 @@ static const char *wslComputeHelperLibName = "wsl_compute_helper.dll"; #else #define CCONV -static const char *wslComputeHelperLibName = "libwsl_compute_helper.so"; +[[maybe_unused]] static const char *wslComputeHelperLibName = "libwsl_compute_helper.so"; #endif typedef size_t(CCONV *getSizeRequiredForStructFPT)(TOK structId);