Move kernel binary helpers to shared

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2021-10-06 11:43:42 +00:00
committed by Compute-Runtime-Automation
parent 6ea9845016
commit 7187769744
35 changed files with 37 additions and 44 deletions

View File

@@ -20,6 +20,9 @@ set(NEO_CORE_HELPERS_TESTS
${CMAKE_CURRENT_SOURCE_DIR}/file_io_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}hw_helper_extended_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hash_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kernel_binary_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/kernel_filename_helper.h
${CMAKE_CURRENT_SOURCE_DIR}/kernel_helpers_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kernel_helpers_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/memory_leak_listener.h
${CMAKE_CURRENT_SOURCE_DIR}/memory_management.h

View File

@@ -0,0 +1,35 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/helpers/kernel_binary_helper.h"
#include "shared/test/common/helpers/test_files.h"
#include "shared/test/common/libult/global_environment.h"
#include <string>
extern PRODUCT_FAMILY productFamily;
KernelBinaryHelper::KernelBinaryHelper(const std::string &name, bool appendOptionsToFileName) {
// set mock compiler to return expected kernel
MockCompilerDebugVars fclDebugVars;
MockCompilerDebugVars igcDebugVars;
retrieveBinaryKernelFilename(fclDebugVars.fileName, name + "_", ".bc");
retrieveBinaryKernelFilename(igcDebugVars.fileName, name + "_", ".gen");
fclDebugVars.appendOptionsToFileName = appendOptionsToFileName;
igcDebugVars.appendOptionsToFileName = appendOptionsToFileName;
gEnvironment->fclPushDebugVars(fclDebugVars);
gEnvironment->igcPushDebugVars(igcDebugVars);
}
KernelBinaryHelper::~KernelBinaryHelper() {
gEnvironment->igcPopDebugVars();
gEnvironment->fclPopDebugVars();
}

View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <string>
class KernelBinaryHelper {
public:
KernelBinaryHelper(const std::string &name = "copybuffer", bool appendOptionsToFileName = true);
~KernelBinaryHelper();
static const std::string BUILT_INS;
static const std::string BUILT_INS_WITH_IMAGES;
};

View File

