arXiv:2507.04697cs.LGcs.DC2025-07被引 2

评测大模型生成高性能线性代数代码的能力,发现仅凭函数名即可生成正确代码。

Performance Evaluation of General Purpose Large Language Models for Basic Linear Algebra Subprograms Code Generation

  • 用函数名或参考Fortran代码,让大模型生成优化的C语言代码
  • 部分代码实现多线程、SIMD向量化和缓存分块,速度优于参考实现
  • 适合关注AI辅助高性能计算的开发者与研究者

基于大语言模型(LLM)的生成式AI技术已用于辅助或自动生成程序代码。本文评估现有通用大模型在生成CPU上基本线性代数子程序(BLAS)代码方面的能力。选用OpenAI于2025年4月发布的两个模型:GPT-4.1(生成式预训练转换器)和o4-mini(o系列推理模型)。针对从级别1到3的BLAS例程,尝试三种生成任务:(1) 仅根据函数名生成未优化的C代码;(2) 仅根据函数名生成包含基本性能优化(线程并行化、SIMD向量化、缓存分块)的C代码;(3) 基于Fortran参考代码生成带优化的C代码。结果显示,即使仅提供函数名,仍可在许多情况下生成正确代码。同时确认,线程并行化(使用OpenMP)、SIMD向量化和缓存分块可部分实现,且生成代码的速度优于参考代码。

原文摘要 · Abstract (English)

Generative AI technology based on Large Language Models (LLM) has been developed and applied to assist or automatically generate program codes. In this paper, we evaluate the capability of existing general LLMs for Basic Linear Algebra Subprograms (BLAS) code generation for CPUs. We use two LLMs provided by OpenAI: GPT-4.1, a Generative Pre-trained Transformer (GPT) model, and o4-mini, one of the o-series of Reasoning models. Both have been released in April 2025. For the routines from level-1 to 3 BLAS, we tried to generate (1) C code without optimization from routine name only, (2) C code with basic performance optimizations (thread parallelization, SIMD vectorization, and cache blocking) from routine name only, and (3) C code with basic performance optimizations based on Fortran reference code. As a result, we found that correct code can be generated in many cases even when only routine name are given. We also confirmed that thread parallelization with OpenMP, SIMD vectorization, and cache blocking can be implemented to some extent, and that the code is faster than the reference code.

代码生成大模型高性能计算BLAS

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