Julia for Geophysical Fluid Dynamics: Performance Comparisons between
CPU, GPU, and Fortran-MPI
Abstract
Some programming languages are easy to develop at the cost of slow
execution, while others are lightning fast at run time but are much more
difficult to write. Julia is a programming language that aims to be the
best of both worlds—a development and production language at the same
time. To test Julia’s utility in scientific high-performance computing
(HPC), we built an unstructured-mesh shallow water model in Julia and
compared it against an established Fortran-MPI ocean model, MPAS-Ocean,
as well as a Python shallow water code. Three versions of the Julia
shallow water code were created, for: single-core CPU; graphics
processing unit (GPU); and Message Passing Interface (MPI) CPU clusters.
Comparing identical simulations revealed that our first version of the
single-core CPU Julia model was 13 times faster than Python. Further
Julia optimizations, including static typing and removing implicit
memory allocations, provided an additional 10–20x speed-up of the
single-core CPU Julia model. The GPU-accelerated Julia code is extremely
fast, with a speed-up of 230-380x compared to the single-core CPU Julia
code if communication with the GPU occurs every 10 time steps.
Parallelized Julia-MPI performance was identical to Fortran-MPI
MPAS-Ocean for low processor counts, and ranges from 2x faster to 2x
slower for higher processor counts. Our experience is that Julia
development is fast and convenient for prototyping, but that Julia
requires further investment and expertise to be competitive with
compiled codes. We provide advice on Julia code optimization for HPC
systems.