Browse > Article
http://dx.doi.org/10.7582/GGE.2021.24.2.35

Boosting the Performance of Python-based Geodynamic Code using the Just-In-Time Compiler  

Park, Sangjin (Department of Geophysics, Kangwon National University)
An, Soojung (Department of Geophysics, Kangwon National University)
So, Byung-Dal (Department of Geophysics, Kangwon National University)
Publication Information
Geophysics and Geophysical Exploration / v.24, no.2, 2021 , pp. 35-44 More about this Journal
Abstract
As the execution speed of Python is slower than those of other programming languages (e.g., C, C++, and FORTRAN), Python is not considered to be efficient for writing numerical geodynamic code that requires numerous iterations. Recently, many computational techniques, such as the Just-In-Time (JIT) compiler, have been developed to enhance the calculation speed of Python. Here, we developed two-dimensional (2D) numerical geodynamic code that was optimized for the JIT compiler, based on Python. Our code simulates mantle convection by combining the Particle-In-Cell (PIC) scheme and the finite element method (FEM), which are both commonly used in geodynamic modeling. We benchmarked well-known mantle convection problems to evaluate the reliability of our code, which confirmed that the root mean square velocity and Nusselt number obtained from our numerical modeling were consistent with those of the mantle convection problems. The matrix assembly and PIC processes in our code, when run with the JIT compiler, successfully achieved a speed-up 30× and 258× faster than without the JIT compiler, respectively. Our Python-based FEM-PIC code shows the high potential of Python for geodynamic modeling cases that require complex computations.
Keywords
Python; JIT compiler; mantle convection; code development; boosting;
Citations & Related Records
연도 인용수 순위
  • Reference
