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

@@ -1,5 +1,5 @@
#
# Copyright (C) 2018-2020 Intel Corporation
# Copyright (C) 2018-2021 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
@@ -30,6 +30,7 @@ set(CLOC_LIB_SRCS_LIB
${NEO_SHARED_DIRECTORY}/helpers/file_io.cpp
${NEO_SHARED_DIRECTORY}/helpers/hw_info.cpp
${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_SOURCE_DIR}/opencl/source/platform/extensions.cpp
${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
*
@@ -14,13 +14,13 @@
namespace NEO {
int MultiCommand::singleBuild(const std::vector<std::string> &args) {
int retVal = SUCCESS;
int retVal = OfflineCompiler::ErrorCode::SUCCESS;
if (requestedFatBinary(args)) {
retVal = buildFatBinary(args, argHelper);
} else {
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());
std::string &buildLog = pCompiler->getBuildLog();
@@ -30,14 +30,14 @@ int MultiCommand::singleBuild(const std::vector<std::string> &args) {
}
outFileName += ".bin";
}
if (retVal == SUCCESS) {
if (retVal == OfflineCompiler::ErrorCode::SUCCESS) {
if (!quiet)
argHelper->printf("Build succeeded.\n");
} else {
argHelper->printf("Build failed with error code: %d\n", retVal);
}
if (retVal == SUCCESS) {
if (retVal == OfflineCompiler::ErrorCode::SUCCESS) {
outputFile << getCurrentDirectoryOwn(outDirForBuilds) + outFileName;
} else {
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) {
retVal = ErrorCode::SUCCESS;
retVal = OfflineCompiler::ErrorCode::SUCCESS;
auto pMultiCommand = new MultiCommand();
if (pMultiCommand) {
@@ -56,7 +56,7 @@ MultiCommand *MultiCommand::create(const std::vector<std::string> &args, int &re
retVal = pMultiCommand->initialize(args);
}
if (retVal != ErrorCode::SUCCESS) {
if (retVal != OfflineCompiler::ErrorCode::SUCCESS) {
delete pMultiCommand;
pMultiCommand = nullptr;
}
@@ -107,7 +107,7 @@ int MultiCommand::initialize(const std::vector<std::string> &args) {
} else {
argHelper->printf("Invalid option (arg %zu): %s\n", argIndex, currArg.c_str());
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);
if (lines.empty()) {
argHelper->printf("Command file was empty.\n");
return INVALID_FILE;
return OfflineCompiler::ErrorCode::INVALID_FILE;
}
} else {
argHelper->printf("Could not find/open file with builds argument.s\n");
return INVALID_FILE;
return OfflineCompiler::ErrorCode::INVALID_FILE;
}
runBuilds(args[0]);
@@ -136,7 +136,7 @@ void MultiCommand::runBuilds(const std::string &argZero) {
std::vector<std::string> args = {argZero};
int retVal = splitLineInSeparateArgs(args, lines[i], i);
if (retVal != SUCCESS) {
if (retVal != OfflineCompiler::ErrorCode::SUCCESS) {
retValues.push_back(retVal);
continue;
}
@@ -188,22 +188,22 @@ int MultiCommand::splitLineInSeparateArgs(std::vector<std::string> &qargs, const
}
if (end == std::string::npos) {
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;
i = end;
qargs.push_back(commandsLine.substr(start, argLen));
}
return SUCCESS;
return OfflineCompiler::ErrorCode::SUCCESS;
}
int MultiCommand::showResults() {
int retValue = SUCCESS;
int retValue = OfflineCompiler::ErrorCode::SUCCESS;
int indexRetVal = 0;
for (int retVal : retValues) {
retValue |= retVal;
if (!quiet) {
if (retVal != SUCCESS) {
if (retVal != OfflineCompiler::ErrorCode::SUCCESS) {
argHelper->printf("Build command %d: failed. Error code: %d\n", indexRetVal, retVal);
} else {
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
*
@@ -81,7 +81,7 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
try {
if (numArgs == 1 || (numArgs > 1 && (ConstStringRef("-h") == allArgs[1] || ConstStringRef("--help") == allArgs[1]))) {
helper->printf("%s", help);
return ErrorCode::SUCCESS;
return OfflineCompiler::ErrorCode::SUCCESS;
} else if (numArgs > 1 && ConstStringRef("disasm") == allArgs[1]) {
BinaryDecoder disasm(helper.get());
int retVal = disasm.validateInput(allArgs);
@@ -99,7 +99,7 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
return retVal;
}
} 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()))};
return retValue;
} else if (requestedFatBinary(allArgs)) {
@@ -107,10 +107,10 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
} else if (numArgs > 1 && ConstStringRef("validate") == allArgs[1]) {
return NEO::Ocloc::validate(allArgs, helper.get());
} else {
int retVal = ErrorCode::SUCCESS;
int retVal = OfflineCompiler::ErrorCode::SUCCESS;
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());
std::string buildLog = pCompiler->getBuildLog();
@@ -118,7 +118,7 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
helper->printf("%s\n", buildLog.c_str());
}
if (retVal == ErrorCode::SUCCESS) {
if (retVal == OfflineCompiler::ErrorCode::SUCCESS) {
if (!pCompiler->isQuiet())
helper->printf("Build succeeded.\n");
} 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);
return retVal;

View File

@@ -265,7 +265,7 @@ int buildFatBinary(const std::vector<std::string> &args, OclocArgHelper *argHelp
argsCopy[deviceArgIndex] = targetPlatform.str();
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");
return retVal;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2020 Intel Corporation
* Copyright (C) 2018-2021 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -15,6 +15,7 @@
#include "shared/source/helpers/compiler_options_parser.h"
#include "shared/source/helpers/debug_helpers.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/string.h"
#include "shared/source/os_interface/os_library.h"
@@ -286,11 +287,13 @@ std::string &OfflineCompiler::getBuildLog() {
return buildLog;
}
int OfflineCompiler::getHardwareInfo(const char *pDeviceName) {
int OfflineCompiler::getHardwareInfo(std::string deviceName) {
int retVal = INVALID_DEVICE;
overridePlatformName(deviceName);
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]) {
hwInfo = *hardwareInfoTable[productId];
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
*
@@ -28,22 +28,22 @@ class OsLibrary;
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 getDevicesTypes();
class OfflineCompiler {
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);
int build();
std::string &getBuildLog();
@@ -77,7 +77,7 @@ class OfflineCompiler {
protected:
OfflineCompiler();
int getHardwareInfo(const char *pDeviceName);
int getHardwareInfo(std::string deviceName);
std::string getStringWithinDelimiters(const std::string &src);
int initialize(size_t numArgs, const std::vector<std::string> &allArgs, bool dumpFiles);
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_info.cpp
${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}/kernel_helpers.cpp
${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
*
@@ -8,6 +8,7 @@
#include "shared/source/helpers/hw_info.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/helpers/hw_helper.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) {
std::transform(platform.begin(), platform.end(), platform.begin(), ::tolower);
overridePlatformName(platform);
bool ret = false;
for (int j = 0; j < IGFX_MAX_PRODUCT; j++) {
if (hardwarePrefix[j] == nullptr)
@@ -56,6 +59,7 @@ bool getHwInfoForPlatformString(std::string &platform, const HardwareInfo *&hwIn
break;
}
}
return ret;
}

View File

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