[MLton-commit] r5836

Matthew Fluet fluet at mlton.org
Wed Aug 8 16:40:57 PDT 2007


New defaults for inlining.  This doesn't uniformly improve
performance, but it eliminates some particularly bad x86_64 benchmark
performance problems (at the expense of introducing a performance
problem with output1).

A more systematic inlining heuristic should be on the TODO list, but
this is passable for the Aug. 2007 release.

Benchmarks:
============================================================

SHADOW (Dual-processor AMD Opteron 2.0GHz, 8GB Memory, Fedora Core 7)

Linux shadow 2.6.22.1-41.fc7 #1 SMP Fri Jul 27 18:21:43 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux

gcc (GCC) 4.1.2 20070502 (Red Hat 4.1.2-12)


MLton0 -- ~/devel/mlton/mlton-20051202-1.i386-linux/build/bin/mlton
MLton1 -- ~/devel/mlton/mlton.svn.trunk/build/bin/mlton
MLton2 -- ~/devel/mlton/mlton.svn.trunk.inline/build/bin/mlton
run time ratio
benchmark         MLton0 MLton1 MLton2
barnes-hut          1.00   0.92   0.92
boyer               1.00   1.24   1.13
checksum            1.00   0.61   0.42
count-graphs        1.00   2.24   1.39
DLXSimulator        1.00   1.59   1.51
fft                 1.00   1.01   1.00
fib                 1.00   1.08   1.19
flat-array          1.00   0.99   0.99
hamlet              1.00   1.72   1.40
imp-for             1.00   0.91   0.92
knuth-bendix        1.00   1.43   1.33
lexgen              1.00   1.48   1.23
life                1.00   1.64   1.16
logic               1.00   1.34   1.52
mandelbrot          1.00   0.86   0.90
matrix-multiply     1.00   0.82   0.80
md5                 1.00   1.93   0.10
merge               1.00   1.64   1.72
mlyacc              1.00   1.52   1.42
model-elimination   1.00   1.41   1.30
mpuz                1.00   1.67   1.34
nucleic             1.00   1.11   0.94
output1             1.00   1.07   1.90
peek                1.00   1.74   1.75
psdes-random        1.00   1.16   1.13
ratio-regions       1.00   1.22   0.77
ray                 1.00   1.11   1.11
raytrace            1.00   1.10   1.30
simple              1.00   1.40   1.11
smith-normal-form   1.00   0.82   0.82
tailfib             1.00   1.22   1.23
tak                 1.00   1.22   1.25
tensor              1.00   1.40   1.31
tsp                 1.00   1.06   1.05
tyan                1.00   1.54   1.44
vector-concat       1.00   0.82   0.97
vector-rev          1.00   1.17   1.14
vliw                1.00   2.04   1.85
wc-input1           1.00   1.23   1.23
wc-scanStream       1.00   1.01   1.00
zebra               1.00   1.54   1.55
zern                1.00   1.21   1.39
size
benchmark            MLton0    MLton1    MLton2
barnes-hut          119,430   168,798   167,742
boyer               144,869   215,393   213,649
checksum             65,597    95,825    93,681
count-graphs         76,789   120,593   119,937
DLXSimulator        144,257   195,996   196,204
fft                  75,108   117,087   117,487
fib                  58,029    95,873    93,569
flat-array           58,077    95,857    93,073
hamlet            1,246,688 1,554,825 1,504,601
imp-for              57,901    95,745    93,393
knuth-bendix        124,269   171,116   171,980
lexgen              216,614   283,867   285,419
life                 76,117   119,665   118,081
logic               115,605   167,345   177,809
mandelbrot           58,013    95,713    93,233
matrix-multiply      59,540    96,369    95,249
md5                  93,317   128,172   127,036
merge                59,597    97,985    94,897
mlyacc              516,486   644,507   662,011
model-elimination   646,219   860,898   850,418
mpuz                 60,845    99,569    99,857
nucleic             207,760   271,680   269,104
output1              96,519   135,120   136,816
peek                 91,969   127,244   132,604
psdes-random         58,669    96,721    96,465
ratio-regions        83,997   128,961   120,977
ray                 198,158   256,920   245,128
raytrace            278,187   359,698   372,946
simple              236,873   329,497   343,593
smith-normal-form   192,389   266,972   272,076
tailfib              57,709    95,473    93,137
tak                  58,109    95,905    93,585
tensor              113,380   155,875   162,515
tsp                  97,789   139,083   139,627
tyan                149,593   205,276   212,556
vector-concat        59,301    97,441    94,881
vector-rev           58,545    96,753    94,641
vliw                406,705   522,650   519,402
wc-input1           117,601   164,282   159,338
wc-scanStream       124,769   173,498   170,106
zebra               156,293   212,476   212,700
zern                104,246   132,902   132,438
compile time
benchmark         MLton0 MLton1 MLton2
barnes-hut          3.99   9.70   9.28
boyer               4.19  10.31   9.80
checksum            2.85   7.51   7.11
count-graphs        3.24   8.12   8.01
DLXSimulator        4.47  10.72  10.40
fft                 3.06   8.10   7.75
fib                 2.85   7.51   7.15
flat-array          2.88   7.33   7.14
hamlet             42.27  48.64  46.43
imp-for             2.91   7.34   7.26
knuth-bendix        3.70   9.06   9.01
lexgen              5.19  12.10  11.70
life                3.11   8.20   7.82
logic               3.73   9.01   9.24
mandelbrot          2.87   7.16   7.08
matrix-multiply     2.89   7.70   7.33
md5                 3.21   8.48   8.01
merge               2.85   7.35   7.27
mlyacc             11.72  25.75  25.73
model-elimination  11.77  25.04  24.28
mpuz                2.93   7.47   7.33
nucleic             5.34  11.14  10.88
output1             3.23   8.22   8.17
peek                3.16   8.39   8.01
psdes-random        2.89   7.56   7.23
ratio-regions       3.46   8.58   8.56
ray                 4.64  11.48  11.08
raytrace            6.38  14.74  14.35
simple              5.39  12.97  12.65
smith-normal-form   4.64  11.33  10.91
tailfib             2.87   7.41   7.27
tak                 2.82   7.55   7.12
tensor              4.16  10.01   9.78
tsp                 3.37   8.60   8.48
tyan                4.35  10.35  10.45
vector-concat       2.90   7.52   7.16
vector-rev          2.89   7.13   7.07
vliw                8.65  19.47  19.15
wc-input1           3.57   9.10   8.74
wc-scanStream       3.92   9.29   8.98
zebra               4.35  10.65  10.45
zern                3.20   8.49   8.09
run time
benchmark         MLton0 MLton1 MLton2
barnes-hut         16.94  15.56  15.62
boyer              16.23  20.20  18.37
checksum           43.15  26.34  18.27
count-graphs       21.14  47.42  29.43
DLXSimulator       16.93  26.96  25.56
fft                14.30  14.37  14.36
fib                34.67  37.47  41.13
flat-array          8.49   8.38   8.36
hamlet             15.86  27.24  22.22
imp-for            28.84  26.21  26.65
knuth-bendix       17.72  25.42  23.62
lexgen             19.64  29.15  24.24
life                8.40  13.81   9.77
logic              18.15  24.37  27.68
mandelbrot         23.98  20.69  21.48
matrix-multiply     3.36   2.76   2.69
md5                32.35  62.47   3.38
merge              14.15  23.20  24.40
mlyacc             17.63  26.83  24.97
model-elimination  28.08  39.51  36.58
mpuz               21.87  36.41  29.32
nucleic            16.66  18.48  15.71
output1             7.22   7.71  13.70
peek               19.96  34.74  34.89
psdes-random       16.29  18.90  18.34
ratio-regions      24.32  29.79  18.63
ray                15.23  16.93  16.96
raytrace           16.18  17.87  21.07
simple             20.26  28.33  22.48
smith-normal-form  10.24   8.37   8.39
tailfib            19.36  23.63  23.72
tak                13.00  15.91  16.22
tensor             17.30  24.26  22.70
tsp                20.38  21.67  21.31
tyan               18.24  28.11  26.34
vector-concat      30.09  24.75  29.19
vector-rev         20.34  23.85  23.23
vliw               17.92  36.57  33.06
wc-input1          28.28  34.82  34.88
wc-scanStream      14.68  14.77  14.72
zebra              26.30  40.57  40.67
zern               17.81  21.50  24.81

mlton.svn.trunk
MLton MLTONVERSION (built Wed Aug 08 14:37:03 2007 on shadow)
MLton starting
   Compile SML starting
      pre codegen starting
      pre codegen finished in 184.89 + 86.68 (32% GC)
      amd64 code gen starting
      amd64 code gen finished in 329.74 + 6.21 (2% GC)
   Compile SML finished in 514.72 + 92.89 (15% GC)
   Compile and Assemble starting
   Compile and Assemble finished in 20.98 + 0.76 (3% GC)
   Link starting
   Link finished in 0.89 + 0.00 (0% GC)
MLton finished in 537.15 + 94.66 (15% GC)
mlton.svn.trunk.inline
MLton MLTONVERSION (built Wed Aug 08 15:07:30 2007 on shadow)
MLton starting
   Compile SML starting
      pre codegen starting
      pre codegen finished in 193.23 + 93.84 (33% GC)
      amd64 code gen starting
      amd64 code gen finished in 282.40 + 14.68 (5% GC)
   Compile SML finished in 475.70 + 108.52 (19% GC)
   Compile and Assemble starting
   Compile and Assemble finished in 19.57 + 0.03 (0% GC)
   Link starting
   Link finished in 0.90 + 0.00 (0% GC)
MLton finished in 497.01 + 109.50 (18% GC)

============================================================

FENRIR (Dual-processor Dual-core Intel Xeon 2.0GHz, 2GB Memory, MacOS 10.4)

Darwin fenrir.uchicago.edu 8.10.1 Darwin Kernel Version 8.10.1: Wed May 23 16:33:00 PDT 2007; root:xnu-792.22.5~1/RELEASE_I386 i386 i386

i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. build 5367)


MLton0 -- ~/devel/mlton/mlton-20061119-1.x86-darwin/build/bin/mlton
MLton1 -- ~/devel/mlton/mlton.svn.trunk/build/bin/mlton
MLton2 -- ~/devel/mlton/mlton.svn.trunk.inline/build/bin/mlton
run time ratio
benchmark         MLton0 MLton1 MLton2
barnes-hut          1.00   1.05   1.02
boyer               1.00   0.89   0.79
checksum            1.00   1.09   1.06
count-graphs        1.00   1.72   1.02
DLXSimulator        1.00   1.03   1.04
fft                 1.00   1.01   1.00
fib                 1.00   0.99   0.88
flat-array          1.00   1.00   0.99
hamlet              1.00   1.12   0.94
imp-for             1.00   1.00   1.00
knuth-bendix        1.00   1.06   1.03
lexgen              1.00   1.01   0.92
life                1.00   0.96   0.96
logic               1.00   1.08   1.06
mandelbrot          1.00   1.00   1.15
matrix-multiply     1.00   0.99   0.65
md5                 1.00   1.05   0.08
merge               1.00   0.94   0.97
mlyacc              1.00   1.03   1.07
model-elimination   1.00   1.08   1.08
mpuz                1.00   1.00   1.01
nucleic             1.00   1.16   0.95
output1             1.00   0.98   0.69
peek                1.00   0.94   0.94
psdes-random        1.00   0.94   0.91
ratio-regions       1.00   1.02   0.68
ray                 1.00   0.99   0.95
raytrace            1.00   1.01   0.97
simple              1.00   0.58   0.60
smith-normal-form   1.00   1.00   1.00
tailfib             1.00   1.00   1.00
tak                 1.00   0.91   0.92
tensor              1.00   1.00   1.00
tsp                 1.00   1.03   1.03
tyan                1.00   1.05   1.06
vector-concat       1.00   1.00   1.12
vector-rev          1.00   1.00   1.01
vliw                1.00   1.46   1.24
wc-input1           1.00   1.12   1.00
wc-scanStream       1.00   1.04   1.04
zebra               1.00   1.01   1.06
zern                1.00   1.00   1.04
size
benchmark            MLton0    MLton1    MLton2
barnes-hut          114,688   163,840   167,936
boyer               155,648   204,800   204,800
checksum             61,440   106,496   106,496
count-graphs         77,824   126,976   126,976
DLXSimulator        147,456   196,608   196,608
fft                  77,824   122,880   126,976
fib                  57,344   106,496   102,400
flat-array           57,344   106,496   102,400
hamlet            1,327,104 1,359,872 1,335,296
imp-for              57,344   106,496   102,400
knuth-bendix        126,976   176,128   176,128
lexgen              221,184   270,336   274,432
life                 77,824   126,976   126,976
logic               118,784   167,936   172,032
mandelbrot           61,440   106,496   102,400
matrix-multiply      61,440   106,496   106,496
md5                  90,112   139,264   139,264
merge                61,440   106,496   106,496
mlyacc              540,672   589,824   602,112
model-elimination   684,032   720,896   729,088
mpuz                 61,440   110,592   110,592
nucleic             229,376   282,624   278,528
output1              94,208   143,360   143,360
peek                 90,112   139,264   143,360
psdes-random         61,440   106,496   106,496
ratio-regions        86,016   135,168   131,072
ray                 208,896   237,568   237,568
raytrace            290,816   319,488   331,776
simple              241,664   286,720   307,200
smith-normal-form   208,896   258,048   262,144
tailfib              57,344   106,496   102,400
tak                  57,344   106,496   102,400
tensor              110,592   163,840   167,936
tsp                  94,208   143,360   143,360
tyan                151,552   200,704   208,896
vector-concat        61,440   106,496   106,496
vector-rev           57,344   106,496   106,496
vliw                430,080   450,560   466,944
wc-input1           118,784   167,936   167,936
wc-scanStream       126,976   172,032   172,032
zebra               159,744   208,896   208,896
zern                106,496   135,168   135,168
compile time
benchmark         MLton0 MLton1 MLton2
barnes-hut          3.35   5.22   5.18
boyer               3.42   5.25   5.33
checksum            2.44   4.16   4.22
count-graphs        2.70   4.44   4.57
DLXSimulator        3.61   5.53   5.58
fft                 2.61   4.34   4.48
fib                 2.44   4.14   4.21
flat-array          2.43   4.18   4.22
hamlet             32.15  21.47  21.24
imp-for             2.44   4.16   4.23
knuth-bendix        3.07   4.95   5.03
lexgen              4.21   6.29   6.43
life                2.64   4.38   4.47
logic               3.10   4.88   5.18
mandelbrot          2.47   4.20   4.26
matrix-multiply     2.47   4.20   4.28
md5                 2.72   4.58   4.61
merge               2.47   4.17   4.27
mlyacc              8.66  13.66  13.86
model-elimination   9.07  11.88  12.59
mpuz                2.51   4.24   4.31
nucleic             4.39   6.23   6.30
output1             2.71   4.58   4.63
peek                2.69   4.49   4.62
psdes-random        2.48   4.22   4.29
ratio-regions       2.88   4.78   4.92
ray                 3.84   6.01   6.12
raytrace            5.01   7.33   7.83
simple              4.36   6.74   6.96
smith-normal-form   3.72   5.80   5.91
tailfib             2.47   4.20   4.26
tak                 2.47   4.20   4.27
tensor              3.39   5.29   5.49
tsp                 2.86   4.71   4.84
tyan                3.65   5.58   5.77
vector-concat       2.49   4.23   4.31
vector-rev          2.49   4.22   4.28
vliw                6.53   9.53  10.04
wc-input1           3.02   4.92   4.96
wc-scanStream       3.10   5.03   5.10
zebra               3.55   5.84   5.90
zern                2.74   4.55   4.66
run time
benchmark         MLton0 MLton1 MLton2
barnes-hut         11.68  12.21  11.93
boyer              11.35  10.10   8.92
checksum           28.52  31.15  30.33
count-graphs       12.04  20.73  12.32
DLXSimulator       10.67  10.99  11.05
fft                12.43  12.52  12.38
fib                21.54  21.36  18.98
flat-array          4.62   4.62   4.58
hamlet             10.28  11.46   9.65
imp-for            13.37  13.38  13.38
knuth-bendix       11.27  11.96  11.63
lexgen             10.90  11.03  10.07
life                5.81   5.58   5.56
logic              10.78  11.63  11.44
mandelbrot         16.54  16.54  18.99
matrix-multiply     1.90   1.89   1.24
md5                23.63  24.86   1.87
merge               8.79   8.30   8.52
mlyacc             12.45  12.85  13.28
model-elimination  21.31  23.08  22.94
mpuz               12.38  12.39  12.54
nucleic            11.54  13.41  10.92
output1             6.82   6.66   4.73
peek               21.64  20.28  20.40
psdes-random       14.39  13.54  13.10
ratio-regions      10.66  10.87   7.29
ray                14.18  14.05  13.51
raytrace           11.66  11.77  11.30
simple             19.68  11.41  11.90
smith-normal-form  14.08  14.13  14.13
tailfib            13.62  13.62  13.62
tak                 7.42   6.76   6.85
tensor             20.93  20.93  20.93
tsp                22.42  23.13  23.10
tyan               11.49  12.03  12.16
vector-concat      16.54  16.50  18.54
vector-rev          9.68   9.67   9.76
vliw                9.83  14.32  12.17
wc-input1          14.36  16.09  14.29
wc-scanStream       8.98   9.33   9.31
zebra              15.15  15.34  16.07
zern               14.04  14.06  14.58


