Skip to content

Repository files navigation

OMPAR

OMPAR is a compiler-oriented tool designed to identify and generate parallelization opportunities for serial code. It consists of the following pipeline:

  1. OMPify: Detects opportunities for parallelization in code.
  2. MonoCoder: Generates the appropriate OpenMP pragmas when a for loop is identified as beneficial for parallelization. Note: The weights for OMPify are not included in the repository and will be provided upon request.

OMPAR Workflow

Figure 1: OMPar workflow using a simple pi code example, comparing it with other compilers. Source-to-source automatic compilers (such as AutoPar) generate the necessary pragma, while HPC compilers (such as ICPC) generate a binary parallel output. In contrast, OMPar relies on two LLMs: one for classifying parallelization needs (OMPify) and one for generating the full pragma (MonoCoder-OMP). Both were trained on a large corpus of codes. The evaluation checks if the code compiles, performs with increasing threads, and verifies outputs.

Building OMPar

To build OMPAR, ensure that CUDA 12.1 is supported on your system. Follow these steps:

Clone the repository:

git clone https://github.com/Scientific-Computing-Lab/OMPar
cd OMPar

Create and activate the Conda environment:

conda create -n ompar_env python=3.11 -f environment.yml
conda activate ompar_env

Build the parser:

cd parser
./build.sh

Usage

To use OMPar, you need to download the Ompify model weights from here.

Here’s an example of how to use OMPAR:

code="""for(int i = 0; i <= 1000; i++){ partial_Sum += i; }"""device='cuda'iftorch.cuda.is_available() else'cpu'ompar=OMPAR(model_path=main_args.model_weights, device=device, args=main_args)
pragma=ompar.auto_comp(code)

To run additional use cases, execute the following command:

python run_ompar.py --model_weights /path/to/OMPify

OMPar Evaluation

The following table shows the performance of OMPar on HeCBench test set of 770 loops. OMPar accurately predicted the pragma in 74% of the test loop.

Test setupTPFPTNFNPrecisionRecallAccuracy
OMPar accuracy with ground-truth label3111272627071%81%74%
AutoPar accuracy with ground-truth label632536531771%17%56%
ICPC accuracy with ground-truth label951128537990%25%62%
OMPar accuracy with compile and run check407312627092%85%86%
AutoPar accuracy with compile and run check242536535649%6%50%
ICPC accuracy with compile and run check68531238593%15%49%

The results for OMPar, AutoPar, and ICPC can be reproduced using the information provided in the evaluation folder. Specifically, the data subfolder contains the code to gather the HeCBench serial codes, while the icpc, autoPar, and ompar subfolders describe the methods for running these codes.

About

Automatic parallelization tool using OpenMP pragmas.

Resources

Stars

7 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages