Add warning when device binary had to be recompiled

Introduced a new warning, which is printed to build log, when the
binary needs to be recompiled. Added a new flag -Wno-recompiled-from-ir
to allow suppression of that message. Removed a bug related to memcpy_s
from ModuleBuildLogImp::getString() and aligned it with specification.

Related-To: NEO-5819
Signed-off-by: Patryk Wrobel <patryk.wrobel@intel.com>
This commit is contained in:
Patryk Wrobel
2021-12-22 15:06:58 +00:00
committed by Compute-Runtime-Automation
parent 35f6cd00ee
commit 3599e7aeda
14 changed files with 277 additions and 17 deletions

View File

@@ -20,6 +20,7 @@ set(NEO_CORE_COMPILER_INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/compiler_options/compiler_options_base.h
${CMAKE_CURRENT_SOURCE_DIR}/compiler_options/compiler_options_base.cpp
${CMAKE_CURRENT_SOURCE_DIR}/compiler_options${BRANCH_DIR_SUFFIX}compiler_options.h
${CMAKE_CURRENT_SOURCE_DIR}/compiler_warnings/compiler_warnings.h
)
set_property(GLOBAL PROPERTY NEO_CORE_COMPILER_INTERFACE ${NEO_CORE_COMPILER_INTERFACE})

View File

@@ -10,6 +10,9 @@
#include "shared/source/utilities/const_stringref.h"
#include "shared/source/utilities/stackvec.h"
#include <algorithm>
#include <functional>
namespace NEO {
namespace CompilerOptions {
static constexpr ConstStringRef greaterThan4gbBuffersRequired = "-cl-intel-greater-than-4GB-buffer-required";
@@ -34,6 +37,7 @@ static constexpr ConstStringRef allowZebin = "-allow-zebin";
static constexpr ConstStringRef enableImageSupport = "-D__IMAGE_SUPPORT__=1";
static constexpr ConstStringRef optLevel = "-ze-opt-level=O";
static constexpr ConstStringRef excludeIrFromZebin = "-exclude-ir-from-zebin";
static constexpr ConstStringRef noRecompiledFromIr = "-Wno-recompiled-from-ir";
constexpr size_t nullterminateSize = 1U;
constexpr size_t spaceSeparatorSize = 1U;
@@ -108,6 +112,21 @@ constexpr size_t concatenationLength(const ConstStringRef (&options)[NumOptions]
return (ret != 0U) ? ret - nullterminateSize : 0U;
}
template <typename ContainerT>
inline bool extract(const ConstStringRef &toBeExtracted, ContainerT &options) {
const auto first{std::search(options.begin(), options.end(),
std::default_searcher{toBeExtracted.begin(), toBeExtracted.end()})};
if (first == options.end()) {
return false;
}
const auto last{std::next(first, toBeExtracted.length())};
options.erase(first, last);
return true;
}
template <size_t MaxLength = 256>
class ConstConcatenation {
public:

View File

@@ -0,0 +1,18 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/source/utilities/const_stringref.h"
namespace NEO {
namespace CompilerWarnings {
static constexpr ConstStringRef recompiledFromIr = "warning: module got recompiled from IR because provided native binary is incompatible with underlying device and/or driver [-Wrecompiled-from-ir]";
} // namespace CompilerWarnings
} // namespace NEO

View File

@@ -45,6 +45,28 @@ TEST(CompilerOptions, WhenConcatenateAppendIsCalledThenAddsSpaceAsSeparatorOnlyI
EXPECT_STREQ(expected.c_str(), concatenated.c_str());
}
TEST(CompilerOptions, WhenTryingToExtractNonexistentOptionThenFalseIsReturnedAndStringIsNotModified) {
const std::string optionsInput{"-ze-allow-zebin -cl-intel-has-buffer-offset-arg"};
std::string options{optionsInput};
const bool wasExtracted{NEO::CompilerOptions::extract(NEO::CompilerOptions::noRecompiledFromIr, options)};
EXPECT_FALSE(wasExtracted);
EXPECT_EQ(optionsInput, options);
}
TEST(CompilerOptions, WhenTryingToExtractOptionThatExistsThenTrueIsReturnedAndStringIsModified) {
const std::string optionsInput{"-ze-allow-zebin -Wno-recompiled-from-ir -cl-intel-has-buffer-offset-arg"};
std::string options{optionsInput};
const bool wasExtracted{NEO::CompilerOptions::extract(NEO::CompilerOptions::noRecompiledFromIr, options)};
EXPECT_TRUE(wasExtracted);
const std::string expectedOptions{"-ze-allow-zebin -cl-intel-has-buffer-offset-arg"};
EXPECT_EQ(expectedOptions, options);
}
TEST(CompilerOptions, WhenCheckingForPresenceOfOptionThenRejectsSubstrings) {
EXPECT_FALSE(NEO::CompilerOptions::contains("aaa", "a"));
EXPECT_FALSE(NEO::CompilerOptions::contains("aaa", "aa"));