====================================================================== ICFP 2001 PROGRAMMING CONTEST TEAM FUNCTIONAL BEER Tom Moertel ====================================================================== SML/NG OPTIMIZER 3000, IRON CHEF STYLE My entry is ``SML/NG Optimizer 3000, Iron Chef Style'' which (as the name implies) incorporates technology from the future, and also features today's theme ingredient -- girolle mushrooms -- for the judging panel's tasting enjoyment. WHAT ARE THE INGREDIENTS? ``Team Functional Beer offers a dish that gives the tasters something truly tantalizing: A core of Haskell and exotic shark fin, covered with bean paste and then baked to perfection, all wrapped within a crust of Perl which has been deep fried twice! Shell scripts provide the perfect harmony to the Perl and Haskell morsels, making for an orchestrated presentation to the palette. The Chef is offering this one with a side of espresso, so if the Perl doesn't get the tasters' attention, the caffeine certainly will!'' Heard from the tasting panel: ``It's so pretty! Look at the colors.'' ``I've never had Perl deep fried before. And now, fried twice? I don't know, maybe this Chef is going too far in his efforts to be different.'' ``But I *like* fried Perl. I think it's going to be delicious! I can hardly wait.'' But, enough with the commentators' introductions: It's time to find out who's cuisine reigns supreme! Chairman Kaga sez: ``Allez cuisine!'' HOW TO BUILD THE OPTIMIZER [NOTE] ==> I have provided a prebuilt optimizer binary (``main'' in the source directory). You should only have to rebuild the optimizer in the unlikely (and unfortunate!) event that the optimizer is incompatible with your Red Hat 7.1 environment. (I built mine under Red Hat 6.2, and so I hope that there is no problems with running it under 7.1.) In any case, if you need to rebuild the optimizer: ./buildme HOW TO RUN THE OPTIMIZER From the project directory (the one with this file in it) enter: ./runme time-limit < input-file where time-limit is the number of seconds in which you expect the optimizer to finish its work and input-file contains the markup source that you would like to optimize. IF EVERYTHING THAT COULD GO WRONG DOES GO WRONG The ./runme script is actually a Perl program that serves as a wrapper around the main Haskell executable. The Perl wrapper provides some nice features such as a form of catastrophic-failure protection (if the Haskell program dies, the Perl program returns the last available optimization result from the Haskell program's work file). But, if the Perl wrapper causes problems, you can run the Haskell executable directly like so: source/main time-limit work-file where time-limit is as before and work-file contains your input. NOTE: work-file *will* be overwritten: When the Haskell program exits, the work-file will contain the optimized output. IMPORTANT TIDBITS OF TASTY INFORMATION The program expects at least 10 MB of free storage (twice the maximum input size) to be available on /tmp. You can change the location of this working directory by editing the $WORKDIR variable in the configuration section of runme.in (and in source/runme.in if you are going to rebuild the project). Every so often, the program may emit some diagnostic information to standard error. According to the language of the challenge specification, this should be okay. If it isn't: ./runme time-limit < input-file 2>/dev/null NIFTY STUFF In the source directory: * make test -- runs QuickCheck tests for optimizer. * make stats -- runs 300 optimizations on randmonly generated documents (courtesy of QuickCheck) and generates a histogram of optimizer performance along with the overall reduction average. FINAL WORDS Thanks for taking the time to evaluate my entry. I hope it tantalizes your taste-buds! Tom Moertel 28 July 2001