[go: up one dir, main page]

Skip to main content

Leveraging OpenMP 4.5 Support in CLANG for Fortran

  • Conference paper
  • First Online:
Scaling OpenMP for Exascale Performance and Portability (IWOMP 2017)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 10468))

Included in the following conference series:

  • 1110 Accesses

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Notes

  1. 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. 2.

    Weak symbols are not mentioned by the C/C++ language standards.

  3. 3.

    The symbol will be weak if uninitialized in C, or initialized to 0 in C++.

  4. 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

  1. F2cpp: a python script to convert fortran 77 to C++ code. http://sourceforge.net/projects/f2cpp

  2. OpenMP homepage. http://www.openmp.org/

  3. 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)

    Google Scholar 

  4. Barrowes, B.: F2matlab. http://engineering.dartmouth.edu/~d30574x/consulting/consultingIndex.html

  5. Chen, T., Sura, Z., Sung, H.: Automatic Copying of Pointer-Based Data Structures (2017)

    Google Scholar 

  6. IBM Corporations: Xl fortran for linux. http://www-03.ibm.com/software/products/en/xlfortran-linux

  7. 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

    Google Scholar 

  8. Feldman, S.I., Gay, D.M., Maimone, M.W., Schryer, N.L.: A Fortran to C converter (1990)

    Google Scholar 

  9. 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)

    Google Scholar 

  10. 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

  11. 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

    Chapter  Google Scholar 

  12. Peterson, P.: F2py: Fortran to Python interface generator. http://cens.ioc.ee/projects/f2py2e

  13. L.F. Team. Flang. https://github.com/llvm-flang

  14. T.C. Team. Clang 5 documentation: Libtooling. https://clang.llvm.org/docs/LibTooling.html

Download references

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

Authors

Corresponding author

Correspondence to Hyojin Sung .

Editor information

Editors and Affiliations

Rights and permissions

Reprints 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)

Publish with us

Policies and ethics