Search arXivSearch

arXiv · 2407.03889

Automated C/C++ Program Repair for High-Level Synthesis via Large Language Models

Abstract

In High-Level Synthesis (HLS), converting a regular C/C++ program into its HLS-compatible counterpart (HLS-C) still requires tremendous manual effort. Various program scripts have been introduced to automate this process. But the resulting codes usually contain many issues that should be manually repaired by developers. Since Large Language Models (LLMs) have the ability to automate code generation, they can also be used for automated program repair in HLS. However, due to the limited training of LLMs considering hardware and software simultaneously, hallucinations may occur during program repair using LLMs, leading to compilation failures. Besides, using LLMs for iterative repair also incurs a high cost. To address these challenges, we propose an LLM-driven program repair framework that takes regular C/C++ code as input and automatically generates its corresponding HLS-C code for synthesis while minimizing human repair effort. To mitigate the hallucinations in LLMs and enhance the prompt quality, a Retrieval-Augmented Generation (RAG) paradigm is introduced to guide the LLMs toward correct repair. In addition, we use LLMs to create a static bit width optimization program to identify the optimized bit widths for variables. Moreover, LLM-driven HLS optimization strategies are introduced to add/tune pragmas in HLS-C programs for circuit optimization. Experimental results demonstrate that the proposed LLM-driven automated framework can achieve much higher repair pass rates in 24 real-world applications compared with the traditional scripts and the direct application of LLMs for program repair.

Explore related subjects

Keep this discovery

Explore connections, maps & timelines

BibTeXRIS

Kangwei Xu, Grace Li Zhang, Xunzhao Yin, Cheng Zhuo, Ulf Schlichtmann, Bing Li. 2024-07-04. Automated C/C++ Program Repair for High-Level Synthesis via Large Language Models. https://arxiv.org/abs/2407.03889

Cite the original work for its findings. Save a collection to share your selection of sources.

KEEP EXPLORING

Related papers

Co-Investment with Payoff-Sharing Mechanism for Cooperative Decision-Making in Network Design Games

Network-based systems are inherently interconnected, with the design and performance of subnetworks being interdependent. However, the decisions of self-interested operators may lead to suboptimal outcomes for users and the overall system. This paper explores cooperative mechanisms that can simultaneously benefit both operators and users. We address this challenge using a game-theoretical framework that integrates both non-cooperative and cooperative game theory. In the non-cooperative stage, we propose a network design game in which subnetwork decision-makers strategically design local infrastructures. In the cooperative stage, co-investment with payoff-sharing mechanism is developed to enlarge collective benefits and fairly distribute them. To demonstrate the effectiveness of our framework, we conduct case studies on the Sioux Falls network and real-world public transport networks in Zurich and Winterthur, Switzerland. Our evaluation considers impacts on environmental sustainability, social welfare, and economic efficiency. The proposed framework provides a foundation for improving interdependent networked systems by enabling strategic cooperation among self-interested operators.

eess.SY

Generalizable Optimal Control with Transformers: One Policy Across Diverse Systems

Classical optimal control designs a separate controller for each plant. Even for the Linear Quadratic Regulator (LQR), every new model must be identified and its Riccati equation re-solved. We ask whether a single learned policy can instead serve an entire family of systems, and we show that one transformer can. We train the policy to imitate optimal LQR state feedback across a collection of heterogeneous Multiple-Input, Multiple-Output (MIMO) Linear Time-Invariant (LTI) systems that differ in their state and input dimensions and in their cost objectives. A shared representation lets the same parameters control every member of the family. It combines system-wise standardization, zero-padding and masking across dimensions, and an explicit encoding of the cost matrices. At run time, the policy maps a short window of recent states and the specified cost to a control action. It uses no plant matrices and identifies the dynamics implicitly from the state history. We evaluate on $28$ simulated systems over $9{,}675$ closed-loop rollouts, and no unstable rollout was observed in any of them. On the systems seen during training, it attains a median relative sub-optimality of $0.022\%$, even under parameter perturbations of up to $\pm10\%$. It transfers to unseen systems with lightweight fine-tuning, reaching a median sub-optimality of $0.19\%$. These results support transformers as generalizable near-optimal controllers for structured families of linear systems.

eess.SY

Two-Timescale Asymptotic Simulations of Hybrid Inclusions with Applications to Stochastic Hybrid Optimization

Convergence properties of model-free two-timescale asymptotic simulations of singularly perturbed hybrid inclusions are developed. A hybrid inclusion combines constrained differential and difference inclusions to capture continuous (flow) and discrete (jump) dynamics, respectively. Sufficient conditions are established under which sequences of iterates and step sizes constitute a two-timescale asymptotic simulation of such a system, with limiting behavior characterized via weakly invariant and internally chain-transitive sets of an associated boundary layer and reduced system. To illustrate the applicability of these results, conditions are given under which a two-timescale stochastic approximation of a hybrid optimization algorithm asymptotically recovers the behavior of its deterministic counterpart.

eess.SY