diff --git a/src/runtime_src/core/include/xrt/detail/xclbin.h b/src/runtime_src/core/include/xrt/detail/xclbin.h index fe76148215..bf7d2ac022 100644 --- a/src/runtime_src/core/include/xrt/detail/xclbin.h +++ b/src/runtime_src/core/include/xrt/detail/xclbin.h @@ -221,7 +221,7 @@ extern "C" { enum ACTION_MASK { AM_LOAD_AIE = 0x1, /* Indicates to the driver to load the AIE PID section */ - AM_LOAD_PDI = 0x2, /* Indicates to the driver to program the PDI */ + AM_LOAD_PDI = 0x2, /* Indicates to the driver to program the PDI */ }; struct axlf_section_header { @@ -262,9 +262,9 @@ extern "C" { uint64_t m_uniqueId; /* axlf's uniqueId, use it to skip redownload etc */ struct axlf_header m_header; /* Inline header */ #if defined(__linux__) && defined(__KERNEL__) - struct axlf_section_header m_sections[]; // One or more section headers follow. Flexible array size suitable for kernel space. + struct axlf_section_header m_sections[]; // One or more section headers follow. Flexible array size suitable for kernel space. #else - struct axlf_section_header m_sections[1]; /* One or more section headers follow */ + struct axlf_section_header m_sections[1]; /* One or more section headers follow */ #endif }; @@ -369,7 +369,7 @@ extern "C" { // m_interrupt_id : Bits - 0x0000_00FE; // m_ip_control : Bits = 0x0000_FF00; // properties is also used for ps kernel (i.e. -add-pskernel) - + // PS Kernels // m_type: IP_PS_KERNEL struct { @@ -461,7 +461,7 @@ extern "C" { #if defined(__linux__) && defined(__KERNEL__) struct clock_freq m_clock_freq[]; // Clock array. Flexible array size suitable for kernel space. #else - struct clock_freq m_clock_freq[1]; /* Clock array */ + struct clock_freq m_clock_freq[1]; /* Clock array */ #endif }; @@ -630,15 +630,15 @@ extern "C" { uint8_t reserved[72]; // Reserved }; XCLBIN_STATIC_ASSERT(sizeof(struct aie_partition_info) == 88, "partition_info structure no longer is 88 bytes in size"); - + struct aie_partition { uint8_t schema_version; // Group schema version (default 0) - uint8_t padding0[3]; // Byte alignment - uint32_t mpo_name; // Name of the aie_partition + uint8_t padding0[3]; // Byte alignment + uint32_t mpo_name; // Name of the aie_partition uint32_t operations_per_cycle; // Operations per cycle. Used later to create TOPS (operations_per_cycle * ) uint8_t padding[4]; uint64_t inference_fingerprint; // The unique hash value of the inference function - uint64_t pre_post_fingerprint; // The unique hash value of pre post + uint64_t pre_post_fingerprint; // The unique hash value of pre post struct aie_partition_info info; // Partition information struct array_offset aie_pdi; // PDI Array (aie_partition_info) // kernel_commit_id is modeled after mpo_name @@ -647,7 +647,7 @@ extern "C" { // // The pointer to access the string is initialized as follows: // char * pCharString = (address_of_section) + (mpo value) - uint32_t kernel_commit_id; // The git repo commit id for DPU_PHX_KERNEL + uint32_t kernel_commit_id; // The git repo commit id for DPU_PHX_KERNEL uint8_t reserved[52]; // Reserved }; XCLBIN_STATIC_ASSERT(sizeof(struct aie_partition) == 184, "aie_partition structure no longer is 184 bytes in size"); @@ -655,7 +655,7 @@ extern "C" { /**** END : Xilinx internal section *****/ -# if defined(__cplusplus) && !defined(__KERNEL__) && !defined(_KERNEL_MODE) +# if defined(__cplusplus) && !defined(__KERNEL__) && !defined(_KERNEL_MODE) namespace xclbin { inline const axlf_section_header* get_axlf_section(const axlf* top, axlf_section_kind kind) diff --git a/src/runtime_src/tools/xclbinutil/ElfUtilities.cxx b/src/runtime_src/tools/xclbinutil/ElfUtilities.cxx index d67e053936..074047f0f8 100644 --- a/src/runtime_src/tools/xclbinutil/ElfUtilities.cxx +++ b/src/runtime_src/tools/xclbinutil/ElfUtilities.cxx @@ -32,11 +32,12 @@ namespace XUtil = XclBinUtilities; +namespace fs = std::filesystem; static auto findExecutablePath(const std::string& executable) { - std::filesystem::path executablePath; + fs::path executablePath; #if 0 // Only enabled for the Vitis version of xclbinutil // -- Check to see if XILINX_VITIS has been set @@ -46,7 +47,7 @@ auto findExecutablePath(const std::string& executable) executablePath = xilinxVitisEnv; executablePath = executablePath / "aietools" / "tps" / "lnx64" / "gcc" / "bin" / executable; XUtil::TRACE("Step 1: Looking for executable at: '" + executablePath.string() + "'"); - if (!std::filesystem::exists(executablePath)) { + if (!fs::exists(executablePath)) { executablePath = ""; // Executable doesn't exist XUtil::TRACE("Not found"); } @@ -59,7 +60,7 @@ auto findExecutablePath(const std::string& executable) XUtil::TRACE("Step 2: Looking for executable path"); auto path = boost::process::search_path(executable); executablePath = path.string(); - if (!std::filesystem::exists(executablePath)) + if (!fs::exists(executablePath)) XUtil::TRACE("Not found"); } @@ -67,7 +68,7 @@ auto findExecutablePath(const std::string& executable) // -- Default path /usr/bin if (executablePath.string().empty()) - executablePath = std::filesystem::path("/usr") / "bin" / executable; + executablePath = fs::path("/usr") / "bin" / executable; return executablePath; } @@ -875,10 +876,10 @@ drcCheckExportedFunctions(const std::vector exportedFunctions) // Report all of the mangled functions if (!mangledFunctions.empty()) { std::sort(mangledFunctions.begin(), mangledFunctions.end()); - + auto errMsg = boost::str(boost::format("ERROR: C++ mangled functions are not supported, please export the function. \nOffending function(s):\n")); - for (const auto& entry : mangledFunctions) + for (const auto& entry : mangledFunctions) errMsg += boost::str(boost::format(" %s\n") % entry); throw std::runtime_error(errMsg); diff --git a/src/runtime_src/tools/xclbinutil/KernelUtilities.cxx b/src/runtime_src/tools/xclbinutil/KernelUtilities.cxx index 569651b207..825e6dc8ca 100644 --- a/src/runtime_src/tools/xclbinutil/KernelUtilities.cxx +++ b/src/runtime_src/tools/xclbinutil/KernelUtilities.cxx @@ -135,13 +135,13 @@ void buildXMLKernelEntry(const boost::property_tree::ptree& ptKernel, // but xml only taks numeric value // we need to conver string to correponding nemeric auto sFunctional = ptExtendedData.get("functional", ""); - sFunctional = SectionIPLayout::getFunctionalEnumStr(sFunctional); + sFunctional = SectionIPLayout::getFunctionalEnumStr(sFunctional); ptExtendedData.put("functional", sFunctional); auto sSubType = ptExtendedData.get("subtype", ""); - sSubType = SectionIPLayout::getSubTypeEnumStr(sSubType); + sSubType = SectionIPLayout::getSubTypeEnumStr(sSubType); ptExtendedData.put("subtype", sSubType); - + boost::property_tree::ptree ptEntry; ptEntry.add_child("", ptExtendedData); ptKernelXML.add_child("extended-data", ptEntry); @@ -297,7 +297,7 @@ void addArgsToMemoryConnections(const unsigned int ipLayoutIndexID, // if memory-connection is not empty // 1. for --add-pskernel, user can specify the memory bank indices in // the value - // 2. for --add-kernel, user can specify the memory bank tag in the + // 2. for --add-kernel, user can specify the memory bank tag in the // input file if (memoryConnection == NOT_DEFINED) { ++argIndexID; @@ -355,7 +355,7 @@ void addArgsToMemoryConnections(const unsigned int ipLayoutIndexID, } else { - const auto errMsg = boost::format("Specified memory bank (%d) is invalid. Valid ranges are from 0 to %d.") % memBankIndex % memTopology.size(); + const auto errMsg = boost::format("Specified memory bank (%d) is invalid. Valid ranges are from 0 to %d.") % memBankIndex % memTopology.size(); throw std::runtime_error(errMsg.str()); } } @@ -465,7 +465,7 @@ XclBinUtilities::addKernel(const boost::property_tree::ptree& ptKernel, // "fundtional": "0" // "subtype": "1" // "dpu_kernel_id": "0x101" - // } + // } boost::optional< const boost::property_tree::ptree& > boExtendedData = ptKernel.get_child_optional("extended-data"); if (boExtendedData) { const boost::property_tree::ptree& ptExtendedData = boExtendedData.get(); diff --git a/src/runtime_src/tools/xclbinutil/SectionAIEPartition.cxx b/src/runtime_src/tools/xclbinutil/SectionAIEPartition.cxx index 6b3340f0b5..cfb335bfc6 100644 --- a/src/runtime_src/tools/xclbinutil/SectionAIEPartition.cxx +++ b/src/runtime_src/tools/xclbinutil/SectionAIEPartition.cxx @@ -536,7 +536,7 @@ populate_cdo_groups(const char* pBase, boost::property_tree::ptree ptElement; // Name - auto sName = reinterpret_cast(pBase + element.mpo_name); + auto sName = reinterpret_cast(pBase + element.mpo_name); ptElement.put("name", sName); XUtil::TRACE("Populating CDO group: " + std::string(sName)); @@ -657,7 +657,7 @@ writeAIEPartitionImage(const char* pBuffer, // kernel_commit_id, we should make sure the offset is NOT 0 auto sKernelCommitId = ""; if (pHdr->kernel_commit_id != 0) { - sKernelCommitId = reinterpret_cast(pBuffer + pHdr->kernel_commit_id); + sKernelCommitId = reinterpret_cast(pBuffer + pHdr->kernel_commit_id); } else { XUtil::TRACE(boost::format("Open an existing xclbin: kernel_commit_id is 0x%lx") % pHdr->kernel_commit_id); } @@ -720,7 +720,7 @@ SectionAIEPartition::readXclBinBinary(std::istream& iStream, // Do we have enough room to overlay the header structure if (m_bufferSize < sizeof(aie_partition)) { - auto errMsg = boost::format("ERROR: Segment size (%d) is smaller than the size of the aie_partition structure (%d)") + auto errMsg = boost::format("ERROR: Segment size (%d) is smaller than the size of the aie_partition structure (%d)") % m_bufferSize % sizeof(aie_partition); throw std::runtime_error(boost::str(errMsg)); } diff --git a/src/runtime_src/tools/xclbinutil/SectionAIEResourcesBin.cxx b/src/runtime_src/tools/xclbinutil/SectionAIEResourcesBin.cxx index c51e427ba1..8d01e9f23f 100644 --- a/src/runtime_src/tools/xclbinutil/SectionAIEResourcesBin.cxx +++ b/src/runtime_src/tools/xclbinutil/SectionAIEResourcesBin.cxx @@ -122,12 +122,12 @@ SectionAIEResourcesBin::subSectionExists(const std::string& _sSubSectionName) co ss.write((char*)sBuffer.c_str(), sBuffer.size()); boost::property_tree::ptree pt; - // Create a property tree and determine if the variables are all default values + // Create a property tree and determine if the variables are all default values try{ - boost::property_tree::read_json(ss, pt); + boost::property_tree::read_json(ss, pt); } catch (const boost::property_tree::json_parser_error& e) { - (void)e; + (void)e; auto errMsg = boost::format("ERROR: Unable to parse metadata file of section '%s'") % getSectionIndexName(); throw std::runtime_error(errMsg.str()); } @@ -194,7 +194,7 @@ SectionAIEResourcesBin::copyBufferUpdateMetadata(const char* _pOrigDataSection, // Convert JSON memory image into a boost property tree std::stringstream ss; ss.write((char*)memBuffer.get(), fileSize); - + boost::property_tree::ptree pt; try{ @@ -202,10 +202,10 @@ SectionAIEResourcesBin::copyBufferUpdateMetadata(const char* _pOrigDataSection, } catch (const boost::property_tree::json_parser_error& e) { - (void)e; + (void)e; auto errMsg = boost::format("ERROR: Unable to parse metadata file of section '%s'") % getSectionIndexName(); throw std::runtime_error(errMsg.str()); - } + } // ---------------------- // Extract and update the data @@ -506,13 +506,13 @@ SectionAIEResourcesBin::readXclBinBinary(std::istream& _istream, const axlf_sect // Create a property tree and determine if the variables are all default values boost::property_tree::ptree pt; - + try { boost::property_tree::read_json(ss, pt); } catch (const boost::property_tree::json_parser_error& e) { - (void)e; + (void)e; auto errMsg = boost::format("ERROR: Unable to parse metadata file of section '%s'") % getSectionIndexName(); throw std::runtime_error(errMsg.str()); } diff --git a/src/runtime_src/tools/xclbinutil/SectionSmartNic.cxx b/src/runtime_src/tools/xclbinutil/SectionSmartNic.cxx index 2ddcadc36b..ca5173b564 100644 --- a/src/runtime_src/tools/xclbinutil/SectionSmartNic.cxx +++ b/src/runtime_src/tools/xclbinutil/SectionSmartNic.cxx @@ -282,7 +282,7 @@ SectionSmartNic::marshalFromJSON(const boost::property_tree::ptree& _ptSection, /** * Compares two given property trees to validate that they are the same. - * + * * @param primary - Primary property tree * @param secondary - Secondary property tree */ @@ -325,7 +325,7 @@ using NodeCallBackFuncs = std::map; /** * Used to traverse a node array. - * + * * @param nodeName The primary node name of the array * @param key Optional key value that is used to determine array item uniqueness * @param ptParent Parent property_tree diff --git a/src/runtime_src/tools/xclbinutil/XclBinClass.cxx b/src/runtime_src/tools/xclbinutil/XclBinClass.cxx index 07527248d8..0e6fd1f448 100644 --- a/src/runtime_src/tools/xclbinutil/XclBinClass.cxx +++ b/src/runtime_src/tools/xclbinutil/XclBinClass.cxx @@ -107,7 +107,7 @@ void XclBin::printSections(std::ostream& _ostream) const { XUtil::TRACE("Printing Section Header(s)"); - for (const auto pSection : m_sections) + for (const auto pSection : m_sections) pSection->printHeader(_ostream); } @@ -203,12 +203,12 @@ XclBin::readXclBinBinary(const std::string& _binaryFileName, bool XclBin::checkForValidSection() { - if (FormattedOutput::getXclBinUuidAsString(m_xclBinHeader) != "" && - FormattedOutput::getTimeStampAsString(m_xclBinHeader) != "" && - m_xclBinHeader.m_header.m_length != 0 && + if (FormattedOutput::getXclBinUuidAsString(m_xclBinHeader) != "" && + FormattedOutput::getTimeStampAsString(m_xclBinHeader) != "" && + m_xclBinHeader.m_header.m_length != 0 && m_xclBinHeader.m_header.m_numSections != 0) return true; - + return false; } @@ -217,7 +217,7 @@ XclBin::checkForPlatformVbnv() { if (FormattedOutput::getPlatformVbnvAsString(m_xclBinHeader) != "") return true; - + return false; } @@ -766,9 +766,9 @@ XclBin::findSection(enum axlf_section_kind _eKind, const std::string& _indexName) const { for (auto& section : m_sections) { - if (section->getSectionKind() != _eKind) + if (section->getSectionKind() != _eKind) continue; - + if (section->getSectionIndexName().compare(_indexName) == 0) return section; } @@ -783,9 +783,9 @@ XclBin::findSection(enum axlf_section_kind _eKind, { std::vector vSections; for (auto& section : m_sections) { - if (section->getSectionKind() != _eKind) + if (section->getSectionKind() != _eKind) continue; - + if (_ignoreIndex || section->getSectionIndexName().compare(_indexName) == 0) vSections.push_back(section); } @@ -852,7 +852,7 @@ XclBin::removeSection(const std::string& _sSectionToRemove) } XUtil::QUIET(""); - XUtil::QUIET(boost::format("Section '%s%s'(%d) was successfully removed") + XUtil::QUIET(boost::format("Section '%s%s'(%d) was successfully removed") % _sSectionToRemove % indexEntry % (unsigned int) _eKind); } @@ -1009,7 +1009,7 @@ XclBin::addSubSection(ParameterSectionData& _PSD) pSection->readSubPayload(iSectionFile, _PSD.getSubSectionName(), _PSD.getFormatType()); // Clean-up - if (bNewSection == true) + if (bNewSection == true) addSection(pSection); std::string sSectionAddedName = pSection->getSectionKindAsString(); @@ -1020,7 +1020,7 @@ XclBin::addSubSection(ParameterSectionData& _PSD) % (sSubSection.empty() ? "" : "-") % sSubSection % (unsigned int) pSection->getSectionKind())); std::string optionalIndex; - if (!(pSection->getSectionIndexName().empty())) + if (!(pSection->getSectionIndexName().empty())) optionalIndex = (boost::format("[%s]") % pSection->getSectionIndexName()).str(); XUtil::QUIET(""); @@ -1047,7 +1047,7 @@ XclBin::addSection(ParameterSectionData& _PSD) // See if the user is attempting to add a sub-section { if (!_PSD.getSubSectionName().empty() || // A subsection name has been added - Section::supportsSubSectionName(eKind, "")) { // The section supports default empty subsection + Section::supportsSubSectionName(eKind, "")) { // The section supports default empty subsection addSubSection(_PSD); return; } @@ -1197,7 +1197,7 @@ XclBin::addSections(ParameterSectionData& _PSD) updateHeaderFromSection(pSection); XUtil::TRACE(boost::format("Section '%s' (%d) successfully added.") % pSection->getSectionKindAsString() % (unsigned int) pSection->getSectionKind()); XUtil::QUIET(""); - XUtil::QUIET(boost::format("Section: '%s'(%d) was successfully added.\nFormat : %s\nFile : '%s'") + XUtil::QUIET(boost::format("Section: '%s'(%d) was successfully added.\nFormat : %s\nFile : '%s'") % pSection->getSectionKindAsString() % (unsigned int) pSection->getSectionKind() % _PSD.getFormatTypeAsStr() % sectionName); @@ -1332,7 +1332,7 @@ XclBin::dumpSubSection(ParameterSectionData& _PSD) XUtil::QUIET(""); std::string optionalIndex; - if (!(pSection->getSectionIndexName().empty())) + if (!(pSection->getSectionIndexName().empty())) optionalIndex = boost::str(boost::format("[%s]") % pSection->getSectionIndexName()); XUtil::QUIET(boost::format("Section: '%s%s%s%s'(%d) was successfully written.\nFormat : %s\nFile : '%s'") @@ -1355,7 +1355,7 @@ XclBin::dumpSection(ParameterSectionData& _PSD) // See if the user is attempting to dump a sub-section { if (!_PSD.getSubSectionName().empty() || // A subsection name has been added - Section::supportsSubSectionName(eKind, "")) { // The section supports default empty subsection + Section::supportsSubSectionName(eKind, "")) { // The section supports default empty subsection dumpSubSection(_PSD); return; } @@ -1553,14 +1553,14 @@ XclBin::setKeyValue(const std::string& _keyValue) m_xclBinHeader.m_header.m_actionMask |= AM_LOAD_AIE; } else if (sValue == "LOAD_PDI") { - m_xclBinHeader.m_header.m_actionMask |= AM_LOAD_PDI; + m_xclBinHeader.m_header.m_actionMask |= AM_LOAD_PDI; } else { auto errMsg = boost::format("ERROR: Unknown bit mask '%s' for the key '%s'. Key-value pair: '%s'.") % sValue % sKey % _keyValue; throw std::runtime_error(errMsg.str()); } return; // Key processed - } + } if (sKey == "FeatureRomTimestamp") { m_xclBinHeader.m_header.m_featureRomTimeStamp = XUtil::stringToUInt64(sValue); @@ -1718,7 +1718,7 @@ parsePSKernelString(const std::string& encodedString, // Note: A file name can contain a colen (e.g., C:\test) { XUtil::TRACE("Parsing PSKernel command argument: '" + encodedString + "'"); - const std::string delimiters = ":"; + const std::string delimiters = ":"; // Working variables std::string::size_type pos = 0; @@ -1733,7 +1733,7 @@ parsePSKernelString(const std::string& encodedString, // Update the substring end to be at then end of the encodedString if: // a. No more delimiters were found. - // b. The last known 'token' is being parsed. + // b. The last known 'token' is being parsed. if ((pos == std::string::npos) || (tokens.size() == maxTokens-1)) { pos = encodedString.length(); @@ -1765,11 +1765,11 @@ parsePSKernelString(const std::string& encodedString, // -- [3]: Mem banks -- mem_banks = (tokens.size() > 3) ? tokens[3] : ""; - // add check for leading and trailing ; + // add check for leading and trailing ',' if (!mem_banks.empty()) { if (mem_banks.front() == ',' || mem_banks.back() == ',' ) throw std::runtime_error("Specified mem_banks is not valid"); - + std::cout << "Attention: Specifying memory banks in --add-pskernel is an advanced feature." << std::endl; std::cout << " Be sure to validate connections after performing this operation." << std::endl; } @@ -1860,7 +1860,7 @@ XclBin::addPsKernel(const std::string& encodedString) XUtil::createPSKernelMetadata(memBanks, numInstances, ptFunctions, kernelLibrary, ptPSKernels); // Update the EMBEDDED_METADATA, MEM_TOPOLOGY, IP_LAYOUT, and CONNECTIVITY sections - const boost::property_tree::ptree ptEmpty; + const boost::property_tree::ptree ptEmpty; const boost::property_tree::ptree ptKernels = ptPSKernels.get_child("ps-kernels", ptEmpty); auto kernels = XUtil::as_vector(ptKernels, "kernels"); @@ -1989,7 +1989,7 @@ XclBin::updateInterfaceuuid() } } - // Updating axlf header interface_uuid with interface_uuid from partition_metadata + // Updating axlf header interface_uuid with interface_uuid from partition_metadata boost::property_tree::ptree ptInterface = ptInterfaces[0]; auto sInterfaceUUID = ptInterface.get("interface_uuid", "00000000-0000-0000-0000-000000000000"); sInterfaceUUID.erase(std::remove(sInterfaceUUID.begin(), sInterfaceUUID.end(), '-'), sInterfaceUUID.end()); // Remove the '-' diff --git a/src/runtime_src/tools/xclbinutil/XclBinUtilMain.cxx b/src/runtime_src/tools/xclbinutil/XclBinUtilMain.cxx index a728d396b9..e531623210 100644 --- a/src/runtime_src/tools/xclbinutil/XclBinUtilMain.cxx +++ b/src/runtime_src/tools/xclbinutil/XclBinUtilMain.cxx @@ -111,9 +111,9 @@ void insertTargetMode(const std::string & _sTarget, std::vector & _ // Build the SYS:mode key value std::string modeValue; - if (_sTarget == "hw") + if (_sTarget == "hw") modeValue = bDfxEnable ? "hw_pr" : "flat"; - else if (_sTarget == "hw_emu") + else if (_sTarget == "hw_emu") modeValue = bDfxEnable ? "hw_emu_pr" : "hw_emu"; else if (_sTarget == "sw_emu") { if (bDfxEnable) @@ -291,12 +291,12 @@ int main_(int argc, const char** argv) { return RC_SUCCESS; } - if (!bQuiet) + if (!bQuiet) FormattedOutput::reportVersion(true); // Actions not requiring --input if (bListSections || bListNames) { - if (argc != 2) + if (argc != 2) throw std::runtime_error("ERROR: The '--list-sections' argument is a stand alone option. No other options can be specified with it."); XUtil::printKinds(); @@ -307,13 +307,13 @@ int main_(int argc, const char** argv) { // -- Map the target to the mode if (!sTarget.empty()) { // Make sure that SYS:mode isn't being used - if (!XclBin::findKeyAndGetValue("SYS","mode", keyValuePairs).empty()) + if (!XclBin::findKeyAndGetValue("SYS","mode", keyValuePairs).empty()) throw std::runtime_error("ERROR: The option '--target' and the key 'SYS:mode' are mutually exclusive."); insertTargetMode(sTarget, keyValuePairs); } else { // Validate that the SYS:dfx_enable is not set - if (!XclBin::findKeyAndGetValue("SYS","dfx_enable", keyValuePairs).empty()) + if (!XclBin::findKeyAndGetValue("SYS","dfx_enable", keyValuePairs).empty()) throw std::runtime_error("ERROR: The option '--target' needs to be defined when using 'SYS:dfx_enable'."); } @@ -323,21 +323,21 @@ int main_(int argc, const char** argv) { // Signing DRCs if (bValidateSignature == true) { - if (sCertificate.empty()) + if (sCertificate.empty()) throw std::runtime_error("ERROR: Validate signature specified with no certificate defined."); - if (sInputFile.empty()) + if (sInputFile.empty()) throw std::runtime_error("ERROR: Validate signature specified with no input file defined."); } - if (!sPrivateKey.empty() && sOutputFile.empty()) + if (!sPrivateKey.empty() && sOutputFile.empty()) throw std::runtime_error("ERROR: Private key specified, but no output file defined."); - if (sCertificate.empty() && !sOutputFile.empty() && !sPrivateKey.empty()) + if (sCertificate.empty() && !sOutputFile.empty() && !sPrivateKey.empty()) throw std::runtime_error("ERROR: Private key specified, but no certificate defined."); // Report option conflicts - if ((!sSignature.empty() && !sPrivateKey.empty())) + if ((!sSignature.empty() && !sPrivateKey.empty())) throw std::runtime_error("ERROR: The options '-add-signature' (a private signature) and '-private-key' (a PKCS signature) are mutually exclusive."); // Actions requiring --input @@ -345,13 +345,13 @@ int main_(int argc, const char** argv) { // Check to see if there any file conflicts std::vector< std::string> inputFiles; { - if (!sInputFile.empty()) + if (!sInputFile.empty()) inputFiles.push_back(sInputFile); - if (!sCertificate.empty()) + if (!sCertificate.empty()) inputFiles.push_back(sCertificate); - if (!sPrivateKey.empty()) + if (!sPrivateKey.empty()) inputFiles.push_back(sPrivateKey); for (const auto §ion : sectionsToAdd) { @@ -382,11 +382,11 @@ int main_(int argc, const char** argv) { std::vector< std::string> outputFiles; { - if (!sOutputFile.empty()) + if (!sOutputFile.empty()) outputFiles.push_back(sOutputFile); if (!sInfoFile.empty()) { - if (sInfoFile != "") + if (sInfoFile != "") outputFiles.push_back(sInfoFile); } @@ -407,7 +407,7 @@ int main_(int argc, const char** argv) { // Dump the signature if (!sSignatureOutputFile.empty()) { - if (sInputFile.empty()) + if (sInputFile.empty()) throw std::runtime_error("ERROR: Missing input file."); dumpSignatureFile(sInputFile, sSignatureOutputFile); @@ -415,23 +415,23 @@ int main_(int argc, const char** argv) { } // Validate signature for the input file - if (bValidateSignature == true) + if (bValidateSignature == true) verifyXclBinImage(sInputFile, sCertificate, bSignatureDebug); if (!sSignature.empty()) { - if (sInputFile.empty()) + if (sInputFile.empty()) throw std::runtime_error("ERROR: Cannot add signature. Missing input file."); - - if(sOutputFile.empty()) + + if(sOutputFile.empty()) throw std::runtime_error("ERROR: Cannot add signature. Missing output file."); - + XUtil::addSignature(sInputFile, sOutputFile, sSignature, ""); XUtil::QUIET("Exiting"); return RC_SUCCESS; } if (bGetSignature) { - if(sInputFile.empty()) + if(sInputFile.empty()) throw std::runtime_error("ERROR: Cannot read signature. Missing input file."); XUtil::reportSignature(sInputFile); @@ -440,12 +440,12 @@ int main_(int argc, const char** argv) { } if (bRemoveSignature) { - if(sInputFile.empty()) + if(sInputFile.empty()) throw std::runtime_error("ERROR: Cannot remove signature. Missing input file."); - - if(sOutputFile.empty()) + + if(sOutputFile.empty()) throw std::runtime_error("ERROR: Cannot remove signature. Missing output file."); - + XUtil::removeSignature(sInputFile, sOutputFile); XUtil::QUIET("Exiting"); return RC_SUCCESS; @@ -461,7 +461,7 @@ int main_(int argc, const char** argv) { } // -- Remove Sections -- - for (const auto §ion : sectionsToRemove) + for (const auto §ion : sectionsToRemove) xclBin.removeSection(section); // -- Add or Replace Sections -- @@ -508,13 +508,13 @@ int main_(int argc, const char** argv) { // -- Add PS Kernels for (const auto &psKernel : addPsKernels) xclBin.addPsKernel(psKernel); - + // -- Add Fixed Kernels files for (const auto &kernel : addKernels) xclBin.addKernels(kernel); // -- Post Section Processing -- - if ( bResetBankGrouping || + if ( bResetBankGrouping || (( !addKernels.empty() || !addPsKernels.empty()) && !bSkipBankGrouping)) { if (xclBin.findSection(ASK_GROUP_TOPOLOGY) != nullptr) xclBin.removeSection("GROUP_TOPOLOGY"); @@ -522,12 +522,13 @@ int main_(int argc, const char** argv) { if (xclBin.findSection(ASK_GROUP_CONNECTIVITY) != nullptr) xclBin.removeSection("GROUP_CONNECTIVITY"); } - + if (xclBin.findSection(IP_LAYOUT) != nullptr && xclBin.findSection(AIE_PARTITION) != nullptr){ if(!XUtil::checkAIEPartitionIPLayoutCompliance(xclBin)){ throw std::runtime_error("ERROR: The AIE_PARTITION section in the xclbin is not compliant with IP_LAYOUT section"); } - } + } + // Auto add GROUP_TOPOLOGY and/or GROUP_CONNECTIVITY if ((bSkipBankGrouping == false) && (xclBin.findSection(ASK_GROUP_TOPOLOGY) == nullptr) && @@ -535,7 +536,7 @@ int main_(int argc, const char** argv) { (xclBin.findSection(MEM_TOPOLOGY) != nullptr)) XUtil::createMemoryBankGrouping(xclBin); - // add support for transform-pdi + // add support for transform-pdi // transform the PDIs in AIE_PARTITION sections before writing out the output xclbin if (bTransformPdi) { #ifndef _WIN32 @@ -547,11 +548,11 @@ int main_(int argc, const char** argv) { } // -- Remove Keys -- - for (const auto &key : keysToRemove) + for (const auto &key : keysToRemove) xclBin.removeKey(key); // -- Add / Set Keys -- - for (const auto &keyValue : keyValuePairs) + for (const auto &keyValue : keyValuePairs) xclBin.setKeyValue(keyValue); // -- Update Interface uuid in xclbin -- @@ -572,7 +573,7 @@ int main_(int argc, const char** argv) { if (!sOutputFile.empty()) { xclBin.writeXclBinBinary(sOutputFile, bSkipUUIDInsertion); - if (!sPrivateKey.empty() && !sCertificate.empty()) + if (!sPrivateKey.empty() && !sCertificate.empty()) signXclBinImage(sOutputFile, sPrivateKey, sCertificate, sDigestAlgorithm, bSignatureDebug); } @@ -591,14 +592,14 @@ int main_(int argc, const char** argv) { oInfoFile.close(); } } - + if (fileCheck) { if (!xclBin.checkForValidSection() && !xclBin.checkForPlatformVbnv()) throw std::runtime_error("ERROR: The xclbin is missing platformVBNV information and at least one section required by the 'file' command to identify its file type and display file characteristics."); - + else if (!xclBin.checkForPlatformVbnv()) throw std::runtime_error("ERROR: The xclbin is missing platformVBNV information required by the 'file' command to identify its file type and display file characteristics."); - + else if (!xclBin.checkForValidSection()) throw std::runtime_error("ERROR: The xclbin is missing at least one section required by the 'file' command to identify its file type and display file characteristics."); } diff --git a/src/runtime_src/tools/xclbinutil/XclBinUtilities.cxx b/src/runtime_src/tools/xclbinutil/XclBinUtilities.cxx index b5ef8a207d..18b6668072 100644 --- a/src/runtime_src/tools/xclbinutil/XclBinUtilities.cxx +++ b/src/runtime_src/tools/xclbinutil/XclBinUtilities.cxx @@ -39,7 +39,7 @@ #ifdef _WIN32 #define _WIN32_WINNT 0x0501 #pragma warning (disable : 4244) // Addresses Boost conversion Windows build warnings -#endif +#endif #include #include @@ -105,7 +105,7 @@ XclBinUtilities::TRACE(const std::string& _msg, bool _endl) { std::cout << std::endl << std::flush; } -void +void XclBinUtilities::TRACE(const boost::format &fmt, bool endl) { TRACE(boost::str(fmt), endl); } @@ -357,7 +357,7 @@ XclBinUtilities::printKinds() { } } -std::string +std::string XclBinUtilities::getUUIDAsString( const unsigned char (&_uuid)[16] ) { static_assert (sizeof(boost::uuids::uuid) == 16, "Error: UUID size mismatch"); @@ -402,18 +402,18 @@ static const std::string &getSignatureMagicValue() { // Magic Value: 5349474E-9DFF41C0-8CCB82A7-131CC9F3 - unsigned char magicChar[] = { 0x53, 0x49, 0x47, 0x4E, - 0x9D, 0xFF, 0x41, 0xC0, - 0x8C, 0xCB, 0x82, 0xA7, - 0x13, 0x1C, 0xC9, 0xF3}; + unsigned char magicChar[] = { 0x53, 0x49, 0x47, 0x4E, + 0x9D, 0xFF, 0x41, 0xC0, + 0x8C, 0xCB, 0x82, 0xA7, + 0x13, 0x1C, 0xC9, 0xF3}; static std::string sMagicString((char *) &magicChar[0], 16); return sMagicString; } -bool -XclBinUtilities::getSignature(std::fstream& _istream, std::string& _sSignature, +bool +XclBinUtilities::getSignature(std::fstream& _istream, std::string& _sSignature, std::string& _sSignedBy, unsigned int & _totalSize) { _istream.seekg(0); @@ -451,9 +451,7 @@ XclBinUtilities::getSignature(std::fstream& _istream, std::string& _sSignature, return true; } - - -void +void XclBinUtilities::reportSignature(const std::string& _sInputFile) { // Open the file for consumption @@ -476,8 +474,7 @@ XclBinUtilities::reportSignature(const std::string& _sInputFile) std::cout << sSignature << " " << totalSize << std::endl; } - -void +void XclBinUtilities::removeSignature(const std::string& _sInputFile, const std::string& _sOutputFile) { // Open the file for consumption @@ -506,7 +503,7 @@ XclBinUtilities::removeSignature(const std::string& _sInputFile, const std::stri // Copy the file contents (minus the signature) { - // copy file + // copy file unsigned int count = 0; inputStream.seekg(0); char aChar; @@ -585,7 +582,7 @@ XclBinUtilities::addSignature(const std::string& _sInputFile, const std::string& // Copy the file contents { - // copy file + // copy file inputStream.seekg(0); char aChar; while (inputStream.get(aChar)) { @@ -601,7 +598,7 @@ XclBinUtilities::addSignature(const std::string& _sInputFile, const std::string& outputStream.close(); } -void +void XclBinUtilities::write_htonl(std::ostream & _buf, uint32_t _word32) { uint32_t word32 = htonl(_word32); @@ -623,7 +620,7 @@ typedef struct { // Creates a connection property_tree entry -static void addConnection( std::vector & groupConnectivity, +static void addConnection( std::vector & groupConnectivity, unsigned int argIndex, unsigned int ipLayoutIndex, unsigned int memIndex) { boost::property_tree::ptree ptConnection; @@ -652,13 +649,13 @@ isEqual(const boost::property_tree::ptree & first, // Given the collection of connections, appends to the GROUP_TOPOLOGY and // GROUP_CONNECTIVITY additional entries that represents grouped memories. static void -createMemoryBankGroupEntries( std::vector & workingConnections, - std::vector & groupTopology, +createMemoryBankGroupEntries( std::vector & workingConnections, + std::vector & groupTopology, std::vector & groupConnectivity) { // Sort our collection by: IP Layout Index, Argument Index, and Base address - std::sort(workingConnections.begin(), workingConnections.end(), - [](WorkingConnection &a, WorkingConnection &b) { + std::sort(workingConnections.begin(), workingConnections.end(), + [](WorkingConnection &a, WorkingConnection &b) { if (a.ipLayoutIndex != b.ipLayoutIndex) // Level 1: IP Layout Index return a.ipLayoutIndex < b.ipLayoutIndex; @@ -690,7 +687,7 @@ createMemoryBankGroupEntries( std::vector & workingConnection // 3) Same argument if ((nextBaseAddress != workingConnections[peekIndex].baseAddress) || (workingConnections[startIndex].ipLayoutIndex != workingConnections[peekIndex].ipLayoutIndex) || - (workingConnections[startIndex].argIndex != workingConnections[peekIndex].argIndex)) + (workingConnections[startIndex].argIndex != workingConnections[peekIndex].argIndex)) break; groupSize += workingConnections[peekIndex].size; } @@ -700,28 +697,28 @@ createMemoryBankGroupEntries( std::vector & workingConnection // Group requirements: // + Group size must be greater then 1 // + Only one (1) group per IP Argument pair - // + // // Note: Because of how the collection is sorted, if there are multiple groups, // they would be before or after the current group collection. if (startIndex == endIndex) continue; - if ((startIndex != 0) && + if ((startIndex != 0) && (workingConnections[startIndex-1].ipLayoutIndex == workingConnections[startIndex].ipLayoutIndex) && (workingConnections[startIndex-1].argIndex == workingConnections[startIndex].argIndex)) continue; - if ((endIndex < (workingConnections.size() - 1)) && + if ((endIndex < (workingConnections.size() - 1)) && (workingConnections[endIndex+1].ipLayoutIndex == workingConnections[endIndex].ipLayoutIndex) && (workingConnections[endIndex+1].argIndex == workingConnections[endIndex].argIndex)) continue; // The is a valid group, mark it as so - for (unsigned int goodIndex = startIndex; goodIndex <= endIndex; ++goodIndex) + for (unsigned int goodIndex = startIndex; goodIndex <= endIndex; ++goodIndex) workingConnections[goodIndex].canGroup = true; } - // Collect the groups + // Collect the groups for (unsigned int index = 0; index < workingConnections.size(); ++index) { const unsigned int startIndex = index; unsigned int endIndex = index; @@ -733,18 +730,18 @@ createMemoryBankGroupEntries( std::vector & workingConnection for (; endIndex + 1 < workingConnections.size(); ++endIndex) { const unsigned int peekIndex = endIndex + 1; const uint64_t nextBaseAddress = groupBaseAddress + groupSize; - + if ((nextBaseAddress != workingConnections[peekIndex].baseAddress) || (workingConnections[startIndex].ipLayoutIndex != workingConnections[peekIndex].ipLayoutIndex) || - (workingConnections[startIndex].argIndex != workingConnections[peekIndex].argIndex)) + (workingConnections[startIndex].argIndex != workingConnections[peekIndex].argIndex)) break; groupSize += workingConnections[peekIndex].size; } } - + // Update to our next working index index = endIndex; - + // If range is 1 then no grouping is needed if (startIndex == endIndex) { addConnection(groupConnectivity, workingConnections[startIndex].argIndex, workingConnections[startIndex].ipLayoutIndex, workingConnections[startIndex].memIndex); @@ -757,9 +754,9 @@ createMemoryBankGroupEntries( std::vector & workingConnection // Prepare a new entry { const boost::optional sSizeBytes = ptGroupMemory.get_optional("m_size"); - if (sSizeBytes.is_initialized()) + if (sSizeBytes.is_initialized()) ptGroupMemory.put("m_size", (boost::format("0x%lx") % groupSize).str()); - else + else ptGroupMemory.put("m_sizeKB", (boost::format("0x%lx") % (groupSize / 1024)).str()); // Add a tag value to indicate that this entry was the result of grouping memories @@ -768,10 +765,10 @@ createMemoryBankGroupEntries( std::vector & workingConnection memIndexVector.push_back(workingConnections[memIndex].memIndex); } - // Sort the vector + // Sort the vector std::sort(memIndexVector.begin(), memIndexVector.end()); - // Iterate over the collection producing a more compress tag. + // Iterate over the collection producing a more compress tag. // Contigious tag specified as start:end and non-contigious are seperated by ',' // Ex. MBG[0,2,3,4,6,8,9] becomes MBG[0,2:4,6,8:9] std::string newTag = "MBG["; @@ -786,8 +783,8 @@ createMemoryBankGroupEntries( std::vector & workingConnection newTag += ":"; newTag += std::to_string(memIndexVector[idx]); } - - // If terminal then add ']' otherwise add ',' + + // If terminal then add ']' otherwise add ',' newTag += (idx != memIndexVector.size() - 1) ? "," : "]"; idx++; } @@ -800,12 +797,12 @@ createMemoryBankGroupEntries( std::vector & workingConnection // See if this entry has already been added, if so use it for (groupMemIndex = 0; groupMemIndex < (unsigned int) groupTopology.size(); ++groupMemIndex) { - if (isEqual(groupTopology[groupMemIndex], ptGroupMemory)) + if (isEqual(groupTopology[groupMemIndex], ptGroupMemory)) break; } // Entry not found, add it to the array - if (groupMemIndex == groupTopology.size()) + if (groupMemIndex == groupTopology.size()) groupTopology.push_back(ptGroupMemory); // Create the connection entry @@ -813,9 +810,9 @@ createMemoryBankGroupEntries( std::vector & workingConnection } } -static void const +static void const validateMemoryBankGroupEntries( const unsigned int startGroupMemIndex, - const std::vector & groupTopology, + const std::vector & groupTopology, const std::vector & groupConnectivity) { // Were there any memory groups added @@ -836,7 +833,7 @@ validateMemoryBankGroupEntries( const unsigned int startGroupMemIndex, if (searchIndex == index) continue; - // We are looking for common IP and argument indexes + // We are looking for common IP and argument indexes if ((groupConnectivity[searchIndex].get("arg_index") != argIndex) || (groupConnectivity[searchIndex].get("m_ip_layout_index") != ipLayoutIndex)) continue; @@ -863,7 +860,7 @@ validateMemoryBankGroupEntries( const unsigned int startGroupMemIndex, static void transformMemoryBankGroupingCollections(const std::vector & connectivity, - std::vector & groupTopology, + std::vector & groupTopology, std::vector & groupConnectivity) { // Memory types that can be grouped @@ -899,7 +896,7 @@ transformMemoryBankGroupingCollections(const std::vector(sSizeBytes.get())); else { boost::optional sSizeKBytes = groupTopology[memIndex].get_optional("m_sizeKB"); - if (sSizeKBytes.is_initialized()) + if (sSizeKBytes.is_initialized()) sizeBytes = XUtil::stringToUInt64(static_cast(sSizeKBytes.get())) * 1024; } @@ -910,18 +907,18 @@ transformMemoryBankGroupingCollections(const std::vector allDpuKernelIDs; Section *pAIEPartition = xclbin.findSection(AIE_PARTITION); std::string jsonFile = pAIEPartition->getPathAndName(); // If the aie partition metadata file is not found, // then AIE_PARTITION section has already been added hence no-op if(jsonFile.empty()){ - return true; + return true; } boost::property_tree::ptree pt; boost::property_tree::read_json(jsonFile, pt); @@ -934,7 +931,7 @@ XclBinUtilities::checkAIEPartitionIPLayoutCompliance(XclBin & xclbin){ allDpuKernelIDs.insert(dpuKernelIDs.begin(), dpuKernelIDs.end()); } } - + // Get IP_LAYOUT metadata Section *pIPLayout = xclbin.findSection(IP_LAYOUT); boost::property_tree::ptree ptIPLayout; @@ -949,27 +946,27 @@ XclBinUtilities::checkAIEPartitionIPLayoutCompliance(XclBin & xclbin){ if(sm_type == "IP_PS_KERNEL" && sSubType == "DPU"){ std::string sKernelId = ptIPData.get("m_kernel_id", ""); if(allDpuKernelIDs.find(sKernelId) == allDpuKernelIDs.end()){ - XUtil::TRACE("There is no matching dpu_kernel_id in AIE_PARTITION for m_kernel_id " + sKernelId + " in IP_LAYOUT"); + XUtil::TRACE("There is no matching dpu_kernel_id in AIE_PARTITION for m_kernel_id " + sKernelId + " in IP_LAYOUT"); return false; } } } - return true; + return true; } -void +void XclBinUtilities::createMemoryBankGrouping(XclBin & xclbin) { // -- DRC checks - if (xclbin.findSection(ASK_GROUP_TOPOLOGY) != nullptr) + if (xclbin.findSection(ASK_GROUP_TOPOLOGY) != nullptr) throw std::runtime_error("ERROR: GROUP_TOPOLOGY section already exists. Unable to auto create the GROUP_TOPOLOGY section for memory bank grouping."); - if (xclbin.findSection(ASK_GROUP_CONNECTIVITY) != nullptr) + if (xclbin.findSection(ASK_GROUP_CONNECTIVITY) != nullptr) throw std::runtime_error("ERROR: GROUP_CONNECTIVITY section already exists. Unable to auto create the GROUP_CONNECTIVITY section for memory bank grouping."); // -- Create a copy of the MEM_TOPOLOGY section Section *pMemTopology = xclbin.findSection(MEM_TOPOLOGY); - if (pMemTopology == nullptr) + if (pMemTopology == nullptr) throw std::runtime_error("ERROR: MEM_TOPOLOGY section doesn't exist. Unable to auto create the memory bank grouping sections."); boost::property_tree::ptree ptMemTopology; @@ -1011,19 +1008,19 @@ XclBinUtilities::createMemoryBankGrouping(XclBin & xclbin) // Merge connectivity information into the group connectivity for (auto & connection : connectivity) { - groupConnectivity.push_back(connection); + groupConnectivity.push_back(connection); } // Re-create the property tree, create and re-populate the Group Connectivity section, and add it. { boost::property_tree::ptree ptConnection; - for (const auto & connection : groupConnectivity) + for (const auto & connection : groupConnectivity) ptConnection.push_back({"", connection}); - + boost::property_tree::ptree ptGroupConnection; ptGroupConnection.add_child("m_connection", ptConnection); ptGroupConnection.put("m_count", groupConnectivity.size()); - + boost::property_tree::ptree ptTop; ptTop.add_child("group_connectivity", ptGroupConnection); XUtil::TRACE_PrintTree("Group Connectivity", ptTop); @@ -1038,7 +1035,7 @@ XclBinUtilities::createMemoryBankGrouping(XclBin & xclbin) // Re-create the property tree, create and re-populate the Group Topology section, and add it. { boost::property_tree::ptree ptMemData; - for (const auto & mem_data : groupTopology) + for (const auto & mem_data : groupTopology) ptMemData.push_back({"", mem_data}); boost::property_tree::ptree ptGroupTopology; @@ -1074,7 +1071,7 @@ int transform_PDI_file(std::string fileName) return ret; } -void +void XclBinUtilities::transformAiePartitionPDIs(XclBin & xclbin) { // find all sections with type "AIE_PARTITION" in xclbin @@ -1085,7 +1082,7 @@ XclBinUtilities::transformAiePartitionPDIs(XclBin & xclbin) // orig/ // aie_partition.json // 1.pdi, 2.pdi ... - // copy orig/ to transform/ + // copy orig/ to transform/ // for each pdi in transform/, call pdi_transform API from aie-pdi-transform // / // transform/ @@ -1129,13 +1126,13 @@ XclBinUtilities::transformAiePartitionPDIs(XclBin & xclbin) fs::create_directories(origDir); } catch (std::exception& e) { // Not using fs::filesystem_error since std::bad_alloc can throw too. - // if we couldn't create directory, usually something fundamental is wrong (e.g. user has no permission) + // if we couldn't create directory, usually something fundamental is wrong (e.g. user has no permission) std::string errMsg = "ERROR: couldn't create directory: " + std::string(e.what()); throw std::runtime_error(errMsg); } // std::cout << "Temporary directory created: " << origDir << std::endl; - // construct the PSD for dumpЅection + // construct the PSD for dumpSection std::string sDumpSection = sSectionKind + "[" + sSectionIndex + "]:JSON:" + origApJsonPath.string(); // std::cout << "sDumpSection = " << sDumpSection << std::endl; ParameterSectionData dumpPsd(sDumpSection); @@ -1169,7 +1166,7 @@ XclBinUtilities::transformAiePartitionPDIs(XclBin & xclbin) XUtil::TRACE("pdi file transformed: " + entry.path().string()); } - // construct the PSD for addЅection + // construct the PSD for addSection std::string sAddSection = sSectionKind + "[" + sSectionIndex + "]:JSON:" + tranApJsonPath.string(); // std::cout << "sAddSection = " << sAddSection << std::endl; addSections.push_back(sAddSection); @@ -1194,7 +1191,7 @@ XclBinUtilities::transformAiePartitionPDIs(XclBin & xclbin) #if (BOOST_VERSION >= 106400) -int +int XclBinUtilities::exec(const fs::path &cmd, const std::vector &args, bool bThrow, @@ -1207,13 +1204,13 @@ XclBinUtilities::exec(const fs::path &cmd, std::future data_stderr; boost::asio::io_service svc; - boost::process::child runningProcess( cmd.string(), - args, + boost::process::child runningProcess( cmd.string(), + args, boost::process::std_out > data_stdout, boost::process::std_err > data_stderr, boost::this_process::environment(), svc); - svc.run(); + svc.run(); runningProcess.wait(); // Update the return buffers @@ -1228,11 +1225,11 @@ XclBinUtilities::exec(const fs::path &cmd, " Cmd: %s %s\n" " StdOut: %s\n" " StdErr: %s\n") - % exitCode + % exitCode % cmd.string() % boost::algorithm::join(args, " ") % os_stdout.str() % os_stderr.str(); - if (bThrow) + if (bThrow) throw std::runtime_error(errMsg.str()); } @@ -1240,7 +1237,7 @@ XclBinUtilities::exec(const fs::path &cmd, } #else -int +int XclBinUtilities::exec(const fs::path &cmd, const std::vector &args, bool bThrow, @@ -1257,19 +1254,19 @@ XclBinUtilities::exec(const fs::path &cmd, auto errMsg = boost::format("Error: Shell command failed\n" " Cmd: %s %s\n") % cmd.string() % boost::algorithm::join(args, " "); - - if (bThrow) + + if (bThrow) throw std::runtime_error(errMsg.str()); return 1; } - while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) + while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) result += buffer.data(); os_stdout << result; - return 0; + return 0; } diff --git a/src/runtime_src/tools/xclbinutil/XclBinUtilities.h b/src/runtime_src/tools/xclbinutil/XclBinUtilities.h index 87c1e01280..d11ac9bc56 100644 --- a/src/runtime_src/tools/xclbinutil/XclBinUtilities.h +++ b/src/runtime_src/tools/xclbinutil/XclBinUtilities.h @@ -45,7 +45,7 @@ typedef enum { namespace XclBinUtilities { template -std::vector as_vector(boost::property_tree::ptree const& pt, +std::vector as_vector(boost::property_tree::ptree const& pt, boost::property_tree::ptree::key_type const& key) { std::vector r; @@ -63,7 +63,7 @@ std::vector as_vector(boost::property_tree::ptree const& pt, // This template will eventually replace "as_vector" // The issue is that the code needs to be refactored to use this new template template -std::vector as_vector_simple(const boost::property_tree::ptree& pt, +std::vector as_vector_simple(const boost::property_tree::ptree& pt, const boost::property_tree::ptree::key_type& key) { static const boost::property_tree::ptree ptEmpty; @@ -86,7 +86,7 @@ class XclBinUtilException : public std::runtime_error { public: XclBinUtilException(XclBinExceptionType _eExceptionType, const std::string & _msg, - const char * _function = "", + const char * _function = "", const char * _file = __FILE__, int _line = __LINE__) : std::runtime_error(_msg) @@ -98,7 +98,7 @@ class XclBinUtilException : public std::runtime_error { // Empty } - ~XclBinUtilException() + ~XclBinUtilException() { // Empty }