====== Benchmarking a simple PDE solver in Julia and other languages ====== ==== Julia ==== Julia is an innovative new programming language that promises to revolutionize scientific computing. In a nutshell, it is * High-level, dynamic, and general-purpose, like Python * As fast as compiled C, roughly * Aimed squarely at numerics, with libraries and ease-of-use comparable to Matlab Julia's main innovation is a carefully-designed type system combined with just-in-time compilation. The combination allows high-level user code to be compiled to machine-code on-the-fly. ==== The benchmark algorithm ==== The benchmark algorithm here is a simple time-integration of the Kuramoto-Sivashniksy equation \begin{eqnarray*} u_t = -u_{xx} - u_{xxxx} - u u_x \end{eqnarray*} on a 1d periodic domain $[0, L_x]$, with $x$ space and $t$ time, and where subscripts indicate differentiation. The algorithm uses a Fourier decomposition in space and 2nd-order Crank-Nicolson, Adams-Bashforth semi-implicit finite-differencing in time, with collocation computation of the nonlinear term $u u_x$. I implemented the same algorithm in Python, Matlab, C++, and in two forms in Julia. The codes and a detailed description of the algorithm is given below. ==== The results ==== **The left plot** shows execution time of 3200 time steps of the algorithm as a function of $N_x$, the number of gridpoints in the Fourier decomposition. The dominant cost of the algorithm should be the FFTs, which should scale as $N_x \log N_x$. All the codes use the same FFTW libraries, so ideally, they should all collapse onto the same $N_x \log N_x$ line as linear and fixed-size overheads costs decrease relative to that. {{:gibson:juliablog:cputime.png?400|}} {{:gibson:juliablog:timeloc.png?400|}} The right plot shows