CGRAOmp is a front-end to compile OpenMP codes for Coarse-Grained Reconfigurable Architectures (CGRAs) based on LLVM.
The API document generated by doxgen is available.
To use this tool, you can either use docker images or build the LLVM libraries on your machine.
- Takuya Kojima, Boma Adhi, Carlos Cortes, Yiyu Tan, Kentaro Sano, "An Architecture-Independent CGRA Compiler enabling OpenMP Applications", 2022 IEEE International Parallel and Distributed Processing Symposium Workshops (IPDPSW), virtual, May 2022.
There are two options: 1) using prebuilt images and 2) building images with Dockerfile.
You can pull the prebuilt images from DockerHub.
$ docker pull tkojima0107/cgraomp:centos
$ docker pull tkojima0107/cgraomp:ubuntu-20.04
They uses llvm_docker as base images.
You can build the above images with Dockerfiles in docker
CGRAOmp consists of several out-of-tree Passes. In the beginning, you need to build and install LLVM 12.0.x according to the official guide (see llvm-project).
Compiler driver needs the following python packages:
- To visualize data flow graph
- graphviz
- watchdog
- To run backend mapping process
- watchdog
- rich (for rich console mode)
git clone https://github.com/hal-lab-u-tokyo/CGRAOmp.git
cd CGRAOmp
mkdir build
cmake .. [-DCMAKE_INSTALL_PREFIX=<path>] [-DCGRAOMP_ENABLE_DOXYGEN=On]
make -j`proc`
make install
If you want to change the path where the tools and libraries are installed, please specify the directory path by -DCMAKE_INSTALL_PREFIX=<path>
.
If you want to build the API document with Doxgen, please use -DCGRAOMP_ENABLE_DOXYGEN=On
.
The target architecture is defined by a JSON file. This repository includes the following types in share/presents
- Decoupled CGRA
- Time-Multiplexed CGRA (Experimental)
#include <cgraomp.h>
#define N 100
void kernel() {
int X[N], Y[N], Z[N];
const int a = 3;
#pragma omp target parallel for map(to:X[0:N],Y[0:N]) map(from:Z[0:N])
for (int64_t i = 0; i < N; i++) {
Z[i] = X[i] * a + Y[i];
}
}
$ cgraomp-cc vec_madd.c --cgra-config decoupled_affine_AG.json
If no error occurs, it will generate a dot file as a data flow graph.
This compiler only extracts a data flow graph of the OpenMP offloading kernel. To run mapping with the generated DFGs automatically, a script file is needed.
#!/bin/sh
your_mapping_command ${DOTFILE_NAME}
In the script, an environment variable ${DOTFILE_NAME}
provides an actual file name of the generated DFG file.
--cgra-config
(-cc
): specify the path of CGRA configuration file
-o
: specifies the output file name-v
: enables verbose mode-save-temps
: saves temporary files during the compilation--enable-cgraomp-debug
: shows debug messsage in the CGRA OpenMP pass
-O(0|1|2|3|s|z)
: optimization level for host code-Xclang=<arg>
: passes an argument for clang--preopt-pipeline
: changes optimizaiton pipeline in pre-optimization stage
--enable-custom-inst
: enables custom instruction support--diagnostic-file=<path>
: specifies the file path of a diagnostic file-Xcgraomp=<arg>
: passes other options for CGRAOmp passes
--load-dfg-pass-plugin=<path>
: loads DFG pass plugins--dfg-pass-pipeline
: specifies the pass pipeline for DFG optimization (comma-separeted)--dfg-file-prefix
: specifies the prefix used for data flow graph file name--visualize-dfg
: generates image files of DFGs (graphviz is needed)--visualize-dfg-type
: specifies file type of the visualized file (default: png)--simplify-dfg-name
: uses simplified file name for generated DFG files--cgra-dfg-plain
: uses plain node label
--backend-runner
: specifies a runner script to drive a back-end mapping--backend-runner-command
: specifies command to run the runner script (default: bash)--backend-proc-num
: specifies the number of backend process to run simulatanceously (default: 1)--backend-panel-num
: specifies the number of panel to view the backend process stdout (only in rich console mode)--backend-nowait
: finishes immediately when all the backend processes are finished--no-rich-console
: disables rich console mode
- GenMap: a mapping algorith based on genetic algortihm
CGRAOmp is published under the MIT license (see LICENSE file).