MOD2IR: High-Performance Code Generation for a Biophysically Detailed Neuronal Simulation DSL


Advances in computational capabilities and large volumes of experimental data have established computer simulations of brain tissue models as an important pillar in modern neu- roscience. Alongside, a variety of domain specific languages (DSLs) have been developed to succinctly express properties of these models, ensure their portability to different plat- forms, and provide an abstraction that allows scientists to work in their comfort zone of mathematical equations, dele- gating concerns about performance optimizations to down- stream compilers. One of the popular DSLs in modern neu- roscience is the NEURON MODeling Language (NMODL). Until now, its compilation process has been split into first transpiling NMODL to C++ and then using a C++ toolchain to emit the efficient machine code. This approach has several drawbacks including the reliance on different programming models to target heterogeneous hardware, maintainability of multiple compiler back-ends and the lack of flexibility to use the domain information for C++ code optimization. To overcome these limitations, we present MOD2IR, a new open-source code generation pipeline for NMODL. MOD2IR leverages the LLVM toolchain to target multiple CPU and GPU hardware platforms. Generating LLVM IR allows the vector extensions of modern CPU architectures to be tar- geted directly, producing optimized SIMD code. Additionally, this gives MOD2IR significant potential for further optimiza- tions based on the domain information available when LLVM IR code is generated. We present experiments showing that MOD2IR is able to produce on-par execution performance using a single compiler back-end implementation compared to code generated via state-of-the-art C++ compilers, and can even surpass them by up to 1.26×. Moreover, MOD2IR supports JIT-execution of NMODL, yielding both efficient code and an on-the-fly execution workflow.