Helper to override platform name

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2021-01-13 09:30:01 +01:00
committed by Compute-Runtime-Automation
parent 40390f7775
commit 646b551da0
13 changed files with 86 additions and 61 deletions

View File

@ -40,7 +40,7 @@ TEST(OclocApiTests, WhenGoodArgsAreGivenThenSuccessIsReturned) {
nullptr, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, nullptr);
std::string output = testing::internal::GetCapturedStdout(); std::string output = testing::internal::GetCapturedStdout();
EXPECT_EQ(retVal, NEO::SUCCESS); EXPECT_EQ(retVal, NEO::OfflineCompiler::ErrorCode::SUCCESS);
EXPECT_EQ(std::string::npos, output.find("Command was: ocloc -file test_files/copybuffer.cl -device "s + argv[4])); EXPECT_EQ(std::string::npos, output.find("Command was: ocloc -file test_files/copybuffer.cl -device "s + argv[4]));
} }
@ -60,7 +60,7 @@ TEST(OclocApiTests, WhenGoodFamilyNameIsProvidedThenSuccessIsReturned) {
nullptr, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, nullptr);
std::string output = testing::internal::GetCapturedStdout(); std::string output = testing::internal::GetCapturedStdout();
EXPECT_EQ(retVal, NEO::SUCCESS); EXPECT_EQ(retVal, NEO::OfflineCompiler::ErrorCode::SUCCESS);
EXPECT_EQ(std::string::npos, output.find("Command was: ocloc -file test_files/copybuffer.cl -device "s + argv[4])); EXPECT_EQ(std::string::npos, output.find("Command was: ocloc -file test_files/copybuffer.cl -device "s + argv[4]));
} }
@ -80,7 +80,7 @@ TEST(OclocApiTests, WhenArgsWithMissingFileAreGivenThenErrorMessageIsProduced) {
nullptr, nullptr, nullptr, nullptr); nullptr, nullptr, nullptr, nullptr);
std::string output = testing::internal::GetCapturedStdout(); std::string output = testing::internal::GetCapturedStdout();
EXPECT_EQ(retVal, NEO::INVALID_FILE); EXPECT_EQ(retVal, NEO::OfflineCompiler::ErrorCode::INVALID_FILE);
EXPECT_NE(std::string::npos, output.find("Command was: ocloc -file test_files/IDoNotExist.cl -device "s + argv[4])); EXPECT_NE(std::string::npos, output.find("Command was: ocloc -file test_files/IDoNotExist.cl -device "s + argv[4]));
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2017-2020 Intel Corporation * Copyright (C) 2017-2021 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -153,7 +153,7 @@ TEST_F(MultiCommandTests, GivenMissingTextFileWithArgsWhenBuildingMultiCommandTh
EXPECT_STRNE(output.c_str(), ""); EXPECT_STRNE(output.c_str(), "");
EXPECT_EQ(nullptr, pMultiCommand); EXPECT_EQ(nullptr, pMultiCommand);
EXPECT_EQ(INVALID_FILE, retVal); EXPECT_EQ(OfflineCompiler::ErrorCode::INVALID_FILE, retVal);
DebugManager.flags.PrintDebugMessages.set(false); DebugManager.flags.PrintDebugMessages.set(false);
} }
TEST_F(MultiCommandTests, GivenLackOfClFileWhenBuildingMultiCommandThenInvalidFileErrorIsReturned) { TEST_F(MultiCommandTests, GivenLackOfClFileWhenBuildingMultiCommandThenInvalidFileErrorIsReturned) {
@ -178,7 +178,7 @@ TEST_F(MultiCommandTests, GivenLackOfClFileWhenBuildingMultiCommandThenInvalidFi
std::string output = testing::internal::GetCapturedStdout(); std::string output = testing::internal::GetCapturedStdout();
EXPECT_EQ(nullptr, pMultiCommand); EXPECT_EQ(nullptr, pMultiCommand);
EXPECT_EQ(INVALID_FILE, retVal); EXPECT_EQ(OfflineCompiler::ErrorCode::INVALID_FILE, retVal);
DebugManager.flags.PrintDebugMessages.set(false); DebugManager.flags.PrintDebugMessages.set(false);
deleteFileWithArgs(); deleteFileWithArgs();
@ -446,7 +446,7 @@ TEST_F(OfflineCompilerTests, GivenHelpOptionThenBuildDoesNotOccur) {
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());
EXPECT_EQ(PRINT_USAGE, retVal); EXPECT_EQ(OfflineCompiler::ErrorCode::PRINT_USAGE, retVal);
delete pOfflineCompiler; delete pOfflineCompiler;
} }
@ -464,7 +464,7 @@ TEST_F(OfflineCompilerTests, GivenInvalidFileWhenBuildingThenInvalidFileErrorIsR
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);
EXPECT_EQ(INVALID_FILE, retVal); EXPECT_EQ(OfflineCompiler::ErrorCode::INVALID_FILE, retVal);
DebugManager.flags.PrintDebugMessages.set(false); DebugManager.flags.PrintDebugMessages.set(false);
delete pOfflineCompiler; delete pOfflineCompiler;
} }
@ -482,7 +482,7 @@ TEST_F(OfflineCompilerTests, GivenInvalidFlagWhenBuildingThenInvalidCommandLineE
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);
EXPECT_EQ(INVALID_COMMAND_LINE, retVal); EXPECT_EQ(OfflineCompiler::ErrorCode::INVALID_COMMAND_LINE, retVal);
delete pOfflineCompiler; delete pOfflineCompiler;
} }
@ -499,7 +499,7 @@ TEST_F(OfflineCompilerTests, GivenInvalidOptionsWhenBuildingThenInvalidCommandLi
EXPECT_STRNE(output.c_str(), ""); EXPECT_STRNE(output.c_str(), "");
EXPECT_EQ(nullptr, pOfflineCompiler); EXPECT_EQ(nullptr, pOfflineCompiler);
EXPECT_EQ(INVALID_COMMAND_LINE, retVal); EXPECT_EQ(OfflineCompiler::ErrorCode::INVALID_COMMAND_LINE, retVal);
delete pOfflineCompiler; delete pOfflineCompiler;
@ -513,7 +513,7 @@ TEST_F(OfflineCompilerTests, GivenInvalidOptionsWhenBuildingThenInvalidCommandLi
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);
EXPECT_EQ(INVALID_COMMAND_LINE, retVal); EXPECT_EQ(OfflineCompiler::ErrorCode::INVALID_COMMAND_LINE, retVal);
delete pOfflineCompiler; delete pOfflineCompiler;
} }
@ -1209,7 +1209,7 @@ TEST(OfflineCompilerTest, givenCompilerWhenBuildSourceCodeFailsThenGenerateElfBi
MockOfflineCompiler compiler; MockOfflineCompiler compiler;
compiler.overrideBuildSourceCodeStatus = true; compiler.overrideBuildSourceCodeStatus = true;
auto expectedError = BUILD_PROGRAM_FAILURE; auto expectedError = OfflineCompiler::ErrorCode::BUILD_PROGRAM_FAILURE;
compiler.buildSourceCodeStatus = expectedError; compiler.buildSourceCodeStatus = expectedError;
EXPECT_EQ(0u, compiler.generateElfBinaryCalled); EXPECT_EQ(0u, compiler.generateElfBinaryCalled);
@ -1240,7 +1240,7 @@ TEST(OfflineCompilerTest, givenDeviceSpecificKernelFileWhenCompilerIsInitialized
gEnvironment->devicePrefix.c_str()}; gEnvironment->devicePrefix.c_str()};
int retVal = mockOfflineCompiler->initialize(argv.size(), argv); int retVal = mockOfflineCompiler->initialize(argv.size(), argv);
EXPECT_EQ(SUCCESS, retVal); EXPECT_EQ(OfflineCompiler::ErrorCode::SUCCESS, retVal);
EXPECT_STREQ("-cl-opt-disable", mockOfflineCompiler->options.c_str()); EXPECT_STREQ("-cl-opt-disable", mockOfflineCompiler->options.c_str());
} }
@ -1259,7 +1259,7 @@ TEST(OfflineCompilerTest, givenRevisionIdWhenCompilerIsInitializedThenPassItToHw
"3"}; "3"};
int retVal = mockOfflineCompiler->initialize(argv.size(), argv); int retVal = mockOfflineCompiler->initialize(argv.size(), argv);
EXPECT_EQ(SUCCESS, retVal); EXPECT_EQ(OfflineCompiler::ErrorCode::SUCCESS, retVal);
EXPECT_EQ(mockOfflineCompiler->hwInfo.platform.usRevId, 3); EXPECT_EQ(mockOfflineCompiler->hwInfo.platform.usRevId, 3);
} }
@ -1278,7 +1278,7 @@ TEST(OfflineCompilerTest, givenNoRevisionIdWhenCompilerIsInitializedThenHwInfoHa
mockOfflineCompiler->getHardwareInfo(gEnvironment->devicePrefix.c_str()); mockOfflineCompiler->getHardwareInfo(gEnvironment->devicePrefix.c_str());
auto revId = mockOfflineCompiler->hwInfo.platform.usRevId; auto revId = mockOfflineCompiler->hwInfo.platform.usRevId;
int retVal = mockOfflineCompiler->initialize(argv.size(), argv); int retVal = mockOfflineCompiler->initialize(argv.size(), argv);
EXPECT_EQ(SUCCESS, retVal); EXPECT_EQ(OfflineCompiler::ErrorCode::SUCCESS, retVal);
EXPECT_EQ(mockOfflineCompiler->hwInfo.platform.usRevId, revId); EXPECT_EQ(mockOfflineCompiler->hwInfo.platform.usRevId, revId);
} }
@ -1295,7 +1295,7 @@ TEST(OfflineCompilerTest, whenDeviceIsSpecifiedThenDefaultConfigFromTheDeviceIsU
gEnvironment->devicePrefix.c_str()}; gEnvironment->devicePrefix.c_str()};
int retVal = mockOfflineCompiler->initialize(argv.size(), argv); int retVal = mockOfflineCompiler->initialize(argv.size(), argv);
EXPECT_EQ(SUCCESS, retVal); EXPECT_EQ(OfflineCompiler::ErrorCode::SUCCESS, retVal);
auto actualHwInfo = mockOfflineCompiler->hwInfo; auto actualHwInfo = mockOfflineCompiler->hwInfo;
auto expectedHwInfo = actualHwInfo; auto expectedHwInfo = actualHwInfo;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2017-2020 Intel Corporation * Copyright (C) 2017-2021 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -19,7 +19,7 @@ namespace NEO {
class OfflineCompilerTests : public ::testing::Test { class OfflineCompilerTests : public ::testing::Test {
public: public:
OfflineCompiler *pOfflineCompiler = nullptr; OfflineCompiler *pOfflineCompiler = nullptr;
int retVal = SUCCESS; int retVal = OfflineCompiler::ErrorCode::SUCCESS;
std::unique_ptr<OclocArgHelper> oclocArgHelperWithoutInput = std::make_unique<OclocArgHelper>(); std::unique_ptr<OclocArgHelper> oclocArgHelperWithoutInput = std::make_unique<OclocArgHelper>();
}; };
@ -31,7 +31,7 @@ class MultiCommandTests : public ::testing::Test {
MultiCommand *pMultiCommand = nullptr; MultiCommand *pMultiCommand = nullptr;
std::string nameOfFileWithArgs; std::string nameOfFileWithArgs;
std::string outFileList; std::string outFileList;
int retVal = SUCCESS; int retVal = OfflineCompiler::ErrorCode::SUCCESS;
std::unique_ptr<OclocArgHelper> oclocArgHelperWithoutInput = std::make_unique<OclocArgHelper>(); std::unique_ptr<OclocArgHelper> oclocArgHelperWithoutInput = std::make_unique<OclocArgHelper>();
}; };

