Abstract
Modern computer systems are increasingly parallel and heterogeneous, and the demand for high-level programming interfaces for such systems is rapidly growing. OpenMP 4.0 extended its CPU-based directives to support device offloading. Programmers can now simply insert directives to identify computations and data to be offloaded. Compilers/runtime with OpenMP support then manage code translation and data transfers. While there are various ongoing efforts to support OpenMP device offloading for Fortran as well as C/C++, the most widely used open-source compiler, LLVM, supports C/C++ only. In this paper, we describe our project, XLFLANG, that aims to build an OpenMP Fortran compiler by bridging an existing Fortran front-end and LLVM C/C++ front-end (CLANG). We translate output from IBM XL Fortran front-end into CLANG AST and feed it to CLANG where OpenMP directives are lowerized to LLVM IR. This approach allowed us to reuse CLANG code generation and LLVM optimizations while handling Fortran-specific features in our XLFLANG. However, language dependences of CLANG AST especially with OpenMP directive representations pose unique challenges both in correctness and performance aspects. We addressed these challenges to generate CLANG AST, taking care to expose possible optimization opportunities. We were able to map all major OpenMP offloading directives/clauses from Fortran to CLANG AST, and our evaluation shows the resulting AST does not add significant overheads or interfere with later optimizations.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
The output is cropped from the result of CLANG ast-dump. Please be aware that the output of ast-dump from CLANG is in C format and may miss some necessary parenthesis. We use it in the paper because it is more readable than printing raw CLANG AST node information.
- 2.
Weak symbols are not mentioned by the C/C++ language standards.
- 3.
The symbol will be weak if uninitialized in C, or initialized to 0 in C++.
- 4.
It is not the purpose of this paper to compare the sequential and the parallel performance. We did not aggressively optimize how the loops are parallelized for GPU. Nor is it the focus of this paper to compare the performance of CLANG and gnu compiler. For both compilers, we used -O3 for the sequential version only.
References
F2cpp: a python script to convert fortran 77 to C++ code. http://sourceforge.net/projects/f2cpp
OpenMP homepage. http://www.openmp.org/
Antao, S.F., Bataev, A., Jacob, A.C., Bercea, G.T., Eichenberger, A.E., Rokos, G., Martineau, M., Jin, T., Ozen, G., Sura, Z., Chen, T., Sung, H., Bertolli, C., O’Brien, K.: Offloading support for OpenMP in Clang and LLVM. In: LLVM-HPC 2016 (2016)
Barrowes, B.: F2matlab. http://engineering.dartmouth.edu/~d30574x/consulting/consultingIndex.html
Chen, T., Sura, Z., Sung, H.: Automatic Copying of Pointer-Based Data Structures (2017)
IBM Corporations: Xl fortran for linux. http://www-03.ibm.com/software/products/en/xlfortran-linux
Dietrich, R., Juckeland, G., Wolfe, M.: Open ACC programs examined: a performance analysis approach. In: 2015 44th International Conference on Parallel Processing, pp. 310–319, September 2015
Feldman, S.I., Gay, D.M., Maimone, M.W., Schryer, N.L.: A Fortran to C converter (1990)
Grosse-Kunstleve, R.W., Terwilliger, T.C., Sauter, N.K., Adams, P.D.: Automatic Fortran to C++ conversion with fable. Source Code for Biology and Medicine (2012)
JamesBeyer, J.L.: Targeting GPUs with OpenMP 4.5 device directives. http://on-demand.gputechconf.com/gtc/2016/presentation/s6510-jeff-larkin-targeting-gpus-openmp.pdf
Liao, C., Quinlan, D.J., Panas, T., Supinski, B.R.: A ROSE-based OpenMP 3.0 research compiler supporting multiple runtime libraries. In: Sato, M., Hanawa, T., Müller, M.S., Chapman, B.M., Supinski, B.R. (eds.) IWOMP 2010. LNCS, vol. 6132, pp. 15–28. Springer, Heidelberg (2010). doi:10.1007/978-3-642-13217-9_2
Peterson, P.: F2py: Fortran to Python interface generator. http://cens.ioc.ee/projects/f2py2e
L.F. Team. Flang. https://github.com/llvm-flang
T.C. Team. Clang 5 documentation: Libtooling. https://clang.llvm.org/docs/LibTooling.html
Acknowledgement
This work was supported in part by the United States Departmnet of Energy CORAL program (contract B604142). We thank the IBM XL compiler team for their help and support for this work.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2017 Springer International Publishing AG
About this paper
Cite this paper
Sung, H., Chen, T., Sura, Z., Islam, T. (2017). Leveraging OpenMP 4.5 Support in CLANG for Fortran. In: de Supinski, B., Olivier, S., Terboven, C., Chapman, B., Müller, M. (eds) Scaling OpenMP for Exascale Performance and Portability. IWOMP 2017. Lecture Notes in Computer Science(), vol 10468. Springer, Cham. https://doi.org/10.1007/978-3-319-65578-9_3
Download citation
DOI: https://doi.org/10.1007/978-3-319-65578-9_3
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-65577-2
Online ISBN: 978-3-319-65578-9
eBook Packages: Computer ScienceComputer Science (R0)