[mercury-users] Mercury programming by optimization

Michael Hendricks michael at ndrix.org
Tue Mar 6 02:36:37 AEDT 2012

I just finished reading "Programming by Optimization" by Holger Hoos
in the February 2012 edition of Communications of the ACM.  Is
something like this feasible/sensible for Mercury?  It reminds me of
Paul Bone's recent work on automatic parallelization.  It also seems
similar to Mercury's ability to compile different procedures for each
mode and to supply different clauses for different modes.

For those who haven't heard of the idea before, here's a rough idea
couched in terms of Mercury.  A developer is allowed to specify
multiple implementations for a single predicate (and/or mode).  Each
implementation performs the same computation, but perhaps has
different performance characteristics.  The compiler and optimization
tools, based on profiling data, choose among these redundant
implementations to make a highly optimized binary.  The author
describes 2-500x speedups in their research benchmarks.  It allows the
developer to solve a problem in multiple creative ways and have the
compiler make the hard performance computations/decisions on his

Incidentally, the idea also allows a QuickCheck-like testing regime in
which random input is fed to each of the redundant implementations
with the results compared against each other.  Any deviation in the
results suggests a bug in one of the implementations.

Any thoughts on the feasibility of such an idea in Mercury?

mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au

More information about the users mailing list