mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-10 12:53:42 +08:00
[N/N] compiler interface refactor - move to core
Change-Id: I029e3cd7a6adde9df97a0a7760ecbf5d25d8f501
This commit is contained in:
@ -8,6 +8,10 @@ set(NEO_COMPILER_INTERFACE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_cache.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_cache.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_interface.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_interface.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/create_main.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linker.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linker.cpp
|
||||
)
|
||||
|
@ -5,10 +5,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
|
||||
#include "core/compiler_interface/compiler_cache.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.inl"
|
||||
#include "core/compiler_interface/compiler_interface.inl"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "runtime/os_interface/debug_settings_manager.h"
|
@ -7,6 +7,7 @@
|
||||
set(NEO_CORE_COMPILER_INTERFACE_TESTS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_cache_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_interface_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linker_mock.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/linker_tests.cpp
|
||||
)
|
||||
|
@ -6,10 +6,10 @@
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_cache.h"
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/helpers/aligned_memory.h"
|
||||
#include "core/helpers/hash.h"
|
||||
#include "core/helpers/string.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/compiler_interface/default_cl_cache_config.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "test.h"
|
||||
|
@ -5,22 +5,16 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/compiler_interface/compiler_interface.inl"
|
||||
#include "core/helpers/file_io.h"
|
||||
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.inl"
|
||||
#include "runtime/context/context.h"
|
||||
#include "runtime/gen_common/hw_cmds.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "runtime/os_interface/debug_settings_manager.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/global_environment.h"
|
||||
#include "unit_tests/helpers/test_files.h"
|
||||
#include "unit_tests/mocks/mock_cif.h"
|
||||
#include "unit_tests/mocks/mock_compilers.h"
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
@ -1059,74 +1053,6 @@ TEST_F(CompilerInterfaceTest, givenCompilerInterfaceWhenGetSpecializationConstan
|
||||
EXPECT_EQ(TranslationOutput::ErrorCode::Success, err);
|
||||
}
|
||||
|
||||
struct UpdateSpecConstantsTest : public ::testing::Test {
|
||||
void SetUp() override {
|
||||
mockProgram.reset(new MockProgram(executionEnvironment));
|
||||
|
||||
mockProgram->specConstantsIds.reset(new MockCIFBuffer());
|
||||
mockProgram->specConstantsSizes.reset(new MockCIFBuffer());
|
||||
mockProgram->specConstantsValues.reset(new MockCIFBuffer());
|
||||
|
||||
mockProgram->specConstantsIds->PushBackRawCopy(1);
|
||||
mockProgram->specConstantsIds->PushBackRawCopy(2);
|
||||
mockProgram->specConstantsIds->PushBackRawCopy(3);
|
||||
|
||||
mockProgram->specConstantsSizes->PushBackRawCopy(sizeof(char));
|
||||
mockProgram->specConstantsSizes->PushBackRawCopy(sizeof(uint16_t));
|
||||
mockProgram->specConstantsSizes->PushBackRawCopy(sizeof(int));
|
||||
|
||||
mockProgram->specConstantsValues->PushBackRawCopy(&val1);
|
||||
mockProgram->specConstantsValues->PushBackRawCopy(&val2);
|
||||
mockProgram->specConstantsValues->PushBackRawCopy(&val3);
|
||||
|
||||
values = mockProgram->specConstantsValues->GetMemory<const void *>();
|
||||
|
||||
EXPECT_EQ(val1, *reinterpret_cast<const char *>(values[0]));
|
||||
EXPECT_EQ(val2, *reinterpret_cast<const uint16_t *>(values[1]));
|
||||
EXPECT_EQ(val3, *reinterpret_cast<const int *>(values[2]));
|
||||
}
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
std::unique_ptr<MockProgram> mockProgram;
|
||||
|
||||
char val1 = 5;
|
||||
uint16_t val2 = 50;
|
||||
int val3 = 500;
|
||||
const void *const *values;
|
||||
};
|
||||
|
||||
TEST_F(UpdateSpecConstantsTest, givenNewSpecConstValueWhenUpdateSpecializationConstantThenProperValueIsUpdated) {
|
||||
int newSpecConstVal3 = 5000;
|
||||
|
||||
auto ret = mockProgram->updateSpecializationConstant(3, sizeof(int), &newSpecConstVal3);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, ret);
|
||||
EXPECT_EQ(val1, *reinterpret_cast<const char *>(values[0]));
|
||||
EXPECT_EQ(val2, *reinterpret_cast<const uint16_t *>(values[1]));
|
||||
EXPECT_EQ(newSpecConstVal3, *reinterpret_cast<const int *>(values[2]));
|
||||
}
|
||||
|
||||
TEST_F(UpdateSpecConstantsTest, givenNewSpecConstValueWithUnproperSizeWhenUpdateSpecializationConstantThenErrorIsReturned) {
|
||||
int newSpecConstVal3 = 5000;
|
||||
|
||||
auto ret = mockProgram->updateSpecializationConstant(3, 10 * sizeof(int), &newSpecConstVal3);
|
||||
|
||||
EXPECT_EQ(CL_INVALID_VALUE, ret);
|
||||
EXPECT_EQ(val1, *reinterpret_cast<const char *>(values[0]));
|
||||
EXPECT_EQ(val2, *reinterpret_cast<const uint16_t *>(values[1]));
|
||||
EXPECT_EQ(val3, *reinterpret_cast<const int *>(values[2]));
|
||||
}
|
||||
|
||||
TEST_F(UpdateSpecConstantsTest, givenNewSpecConstValueWithUnproperIdAndSizeWhenUpdateSpecializationConstantThenErrorIsReturned) {
|
||||
int newSpecConstVal3 = 5000;
|
||||
|
||||
auto ret = mockProgram->updateSpecializationConstant(4, sizeof(int), &newSpecConstVal3);
|
||||
|
||||
EXPECT_EQ(CL_INVALID_SPEC_ID, ret);
|
||||
EXPECT_EQ(val1, *reinterpret_cast<const char *>(values[0]));
|
||||
EXPECT_EQ(val2, *reinterpret_cast<const uint16_t *>(values[1]));
|
||||
EXPECT_EQ(val3, *reinterpret_cast<const int *>(values[2]));
|
||||
}
|
||||
|
||||
TEST(TranslationOutput, giveNonEmptyPointerAndSizeMakeCopyWillCloneInputData) {
|
||||
MockCIFBuffer src;
|
||||
src.data.assign({2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37});
|
@ -25,7 +25,7 @@ set(CLOC_SRCS_LIB
|
||||
${NEO_SOURCE_DIR}/offline_compiler/multi_command.h
|
||||
${NEO_SOURCE_DIR}/offline_compiler/options.cpp
|
||||
${NEO_SOURCE_DIR}/offline_compiler/${BRANCH_DIR_SUFFIX}/extra_settings.cpp
|
||||
${NEO_SOURCE_DIR}/runtime/compiler_interface/create_main.cpp
|
||||
${NEO_SOURCE_DIR}/core/compiler_interface/create_main.cpp
|
||||
${NEO_SOURCE_DIR}/runtime/helpers/hw_info.cpp
|
||||
${NEO_SOURCE_DIR}/runtime/platform/extensions.cpp
|
||||
${NEO_SOURCE_DIR}/runtime/platform/extensions.h
|
||||
|
@ -7,13 +7,13 @@
|
||||
|
||||
#include "runtime/built_ins/built_ins.h"
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/helpers/basic_math.h"
|
||||
#include "core/helpers/debug_helpers.h"
|
||||
#include "runtime/built_ins/aux_translation_builtin.h"
|
||||
#include "runtime/built_ins/built_ins.inl"
|
||||
#include "runtime/built_ins/sip.h"
|
||||
#include "runtime/built_ins/vme_dispatch_builder.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/helpers/built_ins_helper.h"
|
||||
#include "runtime/helpers/convert_color.h"
|
||||
#include "runtime/helpers/dispatch_info_builder.h"
|
||||
|
@ -6,12 +6,8 @@
|
||||
|
||||
set(RUNTIME_SRCS_COMPILER_INTERFACE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_interface.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_interface.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_options.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_options.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_interface.inl
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/create_main.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/default_cl_cache_config.cpp
|
||||
)
|
||||
|
||||
|
@ -7,13 +7,13 @@
|
||||
|
||||
#include "runtime/context/context.h"
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/helpers/ptr_math.h"
|
||||
#include "core/helpers/string.h"
|
||||
#include "core/memory_manager/unified_memory_manager.h"
|
||||
#include "runtime/built_ins/built_ins.h"
|
||||
#include "runtime/command_queue/command_queue.h"
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/device_queue/device_queue.h"
|
||||
#include "runtime/gtpin/gtpin_notify.h"
|
||||
|
@ -7,13 +7,13 @@
|
||||
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/memory_manager/memory_operations_handler.h"
|
||||
#include "runtime/aub/aub_center.h"
|
||||
#include "runtime/built_ins/built_ins.h"
|
||||
#include "runtime/built_ins/sip.h"
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/command_stream/tbx_command_stream_receiver_hw.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/compiler_interface/default_cl_cache_config.h"
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
#include "runtime/helpers/hw_helper.h"
|
||||
|
@ -7,11 +7,11 @@
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/helpers/debug_helpers.h"
|
||||
#include "core/helpers/string.h"
|
||||
#include "runtime/api/api.h"
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/device/root_device.h"
|
||||
#include "runtime/event/async_events_handler.h"
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
|
@ -5,18 +5,17 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/utilities/time_measure_wrapper.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/compiler_interface/compiler_options.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/gtpin/gtpin_notify.h"
|
||||
#include "runtime/helpers/validators.h"
|
||||
#include "runtime/os_interface/debug_settings_manager.h"
|
||||
#include "runtime/platform/platform.h"
|
||||
#include "runtime/program/program.h"
|
||||
#include "runtime/source_level_debugger/source_level_debugger.h"
|
||||
|
||||
#include "program.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
namespace NEO {
|
||||
|
@ -5,8 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/elf/writer.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/compiler_interface/compiler_options.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/helpers/validators.h"
|
||||
|
@ -5,8 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/elf/writer.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/compiler_interface/compiler_options.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/helpers/validators.h"
|
||||
|
@ -7,12 +7,12 @@
|
||||
|
||||
#include "program.h"
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/elf/writer.h"
|
||||
#include "core/helpers/debug_helpers.h"
|
||||
#include "core/helpers/string.h"
|
||||
#include "core/memory_manager/unified_memory_manager.h"
|
||||
#include "runtime/command_stream/command_stream_receiver.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/context/context.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/helpers/hw_helper.h"
|
||||
|
@ -6,12 +6,12 @@
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/compiler_interface/linker.h"
|
||||
#include "core/elf/reader.h"
|
||||
#include "core/elf/writer.h"
|
||||
#include "core/helpers/stdio.h"
|
||||
#include "runtime/api/cl_types.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/helpers/base_object.h"
|
||||
#include "runtime/helpers/string_helpers.h"
|
||||
#include "runtime/program/block_kernel_manager.h"
|
||||
|
@ -5,8 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/helpers/file_io.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/context/context.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/program/program.h"
|
||||
|
@ -5,8 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/helpers/file_io.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/context/context.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
#include "unit_tests/helpers/kernel_binary_helper.h"
|
||||
|
@ -5,8 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/built_ins/built_ins.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/context/context.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/helpers/base_object.h"
|
||||
|
@ -5,8 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/helpers/file_io.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/context/context.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
|
@ -5,8 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/helpers/file_io.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/context/context.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
|
@ -5,8 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/helpers/file_io.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
#include "unit_tests/helpers/kernel_binary_helper.h"
|
||||
|
@ -5,8 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/helpers/file_io.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/context/context.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
|
@ -5,8 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/helpers/file_io.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/context/context.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
|
@ -5,8 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/helpers/file_io.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/context/context.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
|
@ -5,8 +5,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/helpers/file_io.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/context/context.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
#include "unit_tests/helpers/test_files.h"
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
set(IGDRCL_SRCS_tests_compiler_interface
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/compiler_interface_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/default_cl_cache_config_tests.cpp
|
||||
)
|
||||
|
||||
|
@ -5,12 +5,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "core/unit_tests/utilities/destructor_counted.h"
|
||||
#include "runtime/aub/aub_center.h"
|
||||
#include "runtime/built_ins/built_ins.h"
|
||||
#include "runtime/command_stream/preemption.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "runtime/gmm_helper/gmm_helper.h"
|
||||
|
@ -5,10 +5,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/helpers/aligned_memory.h"
|
||||
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "runtime/built_ins/built_ins.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/helpers/mipmap.h"
|
||||
#include "runtime/mem_obj/image.h"
|
||||
#include "runtime/mem_obj/mem_obj_helper.h"
|
||||
|
@ -7,8 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/execution_environment/execution_environment.h"
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "unit_tests/mocks/mock_cif.h"
|
||||
|
||||
#include "ocl_igc_interface/fcl_ocl_device_ctx.h"
|
||||
|
@ -7,10 +7,10 @@
|
||||
|
||||
#include "unit_tests/mocks/mock_context.h"
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/memory_manager/unified_memory_manager.h"
|
||||
#include "runtime/built_ins/built_ins.h"
|
||||
#include "runtime/command_queue/command_queue.h"
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/memory_manager/deferred_deleter.h"
|
||||
#include "runtime/memory_manager/os_agnostic_memory_manager.h"
|
||||
#include "runtime/sharings/sharing.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2017-2018 Intel Corporation
|
||||
# Copyright (C) 2017-2019 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
@ -19,6 +19,7 @@ set(IGDRCL_SRCS_tests_program
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/program_data_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/program_from_binary.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/program_nonuniform.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/program_spec_constants_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/program_tests.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/program_tests.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/program_with_block_kernels_tests.cpp
|
||||
|
92
unit_tests/program/program_spec_constants_tests.cpp
Normal file
92
unit_tests/program/program_spec_constants_tests.cpp
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "core/compiler_interface/compiler_interface.inl"
|
||||
#include "core/helpers/file_io.h"
|
||||
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
|
||||
#include "runtime/helpers/hw_info.h"
|
||||
#include "unit_tests/fixtures/device_fixture.h"
|
||||
#include "unit_tests/global_environment.h"
|
||||
#include "unit_tests/helpers/test_files.h"
|
||||
#include "unit_tests/mocks/mock_cif.h"
|
||||
#include "unit_tests/mocks/mock_compilers.h"
|
||||
#include "unit_tests/mocks/mock_program.h"
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace NEO;
|
||||
|
||||
struct UpdateSpecConstantsTest : public ::testing::Test {
|
||||
void SetUp() override {
|
||||
mockProgram.reset(new MockProgram(executionEnvironment));
|
||||
|
||||
mockProgram->specConstantsIds.reset(new MockCIFBuffer());
|
||||
mockProgram->specConstantsSizes.reset(new MockCIFBuffer());
|
||||
mockProgram->specConstantsValues.reset(new MockCIFBuffer());
|
||||
|
||||
mockProgram->specConstantsIds->PushBackRawCopy(1);
|
||||
mockProgram->specConstantsIds->PushBackRawCopy(2);
|
||||
mockProgram->specConstantsIds->PushBackRawCopy(3);
|
||||
|
||||
mockProgram->specConstantsSizes->PushBackRawCopy(sizeof(char));
|
||||
mockProgram->specConstantsSizes->PushBackRawCopy(sizeof(uint16_t));
|
||||
mockProgram->specConstantsSizes->PushBackRawCopy(sizeof(int));
|
||||
|
||||
mockProgram->specConstantsValues->PushBackRawCopy(&val1);
|
||||
mockProgram->specConstantsValues->PushBackRawCopy(&val2);
|
||||
mockProgram->specConstantsValues->PushBackRawCopy(&val3);
|
||||
|
||||
values = mockProgram->specConstantsValues->GetMemory<const void *>();
|
||||
|
||||
EXPECT_EQ(val1, *reinterpret_cast<const char *>(values[0]));
|
||||
EXPECT_EQ(val2, *reinterpret_cast<const uint16_t *>(values[1]));
|
||||
EXPECT_EQ(val3, *reinterpret_cast<const int *>(values[2]));
|
||||
}
|
||||
ExecutionEnvironment executionEnvironment;
|
||||
std::unique_ptr<MockProgram> mockProgram;
|
||||
|
||||
char val1 = 5;
|
||||
uint16_t val2 = 50;
|
||||
int val3 = 500;
|
||||
const void *const *values;
|
||||
};
|
||||
|
||||
TEST_F(UpdateSpecConstantsTest, givenNewSpecConstValueWhenUpdateSpecializationConstantThenProperValueIsUpdated) {
|
||||
int newSpecConstVal3 = 5000;
|
||||
|
||||
auto ret = mockProgram->updateSpecializationConstant(3, sizeof(int), &newSpecConstVal3);
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, ret);
|
||||
EXPECT_EQ(val1, *reinterpret_cast<const char *>(values[0]));
|
||||
EXPECT_EQ(val2, *reinterpret_cast<const uint16_t *>(values[1]));
|
||||
EXPECT_EQ(newSpecConstVal3, *reinterpret_cast<const int *>(values[2]));
|
||||
}
|
||||
|
||||
TEST_F(UpdateSpecConstantsTest, givenNewSpecConstValueWithUnproperSizeWhenUpdateSpecializationConstantThenErrorIsReturned) {
|
||||
int newSpecConstVal3 = 5000;
|
||||
|
||||
auto ret = mockProgram->updateSpecializationConstant(3, 10 * sizeof(int), &newSpecConstVal3);
|
||||
|
||||
EXPECT_EQ(CL_INVALID_VALUE, ret);
|
||||
EXPECT_EQ(val1, *reinterpret_cast<const char *>(values[0]));
|
||||
EXPECT_EQ(val2, *reinterpret_cast<const uint16_t *>(values[1]));
|
||||
EXPECT_EQ(val3, *reinterpret_cast<const int *>(values[2]));
|
||||
}
|
||||
|
||||
TEST_F(UpdateSpecConstantsTest, givenNewSpecConstValueWithUnproperIdAndSizeWhenUpdateSpecializationConstantThenErrorIsReturned) {
|
||||
int newSpecConstVal3 = 5000;
|
||||
|
||||
auto ret = mockProgram->updateSpecializationConstant(4, sizeof(int), &newSpecConstVal3);
|
||||
|
||||
EXPECT_EQ(CL_INVALID_SPEC_ID, ret);
|
||||
EXPECT_EQ(val1, *reinterpret_cast<const char *>(values[0]));
|
||||
EXPECT_EQ(val2, *reinterpret_cast<const uint16_t *>(values[1]));
|
||||
EXPECT_EQ(val3, *reinterpret_cast<const int *>(values[2]));
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/device/device.h"
|
||||
#include "unit_tests/fixtures/context_fixture.h"
|
||||
#include "unit_tests/fixtures/platform_fixture.h"
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "runtime/compiler_interface/compiler_interface.h"
|
||||
#include "core/compiler_interface/compiler_interface.h"
|
||||
#include "runtime/helpers/options.h"
|
||||
#include "unit_tests/fixtures/context_fixture.h"
|
||||
#include "unit_tests/fixtures/memory_management_fixture.h"
|
||||
|
Reference in New Issue
Block a user