mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 00:24:58 +08:00
Ocloc: allow enforcing binary format specified by user
This commit adds ocloc option for specifying binary format. When a --format flag is passed, the internal options will be changed accordingly to the format specified (zebin/patchtokens) or a warning will be printed if an unknown format will be passed. Signed-off-by: Kacper Nowak <kacper.nowak@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
bd6c9a222b
commit
dd393d11a2
@@ -2777,6 +2777,57 @@ TEST(OclocCompile, givenSpirvInputThenDontGenerateSpirvFile) {
|
||||
EXPECT_FALSE(compilerOutputExists("offline_compiler_test/binary_with_zeroes", "spv"));
|
||||
}
|
||||
|
||||
TEST(OclocCompile, givenFormatFlagWithKnownFormatPassedThenEnforceSpecifiedFormatAccordingly) {
|
||||
MockOfflineCompiler ocloc;
|
||||
|
||||
std::vector<std::string> argvEnforcedFormatPatchtokens = {
|
||||
"ocloc",
|
||||
"-q",
|
||||
"-file",
|
||||
"test_files/copybuffer.cl",
|
||||
"-spv_only",
|
||||
"--format",
|
||||
"patchtokens"};
|
||||
|
||||
std::vector<std::string> argvEnforcedFormatZebin = {
|
||||
"ocloc",
|
||||
"-q",
|
||||
"-file",
|
||||
"test_files/copybuffer.cl",
|
||||
"-spv_only",
|
||||
"--format",
|
||||
"zebin"};
|
||||
|
||||
int retVal = ocloc.initialize(argvEnforcedFormatZebin.size(), argvEnforcedFormatZebin);
|
||||
ASSERT_EQ(0, retVal);
|
||||
EXPECT_TRUE(hasSubstr(ocloc.internalOptions, std::string{CompilerOptions::allowZebin}));
|
||||
|
||||
ocloc.internalOptions.clear();
|
||||
retVal = ocloc.initialize(argvEnforcedFormatPatchtokens.size(), argvEnforcedFormatPatchtokens);
|
||||
ASSERT_EQ(0, retVal);
|
||||
EXPECT_FALSE(hasSubstr(ocloc.internalOptions, std::string{CompilerOptions::allowZebin}));
|
||||
}
|
||||
|
||||
TEST(OclocCompile, givenFormatFlagWithUnknownFormatPassedThenPrintWarning) {
|
||||
MockOfflineCompiler ocloc;
|
||||
|
||||
std::vector<std::string> argvUnknownFormatEnforced = {
|
||||
"ocloc",
|
||||
"-file",
|
||||
"test_files/copybuffer.cl",
|
||||
"-spv_only",
|
||||
"--format",
|
||||
"banana"};
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
int retVal = ocloc.initialize(argvUnknownFormatEnforced.size(), argvUnknownFormatEnforced);
|
||||
const auto output = testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(0, retVal);
|
||||
|
||||
const auto expectedOutput{"Invalid format passed: banana. Ignoring.\n"};
|
||||
EXPECT_EQ(expectedOutput, output);
|
||||
}
|
||||
|
||||
TEST(OfflineCompilerTest, GivenDebugFlagWhenSetStatelessToStatefullBufferOffsetFlagThenStatelessToStatefullOptimizationIsSetCorrectly) {
|
||||
DebugManagerStateRestore stateRestore;
|
||||
MockOfflineCompiler mockOfflineCompiler;
|
||||
|
||||
Reference in New Issue
Block a user