Offline Narrowing-Driven Specialization in Practice

 

          Benchmark Results          
        Hybrid Hybrid   Offline 100%     Online Online  
benchmark codesize Annotated codesize Original runtime Special. Time Hybrid runtime Hybrid speedup Special. Time 100%Off runtime 100% Off speedup Special. Time Online runtime Online speedup
akermann 759 855 1953 860 533 3,66 730 543 3,60 290 342 5,71
allones 683 889 1477 170 1418 1,04 170 1442 1,02 170 1428 1,03
applast 663 926 1145 190 1121 1,02 220 1112 1,03 310 1133 1,01
applastSD 708 1010 1 280 0,1 10,00 450 0,1 10,00 1250 1 1,00
dapp 856 984 338 330 377 0,90 260 360 0,94 220 332 1,02
flip 903 1090 806 220 796 1,01 270 796 1,01 1870 790 1,02
gauss 2919 2743 235 640 237 0,99 700 239 0,98 10480 228 1,03
interSB 1768 1800 161 1610 164 0,98 1780 170 0,95 4720 168 0,96
kmp 30601 25836 327 18160 229 1,43 18860 102 3,21 20120 46 7,11
kmp2 30603 25839 246 18600 180 1,37 19220 85 2,89 22640 33 7,45
kmp3 30603 25839 97 18650 78 1,24 19330 52 1,87 24510 8 12,13
lenghtapp 681 926 2769 590 2876 0,96 550 2637 1,05 1020 2581 1,07
power 813 1028 25 640 27 0,93 800 30 0,83 8940 63 0,40
Average 7889 6905 737 4688 618 1,96 4872 582 2,26 7426 550 3,15

 

In order to compare  the Offline strategies with the Online Partial Evaluator, we have made a slight modification to the online partial evaluator and we have adapted also the same examples for both classes of partial evaluators, the sources of this last application can be found in this hiperlink. Once you download the file, you can uncompress it with:

  tar xvfz peval07.tgz

If you have installed PAKCS goto to load  the file peval.curry, otherwise;  you need to install the PAKCS (version 1.7.3) environment for Curry. Then, start PAKCS and load  the file peval.curry as follows:

 

[gustavo@cmm2 test]$ cd peval
[gustavo@cmm2 peval]$ pakcs
% restoring /usr/local/pakcs/curry2prolog/c2p.state...
  ______      __       _    _    ______   _______    
 |  __  |    /  \     | |  / /  |  ____| |  _____|   Portland Aachen Kiel
 | |  | |   / /\ \    | |_/ /   | |      | |_____    Curry System
 | |__| |  / /__\ \   |  _  |   | |      |_____  |  
 |  ____| / ______ \  | | \ \   | |____   _____| |   Version 1.7.3 (10)
 |_|     /_/      \_\ |_|  \_\  |______| |_______|   September 2006

Curry2Prolog(sicstus) Compiler Environment (Version of 15/09/06)
(RWTH Aachen, CAU Kiel, Portland State University)

Bug reports: mh@informatik.uni-kiel.de

Type ":h" for help

Prelude> :l peval
Parsing 'peval.curry'...
...
generating peval.fcy ...
peval>

Now, you have available the following command:

For instance, a typical session is as follows:

peval> mixon "onexamp/applastSD"
Curry Partial Evaluator (Version 1.4 of November 2006)
(UP Valencia, CAU Kiel)

Annotated expressions to be partially evaluated:

(applastSD.applast (: 1 (: 2 (: 3 (: 4 (: 5 ([] )))))) v1)

Starting peval for program "onexamp/applastSD"...

Independent Renaming:

Specialized Program:

After Post-unfolding:

Writing specialized program into "onexamp/applastSD_pe.fcy"...

Specialization time (msecs): 1290
peval> :q
[gustavo@cmm2 peval]$
 

As you can see the application gives the specialization time also. You can load the specialized program (the benchmark) to verify the average benchmark runtime, we show below how to run the applast_pe.fcy benchmark:
 