mlton.svn.trunk
MLton MLTONVERSION (built Wed Aug 08 14:25:28 2007 on fenrir.uchicago.edu)
MLton starting
   Compile SML starting
      pre codegen starting
      pre codegen finished in 67.83 + 57.61 (46% GC)
      x86 code gen starting
      x86 code gen finished in 116.47 + 9.56 (8% GC)
   Compile SML finished in 184.35 + 67.17 (27% GC)
   Compile and Assemble starting
   Compile and Assemble finished in 13.85 + 0.05 (0% GC)
   Link starting
   Link finished in 0.42 + 0.00 (1% GC)
MLton finished in 198.71 + 67.69 (25% GC)
mlton.svn.trunk.inline
MLton MLTONVERSION (built Wed Aug 08 14:43:39 2007 on fenrir.uchicago.edu)
MLton starting
   Compile SML starting
      pre codegen starting
      pre codegen finished in 69.91 + 67.70 (49% GC)
      x86 code gen starting
      x86 code gen finished in 117.76 + 5.19 (4% GC)
   Compile SML finished in 187.71 + 72.89 (28% GC)
   Compile and Assemble starting
   Compile and Assemble finished in 13.67 + 0.15 (1% GC)
   Link starting
   Link finished in 0.42 + 0.00 (0% GC)
MLton finished in 201.89 + 73.77 (27% GC)



----------------------------------------------------------------------

U   mlton/trunk/benchmark/Makefile
U   mlton/trunk/mlton/control/control-flags.sig
U   mlton/trunk/mlton/control/control-flags.sml
U   mlton/trunk/mlton/main/main.fun
U   mlton/trunk/mlton/ssa/inline.fun
U   mlton/trunk/mlton/ssa/inline.sig
U   mlton/trunk/mlton/ssa/simplify.fun

----------------------------------------------------------------------

Modified: mlton/trunk/benchmark/Makefile
===================================================================
--- mlton/trunk/benchmark/Makefile	2007-08-08 17:25:24 UTC (rev 5835)
+++ mlton/trunk/benchmark/Makefile	2007-08-08 23:40:56 UTC (rev 5836)
@@ -31,15 +31,6 @@
 clean:
 	../bin/clean
 
-.PHONY: install
-install: $(NAME)
-	if [ `whoami` != 'root' ]; then echo >&2 'You should be root'; exit 1; fi
-	cp -p $(NAME) /usr/bin/
-
-.PHONY: tags
-tags:
-	etags *.fun *.sig *.sml
-
 BENCH := barnes-hut boyer checksum count-graphs DLXSimulator fft fib flat-array hamlet imp-for knuth-bendix lexgen life logic mandelbrot matrix-multiply md5 merge mlyacc model-elimination mpuz nucleic output1 peek psdes-random ratio-regions ray raytrace simple smith-normal-form tailfib tak tensor tsp tyan vector-concat vector-rev vliw wc-input1 wc-scanStream zebra zern
 FPBENCH := barnes-hut fft hamlet mandelbrot matrix-multiply nucleic ray raytrace simple tensor tsp tyan vliw zern
 
