Add -config flag to ocloc

Addition of a -config parameter that will allow
the user to set the number of EUs, slices etc.
Knowing these values during AOT can translate into performance.

Signed-off-by: Daria Hinz <daria.hinz@intel.com>
This commit is contained in:
Daria Hinz
2022-07-04 15:24:55 +02:00
committed by Compute-Runtime-Automation
parent c7021c21b3
commit 789dd1900e
7 changed files with 153 additions and 45 deletions

View File

@@ -168,7 +168,7 @@ std::unique_ptr<char[]> OclocArgHelper::loadDataFromFile(const std::string &file
}
}
bool OclocArgHelper::getHwInfoForProductConfig(uint32_t config, NEO::HardwareInfo &hwInfo) {
bool OclocArgHelper::getHwInfoForProductConfig(uint32_t config, NEO::HardwareInfo &hwInfo, uint64_t hwInfoConfig) {
bool retVal = false;
if (config == AOT::UNKNOWN_ISA) {
return retVal;
@@ -179,6 +179,9 @@ bool OclocArgHelper::getHwInfoForProductConfig(uint32_t config, NEO::HardwareInf
hwInfo = *deviceConfig.hwInfo;
const auto &compilerHwInfoConfig = *NEO::CompilerHwInfoConfig::get(hwInfo.platform.eProductFamily);
compilerHwInfoConfig.setProductConfigForHwInfo(hwInfo, deviceConfig.aotConfig);
if (hwInfoConfig) {
setHwInfoValuesFromConfig(hwInfoConfig, hwInfo);
}
NEO::hardwareInfoBaseSetup[hwInfo.platform.eProductFamily](&hwInfo, true);
if (deviceConfig.deviceIds) {
@@ -191,6 +194,26 @@ bool OclocArgHelper::getHwInfoForProductConfig(uint32_t config, NEO::HardwareInf
return retVal;
}
std::vector<NEO::ConstStringRef> OclocArgHelper::getDeprecatedAcronyms() {
std::vector<NEO::ConstStringRef> prefixes{}, deprecatedAcronyms{}, enabledAcronyms{};
for (int j = 0; j < IGFX_MAX_PRODUCT; j++) {
if (NEO::hardwarePrefix[j] == nullptr)
continue;
prefixes.push_back(NEO::hardwarePrefix[j]);
}
for (const auto &device : deviceMap) {
enabledAcronyms.insert(enabledAcronyms.end(), device.acronyms.begin(), device.acronyms.end());
}
for (const auto &prefix : prefixes) {
if (std::any_of(enabledAcronyms.begin(), enabledAcronyms.end(), ProductConfigHelper::findAcronymWithoutDash(prefix.str())))
continue;
deprecatedAcronyms.push_back(prefix);
}
return deprecatedAcronyms;
}
void OclocArgHelper::saveOutput(const std::string &filename, const void *pData, const size_t &dataSize) {
if (outputEnabled()) {
addOutput(filename, pData, dataSize);

View File

@@ -115,13 +115,15 @@ class OclocArgHelper {
};
MOCKABLE_VIRTUAL bool fileExists(const std::string &filename) const;
int parseProductConfigFromString(const std::string &device, size_t begin, size_t end);
bool getHwInfoForProductConfig(uint32_t config, NEO::HardwareInfo &hwInfo);
bool getHwInfoForProductConfig(uint32_t config, NEO::HardwareInfo &hwInfo, uint64_t hwInfoConfig);
std::vector<DeviceMapping> &getAllSupportedDeviceConfigs();
std::vector<NEO::ConstStringRef> getEnabledProductAcronyms();
std::vector<NEO::ConstStringRef> getEnabledReleasesAcronyms();
std::vector<NEO::ConstStringRef> getEnabledFamiliesAcronyms();
std::string getAllSupportedAcronyms();
AOT::PRODUCT_CONFIG getProductConfigForVersionValue(const std::string &device);
std::vector<NEO::ConstStringRef> getDeprecatedAcronyms();
bool setAcronymForDeviceId(std::string &device);
std::vector<std::string> headersToVectorOfStrings();
MOCKABLE_VIRTUAL void readFileToVectorOfStrings(const std::string &filename, std::vector<std::string> &lines);

View File

@@ -340,9 +340,10 @@ int OfflineCompiler::initHardwareInfoForDeprecatedAcronyms(std::string deviceNam
if (deviceId != -1) {
hwInfo.platform.usDeviceID = deviceId;
}
auto hwInfoConfig = defaultHardwareInfoConfigTable[hwInfo.platform.eProductFamily];
setHwInfoValuesFromConfig(hwInfoConfig, hwInfo);
uint64_t config = hwInfoConfig ? hwInfoConfig : defaultHardwareInfoConfigTable[hwInfo.platform.eProductFamily];
setHwInfoValuesFromConfig(config, hwInfo);
hardwareInfoBaseSetup[hwInfo.platform.eProductFamily](&hwInfo, true);
setFamilyType();
return SUCCESS;
}
@@ -364,7 +365,7 @@ int OfflineCompiler::initHardwareInfoForProductConfig(std::string deviceName) {
}
if (config != AOT::UNKNOWN_ISA) {
if (argHelper->getHwInfoForProductConfig(config, hwInfo)) {
if (argHelper->getHwInfoForProductConfig(config, hwInfo, hwInfoConfig)) {
if (revisionId != -1) {
hwInfo.platform.usRevId = revisionId;
}
@@ -626,6 +627,14 @@ int OfflineCompiler::parseCommandLine(size_t numArgs, const std::vector<std::str
} else if ("--format" == currArg) {
formatToEnforce = argv[argIndex + 1];
argIndex++;
} else if (("-config" == currArg) && hasMoreArgs) {
parseHwInfoConfigString(argv[argIndex + 1], hwInfoConfig);
if (!hwInfoConfig) {
argHelper->printf("Error: Invalid config.\n");
retVal = INVALID_COMMAND_LINE;
break;
}
argIndex++;
} else {
argHelper->printf("Invalid option (arg %d): %s\n", argIndex, argv[argIndex].c_str());
retVal = INVALID_COMMAND_LINE;
@@ -767,26 +776,13 @@ auto findDuplicate(const EqComparableT &lhs) {
}
std::string OfflineCompiler::getDeprecatedDevicesTypes() {
std::vector<std::string> prefixes;
for (int j = 0; j < IGFX_MAX_PRODUCT; j++) {
if (hardwarePrefix[j] == nullptr)
continue;
prefixes.push_back(hardwarePrefix[j]);
}
std::vector<NEO::ConstStringRef> enabledAcronyms{};
auto enabledConfigs = argHelper->getAllSupportedDeviceConfigs();
for (const auto &device : enabledConfigs) {
enabledAcronyms.insert(enabledAcronyms.end(), device.acronyms.begin(), device.acronyms.end());
}
auto acronyms = argHelper->getDeprecatedAcronyms();
std::ostringstream os;
for (const auto &prefix : prefixes) {
if (std::any_of(enabledAcronyms.begin(), enabledAcronyms.end(), ProductConfigHelper::findAcronymWithoutDash(prefix)))
continue;
for (const auto &acronym : acronyms) {
if (os.tellp())
os << ", ";
os << prefix;
os << acronym.str();
}
return os.str();
@@ -949,6 +945,9 @@ Usage: ocloc [compile] -file <filename> -device <device_type> [-output <filename
--format zebin - Enforce generating zebin binary
--format patchtokens - Enforce generating patchtokens (legacy) binary.
-config Target hardware info config for a single device,
e.g 1x4x8.
Examples :
Compile file to Intel Compute GPU device binary (out = source_file_Gen9core.bin)
ocloc -file source_file.cl -device skl

View File

@@ -163,6 +163,7 @@ class OfflineCompiler {
struct buildInfo;
std::unique_ptr<buildInfo> pBuildInfo;
int revisionId = -1;
uint64_t hwInfoConfig = 0u;
std::unique_ptr<OclocIgcFacade> igcFacade{nullptr};
std::unique_ptr<OclocFclFacade> fclFacade{nullptr};