Finding Equivalent OpenMP Fortran and C/C++ Code Snippets Using Large Language Models
摘要
This paper investigates the feasibility of using Large Language Models (LLMs) to identify semantically equivalent code snippets across different programming languages. Motivated by the need for cross-language translation datasets between OpenMP Fortran and C/C++, this study aims to determine the optimal LLMs and methodology for finding equivalent OpenMP Fortran vs. C/C++ code pairs. We propose a novel approach involving: (1) the construction of a ground truth dataset using DataRaceBench, (2) experimentation with multiple commercial and open-weight LLMs, (3) comparison of two distinct methods (code embedding-based cosine similarity analysis vs. question-answering prompting), and (4) impact analysis of code preprocessing techniques (comment removal vs. inclusion). Our preliminary evaluation encompasses performance metrics and overhead analysis. The findings provide a systematic understanding of LLMs’ capabilities in cross-language code snippet identification, ultimately offering actionable recommendations for practitioners seeking to leverage these models for automated dataset generation.