diff --git a/opencl/test/unit_test/compiler_interface/default_cl_cache_config_tests.cpp b/opencl/test/unit_test/compiler_interface/default_cl_cache_config_tests.cpp index bf183abc6a..7d6e94a5f6 100644 --- a/opencl/test/unit_test/compiler_interface/default_cl_cache_config_tests.cpp +++ b/opencl/test/unit_test/compiler_interface/default_cl_cache_config_tests.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2020 Intel Corporation + * Copyright (C) 2019-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -14,3 +14,19 @@ TEST(CompilerCache, GivenDefaultClCacheConfigThenValuesAreProperlyPopulated) { EXPECT_STREQ(".cl_cache", cacheConfig.cacheFileExtension.c_str()); EXPECT_TRUE(cacheConfig.enabled); } + +TEST(CompilerCacheTests, GivenExistingConfigWhenLoadingFromCacheThenBinaryIsLoaded) { + NEO::CompilerCache cache(NEO::getDefaultClCompilerCacheConfig()); + static const char *hash = "SOME_HASH"; + std::unique_ptr data(new char[32]); + for (size_t i = 0; i < 32; i++) + data.get()[i] = static_cast(i); + + bool ret = cache.cacheBinary(hash, static_cast(data.get()), 32); + EXPECT_TRUE(ret); + + size_t size; + auto loadedBin = cache.loadCachedBinary(hash, size); + EXPECT_NE(nullptr, loadedBin); + EXPECT_NE(0U, size); +} \ No newline at end of file diff --git a/shared/test/unit_test/CMakeLists.txt b/shared/test/unit_test/CMakeLists.txt index 94675a6204..cdb1ef1a4f 100644 --- a/shared/test/unit_test/CMakeLists.txt +++ b/shared/test/unit_test/CMakeLists.txt @@ -27,6 +27,7 @@ if(NOT SKIP_UNIT_TESTS) ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test_mode.h ${CMAKE_CURRENT_SOURCE_DIR}/tests_configuration.h + ${CMAKE_CURRENT_SOURCE_DIR}/ult_specific_config.cpp ${NEO_SOURCE_DIR}/opencl/source/compiler_interface/default_cache_config.cpp ${NEO_SHARED_DIRECTORY}/helpers/allow_deferred_deleter.cpp ${NEO_SHARED_TEST_DIRECTORY}/common/helpers/api_specific_config_shared_tests.cpp diff --git a/shared/test/unit_test/compiler_interface/compiler_cache_tests.cpp b/shared/test/unit_test/compiler_interface/compiler_cache_tests.cpp index e6bf6f615b..dc1ecf2f8b 100644 --- a/shared/test/unit_test/compiler_interface/compiler_cache_tests.cpp +++ b/shared/test/unit_test/compiler_interface/compiler_cache_tests.cpp @@ -11,12 +11,10 @@ #include "shared/source/helpers/hash.h" #include "shared/source/helpers/hw_info.h" #include "shared/source/helpers/string.h" +#include "shared/test/common/helpers/default_hw_info.h" #include "shared/test/common/libult/global_environment.h" +#include "shared/test/common/mocks/mock_device.h" -#include "opencl/source/compiler_interface/default_cl_cache_config.h" -#include "opencl/test/unit_test/mocks/mock_cl_device.h" -#include "opencl/test/unit_test/mocks/mock_context.h" -#include "opencl/test/unit_test/mocks/mock_program.h" #include "test.h" #include @@ -237,22 +235,6 @@ TEST(CompilerCacheTests, GivenNonExistantConfigWhenLoadingFromCacheThenNullIsRet EXPECT_EQ(0U, size); } -TEST(CompilerCacheTests, GivenExistingConfigWhenLoadingFromCacheThenBinaryIsLoaded) { - CompilerCache cache(getDefaultClCompilerCacheConfig()); - static const char *hash = "SOME_HASH"; - std::unique_ptr data(new char[32]); - for (size_t i = 0; i < 32; i++) - data.get()[i] = static_cast(i); - - bool ret = cache.cacheBinary(hash, static_cast(data.get()), 32); - EXPECT_TRUE(ret); - - size_t size; - auto loadedBin = cache.loadCachedBinary(hash, size); - EXPECT_NE(nullptr, loadedBin); - EXPECT_NE(0U, size); -} - TEST(CompilerInterfaceCachedTests, GivenNoCachedBinaryWhenBuildingThenErrorIsReturned) { TranslationInput inputArgs{IGC::CodeType::oclC, IGC::CodeType::oclGenBin}; @@ -312,8 +294,7 @@ TEST(CompilerInterfaceCachedTests, GivenCachedBinaryWhenBuildingThenSuccessIsRet } TEST(CompilerInterfaceCachedTests, givenKernelWithoutIncludesAndBinaryInCacheWhenCompilationRequestedThenFCLIsNotCalled) { - MockClDevice device{new MockDevice}; - MockContext context(&device, true); + MockDevice device{}; TranslationInput inputArgs{IGC::CodeType::oclC, IGC::CodeType::oclGenBin}; auto src = "__kernel k() {}"; @@ -336,7 +317,7 @@ TEST(CompilerInterfaceCachedTests, givenKernelWithoutIncludesAndBinaryInCacheWhe auto compilerInterface = std::unique_ptr(CompilerInterface::createInstance(std::move(cache), true)); TranslationOutput translationOutput; inputArgs.allowCaching = true; - auto retVal = compilerInterface->build(device.getDevice(), inputArgs, translationOutput); + auto retVal = compilerInterface->build(device, inputArgs, translationOutput); EXPECT_EQ(TranslationOutput::ErrorCode::Success, retVal); gEnvironment->fclPopDebugVars(); @@ -344,8 +325,7 @@ TEST(CompilerInterfaceCachedTests, givenKernelWithoutIncludesAndBinaryInCacheWhe } TEST(CompilerInterfaceCachedTests, givenKernelWithIncludesAndBinaryInCacheWhenCompilationRequestedThenFCLIsCalled) { - MockClDevice device{new MockDevice}; - MockContext context(&device, true); + MockDevice device{}; TranslationInput inputArgs{IGC::CodeType::oclC, IGC::CodeType::oclGenBin}; auto src = "#include \"file.h\"\n__kernel k() {}"; @@ -361,7 +341,7 @@ TEST(CompilerInterfaceCachedTests, givenKernelWithIncludesAndBinaryInCacheWhenCo auto compilerInterface = std::unique_ptr(CompilerInterface::createInstance(std::move(cache), true)); TranslationOutput translationOutput; inputArgs.allowCaching = true; - auto retVal = compilerInterface->build(device.getDevice(), inputArgs, translationOutput); + auto retVal = compilerInterface->build(device, inputArgs, translationOutput); EXPECT_EQ(TranslationOutput::ErrorCode::BuildFailure, retVal); gEnvironment->fclPopDebugVars(); diff --git a/shared/test/unit_test/encoders/test_encode_dispatch_kernel_xehp_and_later.cpp b/shared/test/unit_test/encoders/test_encode_dispatch_kernel_xehp_and_later.cpp index 53fd118f0f..715756e002 100644 --- a/shared/test/unit_test/encoders/test_encode_dispatch_kernel_xehp_and_later.cpp +++ b/shared/test/unit_test/encoders/test_encode_dispatch_kernel_xehp_and_later.cpp @@ -916,6 +916,8 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesDynamicImplicitScaling, givenImp using WALKER_TYPE = typename FamilyType::WALKER_TYPE; using BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START; + VariableBackup backup(&ImplicitScaling::apiSupport, true); + uint32_t dims[] = {16, 1, 1}; std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); @@ -979,6 +981,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesDynamicImplicitScaling, givenImp using WALKER_TYPE = typename FamilyType::WALKER_TYPE; using BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START; using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM; + VariableBackup backup(&ImplicitScaling::apiSupport, true); uint32_t dims[] = {16, 1, 1}; std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); @@ -1070,6 +1073,7 @@ HWCMDTEST_F(IGFX_XE_HP_CORE, CommandEncodeStatesDynamicImplicitScaling, givenImp using WALKER_TYPE = typename FamilyType::WALKER_TYPE; using BATCH_BUFFER_START = typename FamilyType::MI_BATCH_BUFFER_START; using MI_STORE_DATA_IMM = typename FamilyType::MI_STORE_DATA_IMM; + VariableBackup backup(&ImplicitScaling::apiSupport, true); uint32_t dims[] = {16, 1, 1}; std::unique_ptr dispatchInterface(new MockDispatchKernelEncoder()); diff --git a/shared/test/unit_test/encoders/test_implicit_scaling.cpp b/shared/test/unit_test/encoders/test_implicit_scaling.cpp index 111d4ae7e7..6124b70ff5 100644 --- a/shared/test/unit_test/encoders/test_implicit_scaling.cpp +++ b/shared/test/unit_test/encoders/test_implicit_scaling.cpp @@ -120,8 +120,8 @@ TEST_F(ImplicitScalingTests, givenForceSemaphoreUseWhenCheckingSemaphoreUseThenE EXPECT_TRUE(ImplicitScalingHelper::isSemaphoreProgrammingRequired()); } -TEST_F(ImplicitScalingTests, givenDefaultSettingsWhenCheckingCrossTileAtomicSyncThenExpectTrue) { - EXPECT_TRUE(ImplicitScalingHelper::isCrossTileAtomicRequired()); +TEST_F(ImplicitScalingTests, givenDefaultSettingsWhenCheckingCrossTileAtomicSyncThenExpectDefaultDefined) { + EXPECT_EQ(ImplicitScaling::crossTileAtomicSynchronization, ImplicitScalingHelper::isCrossTileAtomicRequired()); } TEST_F(ImplicitScalingTests, givenForceDisableWhenCheckingCrossTileAtomicSyncThenExpectFalse) { diff --git a/shared/test/unit_test/ult_specific_config.cpp b/shared/test/unit_test/ult_specific_config.cpp new file mode 100644 index 0000000000..e3a74554b5 --- /dev/null +++ b/shared/test/unit_test/ult_specific_config.cpp @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2021 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/command_container/implicit_scaling.h" +#include "shared/source/memory_manager/compression_selector.h" +#include "shared/source/page_fault_manager/cpu_page_fault_manager.h" + +namespace NEO { +namespace ImplicitScaling { +bool apiSupport = false; +bool semaphoreProgrammingRequired = false; +bool crossTileAtomicSynchronization = false; +} // namespace ImplicitScaling +bool CompressionSelector::preferRenderCompressedBuffer(const AllocationProperties &properties, const HardwareInfo &hwInfo) { + return false; +} +void PageFaultManager::transferToCpu(void *ptr, size_t size, void *cmdQ) { +} +void PageFaultManager::transferToGpu(void *ptr, void *cmdQ) { +} +} // namespace NEO