@@ -52,10 +43,12 @@
 	cd tests && ../benchmark $(BFLAGS) $(BENCH)
 
 QBENCH := $(BENCH)
-QBFLAGS := -mlton "~/devel/mlton/mlton-20051202-1.i386-linux/build/bin/mlton -codegen {native,c} -align {4,8}" -mlton "~/devel/mlton/mlton.svn.trunk/build/bin/mlton -codegen {amd64,c} -align {4,8}"
+QBFLAGS := -mlton "~/devel/mlton/mlton-20061119-1.x86-darwin/build/bin/mlton"
+QBFLAGS += -mlton "~/devel/mlton/mlton.svn.trunk/build/bin/mlton"
+# QBFLAGS += -mlton "~/devel/mlton/mlton.svn.trunk.inline/build/bin/mlton -drop-pass introduceLoops1 -drop-pass loopInvariant1 -inline-leafa-loops true -inline-leafa-repeat false -inline-leafa-size 20 -drop-pass inlineLeaf2"
+# QBFLAGS += -mlton "~/devel/mlton/mlton.svn.trunk.inline/build/bin/mlton -inline-leafa-loops true -inline-leafa-repeat true -inline-leafa-size 20 -inline-leafb-loops true -inline-leafb-repeat true -inline-leafb-size 40"
+QBFLAGS += -mlton "~/devel/mlton/mlton.svn.trunk.inline/build/bin/mlton"
 
-QBFLAGS := -mlton "~/devel/mlton/mlton.svn.trunk/build/bin/mlton -codegen {amd64} -align {4} {-drop-pass introduceLoops1,} -inline-leaf {'(20;0;0)','(20;20;0)','(20;20;20)','(40;0;0)','(40;40;0)','(40;40;40)','(40;20;0)','(40;20;10)'}"
-
 .PHONY: qtest
 qtest: $(NAME)
 	cd tests && ../benchmark $(QBFLAGS) $(QBENCH) && $(MAKE) clean

Modified: mlton/trunk/mlton/control/control-flags.sig
===================================================================
--- mlton/trunk/mlton/control/control-flags.sig	2007-08-08 17:25:24 UTC (rev 5835)
+++ mlton/trunk/mlton/control/control-flags.sig	2007-08-08 23:40:56 UTC (rev 5836)
@@ -151,14 +151,13 @@
       (* Indentation used in laying out ILs. *)
       val indentation: int ref
 
-      val inline: int ref
-
       val inlineIntoMain: bool ref
 
-      val inlineLeafSize: int option ref
-      val inlineLeafLoops: bool ref
-      val inlineLeafRepeat: bool ref
+      val inlineLeafA: {loops: bool, repeat: bool, size: int option} ref
+      val inlineLeafB: {loops: bool, repeat: bool, size: int option} ref
 
+      val inlineNonRec: {small: int, product: int} ref
+
       (* The input file on the command line, minus path and extension. *)
       val inputFile: File.t ref
 

Modified: mlton/trunk/mlton/control/control-flags.sml
===================================================================
--- mlton/trunk/mlton/control/control-flags.sml	2007-08-08 17:25:24 UTC (rev 5835)
+++ mlton/trunk/mlton/control/control-flags.sml	2007-08-08 23:40:56 UTC (rev 5836)
@@ -653,26 +653,43 @@
                            default = 3,
                            toString = Int.toString}
 
-val inline = control {name = "inline",
-                      default = 60, 
-                      toString = Int.toString}
-
 val inlineIntoMain = control {name = "inlineIntoMain",
                               default = true,
                               toString = Bool.toString}
 
-val inlineLeafLoops = control {name = "inlineLeafLoops",
-                               default = true,
-                               toString = Bool.toString}
+val inlineLeafA = 
+   control {name = "inlineLeafA",
+            default = {loops = true,
+                       repeat = true,
+                       size = SOME 20},
+            toString =
+            fn {loops, repeat, size} =>
+            Layout.toString
+            (Layout.record [("loops", Bool.layout loops),
+                            ("repeat", Bool.layout repeat),
+                            ("size", Option.layout Int.layout size)])}
+val inlineLeafB = 
+   control {name = "inlineLeafB",
+            default = {loops = true,
+                       repeat = true,
+                       size = SOME 40},
+            toString =
+            fn {loops, repeat, size} =>
+            Layout.toString
+            (Layout.record [("loops", Bool.layout loops),
+                            ("repeat", Bool.layout repeat),
+                            ("size", Option.layout Int.layout size)])}
 
-val inlineLeafRepeat = control {name = "inlineLeafRepeat",
-                                default = false,
-                                toString = Bool.toString}
+val inlineNonRec =
+   control {name = "inlineNonRec",
+            default = {small = 60,
+                       product = 320},
+            toString =
+            fn {small, product} =>
+            Layout.toString
+            (Layout.record [("small", Int.layout small),
+                            ("product", Int.layout product)])}
 
-val inlineLeafSize = control {name = "inlineLeafSize",
-                              default = SOME 20,
-                              toString = Option.toString Int.toString}
-
 val inputFile = control {name = "input file",
                          default = "<bogus>",
                          toString = File.toString}

