OMPAR is a compiler-oriented tool designed to identify and generate parallelization opportunities for serial code. It consists of the following pipeline:
- OMPify: Detects opportunities for parallelization in code.
- 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.
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.
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
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' if torch.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
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 setup | TP | FP | TN | FN | Precision | Recall | Accuracy |
---|---|---|---|---|---|---|---|
OMPar accuracy with ground-truth label | 311 | 127 | 262 | 70 | 71% | 81% | 74% |
AutoPar accuracy with ground-truth label | 63 | 25 | 365 | 317 | 71% | 17% | 56% |
ICPC accuracy with ground-truth label | 95 | 11 | 285 | 379 | 90% | 25% | 62% |
OMPar accuracy with compile and run check | 407 | 31 | 262 | 70 | 92% | 85% | 86% |
AutoPar accuracy with compile and run check | 24 | 25 | 365 | 356 | 49% | 6% | 50% |
ICPC accuracy with compile and run check | 68 | 5 | 312 | 385 | 93% | 15% | 49% |
The results for OMPar, AutoPar, and ICPC can be reproduced using the information provided in the benchmarks
folder.