The OpenMP (Open Multi-Processing) specification is a standard for a set of compiler directives, library routines, and environment variables that can be used to specify shared memory parallelism in Fortran and C/C++ programs.
We plan eventually to contribute this implementation to the Clang trunk; initial patches have already been committed. In the meantime, you are welcome to try (and contribute to!) the full OpenMP 3.1 implementation hosted here.
August 23, 2013 - Initial release.
September 27, 2013 - Added support of
November 25, 2013 - Added support of
declare reduction directives.
December 6, 2013 - Added support of variable length arrays in OpenMP constructs.
February 6, 2014 - Upgrade to clang/llvm 3.4.
$ git clone https://github.com/clang-omp/llvm $ git clone https://github.com/clang-omp/compiler-rt llvm/projects/compiler-rt $ git clone -b clang-omp https://github.com/clang-omp/clang llvm/tools/clang
To build clang with OpenMP support just follow the clang/LLVM compiler's standard build procedure (see Getting Started: Building and Running Clang).
To use the newly installed compiler, add the following to your environment. On Mac OS X, replace LD_LIBRARY_PATH with DYLD_LIBRARY_PATH.
export PATH=/install/prefix/bin:$PATH export C_INCLUDE_PATH=/install/prefix/include:<OpenMP include path>:$C_INCLUDE_PATH export CPLUS_INCLUDE_PATH=/install/prefix/include:<OpenMP include path>:$CPLUS_INCLUDE_PATH export LIBRARY_PATH=/install/prefix/lib:<OpenMP library path>:$LIBRARY_PATH export LD_LIBRARY_PATH=/install/prefix/lib:<OpenMP library path>:$LD_LIBRARY_PATH
When you build a program that uses OpenMP directives, add the following options to enable OpenMP support and link to the runtime library.
Confirm that the compiler is working correctly by saving the above code to a file.
$ clang -fopenmp hello.c -o hello $ ./hello
Compilation should proceed with no errors or warnings.
Execute the output
./hello. You should see more than
one “Hello” line with different thread numbers. Note that
the lines may be mixed together. If you see only one, try setting the
environment variable OMP_NUM_THREADS
to some number (say 4) and try again.
If you would like to see performance impact, you can try to compile and execute a more complex example Matrices Multiplication.
We welcome contributions of all kinds: patches, code reviews, testing and bug reports.
However, as any other open source project, we have to maintain some level of control to prevent complete chaos and keep a single architectural direction. You can send your patches here for review and commit; also, we are very open with granting commit access rights to recognized members of Clang/LLVM community.
We plan eventually to contribute this OpenMP implementation to the Clang trunk, where it will be governed by existing Clang/LLVM community development policies.
Full support for OpenMP 3.1 and some elements of OpenMP 4.0 are implemented. This implementation relies on the Intel OpenMP API, and should be used along with Intel® OpenMP* Runtime Library that supports that API (available from www.openmprtl.org).
The following openly available OpenMP test suites pass:
- OpenMP Validation Suite by OpenUH Research Compiler - passed 119 tests of 123.
OS: Linux or Mac OS X
Please note that this is a preliminary version. While everything is carefully tested and works fine, there are known internal design quality issues. We plan to refactor some parts of the code before submitting them to Clang trunk. And yes, any help with this would be appreciated!
Among known design issues are:
- Combined constructs (
#pragma omp parallel forand
#pragma omp parallel sections). Currently these constructs are represented as a pair of
#pragma omp paralleland
#pragma omp for/sectionsconstructs. This solution leads to ugly representation in AST because of the troubles with the variables capturing.
- Calculation of iteration indices for
#pragma omp foris not quite optimal. AST representation of this construct also is not very good and should be re-designed.
- Analysis of atomic constructs and loops should be reworked for better diagnostics and readability.
LLVM, Clang, and Compiler-rt are distributed under LLVM's the University of Illinois/NCSA Open Source License. In addition to the "UIUC" BSD-Style license license, the runtime library component of LLVM (Compiler_rt) is also licensed under the MIT License. For details, including information about third-party components, see LICENSE.txt in the code repositories.
If you would like to report a bug, or make a feature request, you can submit an issue in Github here.