Modified: mlton/trunk/mlton/main/main.fun
===================================================================
--- mlton/trunk/mlton/main/main.fun	2007-08-08 17:25:24 UTC (rev 5835)
+++ mlton/trunk/mlton/main/main.fun	2007-08-08 23:40:56 UTC (rev 5836)
@@ -340,23 +340,70 @@
         boolRef Native.IEEEFP),
        (Expert, "indentation", " <n>", "indentation level in ILs",
         intRef indentation),
-       (Normal, "inline", " <n>", "set inlining threshold", intRef inline),
+       (Normal, "inline", " <n>", "set inlining threshold", 
+        Int (fn i => inlineNonRec := {small = i,
+                                      product = #product (!inlineNonRec)})),
        (Expert, "inline-into-main", " {true|false}",
         "inline functions into main",
         boolRef inlineIntoMain),
-       (Expert, "inline-leaf-size", " 20", "set leaf inlining threshold",
-        SpaceString (fn s => 
-                     inlineLeafSize := 
-                     (if s = "inf"
-                         then NONE
-                      else if String.forall (s, Char.isDigit)
-                         then Int.fromString s
-                      else (usage o concat)
-                           ["invalid -inline-leaf-size flag: ", s]))),
-       (Expert, "inline-leaf-loops", " {true|false}", " leaf inline loops",
-        boolRef inlineLeafLoops),
-       (Expert, "inline-leaf-repeat", " {false|true}", " repeat leaf inline",
-        boolRef inlineLeafRepeat),
+       (Expert, "inline-leafa-loops", " {true|false}", "leaf inline loops",
+        Bool (fn loops =>
+              case !inlineLeafA of
+                 {repeat, size, ...} =>
+                    inlineLeafA :=
+                    {loops = loops, repeat = repeat, size = size})),
+       (Expert, "inline-leafa-repeat", " {true|false}", "leaf inline repeat",
+        Bool (fn repeat =>
+              case !inlineLeafA of
+                 {loops, size, ...} =>
+                    inlineLeafA :=
+                    {loops = loops, repeat = repeat, size = size})),
+       (Expert, "inline-leafa-size", " <n>", "set leaf inlining threshold (20)",
+        SpaceString (fn s =>
+                     case !inlineLeafA of
+                        {loops, repeat, ...} =>
+                           inlineLeafA :=
+                           {loops = loops, repeat = repeat,
+                            size = (if s = "inf"
+                                       then NONE
+                                    else if String.forall (s, Char.isDigit)
+                                       then Int.fromString s
+                                    else (usage o concat)
+                                         ["invalid -inline-leaf-size flag: ", s])})),
+       (Expert, "inline-leafb-loops", " {true|false}", "leaf inline loops",
+        Bool (fn loops =>
+              case !inlineLeafB of
+                 {repeat, size, ...} =>
+                    inlineLeafB :=
+                    {loops = loops, repeat = repeat, size = size})),
+       (Expert, "inline-leafb-repeat", " {true|false}", "leaf inline repeat",
+        Bool (fn repeat =>
+              case !inlineLeafB of
+                 {loops, size, ...} =>
+                    inlineLeafB :=
+                    {loops = loops, repeat = repeat, size = size})),
+       (Expert, "inline-leafb-size", " <n>", "set leaf inlining threshold (40)",
+        SpaceString (fn s =>
+                     case !inlineLeafB of
+                        {loops, repeat, ...} =>
+                           inlineLeafB :=
+                           {loops = loops, repeat = repeat,
+                            size = (if s = "inf"
+                                       then NONE
+                                    else if String.forall (s, Char.isDigit)
+                                       then Int.fromString s
+                                    else (usage o concat)
+                                         ["invalid -inline-leaf-size flag: ", s])})),
+       (Expert, "inline-nonrec-product", " <n>", "set inlining threshold (320)", 
+        Int (fn product => 
+             case !inlineNonRec of
+                {small, ...} =>
+                   inlineNonRec := {small = small, product = product})),
+       (Expert, "inline-nonrec-small", " <n>", "set inlining threshold (60)", 
+        Int (fn small => 
+             case !inlineNonRec of
+                {product, ...} =>
+                   inlineNonRec := {small = small, product = product})),
        (Normal, "keep", " {g|o|sml}", "save intermediate files",
         SpaceString (fn s =>
                      case s of
@@ -439,6 +486,30 @@
         SpaceString (fn s => output := SOME s)),
        (Expert, "polyvariance", " {true|false}", "use polyvariance",
         Bool (fn b => if b then () else polyvariance := NONE)),
+       (Expert, "polyvariance-product", " <n>", "set polyvariance threshold (300)",
+        Int (fn product => 
+             case !polyvariance of
+                SOME {rounds, small, ...} =>
+                   polyvariance := SOME {product = product,
+                                         rounds = rounds,
+                                         small = small}
+              | _ => ())),
+       (Expert, "polyvariance-rounds", " <n>", "set polyvariance rounds (2)",
+        Int (fn rounds => 
+             case !polyvariance of
+                SOME {product, small, ...} =>
+                   polyvariance := SOME {product = product,
+                                         rounds = rounds,
+                                         small = small}
+              | _ => ())),
+       (Expert, "polyvariance-small", " <n>", "set polyvariance threshold (30)",
+        Int (fn small => 
+             case !polyvariance of
+                SOME {product, rounds, ...} =>
+                   polyvariance := SOME {product = product,
+                                         rounds = rounds,
+                                         small = small}
+              | _ => ())),
        (Expert, "prefer-abs-paths", " {false|true}",
         "prefer absolute paths when referring to files",
         boolRef preferAbsPaths),

Modified: mlton/trunk/mlton/ssa/inline.fun
===================================================================
--- mlton/trunk/mlton/ssa/inline.fun	2007-08-08 17:25:24 UTC (rev 5835)
+++ mlton/trunk/mlton/ssa/inline.fun	2007-08-08 23:40:56 UTC (rev 5836)
@@ -548,36 +548,17 @@
       program
    end
 
-fun inlineLeafOnce (p, {size}) =
+fun inlineLeaf (p, {loops, repeat, size}) =
    if size = SOME 0
       then p
    else transform {program = p,
-                   shouldInline = leafOnce (p, {size = size}),
+                   shouldInline = 
+                   case (loops, repeat) of
+                      (false, false) => leafOnce (p, {size = size})
+                    | (false, true) => leafRepeat (p, {size = size})
+                    | (true, false) => leafOnceNoLoop (p, {size = size})
+                    | (true, true) => leafRepeatNoLoop (p, {size = size}),
                    inlineIntoMain = true}
-fun inlineLeafOnceNoLoop (p, {size}) =
-   if size = SOME 0
-      then p
-   else transform {program = p,
-                   shouldInline = leafOnceNoLoop (p, {size = size}),
-                   inlineIntoMain = true}
-fun inlineLeafRepeat (p, {size}) =
-   if size = SOME 0
-      then p
-   else transform {program = p,
-                   shouldInline = leafRepeat (p, {size = size}),
-                   inlineIntoMain = true}
-fun inlineLeafRepeatNoLoop (p, {size}) =
-   if size = SOME 0
-      then p
-   else transform {program = p,
-                   shouldInline = leafRepeatNoLoop (p, {size = size}),
-                   inlineIntoMain = true}
-fun inlineLeaf (p, {loops, repeat, size}) =
-   case (loops, repeat) of
-      (false, false) => inlineLeafOnce (p, {size = size})
-    | (false, true) => inlineLeafRepeat (p, {size = size})
-    | (true, false) => inlineLeafOnceNoLoop (p, {size = size})
-    | (true, true) => inlineLeafRepeatNoLoop (p, {size = size})
 fun inlineNonRecursive (p, arg) =
    transform {program = p,
               shouldInline = nonRecursive (p, arg),

Modified: mlton/trunk/mlton/ssa/inline.sig
===================================================================
--- mlton/trunk/mlton/ssa/inline.sig	2007-08-08 17:25:24 UTC (rev 5835)
+++ mlton/trunk/mlton/ssa/inline.sig	2007-08-08 23:40:56 UTC (rev 5836)
@@ -19,10 +19,6 @@
 
       val inlineLeaf: 
          Program.t * {loops: bool, repeat: bool, size: int option} -> Program.t
-      val inlineLeafOnce: Program.t * {size:int option} -> Program.t
-      val inlineLeafOnceNoLoop: Program.t * {size:int option} -> Program.t
-      val inlineLeafRepeat: Program.t * {size:int option} -> Program.t
-      val inlineLeafRepeatNoLoop: Program.t * {size:int option} -> Program.t
-         
-      val inlineNonRecursive: Program.t * {small:int,product:int} -> Program.t
+      val inlineNonRecursive: 
+         Program.t * {small:int,product:int} -> Program.t
    end

Modified: mlton/trunk/mlton/ssa/simplify.fun
===================================================================
--- mlton/trunk/mlton/ssa/simplify.fun	2007-08-08 17:25:24 UTC (rev 5835)
+++ mlton/trunk/mlton/ssa/simplify.fun	2007-08-08 23:40:56 UTC (rev 5836)
@@ -36,10 +36,12 @@
 
 val ssaPassesDefault =
    {name = "removeUnused1", doit = RemoveUnused.remove} ::
-   {name = "inlineLeaf", doit = fn p => 
-    Inline.inlineLeaf (p, {loops = !Control.inlineLeafLoops,
-                           repeat = !Control.inlineLeafRepeat,
-                           size = !Control.inlineLeafSize})} ::
+   {name = "introduceLoops1", doit = IntroduceLoops.introduceLoops} ::
+   {name = "loopInvariant1", doit = LoopInvariant.loopInvariant} ::
+   {name = "inlineLeaf1", doit = fn p => 
+    Inline.inlineLeaf (p, !Control.inlineLeafA)} ::
+   {name = "inlineLeaf2", doit = fn p => 
+    Inline.inlineLeaf (p, !Control.inlineLeafB)} ::
    {name = "contify1", doit = Contify.contify} ::
    {name = "localFlatten1", doit = LocalFlatten.flatten} ::
    {name = "constantPropagation", doit = ConstantPropagation.simplify} ::
@@ -57,12 +59,12 @@
    {name = "polyEqual", doit = PolyEqual.polyEqual} ::
    {name = "contify2", doit = Contify.contify} ::
    {name = "inlineNonRecursive", doit = fn p =>
-    Inline.inlineNonRecursive (p, {small = !Control.inline, product = 320})} ::
+    Inline.inlineNonRecursive (p, !Control.inlineNonRec)} ::
    {name = "localFlatten2", doit = LocalFlatten.flatten} ::
    {name = "removeUnused3", doit = RemoveUnused.remove} ::
    {name = "contify3", doit = Contify.contify} ::
-   {name = "introduceLoops", doit = IntroduceLoops.introduceLoops} ::
-   {name = "loopInvariant", doit = LoopInvariant.loopInvariant} ::
+   {name = "introduceLoops2", doit = IntroduceLoops.introduceLoops} ::
+   {name = "loopInvariant2", doit = LoopInvariant.loopInvariant} ::
    {name = "localRef", doit = LocalRef.eliminate} ::
    {name = "flatten", doit = Flatten.flatten} ::
    {name = "localFlatten3", doit = LocalFlatten.flatten} ::
@@ -98,6 +100,7 @@
 
    val inlinePassGen =
       let
+         datatype t = Bool of bool | IntOpt of int option
          val count = Counter.new 1
          fun nums s =
             Exn.withEscape
@@ -112,11 +115,15 @@
                         then let
                                 val s = String.substring2 (s, {start = 1, finish = l - 1})
                                 fun doit s =
-                                   if s = "inf"
-                                      then NONE
+                                   if s = "true"
+                                      then Bool true
+                                   else if s = "false"
+                                      then Bool false
+                                   else if s = "inf"
+                                      then IntOpt NONE
                                    else if String.forall (s, Char.isDigit)
-                                           then Int.fromString s
-                                        else escape NONE
+                                      then IntOpt (Int.fromString s)
+                                   else escape NONE
                              in
                                 case List.map (String.split (s, #","), doit) of
                                    l as _::_ => SOME l
@@ -139,74 +146,28 @@
                     val s = String.dropPrefix (s, String.size "inlineNonRecursive")
                  in
                     case nums s of
-                       SOME [] => mk (320, 60)
-                     | SOME [SOME product, SOME small] => mk (product, small)
+                       SOME [IntOpt (SOME product), IntOpt (SOME small)] => 
+                          mk (product, small)
                      | _ => NONE
                  end
-         else if String.hasPrefix (s, {prefix = "inlineLeafRepeat"})
+         else if String.hasPrefix (s, {prefix = "inlineLeaf"})
             then let
-                    fun mk size =
+                    fun mk (loops, repeat, size) =
                        SOME {name = concat ["inlineLeafRepeat(", 
+                                            Bool.toString loops, ",",
+                                            Bool.toString repeat, ",",
                                             Option.toString Int.toString size, ")#",
                                             Int.toString (Counter.next count)],
                              doit = (fn p => 
-                                     Inline.inlineLeafRepeat
-                                     (p, {size = size}))}
-                    val s = String.dropPrefix (s, String.size "inlineLeafRepeat")
+                                     Inline.inlineLeaf
+                                     (p, {loops = loops, repeat = repeat, size = size}))}
+                    val s = String.dropPrefix (s, String.size "inlineLeaf")
                  in
                     case nums s of
-                       SOME [] => mk (SOME 20)
-                     | SOME [size] => mk size
+                       SOME [Bool loops, Bool repeat, IntOpt size] => 
+                          mk (loops, repeat, size)
                      | _ => NONE
                  end
-         else if String.hasPrefix (s, {prefix = "inlineLeafRepeatNoLoop"})
-            then let
-                    fun mk size =
-                       SOME {name = concat ["inlineLeafRepeatNoLoop(", 
-                                            Option.toString Int.toString size, ")#",
-                                            Int.toString (Counter.next count)],
-                             doit = (fn p => 
-                                     Inline.inlineLeafRepeatNoLoop
-                                     (p, {size = size}))}
-                    val s = String.dropPrefix (s, String.size "inlineLeafRepeatNoLoop")
-                 in
-                    case nums s of
-                       SOME [] => mk (SOME 20)
-                     | SOME [size] => mk size
-                     | _ => NONE
-                 end
-         else if String.hasPrefix (s, {prefix = "inlineLeafOnceNoLoop"})
-            then let
-                    fun mk size =
-                       SOME {name = concat ["inlineLeafOnceNoLoop(", 
-                                            Option.toString Int.toString size, ")#",
-                                            Int.toString (Counter.next count)],
-                             doit = (fn p => 
-                                     Inline.inlineLeafOnceNoLoop 
-                                     (p, {size = size}))}
-                    val s = String.dropPrefix (s, String.size "inlineLeafOnceNoLoop")
-                 in
-                    case nums s of
-                       SOME [] => mk (SOME 20)
-                     | SOME [size] => mk size
-                     | _ => NONE
-                 end
-         else if String.hasPrefix (s, {prefix = "inlineLeafOnce"})
-            then let
-                    fun mk size =
-                       SOME {name = concat ["inlineLeafOnce(", 
-                                            Option.toString Int.toString size, ")#",
-                                            Int.toString (Counter.next count)],
-                             doit = (fn p => 
-                                     Inline.inlineLeafOnce
-                                     (p, {size = size}))}
-                    val s = String.dropPrefix (s, String.size "inlineLeafOnce")
-                 in
-                    case nums s of
-                       SOME [] => mk (SOME 20)
-                     | SOME [size] => mk size
-                     | _ => NONE
-                 end
          else NONE
       end
 




More information about the MLton-commit mailing list