NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Can Large Language Models Write Parallel Code?

Daniel Nichols, Joshua Hoke Davis, Zhaojun Xie, Arjun Rajaram, Abhinav Bhatele

Abstract

While Large Language Models (LLMs) have demonstrated remarkable proficiency in generating sequential code, their ability to navigate the complexities of parallel programming remains largely unquantified. This paper summarizes the introduction of ParEval, a comprehensive benchmark designed to evaluate LLMs on high-performance computing (HPC) tasks. The study reveals a significant "parallel tax," where models that excel at sequential logic struggle with data distribution, synchronization, and hardware-specific APIs. Our findings indicate that while LLMs can occasionally produce functionally correct parallel code, they often fail to achieve the performance and efficiency required for real-world HPC applications.

Introduction

Parallel programming—the art of writing code to execute across multiple CPU cores, GPUs, or distributed clusters—is a cornerstone of modern scientific computing. Unlike sequential programming, it requires developers to reason about complex concepts such as race conditions, memory consistency, and explicit communication protocols like MPI or CUDA.

Existing benchmarks like HumanEval focus primarily on simple Python tasks, which do not capture the "performance-first" requirements of High-Performance Computing (HPC). To bridge this gap, researchers developed ParEval to determine if LLMs can generate code that is not only functionally correct but also computationally efficient.

The ParEval Benchmark

ParEval consists of 420 hand-crafted prompts designed to be "out-of-distribution" for most training sets. By using variations of common algorithms (e.g., requesting a reverse prefix sum instead of a standard one), the benchmark prevents models from relying on memorized solutions.

The benchmark covers 12 computational problem types, including sorting, stencils, and Fourier transforms, across seven distinct execution models:

  • Sequential: Standard C++.
  • Shared Memory: OpenMP and Kokkos.
  • Distributed Memory: MPI and hybrid MPI+OpenMP.
  • GPU: CUDA and HIP.

Performance Metrics

To move beyond simple pass/fail criteria, the authors introduced two novel metrics:

  1. Speedup_n@k: The expected best speedup achieved by the model given $k$ attempts, using $n$ parallel resources.
  2. Efficiency_n@k: A measure of how well the generated code scales, calculated as speedup per thread or process.

Key Insights and Analysis

The Parallel Tax

The evaluation revealed a massive performance cliff. For instance, GPT-3.5 achieved a ~76% success rate on serial tasks but plummeted to ~40% on parallel tasks. This "parallel tax" suggests that the reasoning required for concurrency is significantly more taxing for current architectures than standard algorithmic logic.

Abstraction vs. Explicit Control

LLMs performed best when using high-level abstractions like OpenMP and Kokkos. These frameworks utilize pragmas and abstractions that closely resemble sequential code, making them more accessible to models trained on general-purpose datasets. Conversely, models struggled most with MPI (Message Passing Interface). Distributed memory programming requires a fundamental restructuring of the algorithm to handle rank-specific logic and explicit data movement, a task current LLMs find difficult to execute reliably.

Correctness vs. Performance

A critical finding of the study is that functional correctness does not equate to performance. Even when GPT-4—the most performant model tested—produced "correct" code, it only achieved approximately 13% of the maximum possible efficiency. Many models generated code that technically utilized multiple threads but contained bottlenecks or synchronization overheads that rendered the code barely faster than a single-threaded version.

Results Summary

  • Top Performers: GPT-3.5 and GPT-4 led the field in correctness. Interestingly, GPT-3.5 slightly outperformed GPT-4 in parallel pass@1 scores (39.6 vs 37.8).
  • Open Source: Phind-CodeLlama-V2 emerged as the strongest open-source model, significantly outperforming the base CodeLlama models.
  • Translation Benefits: Providing a model with a correct sequential implementation as a starting point significantly improved the success rates for smaller, open-source models, suggesting that LLMs are better at "translating" parallelism than inventing it from scratch.

Conclusion and Future Work

The ParEval benchmark highlights a significant gap in the capabilities of current LLMs. While they are becoming adept at general coding, the specific demands of HPC—namely the need for efficient data movement and synchronization—remain a hurdle. Future work will focus on using ParEval to fine-tune models specifically for HPC environments and expanding the benchmark to include emerging languages like SYCL and Rust. The results suggest that simply increasing model size is insufficient; improved reasoning regarding hardware architecture and concurrency is essential for the next generation of AI coding assistants.

Summary updated

BibTeX
@inproceedings{nichols2024can,
  author = {Daniel Nichols and Joshua Hoke Davis and Zhaojun Xie and Arjun Rajaram and Abhinav Bhatele},
  title = {{Can Large Language Models Write Parallel Code?}},
  booktitle = {HPDC},
  year = {2024},
  doi = {10.1145/3625549.3658689},
}
Figure