@@ -0,0 +1,11 @@
/*
* Copyright (C) 2020-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/test/common/helpers/kernel_binary_helper.h"
const std::string KernelBinaryHelper::BUILT_INS("7836643072362489210");
const std::string KernelBinaryHelper::BUILT_INS_WITH_IMAGES("10613492505254921609_images");

View File

@@ -0,0 +1,21 @@
/*
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <algorithm>
#include <string>
class KernelFilenameHelper {
public:
static void getKernelFilenameFromInternalOption(std::string &option, std::string &filename) {
// remove leading spaces
size_t position = option.find_first_not_of(" ");
filename = option.substr(position);
// replace space with underscore
std::replace(filename.begin(), filename.end(), ' ', '_');
}
};

View File

@@ -55,6 +55,10 @@ set(igdrcl_libult_common_SRCS_LIB_ULT
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/device_fixture.h
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/mock_execution_environment_gmm_fixture.cpp
${NEO_SHARED_TEST_DIRECTORY}/common/fixtures/mock_execution_environment_gmm_fixture.h
${NEO_SHARED_TEST_DIRECTORY}/common/helpers${BRANCH_DIR_SUFFIX}kernel_binary_helper_hash_value.cpp
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/kernel_binary_helper.cpp
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/kernel_binary_helper.h
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/kernel_filename_helper.h
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/memory_leak_listener.cpp
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/memory_leak_listener.h
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/memory_management.cpp

View File

@@ -10,6 +10,7 @@
#include "shared/source/helpers/hw_info.h"
#include "shared/source/os_interface/os_inc_base.h"
TestEnvironment *gEnvironment;
TestEnvironment::TestEnvironment() {
igcDebugVarStack.reserve(3);
fclDebugVarStack.reserve(3);

View File

@@ -8,11 +8,10 @@
#include "shared/test/common/mocks/mock_compiler_interface_spirv.h"
#include "shared/source/helpers/file_io.h"
#include "shared/test/common/helpers/kernel_binary_helper.h"
#include "shared/test/common/helpers/test_files.h"
#include "shared/test/common/libult/global_environment.h"
#include "opencl/test/unit_test/helpers/kernel_binary_helper.h"
namespace NEO {
TranslationOutput::ErrorCode MockCompilerInterfaceSpirv::compile(const NEO::Device &device, const TranslationInput &input, TranslationOutput &output) {
std::string kernelName;

View File

@@ -28,9 +28,7 @@ if(NOT SKIP_UNIT_TESTS)
${CMAKE_CURRENT_SOURCE_DIR}/test_mode.h
${CMAKE_CURRENT_SOURCE_DIR}/tests_configuration.h
${NEO_SOURCE_DIR}/opencl/source/compiler_interface/default_cache_config.cpp
${NEO_SOURCE_DIR}/opencl/test/unit_test/helpers/kernel_binary_helper_hash_value.cpp
${NEO_SOURCE_DIR}/opencl/test/unit_test/libult/io_functions.cpp
${NEO_SOURCE_DIR}/opencl/test/unit_test/test_macros/test_checks_ocl.cpp
${NEO_SHARED_DIRECTORY}/helpers/allow_deferred_deleter.cpp
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/api_specific_config_shared_tests.cpp
${NEO_SHARED_TEST_DIRECTORY}/common/test_macros/test_checks_shared.cpp

View File

@@ -9,10 +9,12 @@
#include "shared/source/gmm_helper/gmm_helper.h"
#include "shared/source/gmm_helper/gmm_interface.h"
#include "shared/source/gmm_helper/resource_info.h"
#include "shared/source/helpers/api_specific_config.h"
#include "shared/source/os_interface/hw_info_config.h"
#include "shared/source/utilities/debug_settings_reader.h"
#include "shared/test/common/helpers/custom_event_listener.h"
#include "shared/test/common/helpers/default_hw_info.inl"
#include "shared/test/common/helpers/kernel_binary_helper.h"
#include "shared/test/common/helpers/memory_leak_listener.h"
#include "shared/test/common/helpers/test_files.h"
#include "shared/test/common/helpers/ult_hw_config.inl"
@@ -23,10 +25,7 @@
#include "shared/test/unit_test/base_ult_config_listener.h"
#include "shared/test/unit_test/tests_configuration.h"
#include "opencl/source/os_interface/ocl_reg_path.h"
#include "opencl/test/unit_test/helpers/kernel_binary_helper.h"
#include "opencl/test/unit_test/mocks/mock_gmm.h"
#include "opencl/test/unit_test/mocks/mock_program.h"
#include "gmock/gmock.h"
@@ -66,7 +65,6 @@ bool disabled = false;
} // namespace NEO
using namespace NEO;
TestEnvironment *gEnvironment;
PRODUCT_FAMILY productFamily = DEFAULT_TEST_PLATFORM::hwInfo.platform.eProductFamily;
GFXCORE_FAMILY renderCoreFamily = DEFAULT_TEST_PLATFORM::hwInfo.platform.eRenderCoreFamily;
@@ -288,7 +286,7 @@ int main(int argc, char **argv) {
generateRandomInput = true;
} else if (!strcmp("--read-config", argv[i]) && (testMode == TestMode::AubTests || testMode == TestMode::AubTestsWithTbx)) {
if (DebugManager.registryReadAvailable()) {
DebugManager.setReaderImpl(SettingsReader::create(oclRegPath));
DebugManager.setReaderImpl(SettingsReader::create(ApiSpecificConfig::getRegistryPath()));
DebugManager.injectSettingsFromReader();
}
} else if (!strcmp("--dump_buffer_format", argv[i]) && testMode == TestMode::AubTests) {