Introduction
High-Performance Computing (HPC) is currently grappling with a significant "legacy code" challenge. For decades, Fortran has served as the primary language for scientific computing, resulting in vast codebases that are difficult to integrate with modern software stacks and heterogeneous hardware architectures. While C++ has emerged as the preferred language for modern HPC due to its object-oriented design and performance, manual translation from Fortran is a slow, error-prone process requiring deep expertise in both languages and parallel programming models like OpenMP.
While general-purpose Large Language Models (LLMs) such as GPT-4 demonstrate impressive coding capabilities, they often struggle with the niche, highly technical syntax of HPC-specific parallel directives. This research addresses the critical lack of high-quality, parallel-code-specific datasets required to train models for this modernization task.
Methodology and Data Curation
Researchers from Lawrence Livermore National Laboratory and the University of Connecticut developed a specialized pipeline to create a high-fidelity translation dataset. The source data was curated from three representative open-source OpenMP benchmarks: the NAS Parallel Benchmarks (NPB), the Polyhedral Benchmark (PolyBench), and DataRaceBench (DRB).
The curation process involved several key steps to ensure data quality:
- Data Cleaning: Standardizing formatting, removing comments to reduce training noise, and normalizing whitespaces.
- Function Mapping: Utilizing "inlining" and "outlining" techniques to ensure semantic equivalence and 1-to-1 functional pairing between Fortran and C++ versions.
- Similarity-Based Calibration: The team employed StarCoder embeddings to calculate cosine similarity between code pairs. This allowed for the identification and removal of "outliers"—pairs that were semantically inconsistent despite being labeled as translations.
Results and Performance Analysis
The effectiveness of the fine-tuned models was evaluated using CodeBLEU (a metric considering both syntax and semantics) and expert human review. The results demonstrate that domain specificity acts as a significant force multiplier for model performance.
Key findings include:
- Massive Performance Gains: Models with prior coding knowledge (specifically StarCoder) saw a 9.9x increase in CodeBLEU scores after fine-tuning. Models without prior coding knowledge saw a 5.1x increase.
- Outperforming GPT-4: The fine-tuned StarCoder (15.5B parameters) achieved a CodeBLEU score of 0.613, surpassing GPT-4’s score of 0.560.
- Human-Level Proficiency: Expert programmers rated the fine-tuned StarCoder at 4.77 out of 5, slightly higher than GPT-4’s 4.72, indicating the model has reached a proficiency level comparable to professional programmers in this niche domain.
Conclusion and Future Work
This study proves that specialized, smaller models can outperform general-purpose giants like GPT-4 when trained on high-quality, domain-specific data. While the current results are promising, future work will focus on expanding the dataset scale to include more diverse "real-world" legacy applications and extending the scope to other parallel paradigms such as CUDA or OpenACC. Translating highly complex, non-standard HPC patterns remains an ongoing challenge that will benefit from even more diverse training examples.
Summary updated