MOVING OLD FORTRAN TO PYTHON WHILE MAINTAINING FORTRAN-LEVEL PERFORMANCE
Ключевые слова:
Application migration, gradual typing, interop- erability, just-in-time compilation, legacy code, software main- tenance, transpilation.Аннотация
We propose a method of accelerating Python code by just-in-time compilation leveraging type hints mechanism introduced in Python 3.5. In our approach performance-critical kernels are expected to be written as if Python was a strictly typed language, however without the need to extend Python syntax. This approach can be applied to any Python applica- tion, however we focus on a special case when legacy Fortran applications are automatically translated into Python for easier maintenance. We developed a framework implementing two- way transpilation and achieved performance equivalent to that of Python manually translated to Fortran, and better than using other currently available JIT alternatives (up to 5x times faster than Numba in some experiments).
Библиографические ссылки
K. Bennett, “Legacy systems: coping with success,” IEEE Software, vol. 12, no. 1, pp. 19–23, Jan 1995.
F. G. Tinetti and M. Me´ndez, “Fortran legacy software: Source code update and possible parallelisation issues,” SIGPLAN Fortran Forum, vol. 31, no. 1, pp. 5–22, Mar. 2012. [Online]. Available: http://doi.acm.org/10.1145/2179280.2179281
G. M. Amdahl, “Validity of the single processor approach to achieving large scale computing capabilities,” in Proceedings of the April 18-20, 1967, Spring Joint Computer Conference, ser. AFIPS ’67 (Spring). New York, NY, USA: ACM, 1967, pp. 483–485. [Online]. Available: http://doi.acm.org/10.1145/1465482.1465560
G. van Rossum and I. Levkivskyi. (2014, Dec.) Pep 483 – the theory of type hints. [Online]. Available: https://www.python.org/dev/peps/ pep-0483/
G. van Rossum, J. Lehtosalo, and . Langa. (2014, Sep.) Pep 484
– type hints. [Online]. Available: https://www.python.org/dev/peps/ pep-0484/
S. I. Feldman, “A fortran to c converter,” in ACM SIGPLAN Fortran Forum, vol. 9, no. 2. ACM, 1990, pp. 21–22.
R. W. Grosse-Kunstleve, T. C. Terwilliger, N. K. Sauter, and P. D. Adams, “Automatic fortran to c++ conversion with fable,” Source code for biology and medicine, vol. 7, no. 1, p. 1, 2012.
K. Seymour and J. Dongarra, “Automatic translation of fortran to jvm bytecode,” Concurrency and Computation: Practice and Experience, vol. 15, no. 3-5, pp. 207–222, 2003.
A. Corrigan, F. Camelli, R. Lo¨hner, and F. Mut, “Semi-automatic porting of a large-scale fortran cfd code to gpus,” International Journal for Numerical Methods in Fluids, vol. 69, no. 2, pp. 314–331, 2012.
T. E. Oliphant, A guide to NumPy. Trelgol Publishing USA, 2006, vol. 1.
P. Peterson, “F2py: a tool for connecting fortran and python programs,” International Journal of Computational Science and Engineering, vol. 4, no. 4, pp. 296–305, 2009. [Online]. Available: http://cens.ioc.ee/∼pearu/papers/IJCSE4.4 Paper 8.pdf
S. K. Lam, A. Pitrou, and S. Seibert, “Numba: A llvm-based python jit compiler,” in Proceedings of the Second Workshop on the LLVM Compiler Infrastructure in HPC, ser. LLVM ’15. New York, NY, USA: ACM, 2015, pp. 7:1–7:6. [Online]. Available: http://doi.acm.org/10.1145/2833157.2833162
S. Behnel, R. Bradshaw, D. Seljebotn, G. Ewing et al. Cython:
C-extensions for python, 2008. [Online]. Available: http://cython.org/
D. S. Seljebotn, “Fast numerical computations with cython,” in Pro- ceedings of the 8th Python in Science Conference, vol. 37, 2009.
S. Behnel, R. Bradshaw, C. Citro, L. Dalcin, D. S. Seljebotn, and K. Smith, “Cython: The best of both worlds,” Computing in Science & Engineering, vol. 13, no. 2, pp. 31–39, 2011. [Online]. Available: http://scitation.aip.org/content/aip/journal/cise/ 13/2/10.1109/MCSE.2010.118