1 Wilbers, I. M., Langtangen, H. P., and Odegard, A., 2009, Using cython to speed up numerical python programs, Fifth National Conference on Computational Mechanics, 9, 495-512.
2 Yuen, D. A., and Peltier, W. R., 1982, Normal modes of the viscoelastic earth, Geophys. J. Int., 69(2), 495-526, doi: 10.1111/j.1365-246X.1982.tb04962.x.   DOI
3 Pedregosa, F., Varoquaux, G., Gramfort, A., Michel, V., Thirion, B., Grisel, O., Blondel, M., Prettenhofer, P., Weiss, R. and Dubourg, V., 2011, Scikit-learn: Machine learning in Python, J. Mach. Learn. Res., 12, 2825-2830.
4 Chaves, J. C., Nehrbass, J., Guilfoos, B., Gardiner, J., Ahalt, S., Krishnamurthy, A., Unpingco, J., Chalker, A., Warnock, A., and Samsi, S., 2006, Octave and Python: High-level scripting languages productivity and performance evaluation, HPCMP Users Group Conference, 429-434, doi: 10.1109/HPCMPUGC.2006.55.   DOI
5 Cock, P. J., Antao, T., Chang, J. T., Chapman, B. A., Cox, C. J., Dalke, A., Friedberg, I., Hamelryck, T., Kauff, F., and Wilczynski, B., 2009, Biopython: freely available Python tools for computational molecular biology and bioinformatics, Bioinformatics, 25(11), 1422-1423, doi: 10.1093/bioinformatics/btp163.   DOI
6 Van Keken, P. E., King, S. D., Schmeling, H., Christensen, U. R., Neumeister, D., and Doin, M. P., 1997, A comparison of methods for the modeling of thermochemical convection, J. Geophys. Res.-Solid Earth, 102(B10), 22477-22495, doi: 10.1029/97JB01353.   DOI
7 Aagaard, B. T., Knepley, M. G., & Williams, C. A., 2013, A domain decomposition approach to implementing fault slip in finite-element models of quasi-static and dynamic crustal deformation, J. Geophys. Res.-Solid Earth, 118(6), 3059-3079, doi: 10.1002/jgrb.5021.   DOI
8 Akeret, J., Gamper, L., Amara, A., and Refregier, A., 2015, HOPE: A Python just-in-time compiler for astrophysical computations, Astron. Comput., 10, 1-8, doi: 10.1016/j.ascom.2014.12.001.   DOI
9 Behnel, S., Bradshaw, R., Citro, C., Dalcin, L., Seljebotn, D. S., and Smith, K., 2011, Cython: The best of both worlds, Comput. Sci. Eng., 13(2), 31-39, doi: 10.1109/MCSE.2010.118.   DOI
10 Blankenbach, B., Busse, F., Christensen, U., Cserepes, L., Gunkel, D., Hansen, U., Harder, H., Jarvis, G., Koch, M., and Marquart, G., 1989, A benchmark comparison for mantle convection codes, Geophys. J. Int., 98(1), 23-38, doi: 10.1111/j.1365-246X.1989.tb05511.x.   DOI
11 Lam, S. K., Pitrou, A., and Seibert, S., 2015, Numba: A llvm-based python jit compiler, Proceedings of the Second Workshop on the LLVM Compiler Infrastructure in HPC, 1-6, doi: 10.1145/2833157.2833162.   DOI
12 Tackley, P. J., and King, S. D., 2003, Testing the tracer ratio method for modeling active compositional fields in mantle convection simulations, Geochem. Geophys. Geosyst., 4(4), 8302, doi: 10.1029/2001GC000214.   DOI
13 Leng, W., and Zhong, S., 2011, Implementation and application of adaptive mesh refinement for thermochemical mantle convection studies, Geochem. Geophys. Geosyst., 12(4), Q04006, doi: 10.1029/2010GC003425.   DOI
14 Omelchenko, Y. A., and Karimabadi, H., 2006, Self-adaptive time integration of flux-conservative equations with sources, J. Comput. Phys., 216(1), 179-194, doi: 10.1016/j.jcp.2005.12.008.   DOI
15 Mansour et al., 2020, Underworld2: Python Geodynamics Modelling for Desktop, HPC and Cloud, Journal of Open Source Software, 5(47), 1797, doi: 10.21105/joss.01797.   DOI
16 O'Boyle, N. M., Morley, C., and Hutchison, G. R., 2008, Pybel: a Python wrapper for the OpenBabel cheminformatics toolkit, Chem. Cent. J., 2(1), 1-7, doi: 10.1186/1752-153X-2-5.   DOI
17 Oliphant, T. E., 2007, Python for scientific computing, Comput. Sci. Eng., 9(3), 10-20, doi: 10.1109/MCSE.2007.58.   DOI
18 O'Neill, C., Moresi, L., Muller, D., Albert, R., and Dufour, F., 2006, Ellipsis 3D: A particle-in-cell finite-element hybrid code for modelling mantle convection and lithospheric deformation, Comput. Geosci., 32(10), 1769-1779.   DOI
19 Samuel, H., and Evonuk, M., 2010, Modeling advection in geophysical flows with particle level sets, Geochem. Geophys. Geosyst., 11(8), Q08020, doi: 10.1029/2010GC003081.   DOI
20 Samuel, H., 2018, A deformable particle-in-cell method for advective transport in geodynamic modelling, Geophys. J. Int., 214(3), 1744-1773, doi: 10.1093/gji/ggy231.   DOI
21 Schenk, O., Gartner, K., Fichtner, W., and Stricker, A., 2001, PARDISO: a high-performance serial and parallel sparse linear solver in semiconductor device simulation, Futur. Gener. Comp. Syst., 18(1), 69-78, doi: 10.1016/S0167-739X(00)00076-5.   DOI
22 Srinath, K. R., 2017, Python-the fastest growing programming language, International Research Journal of Engineering and Technology, 4(12), 354-357.
23 Virtanen, P., Gommers, R., Oliphant, T. E., Haberland, M., Reddy, T., Cournapeau, D., Burovski, E., Peterson, P., Weckesser, W., and Bright, J., 2020, SciPy 1.0: fundamental algorithms for scientific computing in Python, Nat. Methods, 17, 261-272.   DOI
24 Thieulot, C., 2011, FANTOM: Two-and three-dimensional numerical modelling of creeping flows for the solution of geological problems, Phys. Earth Planet. Inter., 188(1-2), 47-68, doi: 10.1016/j.pepi.2011.06.011.   DOI
25 Thieulot, C., 2014, ELEFANT: a user-friendly multipurpose geodynamics code. Solid Earth Discussions, 6(2), 1949-2096, doi: 10.5194/sed-6-1949-2014.   DOI
26 Van Der Walt, S., Colbert, S. C., and Varoquaux, G., 2011, The NumPy array: a structure for efficient numerical computation, Comput. Sci. Eng., 13(2), 22-30, doi: 10.1109/MCSE.2011.37.   DOI
27 Wang, H., Agrusta, R., and van Hunen, J., 2015, Advantages of a conservative velocity interpolation (CVI) scheme for particle-in-cell methods with application in geodynamic modeling, Geochem. Geophys. Geosyst., 16, 2015-2023, doi: 10.1002/2015GC005824.   DOI
28 Sun, Q., Berkelbach, T. C., Blunt, N. S., Booth, G. H., Guo, S., Li, Z., Liu, J., McClain, J. D., Sayfutyarova, E. R., Sharma, S., Wouters, S., and Chan, G. K., 2018, PySCF: the Python-based simulations of chemistry framework, Wiley Interdiscip. Rev.-Comput. Mol. Sci., 8, e1340, doi: 10.1002/wcms.1340.   DOI
29 Dabrowski, M., Krotkiewski, M., and Schmid, D. W., 2008, MILAMIN: MATLAB-based finite element method solver for large problems, Geochem. Geophys. Geosyst., 9(4), Q04030, doi: 10.1029/2007GC001719.   DOI
30 Dalcin, L. D., Paz, R. R., Kler, P. A., and Cosimo, A., 2011, Parallel distributed computing using Python, Adv. Water Resour., 34(9), 1124-1139, doi: 10.1016/j.advwatres. 2011.04.013.   DOI
31 Gurnis, M., and Davies, G. F., 1986, Mixing in numerical models of mantle convection incorporating plate kinematics, J. Geophys. Res.-Solid Earth, 91(B6), 6375-6395, doi: 10.1029/JB091iB06p06375.   DOI
32 Furuichi, M., and May, D. A., 2015, Implicit solution of the material transport in stokes flow simulation: Toward thermal convection simulation surrounded by free surface, Comput. Phys. Commun., 192, 1-11, doi: 10.1016/j.cpc.2015. 02.011.   DOI
33 Garel, F., Goes, S., Davies, D. R., Davies, J. H., Kramer, S. C., and Wilson, C. R., 2014, Interaction of subducted slabs with the mantle transition-zone: A regime diagram from 2-D thermo-mechanical models with a mobile trench and an overriding plate, Geochem. Geophys. Geosyst., 15(5), 1739-1765, doi: 10.1002/2014GC005257.   DOI
34 Glerum, A., Thieulot, C., Fraters, M., Blom, C., & Spakman, W., 2018, Nonlinear viscoplasticity in ASPECT: benchmarking and applications to subduction, Solid Earth, 9(2), 267-294, doi: 10.1111/jmg.12144.   DOI
35 Hunter, J. D., 2007, Matplotlib: A 2D graphics environment, IEEE Ann. Hist. Comput., 9(03), 90-95, doi: 10.1109/MCSE.2007.55.   DOI
36 King, S. D., 2009, On topography and geoid from 2-D stagnant lid convection calculations, Geochem. Geophys. Geosyst., 10(3), Q03002, doi: 10.1029/2008GC002250.   DOI
37 Gerya, T., 2015, Tectonic overpressure and underpressure in lithospheric tectonics and metamorphism, J. Metamorph. Geol., 33(8), 785-800, doi: 10.1111/jmg.12144.   DOI
38 Gassmoller, R., Lokavarapu, H., Heien, E., Puckett, E. G., and Bangerth, W., 2018, Flexible and Scalable Particle-in-Cell Methods With Adaptive Mesh Refinement for Geodynamic Computations, Geochem. Geophys. Geosyst., 19(9), 3596-3604, doi: 10.1029/2018GC007508.   DOI