The handling of stencils was one aspect of PM-0.4 with which I was least happy. Since these are a key requirement for nearly all numerical modelling, I have long been looking for a way to make their coding as straightforward as possible. However, this has been one of the greatest challenges in terms of implementation, since the amount of code restructuring need to make a stencil operate efficiently (separating out halo computation, overlapping computation and halo exchange, tiling and the interaction of stencils with sequential loops, merging stencils, etc., etc.) significantly exceeds that of any other language feature and was one of the primary motivators for adding compiler passes. The idea is to enable a simple @ operator to access neighbouring values in the model grid, allowing you to write something like:
new_cell = (cell@[-1,0]+cell@[1,0]+cell@[0,-1]+cell@[0,1])/4.0
and then to let the compiler do all of the additional work needed to create optimised distributed stencil code. For this simple example, this is not too difficult. For realistic modelling code, however, this becomes much more complex - stencils will typically be abstracted into their own procedures and then applied to multiple variables at disparate points in the code that make the most mathematical, as opposed to computational, sense. Optimal coding in this context involves inter-procedural inference of halo extents and access patterns and extensive high-level code restructuring, including inlining, outlining and a lot of code motion. Getting all of this to work satisfactorally has taken the best part of a year, but has been a necessary step in making the language as effective as possible in its chosen problem domain.
At the time of writing this, I am planning to release PM-0.5 in the first quarter of 2026, starting with an MPI only version, but then bringing in support to generate hybrid MPI/OpenMP and MPI/OpenAcc target code once these have been tested. I will keep the roadmap on GitHub up to date.
So seasons greetings and hope to have something very interesting for you in the new year!
Comments
Post a Comment