arXiv:2608.08085cs.DCcs.AI2026-08

LLM生成代码优化时,放弃传统抽象反而性能更优。

Effect of Abstractions and Prompting Strategies on LLM-Guided High-Performance Optimizations

论文配图:Effect of Abstractions and Prompting Strategies on LLM-Guided High-Performance Optimizations
图 1 · 摘自论文原文
  • 用目标驱动的提示词引导LLM直接生成优化后的C代码
  • 在PolyBench上比传统框架提升性能与正确率
  • 适合研究自动化代码优化与LLM应用的开发者

代码性能优化是现代软件开发的关键环节,可提升响应速度并降低资源消耗。此类优化需深入理解底层硬件与并行处理细节,对经验丰富的开发者也具挑战性。随着大语言模型(LLMs)在代码生成与理解方面能力增强,将其融入自动代码优化成为研究热点。传统自动化优化依赖将源代码转换为特定领域表示,再通过网格搜索或机器学习进行调优,并遵守严格规则与有限可行变换以确保可验证性。而LLMs能捕捉高层语义,可执行超越可验证范围的变换。本文通过PolyBench基准测试,研究传统抽象是否有助于提升LLM引导的高性能计算(HPC)程序优化的性能与正确性。结果表明,在所评估设置下,给定明确优化目标的LLM生成的C代码,在测量性能和有效性方面优于使用成熟框架构建计算流水线与优化调度的结果,暗示未来应探索替代方案以实现可验证的LLM引导代码优化。

原文摘要 · Abstract (English)

Code performance optimization is a vital aspect of modern software development, as it enables faster response times and reduced resource usage. These optimizations require a deep understanding of low-level hardware details and the intricacies of parallel processing, making them challenging even for experienced developers. With the advent of Large Language Models (LLMs), which are increasingly capable of generating and understanding code, there is growing interest in incorporating these models into automated code optimization processes. Traditionally, this automation involves transcribing the source code into a domain-specific representation that can be auto-tuned using grid search or machine learning algorithms, while adhering to strict rules and a limited set of feasible transformations to ensure verifiability. LLMs incorporate high-level code semantics and can thus perform transformations that go beyond verifiable automated optimizations. This paper investigates whether the traditional abstractions used in automated code optimization improve the performance and correctness of LLM-guided optimizations of parallel HPC applications. We evaluate this using the PolyBench benchmark suite and demonstrate that, in our evaluated setting, LLMs provided with specific optimization goals achieve better measured performance and validity rates when generating C code compared to creating computation pipelines and optimization schedules with established frameworks, suggesting that future development should explore alternative approaches for verifiable LLM-guided code optimization.

代码优化LLMHPC提示工程

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。