mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 08:53:55 +08:00
New query option ocloc query SUPPORTED_DEVICE allows to generate a YAML file containing information about supported devices for: - the current version of ocloc on Windows - the current and previous versions of ocloc on Linux Each version of ocloc build needs to set NEO_OCLOC_CURRENT_LIB_NAME NEO_OCLOC_FORMER_LIB_NAME cmake defines for the ocloc to be able to find a previous lib and query its supported devices. Example of correct format: NEO_OCLOC_FORMER_LIB_NAME=libocloc-1.0.so NEO_OCLOC_CURRENT_LIB_NAME=libocloc-2.0.so Related-To: NEO-9630 Signed-off-by: Fabian Zwoliński <fabian.zwolinski@intel.com>
104 lines
3.5 KiB
C++
104 lines
3.5 KiB
C++
/*
|
|
* Copyright (C) 2024 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "shared/offline_compiler/source/ocloc_arg_helper.h"
|
|
#include "shared/source/helpers/product_config_helper.h"
|
|
|
|
#include <map>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace Ocloc {
|
|
|
|
namespace SupportedDevicesYamlConstants {
|
|
constexpr std::string_view deviceIpVersions = "device_ip_versions";
|
|
constexpr std::string_view ipToDevRevId = "ip_to_dev_rev_id";
|
|
constexpr std::string_view acronym = "acronym";
|
|
constexpr std::string_view familyGroups = "family_groups";
|
|
constexpr std::string_view releaseGroups = "release_groups";
|
|
|
|
// Fields in IpToDevRevId section
|
|
constexpr std::string_view ip = "ip";
|
|
constexpr std::string_view revisionId = "revision_id";
|
|
constexpr std::string_view deviceId = "device_id";
|
|
} // namespace SupportedDevicesYamlConstants
|
|
|
|
enum class SupportedDevicesMode {
|
|
merge,
|
|
concat,
|
|
unknown
|
|
};
|
|
|
|
class SupportedDevicesHelper {
|
|
public:
|
|
struct DeviceInfo {
|
|
uint32_t deviceId;
|
|
uint32_t revisionId;
|
|
uint32_t ipVersion;
|
|
};
|
|
|
|
struct SupportedDevicesData {
|
|
std::vector<uint32_t> deviceIpVersions;
|
|
std::vector<DeviceInfo> deviceInfos;
|
|
std::vector<std::pair<std::string, uint32_t>> acronyms;
|
|
std::vector<std::pair<std::string, std::vector<uint32_t>>> familyGroups;
|
|
std::vector<std::pair<std::string, std::vector<uint32_t>>> releaseGroups;
|
|
};
|
|
|
|
public:
|
|
SupportedDevicesHelper(SupportedDevicesMode mode, ProductConfigHelper *productConfigHelper)
|
|
: mode(mode), productConfigHelper(productConfigHelper) {}
|
|
|
|
std::string getOclocCurrentVersionOutputFilename() const;
|
|
SupportedDevicesData collectSupportedDevicesData(const std::vector<DeviceAotInfo> &enabledDevices) const;
|
|
|
|
std::string serialize(std::string_view oclocVersion, const SupportedDevicesData &data) const;
|
|
std::map<std::string, SupportedDevicesData> deserialize(std::string_view yamlString) const;
|
|
|
|
std::string mergeAndSerializeWithFormerVersionData(const SupportedDevicesData ¤tVersionData) const;
|
|
std::string concatAndSerializeWithFormerVersionData(const SupportedDevicesData ¤tVersionData) const;
|
|
|
|
MOCKABLE_VIRTUAL std::string getDataFromFormerOclocVersion() const;
|
|
|
|
protected:
|
|
MOCKABLE_VIRTUAL std::string getOclocCurrentLibName() const;
|
|
MOCKABLE_VIRTUAL std::string getOclocFormerLibName() const;
|
|
MOCKABLE_VIRTUAL std::string getOclocCurrentVersion() const;
|
|
std::string getOclocFormerVersion() const;
|
|
std::string extractOclocVersion(std::string_view oclocLibNameWithVersion) const;
|
|
SupportedDevicesData mergeOclocVersionData(const std::map<std::string, SupportedDevicesData> &versionDataMap) const;
|
|
std::string getOutputFilenameSuffix([[maybe_unused]] SupportedDevicesMode mode) const;
|
|
|
|
private:
|
|
SupportedDevicesMode mode;
|
|
ProductConfigHelper *productConfigHelper;
|
|
static constexpr std::string_view fileExtension = ".yaml";
|
|
};
|
|
|
|
inline SupportedDevicesMode parseSupportedDevicesMode(std::string_view modeStr) {
|
|
if (modeStr == "-merge") {
|
|
return SupportedDevicesMode::merge;
|
|
} else if (modeStr == "-concat") {
|
|
return SupportedDevicesMode::concat;
|
|
} else {
|
|
return SupportedDevicesMode::unknown;
|
|
}
|
|
}
|
|
|
|
inline std::string toStr(SupportedDevicesMode mode) {
|
|
switch (mode) {
|
|
case SupportedDevicesMode::concat:
|
|
return "concat";
|
|
case SupportedDevicesMode::merge:
|
|
return "merge";
|
|
default:
|
|
return "unknown";
|
|
}
|
|
}
|
|
} // namespace Ocloc
|