mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 07:14:10 +08:00
ocloc - argHelper support for MultiCommand and FatBinary
Change-Id: If4a4e6292609ce544a6534ebd4937ffe1cc09e67
This commit is contained in:
@@ -18,9 +18,9 @@ set(IGDRCL_SRCS_offline_compiler_mock
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/decoder/mock/mock_decoder.h
|
${CMAKE_CURRENT_SOURCE_DIR}/decoder/mock/mock_decoder.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/decoder/mock/mock_encoder.h
|
${CMAKE_CURRENT_SOURCE_DIR}/decoder/mock/mock_encoder.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/decoder/mock/mock_iga_wrapper.h
|
${CMAKE_CURRENT_SOURCE_DIR}/decoder/mock/mock_iga_wrapper.h
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/mock/mock_argument_helper.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mock/mock_offline_compiler.h
|
${CMAKE_CURRENT_SOURCE_DIR}/mock/mock_offline_compiler.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mock/mock_sip_ocloc_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/mock/mock_sip_ocloc_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/mock/mock_argument_helper.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(CLOC_LIB_SRCS_UTILITIES
|
set(CLOC_LIB_SRCS_UTILITIES
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ struct MockDecoder : public BinaryDecoder {
|
|||||||
: BinaryDecoder(file, patch, dump) {
|
: BinaryDecoder(file, patch, dump) {
|
||||||
this->iga.reset(new MockIgaWrapper);
|
this->iga.reset(new MockIgaWrapper);
|
||||||
setMessagePrinter(MessagePrinter{true});
|
setMessagePrinter(MessagePrinter{true});
|
||||||
argHelper = std::make_unique<OclocArgHelper>();
|
uniqueHelper = std::make_unique<OclocArgHelper>();
|
||||||
|
argHelper = uniqueHelper.get();
|
||||||
};
|
};
|
||||||
using BinaryDecoder::binaryFile;
|
using BinaryDecoder::binaryFile;
|
||||||
using BinaryDecoder::decode;
|
using BinaryDecoder::decode;
|
||||||
@@ -34,6 +35,8 @@ struct MockDecoder : public BinaryDecoder {
|
|||||||
using BinaryDecoder::readPatchTokens;
|
using BinaryDecoder::readPatchTokens;
|
||||||
using BinaryDecoder::readStructFields;
|
using BinaryDecoder::readStructFields;
|
||||||
|
|
||||||
|
std::unique_ptr<OclocArgHelper> uniqueHelper;
|
||||||
|
|
||||||
MockIgaWrapper *getMockIga() const {
|
MockIgaWrapper *getMockIga() const {
|
||||||
return static_cast<MockIgaWrapper *>(iga.get());
|
return static_cast<MockIgaWrapper *>(iga.get());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ struct MockEncoder : public BinaryEncoder {
|
|||||||
: BinaryEncoder(dump, elf) {
|
: BinaryEncoder(dump, elf) {
|
||||||
this->iga.reset(new MockIgaWrapper);
|
this->iga.reset(new MockIgaWrapper);
|
||||||
setMessagePrinter(MessagePrinter{true});
|
setMessagePrinter(MessagePrinter{true});
|
||||||
this->argHelper.reset(new MockOclocArgHelper(filesMap));
|
uniqueHelper = std::make_unique<MockOclocArgHelper>(filesMap);
|
||||||
|
argHelper = uniqueHelper.get();
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<std::string, std::string> filesMap;
|
std::map<std::string, std::string> filesMap;
|
||||||
@@ -51,6 +52,8 @@ struct MockEncoder : public BinaryEncoder {
|
|||||||
using BinaryEncoder::write;
|
using BinaryEncoder::write;
|
||||||
using BinaryEncoder::writeDeviceBinary;
|
using BinaryEncoder::writeDeviceBinary;
|
||||||
|
|
||||||
|
std::unique_ptr<OclocArgHelper> uniqueHelper;
|
||||||
|
|
||||||
MockIgaWrapper *getMockIga() const {
|
MockIgaWrapper *getMockIga() const {
|
||||||
return static_cast<MockIgaWrapper *>(iga.get());
|
return static_cast<MockIgaWrapper *>(iga.get());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ class MockOfflineCompiler : public OfflineCompiler {
|
|||||||
using OfflineCompiler::useOptionsSuffix;
|
using OfflineCompiler::useOptionsSuffix;
|
||||||
|
|
||||||
MockOfflineCompiler() : OfflineCompiler() {
|
MockOfflineCompiler() : OfflineCompiler() {
|
||||||
argHelper.reset(new OclocArgHelper(
|
uniqueHelper = std::make_unique<OclocArgHelper>();
|
||||||
0, nullptr, nullptr, nullptr, 0, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr));
|
argHelper = uniqueHelper.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
int initialize(size_t numArgs, const std::vector<std::string> &argv) {
|
int initialize(size_t numArgs, const std::vector<std::string> &argv) {
|
||||||
@@ -90,5 +90,7 @@ class MockOfflineCompiler : public OfflineCompiler {
|
|||||||
size_t getGenBinarySize() {
|
size_t getGenBinarySize() {
|
||||||
return genBinarySize;
|
return genBinarySize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<OclocArgHelper> uniqueHelper;
|
||||||
};
|
};
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ TEST_F(MultiCommandTests, MultiCommandSuccessfulBuildTest) {
|
|||||||
int numOfBuild = 4;
|
int numOfBuild = 4;
|
||||||
createFileWithArgs(singleArgs, numOfBuild);
|
createFileWithArgs(singleArgs, numOfBuild);
|
||||||
|
|
||||||
auto pMultiCommand = std::unique_ptr<MultiCommand>(MultiCommand::create(argv, retVal));
|
auto pMultiCommand = std::unique_ptr<MultiCommand>(MultiCommand::create(argv, retVal, uniqueHelper.get()));
|
||||||
|
|
||||||
EXPECT_NE(nullptr, pMultiCommand);
|
EXPECT_NE(nullptr, pMultiCommand);
|
||||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||||
@@ -87,7 +87,7 @@ TEST_F(MultiCommandTests, MultiCommandSuccessfulBuildWithOutputFileTest) {
|
|||||||
int numOfBuild = 4;
|
int numOfBuild = 4;
|
||||||
createFileWithArgs(singleArgs, numOfBuild);
|
createFileWithArgs(singleArgs, numOfBuild);
|
||||||
|
|
||||||
auto pMultiCommand = std::unique_ptr<MultiCommand>(MultiCommand::create(argv, retVal));
|
auto pMultiCommand = std::unique_ptr<MultiCommand>(MultiCommand::create(argv, retVal, uniqueHelper.get()));
|
||||||
|
|
||||||
EXPECT_NE(nullptr, pMultiCommand);
|
EXPECT_NE(nullptr, pMultiCommand);
|
||||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||||
@@ -99,11 +99,6 @@ TEST_F(MultiCommandTests, MultiCommandSuccessfulBuildWithOutputFileTest) {
|
|||||||
EXPECT_TRUE(compilerOutputExists(outFileName, "bin"));
|
EXPECT_TRUE(compilerOutputExists(outFileName, "bin"));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (OfflineCompiler *pSingle : pMultiCommand->singleBuilds) {
|
|
||||||
std::string buildLog = pSingle->getBuildLog();
|
|
||||||
EXPECT_STREQ(buildLog.c_str(), "");
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteFileWithArgs();
|
deleteFileWithArgs();
|
||||||
}
|
}
|
||||||
TEST_F(MultiCommandTests, GoodMultiBuildTestWithspecifiedOutputDir) {
|
TEST_F(MultiCommandTests, GoodMultiBuildTestWithspecifiedOutputDir) {
|
||||||
@@ -126,7 +121,7 @@ TEST_F(MultiCommandTests, GoodMultiBuildTestWithspecifiedOutputDir) {
|
|||||||
int numOfBuild = 4;
|
int numOfBuild = 4;
|
||||||
createFileWithArgs(singleArgs, numOfBuild);
|
createFileWithArgs(singleArgs, numOfBuild);
|
||||||
|
|
||||||
pMultiCommand = MultiCommand::create(argv, retVal);
|
pMultiCommand = MultiCommand::create(argv, retVal, uniqueHelper.get());
|
||||||
|
|
||||||
EXPECT_NE(nullptr, pMultiCommand);
|
EXPECT_NE(nullptr, pMultiCommand);
|
||||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||||
@@ -151,12 +146,12 @@ TEST_F(MultiCommandTests, LackOfTxtFileWithArgsMultiTest) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
testing::internal::CaptureStdout();
|
testing::internal::CaptureStdout();
|
||||||
auto pMultiCommand = std::unique_ptr<MultiCommand>(MultiCommand::create(argv, retVal));
|
auto pMultiCommand = std::unique_ptr<MultiCommand>(MultiCommand::create(argv, retVal, uniqueHelper.get()));
|
||||||
std::string output = testing::internal::GetCapturedStdout();
|
std::string output = testing::internal::GetCapturedStdout();
|
||||||
|
|
||||||
EXPECT_STRNE(output.c_str(), "");
|
EXPECT_STRNE(output.c_str(), "");
|
||||||
EXPECT_EQ(nullptr, pMultiCommand);
|
EXPECT_EQ(nullptr, pMultiCommand);
|
||||||
EXPECT_EQ(INVALID_COMMAND_LINE, retVal);
|
EXPECT_EQ(INVALID_FILE, retVal);
|
||||||
DebugManager.flags.PrintDebugMessages.set(false);
|
DebugManager.flags.PrintDebugMessages.set(false);
|
||||||
}
|
}
|
||||||
TEST_F(MultiCommandTests, LackOfClFilePointedInTxtFileMultiTest) {
|
TEST_F(MultiCommandTests, LackOfClFilePointedInTxtFileMultiTest) {
|
||||||
@@ -177,7 +172,7 @@ TEST_F(MultiCommandTests, LackOfClFilePointedInTxtFileMultiTest) {
|
|||||||
int numOfBuild = 4;
|
int numOfBuild = 4;
|
||||||
createFileWithArgs(singleArgs, numOfBuild);
|
createFileWithArgs(singleArgs, numOfBuild);
|
||||||
testing::internal::CaptureStdout();
|
testing::internal::CaptureStdout();
|
||||||
auto pMultiCommand = std::unique_ptr<MultiCommand>(MultiCommand::create(argv, retVal));
|
auto pMultiCommand = std::unique_ptr<MultiCommand>(MultiCommand::create(argv, retVal, uniqueHelper.get()));
|
||||||
std::string output = testing::internal::GetCapturedStdout();
|
std::string output = testing::internal::GetCapturedStdout();
|
||||||
|
|
||||||
EXPECT_STRNE(output.c_str(), "");
|
EXPECT_STRNE(output.c_str(), "");
|
||||||
@@ -207,7 +202,7 @@ TEST_F(MultiCommandTests, GoodMultiBuildTestWithOutputFileListFlag) {
|
|||||||
int numOfBuild = 4;
|
int numOfBuild = 4;
|
||||||
createFileWithArgs(singleArgs, numOfBuild);
|
createFileWithArgs(singleArgs, numOfBuild);
|
||||||
|
|
||||||
pMultiCommand = MultiCommand::create(argv, retVal);
|
pMultiCommand = MultiCommand::create(argv, retVal, uniqueHelper.get());
|
||||||
|
|
||||||
EXPECT_NE(nullptr, pMultiCommand);
|
EXPECT_NE(nullptr, pMultiCommand);
|
||||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||||
@@ -233,7 +228,7 @@ TEST_F(OfflineCompilerTests, GoodArgTest) {
|
|||||||
"-device",
|
"-device",
|
||||||
gEnvironment->devicePrefix.c_str()};
|
gEnvironment->devicePrefix.c_str()};
|
||||||
|
|
||||||
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal);
|
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
|
||||||
|
|
||||||
EXPECT_NE(nullptr, pOfflineCompiler);
|
EXPECT_NE(nullptr, pOfflineCompiler);
|
||||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||||
@@ -262,7 +257,7 @@ TEST_F(OfflineCompilerTests, GoodBuildTest) {
|
|||||||
"-device",
|
"-device",
|
||||||
gEnvironment->devicePrefix.c_str()};
|
gEnvironment->devicePrefix.c_str()};
|
||||||
|
|
||||||
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal);
|
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
|
||||||
|
|
||||||
EXPECT_NE(nullptr, pOfflineCompiler);
|
EXPECT_NE(nullptr, pOfflineCompiler);
|
||||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||||
@@ -290,7 +285,7 @@ TEST_F(OfflineCompilerTests, GoodBuildTestWithLlvmText) {
|
|||||||
gEnvironment->devicePrefix.c_str(),
|
gEnvironment->devicePrefix.c_str(),
|
||||||
"-llvm_text"};
|
"-llvm_text"};
|
||||||
|
|
||||||
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal);
|
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
|
||||||
|
|
||||||
EXPECT_NE(nullptr, pOfflineCompiler);
|
EXPECT_NE(nullptr, pOfflineCompiler);
|
||||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||||
@@ -328,7 +323,7 @@ TEST_F(OfflineCompilerTests, GoodParseBinToCharArray) {
|
|||||||
"-device",
|
"-device",
|
||||||
gEnvironment->devicePrefix.c_str()};
|
gEnvironment->devicePrefix.c_str()};
|
||||||
|
|
||||||
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal);
|
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
|
||||||
// clang-format off
|
// clang-format off
|
||||||
uint8_t binary[] = {
|
uint8_t binary[] = {
|
||||||
0x02, 0x23, 0x3, 0x40, 0x56, 0x7, 0x80, 0x90, 0x1, 0x03,
|
0x02, 0x23, 0x3, 0x40, 0x56, 0x7, 0x80, 0x90, 0x1, 0x03,
|
||||||
@@ -372,7 +367,7 @@ TEST_F(OfflineCompilerTests, GoodBuildTestWithCppFile) {
|
|||||||
gEnvironment->devicePrefix.c_str(),
|
gEnvironment->devicePrefix.c_str(),
|
||||||
"-cpp_file"};
|
"-cpp_file"};
|
||||||
|
|
||||||
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal);
|
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
|
||||||
|
|
||||||
EXPECT_NE(nullptr, pOfflineCompiler);
|
EXPECT_NE(nullptr, pOfflineCompiler);
|
||||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||||
@@ -396,7 +391,7 @@ TEST_F(OfflineCompilerTests, GoodBuildTestWithOutputDir) {
|
|||||||
"-out_dir",
|
"-out_dir",
|
||||||
"offline_compiler_test"};
|
"offline_compiler_test"};
|
||||||
|
|
||||||
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal);
|
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
|
||||||
|
|
||||||
EXPECT_NE(nullptr, pOfflineCompiler);
|
EXPECT_NE(nullptr, pOfflineCompiler);
|
||||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||||
@@ -415,7 +410,7 @@ TEST_F(OfflineCompilerTests, PrintUsage) {
|
|||||||
"--help"};
|
"--help"};
|
||||||
|
|
||||||
testing::internal::CaptureStdout();
|
testing::internal::CaptureStdout();
|
||||||
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal);
|
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
|
||||||
std::string output = testing::internal::GetCapturedStdout();
|
std::string output = testing::internal::GetCapturedStdout();
|
||||||
EXPECT_EQ(nullptr, pOfflineCompiler);
|
EXPECT_EQ(nullptr, pOfflineCompiler);
|
||||||
EXPECT_STRNE("", output.c_str());
|
EXPECT_STRNE("", output.c_str());
|
||||||
@@ -433,7 +428,7 @@ TEST_F(OfflineCompilerTests, NaughtyArgTest_File) {
|
|||||||
gEnvironment->devicePrefix.c_str()};
|
gEnvironment->devicePrefix.c_str()};
|
||||||
|
|
||||||
testing::internal::CaptureStdout();
|
testing::internal::CaptureStdout();
|
||||||
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal);
|
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
|
||||||
std::string output = testing::internal::GetCapturedStdout();
|
std::string output = testing::internal::GetCapturedStdout();
|
||||||
EXPECT_STRNE(output.c_str(), "");
|
EXPECT_STRNE(output.c_str(), "");
|
||||||
EXPECT_EQ(nullptr, pOfflineCompiler);
|
EXPECT_EQ(nullptr, pOfflineCompiler);
|
||||||
@@ -451,7 +446,7 @@ TEST_F(OfflineCompilerTests, NaughtyArgTest_Flag) {
|
|||||||
gEnvironment->devicePrefix.c_str()};
|
gEnvironment->devicePrefix.c_str()};
|
||||||
|
|
||||||
testing::internal::CaptureStdout();
|
testing::internal::CaptureStdout();
|
||||||
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal);
|
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
|
||||||
std::string output = testing::internal::GetCapturedStdout();
|
std::string output = testing::internal::GetCapturedStdout();
|
||||||
EXPECT_STRNE(output.c_str(), "");
|
EXPECT_STRNE(output.c_str(), "");
|
||||||
EXPECT_EQ(nullptr, pOfflineCompiler);
|
EXPECT_EQ(nullptr, pOfflineCompiler);
|
||||||
@@ -467,7 +462,7 @@ TEST_F(OfflineCompilerTests, NaughtyArgTest_NumArgs) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
testing::internal::CaptureStdout();
|
testing::internal::CaptureStdout();
|
||||||
pOfflineCompiler = OfflineCompiler::create(argvA.size(), argvA, true, retVal);
|
pOfflineCompiler = OfflineCompiler::create(argvA.size(), argvA, true, retVal, uniqueHelper.get());
|
||||||
std::string output = testing::internal::GetCapturedStdout();
|
std::string output = testing::internal::GetCapturedStdout();
|
||||||
EXPECT_STRNE(output.c_str(), "");
|
EXPECT_STRNE(output.c_str(), "");
|
||||||
|
|
||||||
@@ -482,7 +477,7 @@ TEST_F(OfflineCompilerTests, NaughtyArgTest_NumArgs) {
|
|||||||
"test_files/ImANaughtyFile.cl",
|
"test_files/ImANaughtyFile.cl",
|
||||||
"-device"};
|
"-device"};
|
||||||
testing::internal::CaptureStdout();
|
testing::internal::CaptureStdout();
|
||||||
pOfflineCompiler = OfflineCompiler::create(argvB.size(), argvB, true, retVal);
|
pOfflineCompiler = OfflineCompiler::create(argvB.size(), argvB, true, retVal, uniqueHelper.get());
|
||||||
output = testing::internal::GetCapturedStdout();
|
output = testing::internal::GetCapturedStdout();
|
||||||
EXPECT_STRNE(output.c_str(), "");
|
EXPECT_STRNE(output.c_str(), "");
|
||||||
EXPECT_EQ(nullptr, pOfflineCompiler);
|
EXPECT_EQ(nullptr, pOfflineCompiler);
|
||||||
@@ -500,7 +495,7 @@ TEST_F(OfflineCompilerTests, GivenNonexistantDeviceWhenCompilingThenExitWithErro
|
|||||||
"foobar"};
|
"foobar"};
|
||||||
|
|
||||||
testing::internal::CaptureStdout();
|
testing::internal::CaptureStdout();
|
||||||
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal);
|
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
|
||||||
std::string output = testing::internal::GetCapturedStdout();
|
std::string output = testing::internal::GetCapturedStdout();
|
||||||
EXPECT_STREQ(output.c_str(), "Error: Cannot get HW Info for device foobar.\n");
|
EXPECT_STREQ(output.c_str(), "Error: Cannot get HW Info for device foobar.\n");
|
||||||
EXPECT_EQ(nullptr, pOfflineCompiler);
|
EXPECT_EQ(nullptr, pOfflineCompiler);
|
||||||
@@ -515,7 +510,7 @@ TEST_F(OfflineCompilerTests, NaughtyKernelTest) {
|
|||||||
"-device",
|
"-device",
|
||||||
gEnvironment->devicePrefix.c_str()};
|
gEnvironment->devicePrefix.c_str()};
|
||||||
|
|
||||||
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal);
|
pOfflineCompiler = OfflineCompiler::create(argv.size(), argv, true, retVal, uniqueHelper.get());
|
||||||
|
|
||||||
EXPECT_NE(nullptr, pOfflineCompiler);
|
EXPECT_NE(nullptr, pOfflineCompiler);
|
||||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||||
@@ -1052,7 +1047,7 @@ TEST(OfflineCompilerTest, givenNonExistingFilenameWhenUsedToReadOptionsThenReadO
|
|||||||
ASSERT_FALSE(fileExists(file.c_str()));
|
ASSERT_FALSE(fileExists(file.c_str()));
|
||||||
|
|
||||||
auto helper = std::make_unique<OclocArgHelper>();
|
auto helper = std::make_unique<OclocArgHelper>();
|
||||||
bool result = OfflineCompiler::readOptionsFromFile(options, file, helper);
|
bool result = OfflineCompiler::readOptionsFromFile(options, file, helper.get());
|
||||||
|
|
||||||
EXPECT_FALSE(result);
|
EXPECT_FALSE(result);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include <CL/cl.h>
|
#include <CL/cl.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
|
||||||
@@ -20,17 +21,20 @@ class OfflineCompilerTests : public ::testing::Test {
|
|||||||
public:
|
public:
|
||||||
OfflineCompilerTests() : pOfflineCompiler(nullptr),
|
OfflineCompilerTests() : pOfflineCompiler(nullptr),
|
||||||
retVal(CL_SUCCESS) {
|
retVal(CL_SUCCESS) {
|
||||||
|
uniqueHelper = std::make_unique<OclocArgHelper>();
|
||||||
// ctor
|
// ctor
|
||||||
}
|
}
|
||||||
|
|
||||||
OfflineCompiler *pOfflineCompiler;
|
OfflineCompiler *pOfflineCompiler;
|
||||||
int retVal;
|
int retVal;
|
||||||
|
std::unique_ptr<OclocArgHelper> uniqueHelper;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MultiCommandTests : public ::testing::Test {
|
class MultiCommandTests : public ::testing::Test {
|
||||||
public:
|
public:
|
||||||
MultiCommandTests() : pMultiCommand(nullptr),
|
MultiCommandTests() : pMultiCommand(nullptr),
|
||||||
retVal(CL_SUCCESS) {
|
retVal(CL_SUCCESS) {
|
||||||
|
uniqueHelper = std::make_unique<OclocArgHelper>();
|
||||||
}
|
}
|
||||||
void createFileWithArgs(const std::vector<std::string> &, int numOfBuild);
|
void createFileWithArgs(const std::vector<std::string> &, int numOfBuild);
|
||||||
void deleteFileWithArgs();
|
void deleteFileWithArgs();
|
||||||
@@ -39,6 +43,7 @@ class MultiCommandTests : public ::testing::Test {
|
|||||||
std::string nameOfFileWithArgs;
|
std::string nameOfFileWithArgs;
|
||||||
std::string outFileList;
|
std::string outFileList;
|
||||||
int retVal;
|
int retVal;
|
||||||
|
std::unique_ptr<OclocArgHelper> uniqueHelper;
|
||||||
};
|
};
|
||||||
|
|
||||||
void MultiCommandTests::createFileWithArgs(const std::vector<std::string> &singleArgs, int numOfBuild) {
|
void MultiCommandTests::createFileWithArgs(const std::vector<std::string> &singleArgs, int numOfBuild) {
|
||||||
|
|||||||
@@ -32,15 +32,9 @@ using PTMap = std::unordered_map<uint8_t, std::unique_ptr<PatchToken>>;
|
|||||||
|
|
||||||
class BinaryDecoder {
|
class BinaryDecoder {
|
||||||
public:
|
public:
|
||||||
BinaryDecoder() : iga(new IgaWrapper) {
|
|
||||||
iga->setMessagePrinter(messagePrinter);
|
|
||||||
if (nullptr == argHelper) {
|
|
||||||
argHelper = std::make_unique<OclocArgHelper>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BinaryDecoder(const std::string &file, const std::string &patch, const std::string &dump)
|
BinaryDecoder(const std::string &file, const std::string &patch, const std::string &dump)
|
||||||
: binaryFile(file), pathToPatch(patch), pathToDump(dump){};
|
: binaryFile(file), pathToPatch(patch), pathToDump(dump){};
|
||||||
BinaryDecoder(std::unique_ptr<OclocArgHelper> helper) : argHelper(std::move(helper)), iga(new IgaWrapper) {
|
BinaryDecoder(OclocArgHelper *helper) : argHelper(helper), iga(new IgaWrapper) {
|
||||||
iga->setMessagePrinter(messagePrinter);
|
iga->setMessagePrinter(messagePrinter);
|
||||||
};
|
};
|
||||||
int decode();
|
int decode();
|
||||||
@@ -48,7 +42,7 @@ class BinaryDecoder {
|
|||||||
void setMessagePrinter(const MessagePrinter &messagePrinter);
|
void setMessagePrinter(const MessagePrinter &messagePrinter);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<OclocArgHelper> argHelper = nullptr;
|
OclocArgHelper *argHelper = nullptr;
|
||||||
bool ignoreIsaPadding = false;
|
bool ignoreIsaPadding = false;
|
||||||
BinaryHeader programHeader, kernelHeader;
|
BinaryHeader programHeader, kernelHeader;
|
||||||
std::vector<char> binary;
|
std::vector<char> binary;
|
||||||
|
|||||||
@@ -17,13 +17,9 @@
|
|||||||
|
|
||||||
class BinaryEncoder {
|
class BinaryEncoder {
|
||||||
public:
|
public:
|
||||||
BinaryEncoder() : iga(new IgaWrapper) {
|
|
||||||
iga->setMessagePrinter(messagePrinter);
|
|
||||||
argHelper = std::make_unique<OclocArgHelper>();
|
|
||||||
}
|
|
||||||
BinaryEncoder(const std::string &dump, const std::string &elf)
|
BinaryEncoder(const std::string &dump, const std::string &elf)
|
||||||
: pathToDump(dump), elfName(elf){};
|
: pathToDump(dump), elfName(elf){};
|
||||||
BinaryEncoder(std::unique_ptr<OclocArgHelper> helper) : argHelper(std::move(helper)), iga(new IgaWrapper) {
|
BinaryEncoder(OclocArgHelper *helper) : argHelper(helper), iga(new IgaWrapper) {
|
||||||
iga->setMessagePrinter(messagePrinter);
|
iga->setMessagePrinter(messagePrinter);
|
||||||
}
|
}
|
||||||
int encode();
|
int encode();
|
||||||
@@ -32,7 +28,7 @@ class BinaryEncoder {
|
|||||||
void setMessagePrinter(const MessagePrinter &messagePrinter);
|
void setMessagePrinter(const MessagePrinter &messagePrinter);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<OclocArgHelper> argHelper = nullptr;
|
OclocArgHelper *argHelper = nullptr;
|
||||||
bool ignoreIsaPadding = false;
|
bool ignoreIsaPadding = false;
|
||||||
std::string pathToDump, elfName;
|
std::string pathToDump, elfName;
|
||||||
MessagePrinter messagePrinter;
|
MessagePrinter messagePrinter;
|
||||||
|
|||||||
@@ -7,15 +7,18 @@
|
|||||||
|
|
||||||
#include "shared/offline_compiler/source/multi_command.h"
|
#include "shared/offline_compiler/source/multi_command.h"
|
||||||
|
|
||||||
namespace NEO {
|
#include "shared/source/utilities/const_stringref.h"
|
||||||
int MultiCommand::singleBuild(size_t numArgs, const std::vector<std::string> &allArgs) {
|
|
||||||
int retVal = ErrorCode::SUCCESS;
|
|
||||||
std::string buildLog;
|
|
||||||
OfflineCompiler *pCompiler = OfflineCompiler::create(numArgs, allArgs, true, retVal);
|
|
||||||
if (retVal == ErrorCode::SUCCESS) {
|
|
||||||
retVal = buildWithSafetyGuard(pCompiler);
|
|
||||||
|
|
||||||
buildLog = pCompiler->getBuildLog();
|
#include <memory>
|
||||||
|
|
||||||
|
namespace NEO {
|
||||||
|
int MultiCommand::singleBuild(const std::vector<std::string> &allArgs) {
|
||||||
|
int retVal = SUCCESS;
|
||||||
|
std::unique_ptr<OfflineCompiler> pCompiler{OfflineCompiler::create(allArgs.size(), allArgs, true, retVal, argHelper)};
|
||||||
|
if (retVal == SUCCESS) {
|
||||||
|
retVal = buildWithSafetyGuard(pCompiler.get());
|
||||||
|
|
||||||
|
std::string &buildLog = pCompiler->getBuildLog();
|
||||||
if (buildLog.empty() == false) {
|
if (buildLog.empty() == false) {
|
||||||
printf("%s\n", buildLog.c_str());
|
printf("%s\n", buildLog.c_str());
|
||||||
}
|
}
|
||||||
@@ -27,45 +30,24 @@ int MultiCommand::singleBuild(size_t numArgs, const std::vector<std::string> &al
|
|||||||
printf("Build failed with error code: %d\n", retVal);
|
printf("Build failed with error code: %d\n", retVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (buildLog.empty() == false) {
|
|
||||||
singleBuilds.push_back(pCompiler);
|
|
||||||
} else {
|
|
||||||
delete pCompiler;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outputFileList != "") {
|
if (retVal == SUCCESS) {
|
||||||
std::ofstream myfile(outputFileList, std::fstream::app);
|
outputFile << getCurrentDirectoryOwn(outDirForBuilds) + outFileName + ".bin";
|
||||||
if (myfile.is_open()) {
|
} else {
|
||||||
if (retVal == ErrorCode::SUCCESS)
|
outputFile << "Unsuccesful build";
|
||||||
myfile << getCurrentDirectoryOwn(outDirForBuilds) + OutFileName + ".bin";
|
|
||||||
else
|
|
||||||
myfile << "Unsuccesful build";
|
|
||||||
myfile << std::endl;
|
|
||||||
myfile.close();
|
|
||||||
} else
|
|
||||||
printf("Unable to open outputFileList\n");
|
|
||||||
}
|
}
|
||||||
|
outputFile << '\n';
|
||||||
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
MultiCommand::MultiCommand() = default;
|
|
||||||
|
|
||||||
MultiCommand::~MultiCommand() {
|
MultiCommand *MultiCommand::create(const std::vector<std::string> &args, int &retVal, OclocArgHelper *helper) {
|
||||||
deleteBuildsWithWarnigs();
|
|
||||||
}
|
|
||||||
|
|
||||||
void MultiCommand::deleteBuildsWithWarnigs() {
|
|
||||||
for (OfflineCompiler *pSingle : singleBuilds)
|
|
||||||
delete pSingle;
|
|
||||||
singleBuilds.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
MultiCommand *MultiCommand::create(const std::vector<std::string> &argv, int &retVal) {
|
|
||||||
retVal = ErrorCode::SUCCESS;
|
retVal = ErrorCode::SUCCESS;
|
||||||
auto pMultiCommand = new MultiCommand();
|
auto pMultiCommand = new MultiCommand();
|
||||||
|
|
||||||
if (pMultiCommand) {
|
if (pMultiCommand) {
|
||||||
retVal = pMultiCommand->initialize(argv);
|
pMultiCommand->argHelper = helper;
|
||||||
|
retVal = pMultiCommand->initialize(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retVal != ErrorCode::SUCCESS) {
|
if (retVal != ErrorCode::SUCCESS) {
|
||||||
@@ -76,103 +58,90 @@ MultiCommand *MultiCommand::create(const std::vector<std::string> &argv, int &re
|
|||||||
return pMultiCommand;
|
return pMultiCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string MultiCommand::eraseExtensionFromPath(std::string &filePath) {
|
void MultiCommand::addAdditionalOptionsToSingleCommandLine(std::vector<std::string> &singleLineWithArguments, size_t buildId) {
|
||||||
size_t extPos = filePath.find_last_of(".", filePath.size());
|
|
||||||
if (extPos == std::string::npos) {
|
|
||||||
extPos = filePath.size();
|
|
||||||
}
|
|
||||||
std::string fileName;
|
|
||||||
std::string fileTrunk = filePath.substr(0, extPos);
|
|
||||||
|
|
||||||
return fileTrunk;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MultiCommand::addAdditionalOptionsToSingleCommandLine(std::vector<std::string> &singleLineWithArguments, int buildId) {
|
|
||||||
bool hasOutDir = false;
|
bool hasOutDir = false;
|
||||||
bool hasSpecificName = false;
|
bool hasOutName = false;
|
||||||
for (auto arg : singleLineWithArguments) {
|
for (const auto &arg : singleLineWithArguments) {
|
||||||
if (arg == "-out_dir") {
|
if (ConstStringRef("-out_dir") == arg) {
|
||||||
hasOutDir = true;
|
hasOutDir = true;
|
||||||
}
|
} else if (ConstStringRef("-output") == arg) {
|
||||||
if (arg == "-output") {
|
hasOutName = true;
|
||||||
hasSpecificName = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasOutDir) {
|
if (!hasOutDir) {
|
||||||
singleLineWithArguments.push_back("-out_dir");
|
singleLineWithArguments.push_back("-out_dir");
|
||||||
outDirForBuilds = eraseExtensionFromPath(pathToCMD);
|
outDirForBuilds = OfflineCompiler::getFileNameTrunk(pathToCommandFile);
|
||||||
singleLineWithArguments.push_back(outDirForBuilds);
|
singleLineWithArguments.push_back(outDirForBuilds);
|
||||||
}
|
}
|
||||||
if (!hasSpecificName) {
|
if (!hasOutName) {
|
||||||
singleLineWithArguments.push_back("-output");
|
singleLineWithArguments.push_back("-output");
|
||||||
OutFileName = "build_no_" + std::to_string(buildId + 1);
|
outFileName = "build_no_" + std::to_string(buildId + 1);
|
||||||
singleLineWithArguments.push_back(OutFileName);
|
singleLineWithArguments.push_back(outFileName);
|
||||||
}
|
}
|
||||||
if (quiet)
|
if (quiet)
|
||||||
singleLineWithArguments.push_back("-q");
|
singleLineWithArguments.push_back("-q");
|
||||||
}
|
}
|
||||||
|
|
||||||
int MultiCommand::initialize(const std::vector<std::string> &allArgs) {
|
int MultiCommand::initialize(const std::vector<std::string> &args) {
|
||||||
int retVal = ErrorCode::SUCCESS;
|
if (args[args.size() - 1] == "--help") {
|
||||||
size_t numArgs = allArgs.size();
|
printHelp();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
for (uint32_t argIndex = 1; argIndex < numArgs; argIndex++) {
|
for (size_t argIndex = 1; argIndex < args.size(); argIndex++) {
|
||||||
if (allArgs[argIndex] == "-multi") {
|
const auto &currArg = args[argIndex];
|
||||||
if (numArgs > argIndex + 1)
|
const bool hasMoreArgs = (argIndex + 1 < args.size());
|
||||||
pathToCMD = allArgs[argIndex + 1];
|
if (hasMoreArgs && ConstStringRef("-multi") == currArg) {
|
||||||
else {
|
pathToCommandFile = args[++argIndex];
|
||||||
printHelp();
|
} else if (hasMoreArgs && ConstStringRef("-output_file_list") == currArg) {
|
||||||
return INVALID_COMMAND_LINE;
|
outputFileList = args[++argIndex];
|
||||||
}
|
} else if (ConstStringRef("-q") == currArg) {
|
||||||
argIndex++;
|
|
||||||
} else if (allArgs[argIndex] == "-q") {
|
|
||||||
quiet = true;
|
quiet = true;
|
||||||
} else if (allArgs[argIndex] == "-output_file_list") {
|
|
||||||
if (numArgs > argIndex + 1)
|
|
||||||
outputFileList = allArgs[argIndex + 1];
|
|
||||||
else {
|
|
||||||
printHelp();
|
|
||||||
return INVALID_COMMAND_LINE;
|
|
||||||
}
|
|
||||||
argIndex++;
|
|
||||||
} else if (allArgs[argIndex] == "--help") {
|
|
||||||
printHelp();
|
|
||||||
return PRINT_USAGE;
|
|
||||||
} else {
|
} else {
|
||||||
printf("Invalid option (arg %d): %s\n", argIndex, allArgs[argIndex].c_str());
|
printf("Invalid option (arg %zu): %s\n", argIndex, currArg.c_str());
|
||||||
|
printHelp();
|
||||||
return INVALID_COMMAND_LINE;
|
return INVALID_COMMAND_LINE;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//save file with builds arguments to vector of strings, line by line
|
//save file with builds arguments to vector of strings, line by line
|
||||||
openFileWithBuildsArguments();
|
if (argHelper->fileExists(pathToCommandFile)) {
|
||||||
if (!lines.empty()) {
|
argHelper->readFileToVectorOfStrings(pathToCommandFile, lines);
|
||||||
for (unsigned int i = 0; i < lines.size(); i++) {
|
if (lines.empty()) {
|
||||||
std::vector<std::string> singleLineWithArguments;
|
printf("Command file was empty.\n");
|
||||||
unsigned int numberOfArg;
|
return INVALID_FILE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf("Could not find/open file with builds argument.s\n");
|
||||||
|
return INVALID_FILE;
|
||||||
|
}
|
||||||
|
|
||||||
singleLineWithArguments.push_back(allArgs[0]);
|
runBuilds(args[0]);
|
||||||
retVal = splitLineInSeparateArgs(singleLineWithArguments, lines[i], i);
|
|
||||||
if (retVal != ErrorCode::SUCCESS) {
|
|
||||||
retValues.push_back(retVal);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
addAdditionalOptionsToSingleCommandLine(singleLineWithArguments, i);
|
if (outputFileList != "") {
|
||||||
|
argHelper->saveOutput(outputFileList, outputFile);
|
||||||
|
}
|
||||||
|
return showResults();
|
||||||
|
}
|
||||||
|
|
||||||
numberOfArg = static_cast<unsigned int>(singleLineWithArguments.size());
|
void MultiCommand::runBuilds(const std::string &argZero) {
|
||||||
|
for (size_t i = 0; i < lines.size(); ++i) {
|
||||||
|
std::vector<std::string> args = {argZero};
|
||||||
|
|
||||||
if (!quiet)
|
int retVal = splitLineInSeparateArgs(args, lines[i], i);
|
||||||
printf("\nCommand number %d: ", i + 1);
|
if (retVal != SUCCESS) {
|
||||||
retVal = singleBuild(numberOfArg, singleLineWithArguments);
|
|
||||||
retValues.push_back(retVal);
|
retValues.push_back(retVal);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return showResults();
|
if (!quiet) {
|
||||||
} else {
|
printf("Command numer %zu: \n", i + 1);
|
||||||
printHelp();
|
}
|
||||||
return INVALID_COMMAND_LINE;
|
|
||||||
|
addAdditionalOptionsToSingleCommandLine(args, i);
|
||||||
|
retVal = singleBuild(args);
|
||||||
|
retValues.push_back(retVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,83 +163,45 @@ Usage: ocloc multi <file_name>
|
|||||||
)===");
|
)===");
|
||||||
}
|
}
|
||||||
|
|
||||||
int MultiCommand::splitLineInSeparateArgs(std::vector<std::string> &qargs, const std::string &command, int numberOfBuild) {
|
int MultiCommand::splitLineInSeparateArgs(std::vector<std::string> &qargs, const std::string &commandsLine, size_t numberOfBuild) {
|
||||||
unsigned int len = static_cast<unsigned int>(command.length());
|
size_t start, end, argLen;
|
||||||
|
for (size_t i = 0; i < commandsLine.length(); ++i) {
|
||||||
bool qot = false, sqot = false;
|
const char &currChar = commandsLine[i];
|
||||||
int arglen;
|
if ('\"' == currChar) {
|
||||||
|
start = i + 1;
|
||||||
for (unsigned int i = 0; i < len; i++) {
|
end = commandsLine.find('\"', start);
|
||||||
int start = i;
|
} else if ('\'' == currChar) {
|
||||||
if (command[i] == '\"') {
|
start = i + 1;
|
||||||
qot = true;
|
end = commandsLine.find('\'', start);
|
||||||
} else if (command[i] == '\'')
|
} else if (' ' == currChar) {
|
||||||
sqot = true;
|
continue;
|
||||||
|
|
||||||
if (qot) {
|
|
||||||
i++;
|
|
||||||
start++;
|
|
||||||
while (i < len && command[i] != '\"')
|
|
||||||
i++;
|
|
||||||
if (i < len)
|
|
||||||
qot = false;
|
|
||||||
arglen = i - start;
|
|
||||||
i++;
|
|
||||||
} else if (sqot) {
|
|
||||||
i++;
|
|
||||||
while (i < len && command[i] != '\'')
|
|
||||||
i++;
|
|
||||||
if (i < len)
|
|
||||||
sqot = false;
|
|
||||||
arglen = i - start;
|
|
||||||
i++;
|
|
||||||
} else {
|
} else {
|
||||||
while (i < len && command[i] != ' ')
|
start = i;
|
||||||
i++;
|
end = commandsLine.find(" ", start);
|
||||||
arglen = i - start;
|
end = (end == std::string::npos) ? commandsLine.length() : end;
|
||||||
}
|
}
|
||||||
qargs.push_back(command.substr(start, arglen));
|
if (end == std::string::npos) {
|
||||||
}
|
printf("One of the quotes is open in build number %zu\n", numberOfBuild + 1);
|
||||||
if (qot || sqot) {
|
return INVALID_FILE;
|
||||||
printf("One of the quotes is open in build number %d\n", numberOfBuild + 1);
|
|
||||||
return INVALID_COMMAND_LINE;
|
|
||||||
}
|
|
||||||
return ErrorCode::SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MultiCommand::openFileWithBuildsArguments() {
|
|
||||||
std::fstream multiCmdFile;
|
|
||||||
std::stringstream fileContent;
|
|
||||||
multiCmdFile.open(pathToCMD, std::fstream::in);
|
|
||||||
|
|
||||||
if (multiCmdFile.is_open()) {
|
|
||||||
std::string param;
|
|
||||||
fileContent << multiCmdFile.rdbuf();
|
|
||||||
multiCmdFile.close();
|
|
||||||
while (std::getline(fileContent, param, '\n')) {
|
|
||||||
param.erase(param.find_last_not_of(" \r\t") + 1);
|
|
||||||
param.erase(0, param.find_first_not_of(" \r\t"));
|
|
||||||
if (!param.empty()) {
|
|
||||||
lines.push_back(param);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
argLen = end - start;
|
||||||
printf("Can not open file with builds arguments\n");
|
i = end;
|
||||||
|
qargs.push_back(commandsLine.substr(start, argLen));
|
||||||
}
|
}
|
||||||
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MultiCommand::showResults() {
|
int MultiCommand::showResults() {
|
||||||
int retValue = ErrorCode::SUCCESS;
|
int retValue = SUCCESS;
|
||||||
int indexRetVal = 0;
|
int indexRetVal = 0;
|
||||||
for (int retVal : retValues) {
|
for (int retVal : retValues) {
|
||||||
if (retVal != ErrorCode::SUCCESS) {
|
retValue |= retVal;
|
||||||
if (retValue == ErrorCode::SUCCESS)
|
if (!quiet) {
|
||||||
retValue = retVal;
|
if (retVal != SUCCESS) {
|
||||||
if (!quiet)
|
|
||||||
printf("Build %d: failed. Error code: %d\n", indexRetVal, retVal);
|
printf("Build %d: failed. Error code: %d\n", indexRetVal, retVal);
|
||||||
} else {
|
} else {
|
||||||
if (!quiet)
|
|
||||||
printf("Build %d: successful\n", indexRetVal);
|
printf("Build %d: successful\n", indexRetVal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
indexRetVal++;
|
indexRetVal++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,41 +14,39 @@
|
|||||||
|
|
||||||
#include <CL/cl.h>
|
#include <CL/cl.h>
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
|
||||||
class MultiCommand {
|
class MultiCommand {
|
||||||
public:
|
public:
|
||||||
static MultiCommand *create(const std::vector<std::string> &argv, int &retVal);
|
|
||||||
void deleteBuildsWithWarnigs();
|
|
||||||
|
|
||||||
std::vector<OfflineCompiler *> singleBuilds;
|
|
||||||
|
|
||||||
MultiCommand &operator=(const MultiCommand &) = delete;
|
MultiCommand &operator=(const MultiCommand &) = delete;
|
||||||
MultiCommand(const MultiCommand &) = delete;
|
MultiCommand(const MultiCommand &) = delete;
|
||||||
~MultiCommand();
|
~MultiCommand() = default;
|
||||||
|
|
||||||
|
static MultiCommand *create(const std::vector<std::string> &args, int &retVal, OclocArgHelper *helper);
|
||||||
|
|
||||||
std::string outDirForBuilds;
|
std::string outDirForBuilds;
|
||||||
std::string outputFileList = "";
|
std::string outputFileList;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int splitLineInSeparateArgs(std::vector<std::string> &qargs, const std::string &command, int numberOfBuild);
|
MultiCommand() = default;
|
||||||
void openFileWithBuildsArguments();
|
|
||||||
void addAdditionalOptionsToSingleCommandLine(std::vector<std::string> &, int);
|
int initialize(const std::vector<std::string> &args);
|
||||||
void printHelp();
|
int splitLineInSeparateArgs(std::vector<std::string> &qargs, const std::string &command, size_t numberOfBuild);
|
||||||
int initialize(const std::vector<std::string> &allArgs);
|
|
||||||
int showResults();
|
int showResults();
|
||||||
int singleBuild(size_t numArgs, const std::vector<std::string> &allArgs);
|
int singleBuild(const std::vector<std::string> &args);
|
||||||
std::string eraseExtensionFromPath(std::string &filePath);
|
void addAdditionalOptionsToSingleCommandLine(std::vector<std::string> &, size_t buildId);
|
||||||
std::string OutFileName;
|
void printHelp();
|
||||||
|
void runBuilds(const std::string &argZero);
|
||||||
|
|
||||||
|
OclocArgHelper *argHelper = nullptr;
|
||||||
std::vector<int> retValues;
|
std::vector<int> retValues;
|
||||||
std::string pathToCMD;
|
|
||||||
std::vector<std::string> lines;
|
std::vector<std::string> lines;
|
||||||
|
std::string outFileName;
|
||||||
|
std::string pathToCommandFile;
|
||||||
|
std::stringstream outputFile;
|
||||||
bool quiet = false;
|
bool quiet = false;
|
||||||
|
|
||||||
MultiCommand();
|
|
||||||
};
|
};
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
|
|||||||
printHelp();
|
printHelp();
|
||||||
return ErrorCode::SUCCESS;
|
return ErrorCode::SUCCESS;
|
||||||
} else if (numArgs > 1 && !strcmp(argv[1], "disasm")) {
|
} else if (numArgs > 1 && !strcmp(argv[1], "disasm")) {
|
||||||
BinaryDecoder disasm(std::move(helper));
|
BinaryDecoder disasm(helper.get());
|
||||||
int retVal = disasm.validateInput(allArgs);
|
int retVal = disasm.validateInput(allArgs);
|
||||||
if (retVal == 0) {
|
if (retVal == 0) {
|
||||||
return disasm.decode();
|
return disasm.decode();
|
||||||
@@ -73,7 +73,7 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
} else if (numArgs > 1 && !strcmp(argv[1], "asm")) {
|
} else if (numArgs > 1 && !strcmp(argv[1], "asm")) {
|
||||||
BinaryEncoder assembler(std::move(helper));
|
BinaryEncoder assembler(helper.get());
|
||||||
int retVal = assembler.validateInput(allArgs);
|
int retVal = assembler.validateInput(allArgs);
|
||||||
if (retVal == 0) {
|
if (retVal == 0) {
|
||||||
return assembler.encode();
|
return assembler.encode();
|
||||||
@@ -82,21 +82,16 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
|
|||||||
}
|
}
|
||||||
} else if (numArgs > 1 && (!strcmp(argv[1], "multi") || !strcmp(argv[1], "-multi"))) {
|
} else if (numArgs > 1 && (!strcmp(argv[1], "multi") || !strcmp(argv[1], "-multi"))) {
|
||||||
int retValue = ErrorCode::SUCCESS;
|
int retValue = ErrorCode::SUCCESS;
|
||||||
auto pMulti = std::unique_ptr<MultiCommand>(MultiCommand::create(allArgs, retValue));
|
std::unique_ptr<MultiCommand> pMulti{(MultiCommand::create(allArgs, retValue, helper.get()))};
|
||||||
return retValue;
|
return retValue;
|
||||||
} else if (requestedFatBinary(numArgs, argv)) {
|
} else if (requestedFatBinary(numArgs, argv)) {
|
||||||
return buildFatbinary(numArgs, argv);
|
return buildFatbinary(numArgs, argv, helper.get());
|
||||||
} else {
|
} else {
|
||||||
int retVal = ErrorCode::SUCCESS;
|
int retVal = ErrorCode::SUCCESS;
|
||||||
std::vector<std::string> allArgs;
|
|
||||||
if (numArgs > 1) {
|
|
||||||
allArgs.assign(argv, argv + numArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
OfflineCompiler *pCompiler = OfflineCompiler::create(numArgs, allArgs, true, retVal, std::move(helper));
|
|
||||||
|
|
||||||
|
std::unique_ptr<OfflineCompiler> pCompiler{OfflineCompiler::create(numArgs, allArgs, true, retVal, helper.get())};
|
||||||
if (retVal == ErrorCode::SUCCESS) {
|
if (retVal == ErrorCode::SUCCESS) {
|
||||||
retVal = buildWithSafetyGuard(pCompiler);
|
retVal = buildWithSafetyGuard(pCompiler.get());
|
||||||
|
|
||||||
std::string buildLog = pCompiler->getBuildLog();
|
std::string buildLog = pCompiler->getBuildLog();
|
||||||
if (buildLog.empty() == false) {
|
if (buildLog.empty() == false) {
|
||||||
@@ -110,7 +105,6 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
|
|||||||
printf("Build failed with error code: %d\n", retVal);
|
printf("Build failed with error code: %d\n", retVal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete pCompiler;
|
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
|
|||||||
@@ -72,6 +72,4 @@ class OclocArgHelper {
|
|||||||
inline bool hasHeaders() { return headers.size() > 0; }
|
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, const void *pData, const size_t &dataSize);
|
||||||
void saveOutput(const std::string &filename, std::ostream &stream);
|
void saveOutput(const std::string &filename, std::ostream &stream);
|
||||||
|
|
||||||
void addInput(const std::string &filename, std::stringstream &stream);
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "shared/offline_compiler/source/ocloc_fatbinary.h"
|
#include "shared/offline_compiler/source/ocloc_fatbinary.h"
|
||||||
|
|
||||||
|
#include "shared/offline_compiler/source/ocloc_arg_helper.h"
|
||||||
#include "shared/offline_compiler/source/offline_compiler.h"
|
#include "shared/offline_compiler/source/offline_compiler.h"
|
||||||
#include "shared/offline_compiler/source/utilities/safety_caller.h"
|
#include "shared/offline_compiler/source/utilities/safety_caller.h"
|
||||||
#include "shared/source/device_binary_format/ar/ar_encoder.h"
|
#include "shared/source/device_binary_format/ar/ar_encoder.h"
|
||||||
@@ -202,7 +203,7 @@ std::vector<ConstStringRef> getTargetPlatformsForFatbinary(ConstStringRef device
|
|||||||
return toProductNames(requestedPlatforms);
|
return toProductNames(requestedPlatforms);
|
||||||
}
|
}
|
||||||
|
|
||||||
int buildFatbinary(int argc, const char *argv[]) {
|
int buildFatbinary(int argc, const char *argv[], OclocArgHelper *helper) {
|
||||||
std::string pointerSizeInBits = (sizeof(void *) == 4) ? "32" : "64";
|
std::string pointerSizeInBits = (sizeof(void *) == 4) ? "32" : "64";
|
||||||
int deviceArgIndex = -1;
|
int deviceArgIndex = -1;
|
||||||
std::string inputFileName = "";
|
std::string inputFileName = "";
|
||||||
@@ -248,7 +249,7 @@ int buildFatbinary(int argc, const char *argv[]) {
|
|||||||
for (auto targetPlatform : targetPlatforms) {
|
for (auto targetPlatform : targetPlatforms) {
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
argsCopy[deviceArgIndex] = targetPlatform.str();
|
argsCopy[deviceArgIndex] = targetPlatform.str();
|
||||||
std::unique_ptr<OfflineCompiler> pCompiler{OfflineCompiler::create(argc, argsCopy, false, retVal)};
|
std::unique_ptr<OfflineCompiler> pCompiler{OfflineCompiler::create(argc, argsCopy, false, retVal, helper)};
|
||||||
auto stepping = pCompiler->getHardwareInfo().platform.usRevId;
|
auto stepping = pCompiler->getHardwareInfo().platform.usRevId;
|
||||||
if (retVal == 0) {
|
if (retVal == 0) {
|
||||||
retVal = buildWithSafetyGuard(pCompiler.get());
|
retVal = buildWithSafetyGuard(pCompiler.get());
|
||||||
@@ -285,7 +286,7 @@ int buildFatbinary(int argc, const char *argv[]) {
|
|||||||
if (false == outputDirectory.empty()) {
|
if (false == outputDirectory.empty()) {
|
||||||
fatbinaryFileName = outputDirectory + "/" + outputFileName;
|
fatbinaryFileName = outputDirectory + "/" + outputFileName;
|
||||||
}
|
}
|
||||||
writeDataToFile(fatbinaryFileName.c_str(), fatbinaryData.data(), fatbinaryData.size());
|
helper->saveOutput(fatbinaryFileName, fatbinaryData.data(), fatbinaryData.size());
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,11 +13,12 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
class OclocArgHelper;
|
||||||
namespace NEO {
|
namespace NEO {
|
||||||
|
|
||||||
bool requestedFatBinary(int argc, const char *argv[]);
|
bool requestedFatBinary(int argc, const char *argv[]);
|
||||||
|
|
||||||
int buildFatbinary(int argc, const char *argv[]);
|
int buildFatbinary(int argc, const char *argv[], OclocArgHelper *helper);
|
||||||
|
|
||||||
std::vector<PRODUCT_FAMILY> getAllSupportedTargetPlatforms();
|
std::vector<PRODUCT_FAMILY> getAllSupportedTargetPlatforms();
|
||||||
std::vector<ConstStringRef> toProductNames(const std::vector<PRODUCT_FAMILY> &productIds);
|
std::vector<ConstStringRef> toProductNames(const std::vector<PRODUCT_FAMILY> &productIds);
|
||||||
|
|||||||
@@ -73,29 +73,12 @@ OfflineCompiler::~OfflineCompiler() {
|
|||||||
delete[] genBinary;
|
delete[] genBinary;
|
||||||
}
|
}
|
||||||
|
|
||||||
OfflineCompiler *OfflineCompiler::create(size_t numArgs, const std::vector<std::string> &allArgs, bool dumpFiles, int &retVal) {
|
OfflineCompiler *OfflineCompiler::create(size_t numArgs, const std::vector<std::string> &allArgs, bool dumpFiles, int &retVal, OclocArgHelper *helper) {
|
||||||
retVal = SUCCESS;
|
retVal = SUCCESS;
|
||||||
auto pOffCompiler = new OfflineCompiler();
|
auto pOffCompiler = new OfflineCompiler();
|
||||||
|
|
||||||
if (pOffCompiler) {
|
if (pOffCompiler) {
|
||||||
pOffCompiler->argHelper = std::make_unique<OclocArgHelper>();
|
pOffCompiler->argHelper = helper;
|
||||||
retVal = pOffCompiler->initialize(numArgs, allArgs, dumpFiles);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (retVal != SUCCESS) {
|
|
||||||
delete pOffCompiler;
|
|
||||||
pOffCompiler = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
return pOffCompiler;
|
|
||||||
}
|
|
||||||
|
|
||||||
OfflineCompiler *OfflineCompiler::create(size_t numArgs, const std::vector<std::string> &allArgs, bool dumpFiles, int &retVal, std::unique_ptr<OclocArgHelper> helper) {
|
|
||||||
retVal = SUCCESS;
|
|
||||||
auto pOffCompiler = new OfflineCompiler();
|
|
||||||
|
|
||||||
if (pOffCompiler) {
|
|
||||||
pOffCompiler->argHelper = std::move(helper);
|
|
||||||
retVal = pOffCompiler->initialize(numArgs, allArgs, dumpFiles);
|
retVal = pOffCompiler->initialize(numArgs, allArgs, dumpFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -884,7 +867,7 @@ void OfflineCompiler::writeOutAllFiles() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OfflineCompiler::readOptionsFromFile(std::string &options, const std::string &file, std::unique_ptr<OclocArgHelper> &helper) {
|
bool OfflineCompiler::readOptionsFromFile(std::string &options, const std::string &file, OclocArgHelper *helper) {
|
||||||
if (!helper->fileExists(file)) {
|
if (!helper->fileExists(file)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ std::string getDevicesTypes();
|
|||||||
|
|
||||||
class OfflineCompiler {
|
class OfflineCompiler {
|
||||||
public:
|
public:
|
||||||
static OfflineCompiler *create(size_t numArgs, const std::vector<std::string> &allArgs, bool dumpFiles, int &retVal);
|
static OfflineCompiler *create(size_t numArgs, const std::vector<std::string> &allArgs, bool dumpFiles, int &retVal, OclocArgHelper *helper);
|
||||||
static OfflineCompiler *create(size_t numArgs, const std::vector<std::string> &allArgs, bool dumpFiles, int &retVal, std::unique_ptr<OclocArgHelper> helper);
|
|
||||||
int build();
|
int build();
|
||||||
std::string &getBuildLog();
|
std::string &getBuildLog();
|
||||||
void printUsage();
|
void printUsage();
|
||||||
@@ -59,7 +58,7 @@ class OfflineCompiler {
|
|||||||
|
|
||||||
std::string parseBinAsCharArray(uint8_t *binary, size_t size, std::string &fileName);
|
std::string parseBinAsCharArray(uint8_t *binary, size_t size, std::string &fileName);
|
||||||
|
|
||||||
static bool readOptionsFromFile(std::string &optionsOut, const std::string &file, std::unique_ptr<OclocArgHelper> &helper);
|
static bool readOptionsFromFile(std::string &optionsOut, const std::string &file, OclocArgHelper *helper);
|
||||||
|
|
||||||
ArrayRef<const uint8_t> getPackedDeviceBinaryOutput() {
|
ArrayRef<const uint8_t> getPackedDeviceBinaryOutput() {
|
||||||
return this->elfBinary;
|
return this->elfBinary;
|
||||||
@@ -136,6 +135,6 @@ class OfflineCompiler {
|
|||||||
CIF::RAII::UPtr_t<IGC::FclOclDeviceCtxTagOCL> fclDeviceCtx = nullptr;
|
CIF::RAII::UPtr_t<IGC::FclOclDeviceCtxTagOCL> fclDeviceCtx = nullptr;
|
||||||
IGC::CodeType::CodeType_t preferredIntermediateRepresentation;
|
IGC::CodeType::CodeType_t preferredIntermediateRepresentation;
|
||||||
|
|
||||||
std::unique_ptr<OclocArgHelper> argHelper = nullptr;
|
OclocArgHelper *argHelper = nullptr;
|
||||||
};
|
};
|
||||||
} // namespace NEO
|
} // namespace NEO
|
||||||
|
|||||||
Reference in New Issue
Block a user