I’ve been upstreaming a bit of my compiler work to the MLIR project.

Yesterday, I merged in a tutorial on mlir-opt, the main debugging tool for running passes on MLIR code. This is roughly the upstreamable parts of my first MLIR tutorial entry, MLIR — Running and Testing a Lowering. Mehdi Amini also provided a lot of useful information during review that taught me some stuff I didn’t know about the tool.

For example, the --mlir-print-ir-tree-dir flag, when combined with --mlir-print-ir-after-all or similar flags, writes each intermediate IR to a file in a specified directory, constructing a directory tree that mirrors the pass pipeline including its nesting. Until now I’ve mostly been using --mlir-print-ir-after-all and spending a lot of time scrolling through the terminal.

I also upstreamed the start of a polynomial math dialect, which replaced the polynomial dialect in the HEIR project. I have yet to upstream our passes and lowerings for it (e.g., no lowering to LLVM yet), but I’m hopeful to get that in this year. Given I’m on paternity leave til November, that also might be a bit ambitious.

I also want to flesh out polynomial approximation passes, which would be able to replace operations like the logarithm with appropriate polynomial evaluation operations (with a statically known polynomial). The IR would also be in charge of keeping track of the error introduced by the approximation, so that combinations of approximations can be reasoned about. This is largely why I’ve been spending so much time learning about polynomial approximation algorithms. I hope to start writing some blog posts about that soon, as I have some basic algorithm implementations ready and just need to write up the prose. The barycentric Remez algorithm would also make for a great chapter in Practical Math, so if you or someone you know would be a good interviewee for that topic, please let me know.


Want to respond? Send me an email, post a webmention, or find me elsewhere on the internet.

This article is syndicated on:

DOI: https://doi.org/10.59350/1jp20-x9t87