mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Store single generic IR in fatbinary when built from SPIR-V input
This change prevents embedding identical SPIR-V section for each target requested in fatbinary build. Instead of duplicating SPIR-V, a new file called 'generic_ir' is added to AR archive. It contains SPIR-V, which was used to build fatbinary. Build fallback in runtime has been also adjusted - if 'generic_ir' file is defined in fatbinary and there is no matching binary, then this generic SPIR-V is used to rebuild for the requested target. Additionally, MockOclocArgumentHelper::loadDataFromFile() was adjusted to ensure null-termination of returned strings. This change also removes possible undefined behavior, which was related to reading names of files from AR archive. Previously, if filename was shorter than requested target name, we tried to read more memory than allowed. Related-To: NEO-6490 Signed-off-by: Patryk Wrobel <patryk.wrobel@intel.com>
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
2eb7ae7a8d
commit
6ac6db7b04
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2021 Intel Corporation
|
||||
* Copyright (C) 2020-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@ -11,10 +11,12 @@
|
||||
#include "shared/offline_compiler/source/ocloc_fatbinary.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "mock/mock_argument_helper.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace NEO {
|
||||
|
||||
class OclocFatBinaryGetTargetConfigsForFatbinary : public ::testing::Test {
|
||||
public:
|
||||
OclocFatBinaryGetTargetConfigsForFatbinary() {
|
||||
@ -23,4 +25,23 @@ class OclocFatBinaryGetTargetConfigsForFatbinary : public ::testing::Test {
|
||||
}
|
||||
std::unique_ptr<OclocArgHelper> oclocArgHelperWithoutInput;
|
||||
};
|
||||
|
||||
class OclocFatBinaryTest : public ::testing::Test {
|
||||
public:
|
||||
OclocFatBinaryTest() {
|
||||
mockArgHelperFilesMap[spirvFilename] = spirvFileContent;
|
||||
mockArgHelper.interceptOutput = true;
|
||||
}
|
||||
|
||||
protected:
|
||||
constexpr static ConstStringRef archiveGenericIrName{"generic_ir"};
|
||||
|
||||
MockOclocArgHelper::FilesMap mockArgHelperFilesMap{};
|
||||
MockOclocArgHelper mockArgHelper{mockArgHelperFilesMap};
|
||||
|
||||
std::string outputArchiveName{"output_archive"};
|
||||
std::string spirvFilename{"input_file.spv"};
|
||||
std::string spirvFileContent{"\x07\x23\x02\x03"};
|
||||
};
|
||||
|
||||
} // namespace NEO
|
||||
|
Reference in New Issue
Block a user