mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-19 06:24:51 +08:00
refactor: extract logic of calling former ocloc to separate function
Related-To: NEO-12273 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
1cca5e24c1
commit
a32bb4d9a4
@@ -8,7 +8,6 @@
|
||||
#include "shared/offline_compiler/source/ocloc_api.h"
|
||||
#include "shared/offline_compiler/source/ocloc_interface.h"
|
||||
#include "shared/offline_compiler/source/ocloc_supported_devices_helper.h"
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <memory>
|
||||
@@ -49,21 +48,8 @@ std::string SupportedDevicesHelper::extractOclocVersion(std::string_view oclocLi
|
||||
}
|
||||
|
||||
std::string SupportedDevicesHelper::getDataFromFormerOclocVersion() const {
|
||||
if (getOclocFormerLibName().empty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::unique_ptr<OsLibrary> oclocLib(OsLibrary::load(getOclocFormerLibName()));
|
||||
|
||||
if (!oclocLib ||
|
||||
!oclocLib->isLoaded()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string retData;
|
||||
|
||||
auto oclocInvokeFunc = reinterpret_cast<pOclocInvoke>(oclocLib->getProcAddress("oclocInvoke"));
|
||||
|
||||
const char *argv[] = {"ocloc", "query", "SUPPORTED_DEVICES", "-concat"};
|
||||
|
||||
unsigned int numArgs = sizeof(argv) / sizeof(argv[0]);
|
||||
@@ -72,19 +58,23 @@ std::string SupportedDevicesHelper::getDataFromFormerOclocVersion() const {
|
||||
size_t *ouputLengths = nullptr;
|
||||
char **outputNames = nullptr;
|
||||
|
||||
oclocInvokeFunc(numArgs, argv,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&numOutputs,
|
||||
&dataOutputs,
|
||||
&ouputLengths,
|
||||
&outputNames);
|
||||
auto retVal = Commands::invokeFormerOcloc(getOclocFormerLibName(),
|
||||
numArgs, argv,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
0,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&numOutputs,
|
||||
&dataOutputs,
|
||||
&ouputLengths,
|
||||
&outputNames);
|
||||
if (!retVal) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const std::string expectedSubstr = getOutputFilenameSuffix(SupportedDevicesMode::concat);
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "shared/offline_compiler/source/offline_linker.h"
|
||||
#include "shared/offline_compiler/source/utilities/safety_caller.h"
|
||||
#include "shared/source/device_binary_format/elf/elf_decoder.h"
|
||||
#include "shared/source/os_interface/os_library.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -263,6 +264,25 @@ int concat(OclocArgHelper *argHelper, const std::vector<std::string> &args) {
|
||||
error = arConcat.concatenate();
|
||||
return error;
|
||||
}
|
||||
std::optional<int> invokeFormerOcloc(const std::string &formerOclocName, unsigned int numArgs, const char *argv[],
|
||||
const uint32_t numSources, const uint8_t **dataSources, const uint64_t *lenSources, const char **nameSources,
|
||||
const uint32_t numInputHeaders, const uint8_t **dataInputHeaders, const uint64_t *lenInputHeaders, const char **nameInputHeaders,
|
||||
uint32_t *numOutputs, uint8_t ***dataOutputs, uint64_t **lenOutputs, char ***nameOutputs) {
|
||||
if (formerOclocName.empty()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
std::unique_ptr<OsLibrary> oclocLib(OsLibrary::load(formerOclocName));
|
||||
|
||||
if (!oclocLib ||
|
||||
!oclocLib->isLoaded()) {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto oclocInvokeFunc = reinterpret_cast<pOclocInvoke>(oclocLib->getProcAddress("oclocInvoke"));
|
||||
|
||||
return oclocInvokeFunc(numArgs, argv, numSources, dataSources, lenSources, nameSources, numInputHeaders, dataInputHeaders, lenInputHeaders, nameInputHeaders, numOutputs, dataOutputs, lenOutputs, nameOutputs);
|
||||
}
|
||||
|
||||
} // namespace Commands
|
||||
} // namespace Ocloc
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "shared/source/utilities/const_stringref.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -41,5 +43,9 @@ int validate(OclocArgHelper *argHelper, const std::vector<std::string> &args);
|
||||
int query(OclocArgHelper *argHelper, const std::vector<std::string> &args);
|
||||
int ids(OclocArgHelper *argHelper, const std::vector<std::string> &args);
|
||||
int concat(OclocArgHelper *argHelper, const std::vector<std::string> &args);
|
||||
std::optional<int> invokeFormerOcloc(const std::string &formerOclocName, unsigned int numArgs, const char *argv[],
|
||||
const uint32_t numSources, const uint8_t **dataSources, const uint64_t *lenSources, const char **nameSources,
|
||||
const uint32_t numInputHeaders, const uint8_t **dataInputHeaders, const uint64_t *lenInputHeaders, const char **nameInputHeaders,
|
||||
uint32_t *numOutputs, uint8_t ***dataOutputs, uint64_t **lenOutputs, char ***nameOutputs);
|
||||
} // namespace Commands
|
||||
} // namespace Ocloc
|
||||
|
||||
Reference in New Issue
Block a user