[gustavo@cmm2 peval]$ pakcs
% restoring /usr/local/pakcs/curry2prolog/c2p.state...
  ______      __       _    _    ______   _______    
 |  __  |    /  \     | |  / /  |  ____| |  _____|   Portland Aachen Kiel
 | |  | |   / /\ \    | |_/ /   | |      | |_____    Curry System
 | |__| |  / /__\ \   |  _  |   | |      |_____  |  
 |  ____| / ______ \  | | \ \   | |____   _____| |   Version 1.7.3 (10)
 |_|     /_/      \_\ |_|  \_\  |______| |_______|   September 2006

Curry2Prolog(sicstus) Compiler Environment (Version of 15/09/06)
(RWTH Aachen, CAU Kiel, Portland State University)

Bug reports: mh@informatik.uni-kiel.de

Type ":h" for help

Prelude> :l peval
Parsing 'peval.curry'...
skipping Flat.curry ...
skipping Flat2Fcy.curry ...
skipping peval.curry ...
peval> mixon "onexamp/applast"
Curry Partial Evaluator (Version 1.4 of November 2006)
(UP Valencia, CAU Kiel)

Annotated expressions to be partially evaluated:

(applast.applast v1 6)

Starting peval for program "onexamp/applast"...

Independent Renaming:

Specialized Program:

After Post-unfolding:

Writing specialized program into "onexamp/applast_pe.fcy"...

Specialization time (msecs): 250
peval> :l onexamp/applast_pe
Compiling 'onexamp/applast_pe.fcy' into 'onexamp/applast_pe.pl'...done
onexamp/applast_pe(module: applast)> bench
success
success
success
success
success
success
success
success
success
success
Runtimes (msecs): [1170,1170,1060,1110,1160,1080,1120,1090,1130,1100]
Average (msecs): 1119
onexamp/applast_pe(module: applast)>
 

After you get the specialized program, applast_pe.fcy in this case, you can load it and execute the bench function; this function executes ten times the program and gives de average in milisecs.

The sources of the Offline strategies adapted to show the specialization time can be found in this hiperlink. Once you download the file, you can proceed as is indicated in this page. You will see the specialization time when you execute mix or mixpo, i.e., hybrid or pure offline specialization. For instance:

OffPeval> annotate "examples/applast"
--------------------------------------------------
         Offline Partial Evaluator v 1.0         
--------------------------------------------------
Loading AbstractCurry program
Computing size-change graphs
Computing binding-time division
[("main",1,[D]),("applast",2,[D,S]),("app",2,[D,S]),("last",1,[D]),("UNF",1,[S]),("MEM",1,[S]),("GEN",1,[S]),("getExecTime",1,[S]),("runBenchmark",2,[S,S])]
Program loaded
Annotating program & linearizing...
Program succesfully annotated
Tranforming annotated program to Curry...
Annotated program stored in <<examples/applast_ann.curry>>
OffPeval> mix "examples/applast_ann"
Offline Narrowing-Driven Partial Evaluator
(Version 0.1 of April 2007)
(Technical University of Valencia)

Main call: (main v0)

Writing original program into "examples/applast_ann_pe.fcy"...

Global & local acceses:"
5"  13

Specialization time (msecs): 200

OffPeval> :l examples/applast_ann_pe
Compiling 'examples/applast_ann_pe.fcy' into 'examples/applast_ann_pe.pl'...done
examples/applast_ann_pe(module: applast_ann)> bench
success
success
success
success
success
success
success
success
success
success
Runtimes (msecs): [1180,1180,1180,1190,1190,1170,1190,1180,1180,1190]
Average (msecs): 1183
examples/applast_ann_pe(module: applast_ann)> :q
 

Please report any bug or comment to garroyo (at) dsic.upv.es.

MiST ELP GPLIS DSIC UPV

Last update / Gustavo Arroyo