用AI自动将老旧Fortran代码转为跨平台的Kokkos代码,省时高效。
From Legacy Fortran to Portable Kokkos: An Autonomous Agentic AI Workflow
- AI代理协作完成代码翻译、验证、编译与优化全流程
- 生成的Kokkos代码在多硬件上性能超越原Fortran基线
- 适合需要现代化科学计算代码的高性能计算研究人员
科学应用仍依赖早期为单一CPU系统开发的遗留Fortran代码。随着高性能计算(HPC)向异构GPU架构演进,许多加速器缺乏原生Fortran支持,亟需对旧代码进行现代化以实现可移植性。Kokkos等框架提供性能可移植性及单源C++抽象,但手动将Fortran转为Kokkos需大量专业知识与时间。大型语言模型(LLM)在源到源代码生成方面展现潜力,但在全自主工作流中实现并行代码的翻译与优化,尤其是在跨硬件的性能可移植性方面仍鲜有探索。本文提出一种代理式AI工作流,由专用LLM“代理”协作完成Fortran内核到可移植Kokkos C++程序的翻译、验证、编译、运行、测试、调试与优化。结果表明,该流程成功现代化多个基准内核,生成的代码在不同硬件分区上具备性能可移植性。使用GPT-5和o4-mini-high等付费OpenAI模型仅花费数美元即可完成工作流,生成的优化代码性能优于原Fortran基线;而开源模型如Llama4-Maverick则常无法产出有效代码。本工作证明了代理式AI在Fortran-to-Kokkos转换中的可行性,并为自主现代化科学计算应用提供了路径,同时揭示了LLM驱动代理系统在科学与系统级任务中执行结构化领域推理的潜力。
原文摘要 · Abstract (English)
Scientific applications continue to rely on legacy Fortran codebases originally developed for homogeneous, CPU-based systems. As High-Performance Computing (HPC) shifts toward heterogeneous GPU-accelerated architectures, many accelerators lack native Fortran bindings, creating an urgent need to modernize legacy codes for portability. Frameworks like Kokkos provide performance portability and a single-source C++ abstraction, but manual Fortran-to-Kokkos porting demands significant expertise and time. Large language models (LLMs) have shown promise in source-to-source code generation, yet their use in fully autonomous workflows for translating and optimizing parallel code remains largely unexplored, especially for performance portability across diverse hardware. This paper presents an agentic AI workflow where specialized LLM "agents" collaborate to translate, validate, compile, run, test, debug, and optimize Fortran kernels into portable Kokkos C++ programs. Results show the pipeline modernizes a range of benchmark kernels, producing performance-portable Kokkos codes across hardware partitions. Paid OpenAI models such as GPT-5 and o4-mini-high executed the workflow for only a few U.S. dollars, generating optimized codes that surpassed Fortran baselines, whereas open-source models like Llama4-Maverick often failed to yield functional codes. This work demonstrates the feasibility of agentic AI for Fortran-to-Kokkos transformation and offers a pathway for autonomously modernizing legacy scientific applications to run portably and efficiently on diverse supercomputers. It further highlights the potential of LLM-driven agentic systems to perform structured, domain-specific reasoning tasks in scientific and systems-oriented applications.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。