ocloc - log output

Change-Id: I2a61b392e05033f963e502a90fe608b742c179a9
This commit is contained in:
chmielew
2020-03-05 11:49:46 +01:00
committed by sys_ocldev
parent 0ae7ab8a81
commit 3976614bd5
20 changed files with 260 additions and 201 deletions

View File

@ -53,6 +53,7 @@ set(IGDRCL_SRCS_offline_compiler_tests
${CMAKE_CURRENT_SOURCE_DIR}/environment.h
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ocloc_fatbinary_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ocloc_fatbinary_tests.h
${CMAKE_CURRENT_SOURCE_DIR}/offline_compiler_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/offline_compiler_tests.h
${NEO_SHARED_DIRECTORY}/helpers/abort.cpp

View File

@ -16,9 +16,9 @@ struct MockDecoder : public BinaryDecoder {
MockDecoder(const std::string &file, const std::string &patch, const std::string &dump)
: BinaryDecoder(file, patch, dump) {
this->iga.reset(new MockIgaWrapper);
setMessagePrinter(MessagePrinter{true});
uniqueHelper = std::make_unique<OclocArgHelper>();
argHelper = uniqueHelper.get();
oclocArgHelperWithoutInput = std::make_unique<OclocArgHelper>();
argHelper = oclocArgHelperWithoutInput.get();
argHelper->getPrinterRef() = MessagePrinter(true);
};
using BinaryDecoder::binaryFile;
using BinaryDecoder::decode;
@ -35,7 +35,7 @@ struct MockDecoder : public BinaryDecoder {
using BinaryDecoder::readPatchTokens;
using BinaryDecoder::readStructFields;
std::unique_ptr<OclocArgHelper> uniqueHelper;
std::unique_ptr<OclocArgHelper> oclocArgHelperWithoutInput;
MockIgaWrapper *getMockIga() const {
return static_cast<MockIgaWrapper *>(iga.get());

View File

@ -21,9 +21,9 @@ struct MockEncoder : public BinaryEncoder {
MockEncoder(const std::string &dump, const std::string &elf)
: BinaryEncoder(dump, elf) {
this->iga.reset(new MockIgaWrapper);
setMessagePrinter(MessagePrinter{true});
uniqueHelper = std::make_unique<MockOclocArgHelper>(filesMap);
argHelper = uniqueHelper.get();
oclocArgHelperWithoutInput = std::make_unique<MockOclocArgHelper>(filesMap);
argHelper = oclocArgHelperWithoutInput.get();
argHelper->getPrinterRef() = MessagePrinter(true);
};
std::map<std::string, std::string> filesMap;
@ -52,7 +52,7 @@ struct MockEncoder : public BinaryEncoder {
using BinaryEncoder::write;
using BinaryEncoder::writeDeviceBinary;
std::unique_ptr<OclocArgHelper> uniqueHelper;
std::unique_ptr<OclocArgHelper> oclocArgHelperWithoutInput;
MockIgaWrapper *getMockIga() const {
return static_cast<MockIgaWrapper *>(iga.get());

View File

@ -5,13 +5,14 @@
*
*/
#include "shared/offline_compiler/source/ocloc_fatbinary.h"
#include "opencl/test/unit_test/offline_compiler/ocloc_fatbinary_tests.h"
#include "shared/source/helpers/hw_helper.h"
#include "gtest/gtest.h"
#include <unordered_set>
namespace NEO {
TEST(OclocFatBinaryRequestedFatBinary, WhenDeviceArgMissingThenReturnsFalse) {
const char *args[] = {"ocloc", "-aaa", "*", "-device", "*"};
@ -126,14 +127,14 @@ TEST(OclocFatBinaryAppendPlatformsForGfxCore, GivenCoreIdThenAppendsEnabledProdu
EXPECT_EQ(2 * appendedPlatformsSet.size(), appendedPlatforms.size());
}
TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenAsterixThenReturnAllEnabledPlatforms) {
TEST_F(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenAsterixThenReturnAllEnabledPlatforms) {
auto allEnabledPlatformsIds = NEO::getAllSupportedTargetPlatforms();
auto expected = NEO::toProductNames(allEnabledPlatformsIds);
auto got = NEO::getTargetPlatformsForFatbinary("*");
auto got = NEO::getTargetPlatformsForFatbinary("*", oclocArgHelperWithoutInput.get());
EXPECT_EQ(expected, got);
}
TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenThenReturnAllEnabledPlatformsThatMatch) {
TEST_F(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenThenReturnAllEnabledPlatformsThatMatch) {
auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms();
auto platform0 = allEnabledPlatforms[0];
auto gfxCore0 = NEO::hardwareInfoTable[platform0]->platform.eRenderCoreFamily;
@ -143,11 +144,11 @@ TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenThenReturnAllEnabledP
std::vector<PRODUCT_FAMILY> platformsForGen;
NEO::appendPlatformsForGfxCore(gfxCore0, allEnabledPlatforms, platformsForGen);
auto expected = NEO::toProductNames(platformsForGen);
auto got = NEO::getTargetPlatformsForFatbinary(genName);
auto got = NEO::getTargetPlatformsForFatbinary(genName, oclocArgHelperWithoutInput.get());
EXPECT_EQ(expected, got);
}
TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenMutiplePlatformThenReturnThosePlatforms) {
TEST_F(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenMutiplePlatformThenReturnThosePlatforms) {
auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms();
if (allEnabledPlatforms.size() < 2) {
return;
@ -158,11 +159,11 @@ TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenMutiplePlatformThenRetur
std::string platform1Name = NEO::hardwarePrefix[platform1];
std::vector<ConstStringRef> expected{platform0Name, platform1Name};
auto got = NEO::getTargetPlatformsForFatbinary(platform0Name + "," + platform1Name);
auto got = NEO::getTargetPlatformsForFatbinary(platform0Name + "," + platform1Name, oclocArgHelperWithoutInput.get());
EXPECT_EQ(expected, got);
}
TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenPlatformOpenRangeFromThenReturnAllEnabledPlatformsThatMatch) {
TEST_F(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenPlatformOpenRangeFromThenReturnAllEnabledPlatformsThatMatch) {
auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms();
if (allEnabledPlatforms.size() < 3) {
return;
@ -174,11 +175,11 @@ TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenPlatformOpenRangeFromThe
auto platformFrom = std::find(allEnabledPlatforms.begin(), allEnabledPlatforms.end(), platform0);
expectedPlatforms.insert(expectedPlatforms.end(), platformFrom, allEnabledPlatforms.end());
auto expected = NEO::toProductNames(expectedPlatforms);
auto got = NEO::getTargetPlatformsForFatbinary(platformName + "-");
auto got = NEO::getTargetPlatformsForFatbinary(platformName + "-", oclocArgHelperWithoutInput.get());
EXPECT_EQ(expected, got);
}
TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenPlatformOpenRangeToThenReturnAllEnabledPlatformsThatMatch) {
TEST_F(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenPlatformOpenRangeToThenReturnAllEnabledPlatformsThatMatch) {
auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms();
if (allEnabledPlatforms.size() < 3) {
return;
@ -190,11 +191,11 @@ TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenPlatformOpenRangeToThenR
auto platformTo = std::find(allEnabledPlatforms.begin(), allEnabledPlatforms.end(), platform0);
expectedPlatforms.insert(expectedPlatforms.end(), allEnabledPlatforms.begin(), platformTo + 1);
auto expected = NEO::toProductNames(expectedPlatforms);
auto got = NEO::getTargetPlatformsForFatbinary("-" + platformName);
auto got = NEO::getTargetPlatformsForFatbinary("-" + platformName, oclocArgHelperWithoutInput.get());
EXPECT_EQ(expected, got);
}
TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenPlatformClosedRangeThenReturnAllEnabledPlatformsThatMatch) {
TEST_F(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenPlatformClosedRangeThenReturnAllEnabledPlatformsThatMatch) {
auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms();
if (allEnabledPlatforms.size() < 4) {
return;
@ -207,10 +208,10 @@ TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenPlatformClosedRangeThenR
std::vector<PRODUCT_FAMILY> expectedPlatforms;
expectedPlatforms.insert(expectedPlatforms.end(), allEnabledPlatforms.begin() + 1, allEnabledPlatforms.begin() + allEnabledPlatforms.size() - 1);
auto expected = NEO::toProductNames(expectedPlatforms);
auto got = NEO::getTargetPlatformsForFatbinary(platformNameFrom + "-" + platformNameTo);
auto got = NEO::getTargetPlatformsForFatbinary(platformNameFrom + "-" + platformNameTo, oclocArgHelperWithoutInput.get());
EXPECT_EQ(expected, got);
got = NEO::getTargetPlatformsForFatbinary(platformNameTo + "-" + platformNameFrom); // swap min with max implicitly
got = NEO::getTargetPlatformsForFatbinary(platformNameTo + "-" + platformNameFrom, oclocArgHelperWithoutInput.get()); // swap min with max implicitly
EXPECT_EQ(expected, got);
}
@ -224,7 +225,7 @@ std::vector<GFXCORE_FAMILY> getEnabledCores() {
return ret;
}
TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenOpenRangeFromThenReturnAllEnabledPlatformsThatMatch) {
TEST_F(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenOpenRangeFromThenReturnAllEnabledPlatformsThatMatch) {
auto allSupportedPlatforms = NEO::getAllSupportedTargetPlatforms();
auto allEnabledCores = getEnabledCores();
@ -243,11 +244,11 @@ TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenOpenRangeFromThenRetu
}
auto expected = NEO::toProductNames(expectedPlatforms);
auto got = NEO::getTargetPlatformsForFatbinary(genName + "-");
auto got = NEO::getTargetPlatformsForFatbinary(genName + "-", oclocArgHelperWithoutInput.get());
EXPECT_EQ(expected, got);
}
TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenOpenRangeToThenReturnAllEnabledPlatformsThatMatch) {
TEST_F(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenOpenRangeToThenReturnAllEnabledPlatformsThatMatch) {
auto allSupportedPlatforms = NEO::getAllSupportedTargetPlatforms();
auto allEnabledCores = getEnabledCores();
@ -267,11 +268,11 @@ TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenOpenRangeToThenReturn
}
auto expected = NEO::toProductNames(expectedPlatforms);
auto got = NEO::getTargetPlatformsForFatbinary("-" + genName);
auto got = NEO::getTargetPlatformsForFatbinary("-" + genName, oclocArgHelperWithoutInput.get());
EXPECT_EQ(expected, got);
}
TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenClosedRangeThenReturnAllEnabledPlatformsThatMatch) {
TEST_F(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenClosedRangeThenReturnAllEnabledPlatformsThatMatch) {
auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms();
auto allEnabledCores = getEnabledCores();
if (allEnabledCores.size() < 4) {
@ -292,69 +293,70 @@ TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenClosedRangeThenReturn
}
auto expected = NEO::toProductNames(expectedPlatforms);
auto got = NEO::getTargetPlatformsForFatbinary(genNameFrom + "-" + genNameTo);
auto got = NEO::getTargetPlatformsForFatbinary(genNameFrom + "-" + genNameTo, oclocArgHelperWithoutInput.get());
EXPECT_EQ(expected, got);
got = NEO::getTargetPlatformsForFatbinary(genNameTo + "-" + genNameFrom); // swap min with max implicitly
got = NEO::getTargetPlatformsForFatbinary(genNameTo + "-" + genNameFrom, oclocArgHelperWithoutInput.get()); // swap min with max implicitly
EXPECT_EQ(expected, got);
}
TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenUnkownGenThenReturnEmptyList) {
auto got = NEO::getTargetPlatformsForFatbinary("gen0");
TEST_F(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenUnkownGenThenReturnEmptyList) {
auto got = NEO::getTargetPlatformsForFatbinary("gen0", oclocArgHelperWithoutInput.get());
EXPECT_TRUE(got.empty());
}
TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenMutiplePlatformWhenAnyOfPlatformsIsUnknownThenReturnEmptyList) {
TEST_F(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenMutiplePlatformWhenAnyOfPlatformsIsUnknownThenReturnEmptyList) {
auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms();
auto platform0 = allEnabledPlatforms[0];
std::string platform0Name = NEO::hardwarePrefix[platform0];
auto got = NEO::getTargetPlatformsForFatbinary(platform0Name + ",unk");
auto got = NEO::getTargetPlatformsForFatbinary(platform0Name + ",unk", oclocArgHelperWithoutInput.get());
EXPECT_TRUE(got.empty());
}
TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenPlatformOpenRangeFromWhenPlatformsIsUnkownThenReturnEmptyList) {
auto got = NEO::getTargetPlatformsForFatbinary("unk-");
TEST_F(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenPlatformOpenRangeFromWhenPlatformsIsUnkownThenReturnEmptyList) {
auto got = NEO::getTargetPlatformsForFatbinary("unk-", oclocArgHelperWithoutInput.get());
EXPECT_TRUE(got.empty());
}
TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenPlatformOpenRangeToWhenPlatformsIsUnkownThenReturnEmptyList) {
auto got = NEO::getTargetPlatformsForFatbinary("-unk");
TEST_F(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenPlatformOpenRangeToWhenPlatformsIsUnkownThenReturnEmptyList) {
auto got = NEO::getTargetPlatformsForFatbinary("-unk", oclocArgHelperWithoutInput.get());
EXPECT_TRUE(got.empty());
}
TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenPlatformClosedRangeWhenAnyOfPlatformsIsUnkownThenReturnEmptyList) {
TEST_F(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenPlatformClosedRangeWhenAnyOfPlatformsIsUnkownThenReturnEmptyList) {
auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms();
auto platform0 = allEnabledPlatforms[0];
std::string platform0Name = NEO::hardwarePrefix[platform0];
auto got = NEO::getTargetPlatformsForFatbinary("unk-" + platform0Name);
auto got = NEO::getTargetPlatformsForFatbinary("unk-" + platform0Name, oclocArgHelperWithoutInput.get());
EXPECT_TRUE(got.empty());
got = NEO::getTargetPlatformsForFatbinary(platform0Name + "-unk");
got = NEO::getTargetPlatformsForFatbinary(platform0Name + "-unk", oclocArgHelperWithoutInput.get());
EXPECT_TRUE(got.empty());
}
TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenOpenRangeFromWhenGenIsUnknownTheReturnEmptyList) {
auto got = NEO::getTargetPlatformsForFatbinary("gen2-");
TEST_F(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenOpenRangeFromWhenGenIsUnknownTheReturnEmptyList) {
auto got = NEO::getTargetPlatformsForFatbinary("gen2-", oclocArgHelperWithoutInput.get());
EXPECT_TRUE(got.empty());
}
TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenOpenRangeToWhenGenIsUnknownTheReturnEmptyList) {
auto got = NEO::getTargetPlatformsForFatbinary("-gen2");
TEST_F(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenOpenRangeToWhenGenIsUnknownTheReturnEmptyList) {
auto got = NEO::getTargetPlatformsForFatbinary("-gen2", oclocArgHelperWithoutInput.get());
EXPECT_TRUE(got.empty());
}
TEST(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenClosedRangeWhenAnyOfGensIsUnknownThenReturnEmptyList) {
TEST_F(OclocFatBinaryGetTargetPlatformsForFatbinary, GivenGenClosedRangeWhenAnyOfGensIsUnknownThenReturnEmptyList) {
auto allEnabledPlatforms = NEO::getAllSupportedTargetPlatforms();
auto platform0 = allEnabledPlatforms[0];
auto gfxCore0 = NEO::hardwareInfoTable[platform0]->platform.eRenderCoreFamily;
std::string genName = NEO::familyName[gfxCore0];
genName[0] = 'g'; // ocloc uses lower case
auto got = NEO::getTargetPlatformsForFatbinary("gen2-" + genName);
auto got = NEO::getTargetPlatformsForFatbinary("gen2-" + genName, oclocArgHelperWithoutInput.get());
EXPECT_TRUE(got.empty());
got = NEO::getTargetPlatformsForFatbinary(genName + "-gen2");
got = NEO::getTargetPlatformsForFatbinary(genName + "-gen2", oclocArgHelperWithoutInput.get());
EXPECT_TRUE(got.empty());
}
} // namespace NEO

View File

@ -0,0 +1,26 @@
/*
* Copyright (C) 2020 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "shared/offline_compiler/source/ocloc_arg_helper.h"
#include "shared/offline_compiler/source/ocloc_fatbinary.h"
#include "gtest/gtest.h"
#include <memory>
namespace NEO {
class OclocFatBinaryGetTargetPlatformsForFatbinary : public ::testing::Test {
public:
OclocFatBinaryGetTargetPlatformsForFatbinary() {
oclocArgHelperWithoutInput = std::make_unique<OclocArgHelper>();
oclocArgHelperWithoutInput->getPrinterRef() = MessagePrinter{true};
}
std::unique_ptr<OclocArgHelper> oclocArgHelperWithoutInput;
};
} // namespace NEO

View File

@ -62,7 +62,7 @@ TEST_F(MultiCommandTests, MultiCommandSuccessfulBuildTest) {
int numOfBuild = 4;
createFileWithArgs(singleArgs, numOfBuild);
auto pMultiCommand = std::unique_ptr<MultiCommand>(MultiCommand::create(argv, retVal, uniqueHelper.get()));
auto pMultiCommand = std::unique_ptr<MultiCommand>(MultiCommand::create(argv, retVal, oclocArgHelperWithoutInput.get()));
EXPECT_NE(nullptr, pMultiCommand);
EXPECT_EQ(CL_SUCCESS, retVal);
@ -87,7 +87,7 @@ TEST_F(MultiCommandTests, MultiCommandSuccessfulBuildWithOutputFileTest) {
int numOfBuild = 4;
createFileWithArgs(singleArgs, numOfBuild);
auto pMultiCommand = std::unique_ptr<MultiCommand>(MultiCommand::create(argv, retVal, uniqueHelper.get()));
auto pMultiCommand = std::unique_ptr<MultiCommand>(MultiCommand::create(argv, retVal, oclocArgHelperWithoutInput.get()));
EXPECT_NE(nullptr, pMultiCommand);
EXPECT_EQ(CL_SUCCESS, retVal);
@ -121,7 +121,7 @@ TEST_F(MultiCommandTests, GoodMultiBuildTestWithspecifiedOutputDir) {
int numOfBuild = 4;
createFileWithArgs(singleArgs, numOfBuild);
pMultiCommand = MultiCommand::create(argv, retVal, uniqueHelper.get());
pMultiCommand = MultiCommand::create(argv, retVal, oclocArgHelperWithoutInput.get());
EXPECT_NE(nullptr, pMultiCommand);
EXPECT_EQ(CL_SUCCESS, retVal);
@ -146,7 +146,7 @@ TEST_F(MultiCommandTests, LackOfTxtFileWithArgsMultiTest) {
};
testing::internal::CaptureStdout();
auto pMultiCommand = std::unique_ptr<MultiCommand>(MultiCommand::create(argv, retVal, uniqueHelper.get()));
auto pMultiCommand = std::unique_ptr<MultiCommand>(MultiCommand::create(argv, retVal, oclocArgHelperWithoutInput.get()));
std::string output = testing::internal::GetCapturedStdout();
EXPECT_STRNE(output.c_str(), "");
@ -172,10 +172,9 @@ TEST_F(MultiCommandTests, LackOfClFilePointedInTxtFileMultiTest) {
int numOfBuild = 4;
createFileWithArgs(singleArgs, numOfBuild);
testing::internal::CaptureStdout();
auto pMultiCommand = std::unique_ptr<MultiCommand>(MultiCommand::create(argv, retVal, uniqueHelper.get()));
auto pMultiCommand = std::unique_ptr<MultiCommand>(MultiCommand::create(argv, retVal, oclocArgHelperWithoutInput.get()));
std::string output = testing::internal::GetCapturedStdout();
EXPECT_STRNE(output.c_str(), "");
EXPECT_EQ(nullptr, pMultiCommand);
EXPECT_EQ(INVALID_FILE, retVal);
DebugManager.flags.PrintDebugMessages.set(false);
@ -202,7 +201,7 @@ TEST_F(MultiCommandTests, GoodMultiBuildTestWithOutputFileListFlag) {
int numOfBuild = 4;
createFileWithArgs(singleArgs, numOfBuild);
pMultiCommand = MultiCommand::create(argv, retVal, uniqueHelper.get());
pMultiCommand = MultiCommand::create(argv, retVal, oclocArgHelperWithoutInput.get());
EXPECT_NE(nullptr, pMultiCommand);
EXPECT_EQ(CL_SUCCESS, retVal);
@ -228,7 +227,7 @@ TEST_F(OfflineCompilerTests, GoodArgTest) {
"-device",
gEnvironment->devicePrefix.c_str()};
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get());
EXPECT_NE(nullptr, pOfflineCompiler);
EXPECT_EQ(CL_SUCCESS, retVal);
@ -257,7 +256,7 @@ TEST_F(OfflineCompilerTests, GoodBuildTest) {
"-device",
gEnvironment->devicePrefix.c_str()};
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get());
EXPECT_NE(nullptr, pOfflineCompiler);
EXPECT_EQ(CL_SUCCESS, retVal);
@ -285,7 +284,7 @@ TEST_F(OfflineCompilerTests, GoodBuildTestWithLlvmText) {
gEnvironment->devicePrefix.c_str(),
"-llvm_text"};
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get());
EXPECT_NE(nullptr, pOfflineCompiler);
EXPECT_EQ(CL_SUCCESS, retVal);
@ -323,7 +322,7 @@ TEST_F(OfflineCompilerTests, GoodParseBinToCharArray) {
"-device",
gEnvironment->devicePrefix.c_str()};
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get());
// clang-format off
uint8_t binary[] = {
0x02, 0x23, 0x3, 0x40, 0x56, 0x7, 0x80, 0x90, 0x1, 0x03,
@ -367,7 +366,7 @@ TEST_F(OfflineCompilerTests, GoodBuildTestWithCppFile) {
gEnvironment->devicePrefix.c_str(),
"-cpp_file"};
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get());
EXPECT_NE(nullptr, pOfflineCompiler);
EXPECT_EQ(CL_SUCCESS, retVal);
@ -391,7 +390,7 @@ TEST_F(OfflineCompilerTests, GoodBuildTestWithOutputDir) {
"-out_dir",
"offline_compiler_test"};
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get());
EXPECT_NE(nullptr, pOfflineCompiler);
EXPECT_EQ(CL_SUCCESS, retVal);
@ -410,7 +409,7 @@ TEST_F(OfflineCompilerTests, PrintUsage) {
"--help"};
testing::internal::CaptureStdout();
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get());
std::string output = testing::internal::GetCapturedStdout();
EXPECT_EQ(nullptr, pOfflineCompiler);
EXPECT_STRNE("", output.c_str());
@ -428,7 +427,7 @@ TEST_F(OfflineCompilerTests, NaughtyArgTest_File) {
gEnvironment->devicePrefix.c_str()};
testing::internal::CaptureStdout();
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get());
std::string output = testing::internal::GetCapturedStdout();
EXPECT_STRNE(output.c_str(), "");
EXPECT_EQ(nullptr, pOfflineCompiler);
@ -446,7 +445,7 @@ TEST_F(OfflineCompilerTests, NaughtyArgTest_Flag) {
gEnvironment->devicePrefix.c_str()};
testing::internal::CaptureStdout();
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get());
std::string output = testing::internal::GetCapturedStdout();
EXPECT_STRNE(output.c_str(), "");
EXPECT_EQ(nullptr, pOfflineCompiler);
@ -462,7 +461,7 @@ TEST_F(OfflineCompilerTests, NaughtyArgTest_NumArgs) {
};
testing::internal::CaptureStdout();
pOfflineCompiler = OfflineCompiler::create(argvA.size(), argvA, true, retVal, uniqueHelper.get());
pOfflineCompiler = OfflineCompiler::create(argvA.size(), argvA, true, retVal, oclocArgHelperWithoutInput.get());
std::string output = testing::internal::GetCapturedStdout();
EXPECT_STRNE(output.c_str(), "");
@ -477,7 +476,7 @@ TEST_F(OfflineCompilerTests, NaughtyArgTest_NumArgs) {
"test_files/ImANaughtyFile.cl",
"-device"};
testing::internal::CaptureStdout();
pOfflineCompiler = OfflineCompiler::create(argvB.size(), argvB, true, retVal, uniqueHelper.get());
pOfflineCompiler = OfflineCompiler::create(argvB.size(), argvB, true, retVal, oclocArgHelperWithoutInput.get());
output = testing::internal::GetCapturedStdout();
EXPECT_STRNE(output.c_str(), "");
EXPECT_EQ(nullptr, pOfflineCompiler);
@ -495,7 +494,7 @@ TEST_F(OfflineCompilerTests, GivenNonexistantDeviceWhenCompilingThenExitWithErro
"foobar"};
testing::internal::CaptureStdout();
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get());
std::string output = testing::internal::GetCapturedStdout();
EXPECT_STREQ(output.c_str(), "Error: Cannot get HW Info for device foobar.\n");
EXPECT_EQ(nullptr, pOfflineCompiler);
@ -510,7 +509,7 @@ TEST_F(OfflineCompilerTests, NaughtyKernelTest) {
"-device",
gEnvironment->devicePrefix.c_str()};
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, oclocArgHelperWithoutInput.get());
EXPECT_NE(nullptr, pOfflineCompiler);
EXPECT_EQ(CL_SUCCESS, retVal);

View File

@ -10,7 +10,6 @@
#include "shared/offline_compiler/source/offline_compiler.h"
#include "gtest/gtest.h"
#include <CL/cl.h>
#include <cstdint>
#include <memory>
@ -19,21 +18,31 @@ namespace NEO {
class OfflineCompilerTests : public ::testing::Test {
public:
OfflineCompiler *pOfflineCompiler = nullptr;
int retVal = CL_SUCCESS;
std::unique_ptr<OclocArgHelper> uniqueHelper = std::make_unique<OclocArgHelper>();
OfflineCompilerTests() : pOfflineCompiler(nullptr),
retVal(SUCCESS) {
oclocArgHelperWithoutInput = std::make_unique<OclocArgHelper>();
// ctor
}
OfflineCompiler *pOfflineCompiler;
int retVal;
std::unique_ptr<OclocArgHelper> oclocArgHelperWithoutInput;
};
class MultiCommandTests : public ::testing::Test {
public:
MultiCommandTests() : pMultiCommand(nullptr),
retVal(SUCCESS) {
oclocArgHelperWithoutInput = std::make_unique<OclocArgHelper>();
}
void createFileWithArgs(const std::vector<std::string> &, int numOfBuild);
void deleteFileWithArgs();
void deleteOutFileList();
MultiCommand *pMultiCommand = nullptr;
std::string nameOfFileWithArgs;
std::string outFileList;
int retVal = CL_SUCCESS;
std::unique_ptr<OclocArgHelper> uniqueHelper = std::make_unique<OclocArgHelper>();
int retVal;
std::unique_ptr<OclocArgHelper> oclocArgHelperWithoutInput;
};
void MultiCommandTests::createFileWithArgs(const std::vector<std::string> &singleArgs, int numOfBuild) {

View File

@ -26,10 +26,6 @@
#define MakeDirectory(dir) mkdir(dir, 0777)
#endif
void BinaryDecoder::setMessagePrinter(const MessagePrinter &messagePrinter) {
this->messagePrinter = messagePrinter;
}
template <typename T>
T readUnaligned(const void *ptr) {
T retVal = 0;
@ -46,7 +42,7 @@ int BinaryDecoder::decode() {
std::stringstream ptmFile;
auto devBinPtr = getDevBinary();
if (devBinPtr == nullptr) {
messagePrinter.printf("Error! Device Binary section was not found.\n");
argHelper->printf("Error! Device Binary section was not found.\n");
exit(1);
}
return processBinary(devBinPtr, ptmFile);
@ -76,7 +72,7 @@ void BinaryDecoder::dumpField(const void *&binaryPtr, const PTField &field, std:
break;
}
default:
messagePrinter.printf("Error! Unknown size.\n");
argHelper->printf("Error! Unknown size.\n");
exit(1);
}
binaryPtr = ptrOffset(binaryPtr, field.size);
@ -125,7 +121,7 @@ uint8_t BinaryDecoder::getSize(const std::string &typeStr) {
} else if (typeStr == "uint64_t") {
return 8;
} else {
messagePrinter.printf("Unhandled type : %s\n", typeStr.c_str());
argHelper->printf("Unhandled type : %s\n", typeStr.c_str());
exit(1);
}
}
@ -136,7 +132,7 @@ std::vector<std::string> BinaryDecoder::loadPatchList() {
} else {
std::vector<std::string> patchList;
if (pathToPatch.empty()) {
messagePrinter.printf("Path to patch list not provided - using defaults, skipping patchokens as undefined.\n");
argHelper->printf("Path to patch list not provided - using defaults, skipping patchokens as undefined.\n");
patchList = {
"struct SProgramBinaryHeader",
"{",
@ -205,22 +201,22 @@ void BinaryDecoder::parseTokens() {
size_t pos = findPos(patchList, "struct SProgramBinaryHeader");
if (pos == patchList.size()) {
messagePrinter.printf("While parsing patchtoken definitions: couldn't find SProgramBinaryHeader.");
argHelper->printf("While parsing patchtoken definitions: couldn't find SProgramBinaryHeader.");
exit(1);
}
pos = findPos(patchList, "enum PATCH_TOKEN");
if (pos == patchList.size()) {
messagePrinter.printf("While parsing patchtoken definitions: couldn't find enum PATCH_TOKEN.");
argHelper->printf("While parsing patchtoken definitions: couldn't find enum PATCH_TOKEN.");
exit(1);
}
pos = findPos(patchList, "struct SKernelBinaryHeader");
if (pos == patchList.size()) {
messagePrinter.printf("While parsing patchtoken definitions: couldn't find SKernelBinaryHeader.");
argHelper->printf("While parsing patchtoken definitions: couldn't find SKernelBinaryHeader.");
exit(1);
}
pos = findPos(patchList, "struct SKernelBinaryHeaderCommon :");
if (pos == patchList.size()) {
messagePrinter.printf("While parsing patchtoken definitions: couldn't find SKernelBinaryHeaderCommon.");
argHelper->printf("While parsing patchtoken definitions: couldn't find SKernelBinaryHeaderCommon.");
exit(1);
}
@ -280,7 +276,7 @@ void BinaryDecoder::parseTokens() {
}
void BinaryDecoder::printHelp() {
messagePrinter.printf(R"===(Disassembles Intel Compute GPU device binary files.
argHelper->printf(R"===(Disassembles Intel Compute GPU device binary files.
Output of such operation is a set of files that can be later used to
reassemble back a valid Intel Compute GPU device binary (using ocloc 'asm'
command). This set of files contains:
@ -329,7 +325,7 @@ Examples:
Disassemble Intel Compute GPU device binary
ocloc disasm -file source_file_Gen9core.bin
)===",
NEO::getDevicesTypes().c_str());
NEO::getDevicesTypes().c_str());
}
int BinaryDecoder::processBinary(const void *&ptr, std::ostream &ptmFile) {
@ -346,7 +342,7 @@ int BinaryDecoder::processBinary(const void *&ptr, std::ostream &ptmFile) {
dumpField(ptr, v, ptmFile);
}
if (numberOfKernels == 0) {
messagePrinter.printf("Warning! Number of Kernels is 0.\n");
argHelper->printf("Warning! Number of Kernels is 0.\n");
}
readPatchTokens(ptr, patchListSize, ptmFile);
@ -386,7 +382,7 @@ void BinaryDecoder::processKernel(const void *&ptr, std::ostream &ptmFile) {
}
if (KernelNameSize == 0) {
messagePrinter.printf("Error! KernelNameSize was 0.\n");
argHelper->printf("Error! KernelNameSize was 0.\n");
exit(1);
}
@ -396,7 +392,7 @@ void BinaryDecoder::processKernel(const void *&ptr, std::ostream &ptmFile) {
ptr = ptrOffset(ptr, KernelNameSize);
std::string fileName = pathToDump + kernelName + "_KernelHeap";
messagePrinter.printf("Trying to disassemble %s.krn\n", kernelName.c_str());
argHelper->printf("Trying to disassemble %s.krn\n", kernelName.c_str());
std::string disassembledKernel;
if (iga->tryDisassembleGenISA(ptr, KernelHeapUnpaddedSize, disassembledKernel)) {
argHelper->saveOutput(fileName + ".asm", disassembledKernel.data(), disassembledKernel.size());
@ -410,7 +406,7 @@ void BinaryDecoder::processKernel(const void *&ptr, std::ostream &ptmFile) {
ptr = ptrOffset(ptr, KernelHeapSize);
if (GeneralStateHeapSize != 0) {
messagePrinter.printf("Warning! GeneralStateHeapSize wasn't 0.\n");
argHelper->printf("Warning! GeneralStateHeapSize wasn't 0.\n");
fileName = pathToDump + kernelName + "_GeneralStateHeap.bin";
argHelper->saveOutput(fileName, ptr, DynamicStateHeapSize);
ptr = ptrOffset(ptr, GeneralStateHeapSize);
@ -425,7 +421,7 @@ void BinaryDecoder::processKernel(const void *&ptr, std::ostream &ptmFile) {
ptr = ptrOffset(ptr, SurfaceStateHeapSize);
if (KernelPatchListSize == 0) {
messagePrinter.printf("Warning! Kernel's patch list size was 0.\n");
argHelper->printf("Warning! Kernel's patch list size was 0.\n");
}
readPatchTokens(ptr, KernelPatchListSize, ptmFile);
}
@ -528,25 +524,25 @@ int BinaryDecoder::validateInput(const std::vector<std::string> &args) {
} else if ("-ignore_isa_padding" == currArg) {
ignoreIsaPadding = true;
} else if ("-q" == currArg) {
this->messagePrinter = MessagePrinter{true};
iga->setMessagePrinter(this->messagePrinter);
argHelper->getPrinterRef() = MessagePrinter(true);
iga->setMessagePrinter(argHelper->getPrinterRef());
} else {
messagePrinter.printf("Unknown argument %s\n", currArg.c_str());
argHelper->printf("Unknown argument %s\n", currArg.c_str());
printHelp();
return -1;
}
}
if (binaryFile.find(".bin") == std::string::npos) {
messagePrinter.printf(".bin extension is expected for binary file.\n");
argHelper->printf(".bin extension is expected for binary file.\n");
printHelp();
return -1;
}
if (false == iga->isKnownPlatform()) {
messagePrinter.printf("Warning : missing or invalid -device parameter - results may be inacurate\n");
argHelper->printf("Warning : missing or invalid -device parameter - results may be inacurate\n");
}
if (!argHelper->outputEnabled()) {
if (pathToDump.empty()) {
messagePrinter.printf("Warning : Path to dump folder not specificed - using ./dump as default.\n");
argHelper->printf("Warning : Path to dump folder not specificed - using ./dump as default.\n");
pathToDump = std::string("dump/");
}
MakeDirectory(pathToDump.c_str());

View File

@ -35,11 +35,10 @@ class BinaryDecoder {
BinaryDecoder(const std::string &file, const std::string &patch, const std::string &dump)
: binaryFile(file), pathToPatch(patch), pathToDump(dump){};
BinaryDecoder(OclocArgHelper *helper) : argHelper(helper), iga(new IgaWrapper) {
iga->setMessagePrinter(messagePrinter);
iga->setMessagePrinter(argHelper->getPrinterRef());
};
int decode();
int validateInput(const std::vector<std::string> &args);
void setMessagePrinter(const MessagePrinter &messagePrinter);
protected:
OclocArgHelper *argHelper = nullptr;
@ -49,7 +48,6 @@ class BinaryDecoder {
std::unique_ptr<IgaWrapper> iga;
PTMap patchTokens;
std::string binaryFile, pathToPatch, pathToDump;
MessagePrinter messagePrinter;
void dumpField(const void *&binaryPtr, const PTField &field, std::ostream &ptmFile);
uint8_t getSize(const std::string &typeStr);

View File

@ -22,10 +22,6 @@
#include <fstream>
#include <sstream>
void BinaryEncoder::setMessagePrinter(const MessagePrinter &messagePrinter) {
this->messagePrinter = messagePrinter;
}
void BinaryEncoder::calculatePatchListSizes(std::vector<std::string> &ptmFile) {
size_t patchListPos = 0;
for (size_t i = 0; i < ptmFile.size(); ++i) {
@ -46,7 +42,7 @@ void BinaryEncoder::calculatePatchListSizes(std::vector<std::string> &ptmFile) {
}
uint32_t size = static_cast<uint32_t>(std::stoul(ptmFile[patchListPos].substr(ptmFile[patchListPos].find_last_of(' ') + 1)));
if (size != calcSize) {
messagePrinter.printf("Warning! Calculated PatchListSize ( %u ) differs from file ( %u ) - changing it. Line %d\n", calcSize, size, static_cast<int>(patchListPos + 1));
argHelper->printf("Warning! Calculated PatchListSize ( %u ) differs from file ( %u ) - changing it. Line %d\n", calcSize, size, static_cast<int>(patchListPos + 1));
ptmFile[patchListPos] = ptmFile[patchListPos].substr(0, ptmFile[patchListPos].find_last_of(' ') + 1);
ptmFile[patchListPos] += std::to_string(calcSize);
}
@ -79,7 +75,7 @@ int BinaryEncoder::createElf(std::stringstream &deviceBinary) {
ElfEncoder.appendSection(NEO::Elf::SHT_OPENCL_OPTIONS, "BuildOptions",
ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(binary.data()), binary.size()));
} else {
messagePrinter.printf("Warning! Missing build section.\n");
argHelper->printf("Warning! Missing build section.\n");
}
//LLVM or SPIRV
if (argHelper->fileExists(pathToDump + "llvm.bin")) {
@ -91,7 +87,7 @@ int BinaryEncoder::createElf(std::stringstream &deviceBinary) {
ElfEncoder.appendSection(NEO::Elf::SHT_OPENCL_SPIRV, "SPIRV Object",
ArrayRef<const uint8_t>(reinterpret_cast<const uint8_t *>(binary.data()), binary.size()));
} else {
messagePrinter.printf("Warning! Missing llvm/spirv section.\n");
argHelper->printf("Warning! Missing llvm/spirv section.\n");
}
//Device Binary
@ -108,7 +104,7 @@ int BinaryEncoder::createElf(std::stringstream &deviceBinary) {
}
void BinaryEncoder::printHelp() {
messagePrinter.printf(R"===(Assembles Intel Compute GPU device binary from input files.
argHelper->printf(R"===(Assembles Intel Compute GPU device binary from input files.
It's expected that input files were previously generated by 'ocloc disasm'
command or are compatible with 'ocloc disasm' output (especially in terms of
file naming scheme). See 'ocloc disasm --help' for additional info.
@ -137,13 +133,13 @@ Examples:
Assemble to Intel Compute GPU device binary
ocloc asm -out reassembled.bin
)===",
NEO::getDevicesTypes().c_str());
NEO::getDevicesTypes().c_str());
}
int BinaryEncoder::encode() {
std::vector<std::string> ptmFile;
if (!argHelper->fileExists(pathToDump + "PTM.txt")) {
messagePrinter.printf("Error! Couldn't find PTM.txt");
argHelper->printf("Error! Couldn't find PTM.txt");
return -1;
}
argHelper->readFileToVectorOfStrings(pathToDump + "PTM.txt", ptmFile);
@ -177,11 +173,11 @@ int BinaryEncoder::processBinary(const std::vector<std::string> &ptmFileLines, s
while (i < ptmFileLines.size()) {
if (ptmFileLines[i].find("Kernel #") != std::string::npos) {
if (processKernel(++i, ptmFileLines, deviceBinary)) {
messagePrinter.printf("Warning while processing kernel!\n");
argHelper->printf("Warning while processing kernel!\n");
return -1;
}
} else if (writeDeviceBinary(ptmFileLines[i++], deviceBinary)) {
messagePrinter.printf("Error while writing to binary!\n");
argHelper->printf("Error while writing to binary!\n");
return -1;
}
}
@ -239,9 +235,9 @@ int BinaryEncoder::processKernel(size_t &line, const std::vector<std::string> &p
if (argHelper->fileExists(pathToDump + kernelName + "_KernelHeap.asm")) {
auto kernelAsAsm = argHelper->readBinaryFile(pathToDump + kernelName + "_KernelHeap.asm");
std::string kernelAsBinary;
messagePrinter.printf("Trying to assemble %s.asm\n", kernelName.c_str());
argHelper->printf("Trying to assemble %s.asm\n", kernelName.c_str());
if (false == iga->tryAssembleGenISA(std::string(kernelAsAsm.begin(), kernelAsAsm.end()), kernelAsBinary)) {
messagePrinter.printf("Error : Could not assemble : %s\n", kernelName.c_str());
argHelper->printf("Error : Could not assemble : %s\n", kernelName.c_str());
return -1;
}
kernelHeapSizeUnpadded = static_cast<uint32_t>(kernelAsBinary.size());
@ -274,7 +270,7 @@ int BinaryEncoder::processKernel(size_t &line, const std::vector<std::string> &p
// Write kernel patchtokens
for (size_t i = kernelPatchtokensMarker; i < kernelInfoEndMarker; ++i) {
if (writeDeviceBinary(ptmFileLines[i], kernelBlob)) {
messagePrinter.printf("Error while writing to binary.\n");
argHelper->printf("Error while writing to binary.\n");
return -1;
}
}
@ -296,7 +292,7 @@ int BinaryEncoder::processKernel(size_t &line, const std::vector<std::string> &p
deviceBinary.write(reinterpret_cast<char *>(&kernelHeapSizeUnpadded), sizeof(uint32_t));
} else {
if (writeDeviceBinary(ptmFileLines[i], deviceBinary)) {
messagePrinter.printf("Error while writing to binary.\n");
argHelper->printf("Error while writing to binary.\n");
return -1;
}
}
@ -327,29 +323,29 @@ int BinaryEncoder::validateInput(const std::vector<std::string> &args) {
} else if ("-ignore_isa_padding" == currArg) {
ignoreIsaPadding = true;
} else if ("-q" == currArg) {
this->messagePrinter = MessagePrinter{true};
iga->setMessagePrinter(this->messagePrinter);
argHelper->getPrinterRef() = MessagePrinter(true);
iga->setMessagePrinter(argHelper->getPrinterRef());
} else {
messagePrinter.printf("Unknown argument %s\n", currArg.c_str());
argHelper->printf("Unknown argument %s\n", currArg.c_str());
printHelp();
return -1;
}
}
if (pathToDump.empty()) {
if (!argHelper->outputEnabled()) {
messagePrinter.printf("Warning : Path to dump folder not specificed - using ./dump as default.\n");
argHelper->printf("Warning : Path to dump folder not specificed - using ./dump as default.\n");
pathToDump = "dump";
addSlash(pathToDump);
}
}
if (elfName.find(".bin") == std::string::npos) {
messagePrinter.printf(".bin extension is expected for binary file.\n");
argHelper->printf(".bin extension is expected for binary file.\n");
printHelp();
return -1;
}
if (false == iga->isKnownPlatform()) {
messagePrinter.printf("Warning : missing or invalid -device parameter - results may be inacurate\n");
argHelper->printf("Warning : missing or invalid -device parameter - results may be inacurate\n");
}
return 0;
}
@ -405,7 +401,7 @@ int BinaryEncoder::writeDeviceBinary(const std::string &line, std::ostream &devi
write<uint64_t>(ss, deviceBinary);
break;
default:
messagePrinter.printf("Unknown size in line: %s\n", line.c_str());
argHelper->printf("Unknown size in line: %s\n", line.c_str());
return -1;
}
}

View File

@ -20,18 +20,15 @@ class BinaryEncoder {
BinaryEncoder(const std::string &dump, const std::string &elf)
: pathToDump(dump), elfName(elf){};
BinaryEncoder(OclocArgHelper *helper) : argHelper(helper), iga(new IgaWrapper) {
iga->setMessagePrinter(messagePrinter);
iga->setMessagePrinter(argHelper->getPrinterRef());
}
int encode();
int validateInput(const std::vector<std::string> &args);
void setMessagePrinter(const MessagePrinter &messagePrinter);
protected:
OclocArgHelper *argHelper = nullptr;
bool ignoreIsaPadding = false;
std::string pathToDump, elfName;
MessagePrinter messagePrinter;
std::unique_ptr<IgaWrapper> iga;
void calculatePatchListSizes(std::vector<std::string> &ptmFile);
MOCKABLE_VIRTUAL bool copyBinaryToBinary(const std::string &srcFileName, std::ostream &outBinary, uint32_t *binaryLength);

View File

@ -12,6 +12,7 @@
#include <exception>
#include <memory>
#include <sstream>
#include <string>
#include <vector>
@ -34,6 +35,7 @@ class MessagePrinter {
if (!suppressMessages) {
::printf("%s", message);
}
ss << std::string(message);
}
template <typename... Args>
@ -41,8 +43,26 @@ class MessagePrinter {
if (!suppressMessages) {
::printf(format, std::forward<Args>(args)...);
}
ss << stringFormat(format, std::forward<Args>(args)...);
}
const std::ostream &getLog() {
return ss;
}
private:
template <typename... Args>
std::string stringFormat(const std::string &format, Args... args) {
std::string outputString;
size_t size = static_cast<size_t>(snprintf(nullptr, 0, format.c_str(), args...) + 1);
if (size <= 0) {
return outputString;
}
outputString.resize(size);
snprintf(&*outputString.begin(), size, format.c_str(), args...);
return outputString;
}
std::stringstream ss;
bool suppressMessages = false;
};

View File

@ -20,14 +20,14 @@ int MultiCommand::singleBuild(const std::vector<std::string> &allArgs) {
std::string &buildLog = pCompiler->getBuildLog();
if (buildLog.empty() == false) {
printf("%s\n", buildLog.c_str());
argHelper->printf("%s\n", buildLog.c_str());
}
if (retVal == ErrorCode::SUCCESS) {
if (!pCompiler->isQuiet())
printf("Build succeeded.\n");
argHelper->printf("Build succeeded.\n");
} else {
printf("Build failed with error code: %d\n", retVal);
argHelper->printf("Build failed with error code: %d\n", retVal);
}
}
@ -99,7 +99,7 @@ int MultiCommand::initialize(const std::vector<std::string> &args) {
} else if (ConstStringRef("-q") == currArg) {
quiet = true;
} else {
printf("Invalid option (arg %zu): %s\n", argIndex, currArg.c_str());
argHelper->printf("Invalid option (arg %zu): %s\n", argIndex, currArg.c_str());
printHelp();
return INVALID_COMMAND_LINE;
}
@ -109,11 +109,11 @@ int MultiCommand::initialize(const std::vector<std::string> &args) {
if (argHelper->fileExists(pathToCommandFile)) {
argHelper->readFileToVectorOfStrings(pathToCommandFile, lines);
if (lines.empty()) {
printf("Command file was empty.\n");
argHelper->printf("Command file was empty.\n");
return INVALID_FILE;
}
} else {
printf("Could not find/open file with builds argument.s\n");
argHelper->printf("Could not find/open file with builds argument.s\n");
return INVALID_FILE;
}
@ -136,7 +136,7 @@ void MultiCommand::runBuilds(const std::string &argZero) {
}
if (!quiet) {
printf("Command numer %zu: \n", i + 1);
argHelper->printf("Command numer %zu: \n", i + 1);
}
addAdditionalOptionsToSingleCommandLine(args, i);
@ -146,7 +146,7 @@ void MultiCommand::runBuilds(const std::string &argZero) {
}
void MultiCommand::printHelp() {
printf(R"===(Compiles multiple files using a config file.
argHelper->printf(R"===(Compiles multiple files using a config file.
Usage: ocloc multi <file_name>
<file_name> Input file containing a list of arguments for subsequent
@ -181,7 +181,7 @@ int MultiCommand::splitLineInSeparateArgs(std::vector<std::string> &qargs, const
end = (end == std::string::npos) ? commandsLine.length() : end;
}
if (end == std::string::npos) {
printf("One of the quotes is open in build number %zu\n", numberOfBuild + 1);
argHelper->printf("One of the quotes is open in build number %zu\n", numberOfBuild + 1);
return INVALID_FILE;
}
argLen = end - start;
@ -198,9 +198,9 @@ int MultiCommand::showResults() {
retValue |= retVal;
if (!quiet) {
if (retVal != SUCCESS) {
printf("Build %d: failed. Error code: %d\n", indexRetVal, retVal);
argHelper->printf("Build %d: failed. Error code: %d\n", indexRetVal, retVal);
} else {
printf("Build %d: successful\n", indexRetVal);
argHelper->printf("Build %d: successful\n", indexRetVal);
}
}
indexRetVal++;

View File

@ -17,8 +17,7 @@
using namespace NEO;
void printHelp() {
printf(R"===(ocloc is a tool for managing Intel Compute GPU device binary format.
const char *help = R"===(ocloc is a tool for managing Intel Compute GPU device binary format.
It can be used for generation (as part of 'compile' command) as well as
manipulation (decoding/modifying - as part of 'disasm'/'asm' commands) of such
binary files.
@ -51,8 +50,7 @@ Examples:
Assemble to Intel Compute GPU device binary (after above disasm)
ocloc asm -out reassembled.bin
)===");
}
)===";
extern "C" {
int oclocInvoke(unsigned int numArgs, const char *argv[],
@ -69,10 +67,10 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
}
try {
if (numArgs == 1 || (numArgs > 1 && (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")))) {
printHelp();
if (numArgs == 1 || (numArgs > 1 && (ConstStringRef("-h") == allArgs[1] || ConstStringRef("--help") == allArgs[1]))) {
helper->printf("%s", help);
return ErrorCode::SUCCESS;
} else if (numArgs > 1 && !strcmp(argv[1], "disasm")) {
} else if (numArgs > 1 && ConstStringRef("disasm") == allArgs[1]) {
BinaryDecoder disasm(helper.get());
int retVal = disasm.validateInput(allArgs);
if (retVal == 0) {
@ -80,7 +78,7 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
} else {
return retVal;
}
} else if (numArgs > 1 && !strcmp(argv[1], "asm")) {
} else if (numArgs > 1 && ConstStringRef("asm") == allArgs[1]) {
BinaryEncoder assembler(helper.get());
int retVal = assembler.validateInput(allArgs);
if (retVal == 0) {
@ -88,7 +86,7 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
} else {
return retVal;
}
} else if (numArgs > 1 && (!strcmp(argv[1], "multi") || !strcmp(argv[1], "-multi"))) {
} else if (numArgs > 1 && (ConstStringRef("multi") == allArgs[1] || ConstStringRef("-multi") == allArgs[1])) {
int retValue = ErrorCode::SUCCESS;
std::unique_ptr<MultiCommand> pMulti{(MultiCommand::create(allArgs, retValue, helper.get()))};
return retValue;
@ -103,20 +101,20 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
std::string buildLog = pCompiler->getBuildLog();
if (buildLog.empty() == false) {
printf("%s\n", buildLog.c_str());
helper->printf("%s\n", buildLog.c_str());
}
if (retVal == ErrorCode::SUCCESS) {
if (!pCompiler->isQuiet())
printf("Build succeeded.\n");
helper->printf("Build succeeded.\n");
} else {
printf("Build failed with error code: %d\n", retVal);
helper->printf("Build failed with error code: %d\n", retVal);
}
}
return retVal;
}
} catch (const std::exception &e) {
printf("%s\n", e.what());
helper->printf("%s\n", e.what());
return -1;
}
return -1;

View File

@ -6,6 +6,7 @@
*/
#include <cstdint>
#ifdef _WIN32
#define SIGNATURE __declspec(dllexport) int __cdecl
#else

View File

@ -10,10 +10,9 @@
#include "shared/source/helpers/file_io.h"
#include "shared/source/helpers/string.h"
#include "decoder/helper.h"
#include <cstring>
#include <sstream>
void Source::toVectorOfStrings(std::vector<std::string> &lines, bool replaceTabs) {
std::string line;
const char *file = reinterpret_cast<const char *>(data);
@ -56,6 +55,7 @@ OclocArgHelper::OclocArgHelper(const uint32_t numSources, const uint8_t **dataSo
OclocArgHelper::~OclocArgHelper() {
if (outputEnabled()) {
saveOutput(oclocStdoutLogName, messagePrinter.getLog());
moveOutputs();
}
}
@ -140,7 +140,7 @@ void OclocArgHelper::saveOutput(const std::string &filename, const void *pData,
}
}
void OclocArgHelper::saveOutput(const std::string &filename, std::ostream &stream) {
void OclocArgHelper::saveOutput(const std::string &filename, const std::ostream &stream) {
std::stringstream ss;
ss << stream.rdbuf();
if (outputEnabled()) {

View File

@ -5,6 +5,8 @@
*
*/
#include "shared/offline_compiler/source/decoder/helper.h"
#include <cctype>
#include <fstream>
#include <memory>
@ -13,6 +15,8 @@
#pragma once
static constexpr auto *oclocStdoutLogName = "stdout.log";
struct Source {
const uint8_t *data;
const size_t length;
@ -42,7 +46,7 @@ class OclocArgHelper {
uint64_t **lenOutputs = nullptr;
bool hasOutput = false;
void moveOutputs();
MessagePrinter messagePrinter;
Source *findSourceFile(const std::string &filename);
bool sourceFileExists(const std::string &filename) const;
@ -71,5 +75,14 @@ class OclocArgHelper {
inline bool outputEnabled() { return hasOutput; }
inline bool hasHeaders() { return headers.size() > 0; }
void saveOutput(const std::string &filename, const void *pData, const size_t &dataSize);
void saveOutput(const std::string &filename, std::ostream &stream);
void saveOutput(const std::string &filename, const std::ostream &stream);
MessagePrinter &getPrinterRef() { return messagePrinter; }
void printf(const char *message) {
messagePrinter.printf(message);
}
template <typename... Args>
void printf(const char *format, Args... args) {
messagePrinter.printf(format, std::forward<Args>(args)...);
}
};

View File

@ -79,7 +79,7 @@ void appendPlatformsForGfxCore(GFXCORE_FAMILY core, const std::vector<PRODUCT_FA
}
}
std::vector<ConstStringRef> getTargetPlatformsForFatbinary(ConstStringRef deviceArg) {
std::vector<ConstStringRef> getTargetPlatformsForFatbinary(ConstStringRef deviceArg, OclocArgHelper *argHelper) {
std::vector<PRODUCT_FAMILY> allSupportedPlatforms = getAllSupportedTargetPlatforms();
if (deviceArg == "*") {
return toProductNames(allSupportedPlatforms);
@ -93,7 +93,7 @@ std::vector<ConstStringRef> getTargetPlatformsForFatbinary(ConstStringRef device
if (set.contains("-")) {
auto range = CompilerOptions::tokenize(deviceArg, '-');
if (range.size() > 2) {
printf("Invalid range : %s - should be from-to or -to or from-\n", set.str().c_str());
argHelper->printf("Invalid range : %s - should be from-to or -to or from-\n", set.str().c_str());
return {};
}
@ -102,7 +102,7 @@ std::vector<ConstStringRef> getTargetPlatformsForFatbinary(ConstStringRef device
if (range[0].contains("gen")) {
auto coreId = asGfxCoreId(range[0]);
if (IGFX_UNKNOWN_CORE == coreId) {
printf("Unknown device : %s\n", set.str().c_str());
argHelper->printf("Unknown device : %s\n", set.str().c_str());
return {};
}
if ('-' == set[0]) {
@ -124,7 +124,7 @@ std::vector<ConstStringRef> getTargetPlatformsForFatbinary(ConstStringRef device
} else {
auto prodId = asProductId(range[0], allSupportedPlatforms);
if (IGFX_UNKNOWN == prodId) {
printf("Unknown device : %s\n", range[0].str().c_str());
argHelper->printf("Unknown device : %s\n", range[0].str().c_str());
return {};
}
auto prodIt = std::find(allSupportedPlatforms.begin(), allSupportedPlatforms.end(), prodId);
@ -140,17 +140,17 @@ std::vector<ConstStringRef> getTargetPlatformsForFatbinary(ConstStringRef device
} else {
if (range[0].contains("gen")) {
if (false == range[1].contains("gen")) {
printf("Ranges mixing platforms and gfxCores is not supported : %s - should be genFrom-genTo or platformFrom-platformTo\n", set.str().c_str());
argHelper->printf("Ranges mixing platforms and gfxCores is not supported : %s - should be genFrom-genTo or platformFrom-platformTo\n", set.str().c_str());
return {};
}
auto coreFrom = asGfxCoreId(range[0]);
auto coreTo = asGfxCoreId(range[1]);
if (IGFX_UNKNOWN_CORE == coreFrom) {
printf("Unknown device : %s\n", set.str().c_str());
argHelper->printf("Unknown device : %s\n", set.str().c_str());
return {};
}
if (IGFX_UNKNOWN_CORE == coreTo) {
printf("Unknown device : %s\n", set.str().c_str());
argHelper->printf("Unknown device : %s\n", set.str().c_str());
return {};
}
if (coreFrom > coreTo) {
@ -164,11 +164,11 @@ std::vector<ConstStringRef> getTargetPlatformsForFatbinary(ConstStringRef device
auto platformFrom = asProductId(range[0], allSupportedPlatforms);
auto platformTo = asProductId(range[1], allSupportedPlatforms);
if (IGFX_UNKNOWN == platformFrom) {
printf("Unknown device : %s\n", set.str().c_str());
argHelper->printf("Unknown device : %s\n", set.str().c_str());
return {};
}
if (IGFX_UNKNOWN == platformTo) {
printf("Unknown device : %s\n", set.str().c_str());
argHelper->printf("Unknown device : %s\n", set.str().c_str());
return {};
}
if (platformFrom > platformTo) {
@ -182,11 +182,11 @@ std::vector<ConstStringRef> getTargetPlatformsForFatbinary(ConstStringRef device
}
} else if (set.contains("gen")) {
if (set.size() == genArg.size()) {
printf("Invalid gen-based device : %s - gen should be followed by a number\n", set.str().c_str());
argHelper->printf("Invalid gen-based device : %s - gen should be followed by a number\n", set.str().c_str());
} else {
auto coreId = asGfxCoreId(set);
if (IGFX_UNKNOWN_CORE == coreId) {
printf("Unknown device : %s\n", set.str().c_str());
argHelper->printf("Unknown device : %s\n", set.str().c_str());
return {};
}
appendPlatformsForGfxCore(coreId, allSupportedPlatforms, requestedPlatforms);
@ -194,7 +194,7 @@ std::vector<ConstStringRef> getTargetPlatformsForFatbinary(ConstStringRef device
} else {
auto prodId = asProductId(set, allSupportedPlatforms);
if (IGFX_UNKNOWN == prodId) {
printf("Unknown device : %s\n", set.str().c_str());
argHelper->printf("Unknown device : %s\n", set.str().c_str());
return {};
}
requestedPlatforms.push_back(prodId);
@ -203,7 +203,7 @@ std::vector<ConstStringRef> getTargetPlatformsForFatbinary(ConstStringRef device
return toProductNames(requestedPlatforms);
}
int buildFatbinary(int argc, const char *argv[], OclocArgHelper *helper) {
int buildFatbinary(int argc, const char *argv[], OclocArgHelper *argHelper) {
std::string pointerSizeInBits = (sizeof(void *) == 4) ? "32" : "64";
int deviceArgIndex = -1;
std::string inputFileName = "";
@ -238,9 +238,9 @@ int buildFatbinary(int argc, const char *argv[], OclocArgHelper *helper) {
}
std::vector<ConstStringRef> targetPlatforms;
targetPlatforms = getTargetPlatformsForFatbinary(ConstStringRef(argv[deviceArgIndex], strlen(argv[deviceArgIndex])));
targetPlatforms = getTargetPlatformsForFatbinary(ConstStringRef(argv[deviceArgIndex], strlen(argv[deviceArgIndex])), argHelper);
if (targetPlatforms.empty()) {
printf("Failed to parse target devices from : %s\n", argv[deviceArgIndex]);
argHelper->printf("Failed to parse target devices from : %s\n", argv[deviceArgIndex]);
return 1;
}
@ -249,29 +249,31 @@ int buildFatbinary(int argc, const char *argv[], OclocArgHelper *helper) {
for (auto targetPlatform : targetPlatforms) {
int retVal = 0;
argsCopy[deviceArgIndex] = targetPlatform.str();
std::unique_ptr<OfflineCompiler> pCompiler{OfflineCompiler::create(argc, argsCopy, false, retVal, helper)};
std::unique_ptr<OfflineCompiler> pCompiler{OfflineCompiler::create(argc, argsCopy, false, retVal, argHelper)};
if (ErrorCode::SUCCESS != retVal) {
printf("Error! Couldn't create OfflineCompiler. Exiting.\n");
argHelper->printf("Error! Couldn't create OfflineCompiler. Exiting.\n");
return retVal;
}
auto stepping = pCompiler->getHardwareInfo().platform.usRevId;
if (retVal == 0) {
retVal = buildWithSafetyGuard(pCompiler.get());
std::string buildLog = pCompiler->getBuildLog();
if (buildLog.empty() == false) {
printf("%s\n", buildLog.c_str());
argHelper->printf("%s\n", buildLog.c_str());
}
if (retVal == 0) {
if (!pCompiler->isQuiet())
printf("Build succeeded for : %s.\n", (targetPlatform.str() + "." + std::to_string(stepping)).c_str());
argHelper->printf("Build succeeded for : %s.\n", (targetPlatform.str() + "." + std::to_string(stepping)).c_str());
} else {
printf("Build failed for : %s with error code: %d\n", (targetPlatform.str() + "." + std::to_string(stepping)).c_str(), retVal);
printf("Command was:");
argHelper->printf("Build failed for : %s with error code: %d\n", (targetPlatform.str() + "." + std::to_string(stepping)).c_str(), retVal);
argHelper->printf("Command was:");
for (auto i = 0; i < argc; ++i)
printf(" %s", argv[i]);
printf("\n");
argHelper->printf(" %s", argv[i]);
argHelper->printf("\n");
}
}
@ -290,7 +292,7 @@ int buildFatbinary(int argc, const char *argv[], OclocArgHelper *helper) {
if (false == outputDirectory.empty()) {
fatbinaryFileName = outputDirectory + "/" + outputFileName;
}
helper->saveOutput(fatbinaryFileName, fatbinaryData.data(), fatbinaryData.size());
argHelper->saveOutput(fatbinaryFileName, fatbinaryData.data(), fatbinaryData.size());
return 0;
}

View File

@ -18,13 +18,13 @@ namespace NEO {
bool requestedFatBinary(int argc, const char *argv[]);
int buildFatbinary(int argc, const char *argv[], OclocArgHelper *helper);
int buildFatbinary(int argc, const char *argv[], OclocArgHelper *argHelper);
std::vector<PRODUCT_FAMILY> getAllSupportedTargetPlatforms();
std::vector<ConstStringRef> toProductNames(const std::vector<PRODUCT_FAMILY> &productIds);
PRODUCT_FAMILY asProductId(ConstStringRef product, const std::vector<PRODUCT_FAMILY> &allSupportedPlatforms);
GFXCORE_FAMILY asGfxCoreId(ConstStringRef core);
void appendPlatformsForGfxCore(GFXCORE_FAMILY core, const std::vector<PRODUCT_FAMILY> &allSupportedPlatforms, std::vector<PRODUCT_FAMILY> &out);
std::vector<ConstStringRef> getTargetPlatformsForFatbinary(ConstStringRef deviceArg);
std::vector<ConstStringRef> getTargetPlatformsForFatbinary(ConstStringRef deviceArg, OclocArgHelper *argHelper);
} // namespace NEO

View File

@ -259,7 +259,7 @@ int OfflineCompiler::initialize(size_t numArgs, const std::vector<std::string> &
std::string oclocOptionsFromFile;
bool oclocOptionsRead = readOptionsFromFile(oclocOptionsFromFile, oclocOptionsFileName, argHelper);
if (oclocOptionsRead && !isQuiet()) {
printf("Building with ocloc options:\n%s\n", oclocOptionsFromFile.c_str());
argHelper->printf("Building with ocloc options:\n%s\n", oclocOptionsFromFile.c_str());
}
if (oclocOptionsRead) {
@ -278,7 +278,7 @@ int OfflineCompiler::initialize(size_t numArgs, const std::vector<std::string> &
bool optionsRead = readOptionsFromFile(options, optionsFileName, argHelper);
if (optionsRead && !isQuiet()) {
printf("Building with options:\n%s\n", options.c_str());
argHelper->printf("Building with options:\n%s\n", options.c_str());
}
std::string internalOptionsFileName = inputFile.substr(0, ext_start);
@ -287,7 +287,7 @@ int OfflineCompiler::initialize(size_t numArgs, const std::vector<std::string> &
std::string internalOptionsFromFile;
bool internalOptionsRead = readOptionsFromFile(internalOptionsFromFile, internalOptionsFileName, argHelper);
if (internalOptionsRead && !isQuiet()) {
printf("Building with internal options:\n%s\n", internalOptionsFromFile.c_str());
argHelper->printf("Building with internal options:\n%s\n", internalOptionsFromFile.c_str());
}
CompilerOptions::concatenateAppend(internalOptions, internalOptionsFromFile);
}
@ -314,7 +314,7 @@ int OfflineCompiler::initialize(size_t numArgs, const std::vector<std::string> &
if ((inputFileSpirV == false) && (inputFileLlvm == false)) {
auto fclLibFile = OsLibrary::load(Os::frontEndDllName);
if (fclLibFile == nullptr) {
printf("Error: Failed to load %s\n", Os::frontEndDllName);
argHelper->printf("Error: Failed to load %s\n", Os::frontEndDllName);
return OUT_OF_HOST_MEMORY;
}
@ -334,7 +334,7 @@ int OfflineCompiler::initialize(size_t numArgs, const std::vector<std::string> &
}
if (false == this->fclMain->IsCompatible<IGC::FclOclDeviceCtx>()) {
printf("Incompatible interface in FCL : %s\n", CIF::InterfaceIdCoder::Dec(this->fclMain->FindIncompatible<IGC::FclOclDeviceCtx>()).c_str());
argHelper->printf("Incompatible interface in FCL : %s\n", CIF::InterfaceIdCoder::Dec(this->fclMain->FindIncompatible<IGC::FclOclDeviceCtx>()).c_str());
DEBUG_BREAK_IF(true);
return OUT_OF_HOST_MEMORY;
}
@ -348,7 +348,7 @@ int OfflineCompiler::initialize(size_t numArgs, const std::vector<std::string> &
preferredIntermediateRepresentation = fclDeviceCtx->GetPreferredIntermediateRepresentation();
} else {
if (!isQuiet()) {
printf("Compilation from IR - skipping loading of FCL\n");
argHelper->printf("Compilation from IR - skipping loading of FCL\n");
}
preferredIntermediateRepresentation = IGC::CodeType::spirV;
}
@ -370,14 +370,14 @@ int OfflineCompiler::initialize(size_t numArgs, const std::vector<std::string> &
std::vector<CIF::InterfaceId_t> interfacesToIgnore = {IGC::OclGenBinaryBase::GetInterfaceId()};
if (false == this->igcMain->IsCompatible<IGC::IgcOclDeviceCtx>(&interfacesToIgnore)) {
printf("Incompatible interface in IGC : %s\n", CIF::InterfaceIdCoder::Dec(this->igcMain->FindIncompatible<IGC::IgcOclDeviceCtx>(&interfacesToIgnore)).c_str());
argHelper->printf("Incompatible interface in IGC : %s\n", CIF::InterfaceIdCoder::Dec(this->igcMain->FindIncompatible<IGC::IgcOclDeviceCtx>(&interfacesToIgnore)).c_str());
DEBUG_BREAK_IF(true);
return OUT_OF_HOST_MEMORY;
}
CIF::Version_t verMin = 0, verMax = 0;
if (false == this->igcMain->FindSupportedVersions<IGC::IgcOclDeviceCtx>(IGC::OclGenBinaryBase::GetInterfaceId(), verMin, verMax)) {
printf("Patchtoken interface is missing");
argHelper->printf("Patchtoken interface is missing");
return OUT_OF_HOST_MEMORY;
}
@ -485,6 +485,7 @@ int OfflineCompiler::parseCommandLine(size_t numArgs, const std::vector<std::str
outputDirectory = argv[argIndex + 1];
argIndex++;
} else if ("-q" == currArg) {
argHelper->getPrinterRef() = MessagePrinter(true);
quiet = true;
} else if ("-output_no_suffix" == currArg) {
outputNoSuffix = true;
@ -492,7 +493,7 @@ int OfflineCompiler::parseCommandLine(size_t numArgs, const std::vector<std::str
printUsage();
retVal = PRINT_USAGE;
} else {
printf("Invalid option (arg %d): %s\n", argIndex, argv[argIndex].c_str());
argHelper->printf("Invalid option (arg %d): %s\n", argIndex, argv[argIndex].c_str());
retVal = INVALID_COMMAND_LINE;
break;
}
@ -500,21 +501,21 @@ int OfflineCompiler::parseCommandLine(size_t numArgs, const std::vector<std::str
if (retVal == SUCCESS) {
if (compile32 && compile64) {
printf("Error: Cannot compile for 32-bit and 64-bit, please choose one.\n");
argHelper->printf("Error: Cannot compile for 32-bit and 64-bit, please choose one.\n");
retVal = INVALID_COMMAND_LINE;
} else if (inputFile.empty()) {
printf("Error: Input file name missing.\n");
argHelper->printf("Error: Input file name missing.\n");
retVal = INVALID_COMMAND_LINE;
} else if (deviceName.empty()) {
printf("Error: Device name missing.\n");
argHelper->printf("Error: Device name missing.\n");
retVal = INVALID_COMMAND_LINE;
} else if (!argHelper->fileExists(inputFile)) {
printf("Error: Input file %s missing.\n", inputFile.c_str());
argHelper->printf("Error: Input file %s missing.\n", inputFile.c_str());
retVal = INVALID_FILE;
} else {
retVal = getHardwareInfo(deviceName.c_str());
if (retVal != SUCCESS) {
printf("Error: Cannot get HW Info for device %s.\n", deviceName.c_str());
argHelper->printf("Error: Cannot get HW Info for device %s.\n", deviceName.c_str());
} else {
std::string extensionsList = getExtensionsList(*hwInfo);
CompilerOptions::concatenateAppend(internalOptions, convertEnabledExtensionsToCompilerInternalOptions(extensionsList.c_str()));
@ -622,7 +623,7 @@ std::string getDevicesTypes() {
}
void OfflineCompiler::printUsage() {
printf(R"===(Compiles input file to Intel Compute GPU device binary (*.bin).
argHelper->printf(R"===(Compiles input file to Intel Compute GPU device binary (*.bin).
Additionally, outputs intermediate representation (e.g. spirV).
Different input and intermediate file formats are available.
@ -731,7 +732,7 @@ Examples :
Compile file to Intel Compute GPU device binary (out = source_file_Gen9core.bin)
ocloc -file source_file.cl -device skl
)===",
NEO::getDevicesTypes().c_str());
NEO::getDevicesTypes().c_str());
}
void OfflineCompiler::storeBinary(