Learning to Parallelize in a Shared-Memory Environment with Transformers

Re'em Harel, Yuval Pinter, Gal Oren
4/27/2022
25 citations
cs.DCcs.CLcs.LG
transformer-attention

Official code: Scientific-Computing-Lab/PragFormer (3 stars, HTML, last commit 2024-10-22).

Abstract

In past years, the world has switched to many-core and multi-core shared memory architectures. As a result, there is a growing need to utilize these architectures by introducing shared memory parallelization schemes to software applications.

Show full abstract

OpenMP is the most comprehensive API that implements such schemes, characterized by a readable interface. Nevertheless, introducing OpenMP into code is challenging due to pervasive pitfalls in management of parallel shared memory. To facilitate the performance of this task, many source-to-source (S2S) compilers have been created over the years, tasked with inserting OpenMP directives into code automatically. In addition to having limited robustness to their input format, these compilers still do not achieve satisfactory coverage and precision in locating parallelizable code and generating appropriate directives. In this work, we propose leveraging recent advances in ML techniques, specifically in natural language processing (NLP), to replace S2S compilers altogether. We create a database (corpus), Open-OMP, specifically for this goal. Open-OMP contains over 28,000 code snippets, half of which contain OpenMP directives while the other half do not need parallelization at all with high probability. We use the corpus to train systems to automatically classify code segments in need of parallelization, as well as suggest individual OpenMP clauses. We train several transformer models, named PragFormer, for these tasks, and show that they outperform statistically-trained baselines and automatic S2S parallelization compilers in both classifying the overall need for an OpenMP directive and the introduction of private and reduction clauses. Our source code and database are available at: https://github.com/Scientific-Computing-Lab-NRCN/PragFormer.

View on arXivView PDF

Code Implementations(1)

31HTML, PythonApr 26, 20222 years ago

Similar Papers

Cite this paper

@article{harel2022learning,
  title  = {Learning to Parallelize in a Shared-Memory Environment with Transformers},
  author = {Re'em Harel and Yuval Pinter and Gal Oren},
  year   = {2022},
  eprint = {2204.12835},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2204.12835}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2204.12835.svg)](https://codeofpaper.com/paper/2204.12835)

Discussion