mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-06 02:18:05 +08:00
Add interface to extract versioning info
Appened ocloc interface with new 'query' feature. Using this feature now one can extract HEAD hash and version of neo. Signed-off-by: Bushev, Dmitry <dmitry.bushev@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
4dda709b41
commit
9e18416098
@@ -59,6 +59,8 @@ set(CLOC_LIB_SRCS_LIB
|
||||
${OCLOC_DIRECTORY}/source/offline_compiler.h
|
||||
${OCLOC_DIRECTORY}/source/offline_compiler_helper.cpp
|
||||
${OCLOC_DIRECTORY}/source/offline_compiler_options.cpp
|
||||
${OCLOC_DIRECTORY}/source/utilities/get_git_version_info.h
|
||||
${OCLOC_DIRECTORY}/source/utilities/get_git_version_info.cpp
|
||||
${NEO_SOURCE_DIR}/shared/source/device_binary_format/device_binary_format_zebin.cpp
|
||||
${NEO_SOURCE_DIR}/shared/source/device_binary_format/zebin_decoder.cpp
|
||||
${NEO_SOURCE_DIR}/shared/source/device_binary_format/yaml/yaml_parser.cpp
|
||||
|
||||
@@ -106,6 +106,8 @@ int oclocInvoke(unsigned int numArgs, const char *argv[],
|
||||
return buildFatBinary(allArgs, helper.get());
|
||||
} else if (numArgs > 1 && ConstStringRef("validate") == allArgs[1]) {
|
||||
return NEO::Ocloc::validate(allArgs, helper.get());
|
||||
} else if (numArgs > 1 && ConstStringRef("query") == allArgs[1]) {
|
||||
return OfflineCompiler::query(numArgs, allArgs, helper.get());
|
||||
} else {
|
||||
int retVal = OfflineCompiler::ErrorCode::SUCCESS;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "offline_compiler.h"
|
||||
|
||||
#include "shared/offline_compiler/source/utilities/get_git_version_info.h"
|
||||
#include "shared/source/compiler_interface/intermediate_representations.h"
|
||||
#include "shared/source/debug_settings/debug_settings_manager.h"
|
||||
#include "shared/source/device_binary_format/device_binary_formats.h"
|
||||
@@ -104,6 +105,22 @@ OfflineCompiler *OfflineCompiler::create(size_t numArgs, const std::vector<std::
|
||||
return pOffCompiler;
|
||||
}
|
||||
|
||||
int OfflineCompiler::query(size_t numArgs, const std::vector<std::string> &allArgs, OclocArgHelper *helper) {
|
||||
int retVal = OUT_OF_HOST_MEMORY;
|
||||
std::unique_ptr<OfflineCompiler> pOffCompiler{new OfflineCompiler()};
|
||||
|
||||
pOffCompiler->queryInvoke = true;
|
||||
pOffCompiler->argHelper = helper;
|
||||
retVal = pOffCompiler->initialize(numArgs, allArgs, true);
|
||||
|
||||
if (retVal != SUCCESS)
|
||||
return retVal;
|
||||
|
||||
retVal = pOffCompiler->performQuery();
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
struct OfflineCompiler::buildInfo {
|
||||
std::unique_ptr<CIF::Builtins::BufferLatest, CIF::RAII::ReleaseHelper<CIF::Builtins::BufferLatest>> fclOptions;
|
||||
std::unique_ptr<CIF::Builtins::BufferLatest, CIF::RAII::ReleaseHelper<CIF::Builtins::BufferLatest>> fclInternalOptions;
|
||||
@@ -360,7 +377,7 @@ int OfflineCompiler::initialize(size_t numArgs, const std::vector<std::string> &
|
||||
size_t sourceFromFileSize = 0;
|
||||
this->pBuildInfo = std::make_unique<buildInfo>();
|
||||
retVal = parseCommandLine(numArgs, allArgs);
|
||||
if (retVal != SUCCESS) {
|
||||
if (retVal != SUCCESS || queryInvoke) {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -585,6 +602,20 @@ int OfflineCompiler::initialize(size_t numArgs, const std::vector<std::string> &
|
||||
return retVal;
|
||||
}
|
||||
|
||||
int OfflineCompiler::performQuery() {
|
||||
int retVal = SUCCESS;
|
||||
|
||||
if (queryOption == QUERY_NEO_REVISION) {
|
||||
auto revision = NEO::getRevision();
|
||||
argHelper->saveOutput("NEO_REVISION", revision.c_str(), revision.size() + 1);
|
||||
} else {
|
||||
auto driverVersion = NEO::getOclDriverVersion();
|
||||
argHelper->saveOutput("OCL_DRIVER_VERSION", driverVersion.c_str(), driverVersion.size() + 1);
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
int OfflineCompiler::parseCommandLine(size_t numArgs, const std::vector<std::string> &argv) {
|
||||
int retVal = SUCCESS;
|
||||
bool compile32 = false;
|
||||
@@ -598,7 +629,7 @@ int OfflineCompiler::parseCommandLine(size_t numArgs, const std::vector<std::str
|
||||
for (uint32_t argIndex = 1; argIndex < numArgs; argIndex++) {
|
||||
const auto &currArg = argv[argIndex];
|
||||
const bool hasMoreArgs = (argIndex + 1 < numArgs);
|
||||
if ("compile" == currArg) {
|
||||
if ("compile" == currArg || "query" == currArg) {
|
||||
//skip it
|
||||
} else if (("-file" == currArg) && hasMoreArgs) {
|
||||
inputFile = argv[argIndex + 1];
|
||||
@@ -653,6 +684,10 @@ int OfflineCompiler::parseCommandLine(size_t numArgs, const std::vector<std::str
|
||||
} else if (("-revision_id" == currArg) && hasMoreArgs) {
|
||||
revisionId = std::stoi(argv[argIndex + 1]);
|
||||
argIndex++;
|
||||
} else if ("NEO_REVISION" == currArg && queryInvoke && !hasMoreArgs) {
|
||||
queryOption = QUERY_NEO_REVISION;
|
||||
} else if ("OCL_DRIVER_VERSION" == currArg && queryInvoke && !hasMoreArgs) {
|
||||
queryOption = QUERY_OCL_DRIVER_VERSION;
|
||||
} else {
|
||||
argHelper->printf("Invalid option (arg %d): %s\n", argIndex, argv[argIndex].c_str());
|
||||
retVal = INVALID_COMMAND_LINE;
|
||||
@@ -661,18 +696,25 @@ int OfflineCompiler::parseCommandLine(size_t numArgs, const std::vector<std::str
|
||||
}
|
||||
|
||||
if (retVal == SUCCESS) {
|
||||
if (compile32 && compile64) {
|
||||
argHelper->printf("Error: Cannot compile for 32-bit and 64-bit, please choose one.\n");
|
||||
retVal = INVALID_COMMAND_LINE;
|
||||
} else if (inputFile.empty()) {
|
||||
argHelper->printf("Error: Input file name missing.\n");
|
||||
retVal = INVALID_COMMAND_LINE;
|
||||
} else if (deviceName.empty() && (false == onlySpirV)) {
|
||||
argHelper->printf("Error: Device name missing.\n");
|
||||
retVal = INVALID_COMMAND_LINE;
|
||||
} else if (!argHelper->fileExists(inputFile)) {
|
||||
argHelper->printf("Error: Input file %s missing.\n", inputFile.c_str());
|
||||
retVal = INVALID_FILE;
|
||||
if (queryInvoke) {
|
||||
if (queryOption == QUERY_LAST) {
|
||||
argHelper->printf("Error: no options for query provided.\n");
|
||||
retVal = INVALID_COMMAND_LINE;
|
||||
}
|
||||
} else {
|
||||
if (compile32 && compile64) {
|
||||
argHelper->printf("Error: Cannot compile for 32-bit and 64-bit, please choose one.\n");
|
||||
retVal = INVALID_COMMAND_LINE;
|
||||
} else if (inputFile.empty()) {
|
||||
argHelper->printf("Error: Input file name missing.\n");
|
||||
retVal = INVALID_COMMAND_LINE;
|
||||
} else if (deviceName.empty() && (false == onlySpirV)) {
|
||||
argHelper->printf("Error: Device name missing.\n");
|
||||
retVal = INVALID_COMMAND_LINE;
|
||||
} else if (!argHelper->fileExists(inputFile)) {
|
||||
argHelper->printf("Error: Input file %s missing.\n", inputFile.c_str());
|
||||
retVal = INVALID_FILE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,8 +43,14 @@ class OfflineCompiler {
|
||||
INVALID_FILE = -5151,
|
||||
PRINT_USAGE = -5152,
|
||||
};
|
||||
enum QueryOption {
|
||||
QUERY_OCL_DRIVER_VERSION = 0,
|
||||
QUERY_NEO_REVISION = 1,
|
||||
QUERY_LAST,
|
||||
};
|
||||
|
||||
static OfflineCompiler *create(size_t numArgs, const std::vector<std::string> &allArgs, bool dumpFiles, int &retVal, OclocArgHelper *helper);
|
||||
static int query(size_t numArgs, const std::vector<std::string> &allArgs, OclocArgHelper *helper);
|
||||
int build();
|
||||
std::string &getBuildLog();
|
||||
void printUsage();
|
||||
@@ -81,6 +87,7 @@ class OfflineCompiler {
|
||||
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);
|
||||
int performQuery();
|
||||
void setStatelessToStatefullBufferOffsetFlag();
|
||||
void resolveExtraSettings();
|
||||
void parseDebugSettings();
|
||||
@@ -124,6 +131,8 @@ class OfflineCompiler {
|
||||
bool inputFileSpirV = false;
|
||||
bool outputNoSuffix = false;
|
||||
bool forceStatelessToStatefulOptimization = false;
|
||||
bool queryInvoke = false;
|
||||
int queryOption = QUERY_LAST;
|
||||
|
||||
std::vector<uint8_t> elfBinary;
|
||||
char *genBinary = nullptr;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#include "driver_version.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef QTR
|
||||
#undef QTR
|
||||
#endif
|
||||
|
||||
#ifdef TOSTR
|
||||
#undef TOSTR
|
||||
#endif
|
||||
|
||||
#define QTR(a) #a
|
||||
#define TOSTR(b) QTR(b)
|
||||
|
||||
namespace NEO {
|
||||
|
||||
std::string getRevision() {
|
||||
#ifdef NEO_REVISION
|
||||
return NEO_REVISION;
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string getOclDriverVersion() {
|
||||
#ifdef NEO_OCL_DRIVER_VERSION
|
||||
return TOSTR(NEO_OCL_DRIVER_VERSION);
|
||||
#else
|
||||
return "";
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace NEO
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
namespace NEO {
|
||||
extern std::string getRevision();
|
||||
extern std::string getOclDriverVersion();
|
||||
} // namespace NEO
|
||||
Reference in New Issue
Block a user