View File

@ -1,5 +1,5 @@
# #
# Copyright (C) 2018-2020 Intel Corporation # Copyright (C) 2018-2021 Intel Corporation
# #
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
# #
@ -30,6 +30,7 @@ set(CLOC_LIB_SRCS_LIB
${NEO_SHARED_DIRECTORY}/helpers/file_io.cpp ${NEO_SHARED_DIRECTORY}/helpers/file_io.cpp
${NEO_SHARED_DIRECTORY}/helpers/hw_info.cpp ${NEO_SHARED_DIRECTORY}/helpers/hw_info.cpp
${NEO_SHARED_DIRECTORY}/helpers/hw_info.h ${NEO_SHARED_DIRECTORY}/helpers/hw_info.h
${NEO_SHARED_DIRECTORY}/helpers${BRANCH_DIR_SUFFIX}/hw_info_extended.cpp
${NEO_SHARED_DIRECTORY}/os_interface/os_library.h ${NEO_SHARED_DIRECTORY}/os_interface/os_library.h
${NEO_SOURCE_DIR}/opencl/source/platform/extensions.cpp ${NEO_SOURCE_DIR}/opencl/source/platform/extensions.cpp
${NEO_SOURCE_DIR}/opencl/source/platform/extensions.h ${NEO_SOURCE_DIR}/opencl/source/platform/extensions.h

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2019-2020 Intel Corporation * Copyright (C) 2019-2021 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -14,13 +14,13 @@
namespace NEO { namespace NEO {
int MultiCommand::singleBuild(const std::vector<std::string> &args) { int MultiCommand::singleBuild(const std::vector<std::string> &args) {
int retVal = SUCCESS; int retVal = OfflineCompiler::ErrorCode::SUCCESS;
if (requestedFatBinary(args)) { if (requestedFatBinary(args)) {
retVal = buildFatBinary(args, argHelper); retVal = buildFatBinary(args, argHelper);
} else { } else {
std::unique_ptr<OfflineCompiler> pCompiler{OfflineCompiler::create(args.size(), args, true, retVal, argHelper)}; std::unique_ptr<OfflineCompiler> pCompiler{OfflineCompiler::create(args.size(), args, true, retVal, argHelper)};
if (retVal == SUCCESS) { if (retVal == OfflineCompiler::ErrorCode::SUCCESS) {
retVal = buildWithSafetyGuard(pCompiler.get()); retVal = buildWithSafetyGuard(pCompiler.get());
std::string &buildLog = pCompiler->getBuildLog(); std::string &buildLog = pCompiler->getBuildLog();
@ -30,14 +30,14 @@ int MultiCommand::singleBuild(const std::vector<std::string> &args) {
} }
outFileName += ".bin"; outFileName += ".bin";
} }
if (retVal == SUCCESS) { if (retVal == OfflineCompiler::ErrorCode::SUCCESS) {
if (!quiet) if (!quiet)
argHelper->printf("Build succeeded.\n"); argHelper->printf("Build succeeded.\n");
} else { } else {
argHelper->printf("Build failed with error code: %d\n", retVal); argHelper->printf("Build failed with error code: %d\n", retVal);
} }
if (retVal == SUCCESS) { if (retVal == OfflineCompiler::ErrorCode::SUCCESS) {
outputFile << getCurrentDirectoryOwn(outDirForBuilds) + outFileName; outputFile << getCurrentDirectoryOwn(outDirForBuilds) + outFileName;
} else { } else {
outputFile << "Unsuccesful build"; outputFile << "Unsuccesful build";
@ -48,7 +48,7 @@ int MultiCommand::singleBuild(const std::vector<std::string> &args) {
} }
MultiCommand *MultiCommand::create(const std::vector<std::string> &args, int &retVal, OclocArgHelper *helper) { MultiCommand *MultiCommand::create(const std::vector<std::string> &args, int &retVal, OclocArgHelper *helper) {
retVal = ErrorCode::SUCCESS; retVal = OfflineCompiler::ErrorCode::SUCCESS;
auto pMultiCommand = new MultiCommand(); auto pMultiCommand = new MultiCommand();
if (pMultiCommand) { if (pMultiCommand) {
@ -56,7 +56,7 @@ MultiCommand *MultiCommand::create(const std::vector<std::string> &args, int &re
retVal = pMultiCommand->initialize(args); retVal = pMultiCommand->initialize(args);
} }
if (retVal != ErrorCode::SUCCESS) { if (retVal != OfflineCompiler::ErrorCode::SUCCESS) {
delete pMultiCommand; delete pMultiCommand;
pMultiCommand = nullptr; pMultiCommand = nullptr;
} }
@ -107,7 +107,7 @@ int MultiCommand::initialize(const std::vector<std::string> &args) {
} else { } else {
argHelper->printf("Invalid option (arg %zu): %s\n", argIndex, currArg.c_str()); argHelper->printf("Invalid option (arg %zu): %s\n", argIndex, currArg.c_str());
printHelp(); printHelp();
return INVALID_COMMAND_LINE; return OfflineCompiler::ErrorCode::INVALID_COMMAND_LINE;
} }
} }
@ -116,11 +116,11 @@ int MultiCommand::initialize(const std::vector<std::string> &args) {
argHelper->readFileToVectorOfStrings(pathToCommandFile, lines); argHelper->readFileToVectorOfStrings(pathToCommandFile, lines);
if (lines.empty()) { if (lines.empty()) {
argHelper->printf("Command file was empty.\n"); argHelper->printf("Command file was empty.\n");
return INVALID_FILE; return OfflineCompiler::ErrorCode::INVALID_FILE;
} }
} else { } else {
argHelper->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; return OfflineCompiler::ErrorCode::INVALID_FILE;
} }
runBuilds(args[0]); runBuilds(args[0]);
@ -136,7 +136,7 @@ void MultiCommand::runBuilds(const std::string &argZero) {
std::vector<std::string> args = {argZero}; std::vector<std::string> args = {argZero};
int retVal = splitLineInSeparateArgs(args, lines[i], i); int retVal = splitLineInSeparateArgs(args, lines[i], i);
if (retVal != SUCCESS) { if (retVal != OfflineCompiler::ErrorCode::SUCCESS) {
retValues.push_back(retVal); retValues.push_back(retVal);
continue; continue;
} }
@ -188,22 +188,22 @@ int MultiCommand::splitLineInSeparateArgs(std::vector<std::string> &qargs, const
} }
if (end == std::string::npos) { if (end == std::string::npos) {
argHelper->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; return OfflineCompiler::ErrorCode::INVALID_FILE;
} }
argLen = end - start; argLen = end - start;
i = end; i = end;
qargs.push_back(commandsLine.substr(start, argLen)); qargs.push_back(commandsLine.substr(start, argLen));
} }
return SUCCESS; return OfflineCompiler::ErrorCode::SUCCESS;
} }
int MultiCommand::showResults() { int MultiCommand::showResults() {
int retValue = SUCCESS; int retValue = OfflineCompiler::ErrorCode::SUCCESS;
int indexRetVal = 0; int indexRetVal = 0;
for (int retVal : retValues) { for (int retVal : retValues) {
retValue |= retVal; retValue |= retVal;
if (!quiet) { if (!quiet) {
if (retVal != SUCCESS) { if (retVal != OfflineCompiler::ErrorCode::SUCCESS) {
argHelper->printf("Build command %d: failed. Error code: %d\n", indexRetVal, retVal); argHelper->printf("Build command %d: failed. Error code: %d\n", indexRetVal, retVal);
} else { } else {
argHelper->printf("Build command %d: successful\n", indexRetVal); argHelper->printf("Build command %d: successful\n", indexRetVal);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 Intel Corporation * Copyright (C) 2020-2021 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -81,7 +81,7 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
try { try {
if (numArgs == 1 || (numArgs > 1 && (ConstStringRef("-h") == allArgs[1] || ConstStringRef("--help") == allArgs[1]))) { if (numArgs == 1 || (numArgs > 1 && (ConstStringRef("-h") == allArgs[1] || ConstStringRef("--help") == allArgs[1]))) {
helper->printf("%s", help); helper->printf("%s", help);
return ErrorCode::SUCCESS; return OfflineCompiler::ErrorCode::SUCCESS;
} else if (numArgs > 1 && ConstStringRef("disasm") == allArgs[1]) { } else if (numArgs > 1 && ConstStringRef("disasm") == allArgs[1]) {
BinaryDecoder disasm(helper.get()); BinaryDecoder disasm(helper.get());
int retVal = disasm.validateInput(allArgs); int retVal = disasm.validateInput(allArgs);
@ -99,7 +99,7 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
return retVal; return retVal;
} }
} else if (numArgs > 1 && ConstStringRef("multi") == allArgs[1]) { } else if (numArgs > 1 && ConstStringRef("multi") == allArgs[1]) {
int retValue = ErrorCode::SUCCESS; int retValue = OfflineCompiler::ErrorCode::SUCCESS;
std::unique_ptr<MultiCommand> pMulti{(MultiCommand::create(allArgs, retValue, helper.get()))}; std::unique_ptr<MultiCommand> pMulti{(MultiCommand::create(allArgs, retValue, helper.get()))};
return retValue; return retValue;
} else if (requestedFatBinary(allArgs)) { } else if (requestedFatBinary(allArgs)) {
@ -107,10 +107,10 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
} else if (numArgs > 1 && ConstStringRef("validate") == allArgs[1]) { } else if (numArgs > 1 && ConstStringRef("validate") == allArgs[1]) {
return NEO::Ocloc::validate(allArgs, helper.get()); return NEO::Ocloc::validate(allArgs, helper.get());
} else { } else {
int retVal = ErrorCode::SUCCESS; int retVal = OfflineCompiler::ErrorCode::SUCCESS;
std::unique_ptr<OfflineCompiler> pCompiler{OfflineCompiler::create(numArgs, allArgs, true, retVal, helper.get())}; std::unique_ptr<OfflineCompiler> pCompiler{OfflineCompiler::create(numArgs, allArgs, true, retVal, helper.get())};
if (retVal == ErrorCode::SUCCESS) { if (retVal == OfflineCompiler::ErrorCode::SUCCESS) {
retVal = buildWithSafetyGuard(pCompiler.get()); retVal = buildWithSafetyGuard(pCompiler.get());
std::string buildLog = pCompiler->getBuildLog(); std::string buildLog = pCompiler->getBuildLog();
@ -118,7 +118,7 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
helper->printf("%s\n", buildLog.c_str()); helper->printf("%s\n", buildLog.c_str());
} }
if (retVal == ErrorCode::SUCCESS) { if (retVal == OfflineCompiler::ErrorCode::SUCCESS) {
if (!pCompiler->isQuiet()) if (!pCompiler->isQuiet())
helper->printf("Build succeeded.\n"); helper->printf("Build succeeded.\n");
} else { } else {
@ -126,7 +126,7 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
} }
} }
if (retVal != ErrorCode::SUCCESS) if (retVal != OfflineCompiler::ErrorCode::SUCCESS)
printOclocCmdLine(numArgs, argv, helper); printOclocCmdLine(numArgs, argv, helper);
return retVal; return retVal;

View File

@ -265,7 +265,7 @@ int buildFatBinary(const std::vector<std::string> &args, OclocArgHelper *argHelp
argsCopy[deviceArgIndex] = targetPlatform.str(); argsCopy[deviceArgIndex] = targetPlatform.str();
std::unique_ptr<OfflineCompiler> pCompiler{OfflineCompiler::create(argsCopy.size(), argsCopy, false, retVal, argHelper)}; std::unique_ptr<OfflineCompiler> pCompiler{OfflineCompiler::create(argsCopy.size(), argsCopy, false, retVal, argHelper)};
if (ErrorCode::SUCCESS != retVal) { if (OfflineCompiler::ErrorCode::SUCCESS != retVal) {
argHelper->printf("Error! Couldn't create OfflineCompiler. Exiting.\n"); argHelper->printf("Error! Couldn't create OfflineCompiler. Exiting.\n");
return retVal; return retVal;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018-2020 Intel Corporation * Copyright (C) 2018-2021 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -15,6 +15,7 @@
#include "shared/source/helpers/compiler_options_parser.h" #include "shared/source/helpers/compiler_options_parser.h"
#include "shared/source/helpers/debug_helpers.h" #include "shared/source/helpers/debug_helpers.h"
#include "shared/source/helpers/file_io.h" #include "shared/source/helpers/file_io.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/helpers/hw_info.h" #include "shared/source/helpers/hw_info.h"
#include "shared/source/helpers/string.h" #include "shared/source/helpers/string.h"
#include "shared/source/os_interface/os_library.h" #include "shared/source/os_interface/os_library.h"
@ -286,11 +287,13 @@ std::string &OfflineCompiler::getBuildLog() {
return buildLog; return buildLog;
} }
int OfflineCompiler::getHardwareInfo(const char *pDeviceName) { int OfflineCompiler::getHardwareInfo(std::string deviceName) {
int retVal = INVALID_DEVICE; int retVal = INVALID_DEVICE;
overridePlatformName(deviceName);
for (unsigned int productId = 0; productId < IGFX_MAX_PRODUCT; ++productId) { for (unsigned int productId = 0; productId < IGFX_MAX_PRODUCT; ++productId) {
if (hardwarePrefix[productId] && (0 == strcmp(pDeviceName, hardwarePrefix[productId]))) { if (hardwarePrefix[productId] && (0 == strcmp(deviceName.c_str(), hardwarePrefix[productId]))) {
if (hardwareInfoTable[productId]) { if (hardwareInfoTable[productId]) {
hwInfo = *hardwareInfoTable[productId]; hwInfo = *hardwareInfoTable[productId];
if (revisionId != -1) { if (revisionId != -1) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2017-2020 Intel Corporation * Copyright (C) 2017-2021 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -28,22 +28,22 @@ class OsLibrary;
std::string convertToPascalCase(const std::string &inString); std::string convertToPascalCase(const std::string &inString);
enum ErrorCode {
SUCCESS = 0,
OUT_OF_HOST_MEMORY = -6,
BUILD_PROGRAM_FAILURE = -11,
INVALID_DEVICE = -33,
INVALID_PROGRAM = -44,
INVALID_COMMAND_LINE = -5150,
INVALID_FILE = -5151,
PRINT_USAGE = -5152,
};
std::string generateFilePath(const std::string &directory, const std::string &fileNameBase, const char *extension); std::string generateFilePath(const std::string &directory, const std::string &fileNameBase, const char *extension);
std::string getDevicesTypes(); std::string getDevicesTypes();
class OfflineCompiler { class OfflineCompiler {
public: public:
enum ErrorCode {
SUCCESS = 0,
OUT_OF_HOST_MEMORY = -6,
BUILD_PROGRAM_FAILURE = -11,
INVALID_DEVICE = -33,
INVALID_PROGRAM = -44,
INVALID_COMMAND_LINE = -5150,
INVALID_FILE = -5151,
PRINT_USAGE = -5152,
};
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, OclocArgHelper *helper);
int build(); int build();
std::string &getBuildLog(); std::string &getBuildLog();
@ -77,7 +77,7 @@ class OfflineCompiler {
protected: protected:
OfflineCompiler(); OfflineCompiler();
int getHardwareInfo(const char *pDeviceName); int getHardwareInfo(std::string deviceName);
std::string getStringWithinDelimiters(const std::string &src); std::string getStringWithinDelimiters(const std::string &src);
int initialize(size_t numArgs, const std::vector<std::string> &allArgs, bool dumpFiles); int initialize(size_t numArgs, const std::vector<std::string> &allArgs, bool dumpFiles);
int parseCommandLine(size_t numArgs, const std::vector<std::string> &allArgs); int parseCommandLine(size_t numArgs, const std::vector<std::string> &allArgs);

View File

@ -61,6 +61,7 @@ set(NEO_CORE_HELPERS
${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tgllp_plus.inl ${CMAKE_CURRENT_SOURCE_DIR}/hw_helper_tgllp_plus.inl
${CMAKE_CURRENT_SOURCE_DIR}/hw_info.cpp ${CMAKE_CURRENT_SOURCE_DIR}/hw_info.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hw_info.h ${CMAKE_CURRENT_SOURCE_DIR}/hw_info.h
${CMAKE_CURRENT_SOURCE_DIR}${BRANCH_DIR_SUFFIX}/hw_info_extended.cpp
${CMAKE_CURRENT_SOURCE_DIR}/interlocked_max.h ${CMAKE_CURRENT_SOURCE_DIR}/interlocked_max.h
${CMAKE_CURRENT_SOURCE_DIR}/kernel_helpers.cpp ${CMAKE_CURRENT_SOURCE_DIR}/kernel_helpers.cpp
${CMAKE_CURRENT_SOURCE_DIR}/kernel_helpers.h ${CMAKE_CURRENT_SOURCE_DIR}/kernel_helpers.h

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2017-2020 Intel Corporation * Copyright (C) 2017-2021 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -8,6 +8,7 @@
#include "shared/source/helpers/hw_info.h" #include "shared/source/helpers/hw_info.h"
#include "shared/source/debug_settings/debug_settings_manager.h" #include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/helpers/hw_helper.h"
#include "hw_cmds.h" #include "hw_cmds.h"
@ -46,6 +47,8 @@ void (*hardwareInfoSetup[IGFX_MAX_PRODUCT])(HardwareInfo *, bool, uint64_t) = {
bool getHwInfoForPlatformString(std::string &platform, const HardwareInfo *&hwInfoIn) { bool getHwInfoForPlatformString(std::string &platform, const HardwareInfo *&hwInfoIn) {
std::transform(platform.begin(), platform.end(), platform.begin(), ::tolower); std::transform(platform.begin(), platform.end(), platform.begin(), ::tolower);
overridePlatformName(platform);
bool ret = false; bool ret = false;
for (int j = 0; j < IGFX_MAX_PRODUCT; j++) { for (int j = 0; j < IGFX_MAX_PRODUCT; j++) {
if (hardwarePrefix[j] == nullptr) if (hardwarePrefix[j] == nullptr)
@ -56,6 +59,7 @@ bool getHwInfoForPlatformString(std::string &platform, const HardwareInfo *&hwIn
break; break;
} }
} }
return ret; return ret;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2018-2020 Intel Corporation * Copyright (C) 2018-2021 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@ -111,6 +111,7 @@ struct EnableGfxFamilyHw {
bool getHwInfoForPlatformString(std::string &platform, const HardwareInfo *&hwInfoIn); bool getHwInfoForPlatformString(std::string &platform, const HardwareInfo *&hwInfoIn);
void setHwInfoValuesFromConfig(const uint64_t hwInfoConfig, HardwareInfo &hwInfoIn); void setHwInfoValuesFromConfig(const uint64_t hwInfoConfig, HardwareInfo &hwInfoIn);
bool parseHwInfoConfigString(const std::string &hwInfoConfigStr, uint64_t &hwInfoConfig); bool parseHwInfoConfigString(const std::string &hwInfoConfigStr, uint64_t &hwInfoConfig);
void overridePlatformName(std::string &name);
aub_stream::EngineType getChosenEngineType(const HardwareInfo &hwInfo); aub_stream::EngineType getChosenEngineType(const HardwareInfo &hwInfo);
const std::string getFamilyNameWithType(const HardwareInfo &hwInfo); const std::string getFamilyNameWithType(const HardwareInfo &hwInfo);

View File

@ -0,0 +1,15 @@
/*
* Copyright (C) 2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/hw_info.h"
namespace NEO {
void overridePlatformName(std::string &name) {
}
} // namespace NEO