[Apr 26 Discussion] Superoptimizer: A Look at the Smallest Program #320
Replies: 11 comments 22 replies
-
I think this paper turns on an observation that is both liberating and frightening: our instruction sets are now (and by "now" I guess I mean 1987!) sufficiently complicated that we no longer know how best to use them. In some cases it just makes sense to define a slow reference implementation that we do understand, and then let a computer brute-force its way through an instruction set in search of the best equivalent version. The paper seems to define "best" as shortest, but I imagine it is easy to retool it to the cost-function of choice. I'd be curious what folks thought of the Krumme & Ackley work (see the second half of §5). It is probably (discuss?) more mathematically elegant than the present work, but it has serious drawbacks of its own. The author proposes a combination of the superoptimizer and the Krumme & Ackley work, and a quick search seems to suggest that superoptimizers today are indeed used in that way. |
Beta Was this translation helpful? Give feedback.
-
This paper tackles a very daunting task: "find the shortest version of the original program"! And the approach towards this is an optimized search with equivalence checks, which also feels like a daunting task (especially nowdays, when we probably have much more convoluted? complicated? large? programs than what scholars at the time were facing). They describe two approaches towards checking whether a potential optimized program is equivalent to the original: a Boolean Test that checks the two programs expressed as boolean formulas (which is extremely costly in terms of both space and time), and a Probabilistic Test (which sounds like it's basically testing?) that checks input output behavior. I personally find the statement "It was found in practice that a program, has a very low probability of |
Beta Was this translation helpful? Give feedback.
-
I really like this short and concise paper. A really simple but powerful idea! Those optimized programs in the appendix are somehow like magic and are hard for programmers to figure out in the first place. I wonder what is the performance of superoptimizer on emerging ISA like RISC-V. Do we still use this kind of brute-force method to find the best instruction implementation? Or we have other heuristics to speedup the process? |
Beta Was this translation helpful? Give feedback.
-
Pretty cool paper, I like the idea of building idioms of functions that are often used like a library, which reminded me of the fast inverse square root, or using a superoptimizer as a benchmark for how succinct an instruction set. I was a bit confused on how might a compiler actually use superoptimizers and when would it know to use it? |
Beta Was this translation helpful? Give feedback.
-
I am left wondering what the impact of unenforced preconditions specified by programmers in the function specification has on this idea. For example, if there is a comment like the following:
Programmers do this all the time because language constructs do not exist or because they were lazy and expected nobody to call But I wonder what impact something like this would have on the size of the search for superoptimization. Could tight enough preconditions make the search space small enough for the superoptimizer to become more than just a toy? |
Beta Was this translation helpful? Give feedback.
-
I'm not well versed in the status of modern superoptimizers, but it would be interesting to see machine learning or machine learning adjacent techniques applied in this context to try to reduce the search space. Doing the simple search space pruning they perform in this paper surely rule out a lot of the potential search space, but I would hope that this search space could be narrowed more to improve the scalability of these techniques. I also find the unexpected behavior that arises out of superoptimization to be very interesting. It's particularly cool to see a set of instructions that are equivalent to a more complex implementation, but seem like it shouldn't work at all. This reminds me of a relatively famous result in the FPGA world when machine learning was used for placement and routing. One design generated through machine learning worked only because of electromagnetic coupling between adjacent wires in the FPGA, completely departing from the digital circuit that was intended to be implemented. In both of these cases, I question how practical the potentially outlandish solutions are for debuggability and reuse reasons. |
Beta Was this translation helpful? Give feedback.
-
I am not familiar with how these techniques are used in modern programs, but it seems like they could be quite useful for compiling short library functions (like abs) that will be frequently used and likely not need to be rewritten/recompiled for a long time. I'm curious how many instructions this sort of compilation could actually save for these types of programs, and how these methods have been used in practice. It sadly seems like the sort of technique that requires too much labor and computational power for most people to both with it outside of academia, but saving a few instructions on these functions might be significant in ML/scientific computing programs (?) |
Beta Was this translation helpful? Give feedback.
-
I think this paper is a delightful read. Finding the shortest instruction sequence that is functionally equivalent to the input program given an instruction set is indeed a challenging task. This paper limits its scope within simple instruction set and register operations to make search possible. I find one of the applications very interesting: the author states that the superoptimizer can be leveraged to design RISC ISA. Intuitively, if you want to add a new instruction, if would be helpful to know that whether this new instruction can be replaced by a combination of existing ones. I am not sure if such "super optimization" is possible on today's ISA, since both search algorithms and ISA have been developed extensively. If this approach is possible, the benefit of having the shortest stream-line instructions would be huge, especially where the processors are all pipelined. |
Beta Was this translation helpful? Give feedback.
-
One thing I have been thinking about is how to decrease the size of the search space. I think it would be cool if the user could provide a sketch to the super optimizer- maybe the programmer has an idea of an ideal ordering of instructions but isn't sure about which arguments to pass. Then the super optimizer could find a satisfying program, or default to the techniques described in the paper if the sketch is unsatisfiable. But after looking at some of these optimized programs, I think it would be highly unlikely for a programmer to be able to come up with a sketch that would produce the shortest program (at least I would not have been able to come up with these on my own). |
Beta Was this translation helpful? Give feedback.
-
It's a very interesting paper with concise and clear idea! Like most of you, I'm interested in how it is used in modern tools. I would think that lots of high-performance C library function's assembly code implementation would be inspired by the (similar) idea of superoptimizers. Just like the author said, he himself is the author of Of course, the long consuming time of exhaustive search limits the program size (only 13 machine instructions), but it can still be helpful when we already know these optimal design. We can store them in a table (with some pattern), and the peephole optimization could just search these entries in the table. When a function hit, we know that this is the shortest program. |
Beta Was this translation helpful? Give feedback.
-
Honestly top tier paper right here. Massalin had an idea, and she communicated it with startling efficiency 1987 was a while ago; Moore (and Proebsting!) have been working hard for us since then, so I wonder what the limitations are now? The nature of exponential things mean it's probably not a lot better, but I wonder just how little of an effect this has? 15 machine instructions? Maybe 20? Seems like it might be applicable to more than it was when it was written |
Beta Was this translation helpful? Give feedback.
-
This is the discussion thread for Superoptimiser: A Look at the Smallest Program by Henry Massalin. The Discussion leaders are Victor Giannakouris and Jonathan Tran.
Beta Was this translation helpful? Give feedback.
All reactions