From 38f53cab8a085cc82f105e1ee940decae0a60a74 Mon Sep 17 00:00:00 2001 From: Lukasz Jobczyk Date: Fri, 20 Mar 2020 12:04:47 +0100 Subject: [PATCH] Add type alias for spec const values map Change-Id: I77c006f3b3953b108091914fec1f7ba040c7590b Signed-off-by: Lukasz Jobczyk --- opencl/source/program/build.cpp | 2 +- opencl/source/program/program.h | 3 +-- .../unit_test/program/program_spec_constants_tests.cpp | 2 +- shared/source/compiler_interface/compiler_interface.cpp | 2 +- shared/source/compiler_interface/compiler_interface.h | 7 ++++--- .../compiler_interface/compiler_interface_tests.cpp | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/opencl/source/program/build.cpp b/opencl/source/program/build.cpp index b7186a8849..a0df085837 100644 --- a/opencl/source/program/build.cpp +++ b/opencl/source/program/build.cpp @@ -109,7 +109,7 @@ cl_int Program::build( inputArgs.apiOptions = ArrayRef(options.c_str(), options.length()); inputArgs.internalOptions = ArrayRef(internalOptions.c_str(), internalOptions.length()); inputArgs.GTPinInput = gtpinGetIgcInit(); - inputArgs.specConstants.specializedValues = this->specConstantsValues; + inputArgs.specializedValues = this->specConstantsValues; DBG_LOG(LogApiCalls, "Build Options", inputArgs.apiOptions.begin(), "\nBuild Internal Options", inputArgs.internalOptions.begin()); diff --git a/opencl/source/program/program.h b/opencl/source/program/program.h index f92cd619f2..1fed0646f1 100644 --- a/opencl/source/program/program.h +++ b/opencl/source/program/program.h @@ -18,7 +18,6 @@ #include "cif/builtins/memory/buffer/buffer.h" #include "patch_list.h" -#include #include #include @@ -330,7 +329,7 @@ class Program : public BaseObject<_cl_program> { bool areSpecializationConstantsInitialized = false; CIF::RAII::UPtr_t specConstantsIds; CIF::RAII::UPtr_t specConstantsSizes; - std::map specConstantsValues; + specConstValuesMap specConstantsValues; BlockKernelManager *blockKernelManager = nullptr; ExecutionEnvironment &executionEnvironment; diff --git a/opencl/test/unit_test/program/program_spec_constants_tests.cpp b/opencl/test/unit_test/program/program_spec_constants_tests.cpp index 03d556c003..f562e39313 100644 --- a/opencl/test/unit_test/program/program_spec_constants_tests.cpp +++ b/opencl/test/unit_test/program/program_spec_constants_tests.cpp @@ -59,7 +59,7 @@ struct UpdateSpecConstantsTest : public ::testing::Test { char val1 = 5; uint16_t val2 = 50; int val3 = 500; - std::map *values; + specConstValuesMap *values; }; TEST_F(UpdateSpecConstantsTest, givenNewSpecConstValueWhenUpdateSpecializationConstantThenProperValueIsCopiedAndUpdated) { diff --git a/shared/source/compiler_interface/compiler_interface.cpp b/shared/source/compiler_interface/compiler_interface.cpp index a5483d5878..5d034f9847 100644 --- a/shared/source/compiler_interface/compiler_interface.cpp +++ b/shared/source/compiler_interface/compiler_interface.cpp @@ -82,7 +82,7 @@ TranslationOutput::ErrorCode CompilerInterface::build( auto idsBuffer = CIF::Builtins::CreateConstBuffer(igcMain.get(), nullptr, 0); auto valuesBuffer = CIF::Builtins::CreateConstBuffer(igcMain.get(), nullptr, 0); - for (const auto &specConst : input.specConstants.specializedValues) { + for (const auto &specConst : input.specializedValues) { idsBuffer->PushBackRawCopy(specConst.first); valuesBuffer->PushBackRawCopy(specConst.second); } diff --git a/shared/source/compiler_interface/compiler_interface.h b/shared/source/compiler_interface/compiler_interface.h index a6983dcf2e..0aed26b573 100644 --- a/shared/source/compiler_interface/compiler_interface.h +++ b/shared/source/compiler_interface/compiler_interface.h @@ -19,10 +19,13 @@ #include "ocl_igc_interface/igc_ocl_device_ctx.h" #include +#include namespace NEO { class Device; +using specConstValuesMap = std::unordered_map; + struct TranslationInput { TranslationInput(IGC::CodeType::CodeType_t srcType, IGC::CodeType::CodeType_t outType, IGC::CodeType::CodeType_t preferredIntermediateType = IGC::CodeType::undefined) : srcType(srcType), preferredIntermediateType(preferredIntermediateType), outType(outType) { @@ -40,9 +43,7 @@ struct TranslationInput { IGC::CodeType::CodeType_t outType = IGC::CodeType::invalid; void *GTPinInput = nullptr; - struct SpecConstants { - std::map specializedValues; - } specConstants; + specConstValuesMap specializedValues; }; struct TranslationOutput { diff --git a/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp b/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp index 259278c770..2c35caf177 100644 --- a/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp +++ b/shared/test/unit_test/compiler_interface/compiler_interface_tests.cpp @@ -746,8 +746,8 @@ TEST_F(CompilerInterfaceTest, givenUpdatedSpecConstValuesWhenBuildProgramThenPro auto specConstCtx = CIF::RAII::UPtr(new MockCompilerDeviceCtx()); pCompilerInterface->setDeviceCtx(*pDevice, specConstCtx.get()); - std::map specConst{{10, 100}}; - inputArgs.specConstants.specializedValues = specConst; + specConstValuesMap specConst{{10, 100}}; + inputArgs.specializedValues = specConst; TranslationOutput translationOutput; auto err = pCompilerInterface->build(*pDevice, inputArgs, translationOutput);