Re: camltk with native code compiler ocamlopt?

From: Thorsten Ohl (ohl@crunch.ikp.physik.th-darmstadt.de)
Date: Mon Jun 16 1997 - 17:00:44 MET DST


Date: Mon, 16 Jun 1997 17:00:44 +0200
Message-Id: <9706161500.AA22140@crunch>
From: Thorsten Ohl <ohl@crunch.ikp.physik.th-darmstadt.de>
To: Wolfram Kahl <kahl@diogenes.informatik.unibw-muenchen.de>
Subject: Re: camltk with native code compiler ocamlopt?
In-Reply-To: <19970613082536.24606.qmail@diogenes.informatik.unibw-muenchen.de>
        <19970613082536.24606.qmail@diogenes.informatik.unibw-muenchen.de>

Wolfram Kahl <kahl@diogenes.informatik.unibw-muenchen.de> wrote:

> I have a done this for 1.02 and it works perfectly;
> for my application the speed doubles.
> For 1.04 a few things had to be changed [...]
> I haven't tried 1.5 yet.

Your patch didn't work for me for 1.05. But it gave me enough
encouragement to try the exercise myself :-). I wound up with a
factor of four in speed.

> IMPORTANT: In order to compile tk.ml; at least on the SUN Sparc,
> it is necessary to change all occurrences of 10000 in asmcomp/emit_*.mlp
> for your machine to say 20000 before making the optimising compiler

I didn't have to make this change for Intel/Linux.

Here is the patch. I haven't really cleaned it up, but it does the
job.

Enjoy,
-Thorsten

diff -rc camltk41.orig/Makefile camltk41/Makefile
*** camltk41.orig/Makefile Sun Dec 1 12:31:40 1996
--- camltk41/Makefile Sat Jun 14 00:52:36 1997
***************
*** 1,6 ****
  include Makefile.config
  
! SUBDIRS=compiler support lib frx jtk safe jpf tkanim
  
  
  Makefile.config:
--- 1,6 ----
  include Makefile.config
  
! SUBDIRS=compiler support lib frx jtk safe jpf # tkanim
  
  
  Makefile.config:
***************
*** 15,23 ****
          cd jtk; $(MAKE)
  # cd threads; $(MAKE)
          cd jpf; $(MAKE)
! cd tkanim; $(MAKE)
          cd safe; $(MAKE)
  
  lib: Widgets.src
          compiler/tkcompiler
          cd lib; $(MAKE)
--- 15,29 ----
          cd jtk; $(MAKE)
  # cd threads; $(MAKE)
          cd jpf; $(MAKE)
! # cd tkanim; $(MAKE)
          cd safe; $(MAKE)
  
+ opt: Makefile.config
+ cd support; $(MAKE) opt
+ cd lib; $(MAKE) -f Makefile.gen; $(MAKE) opt
+ cd frx; $(MAKE) opt
+ cd jpf; $(MAKE) opt
+
  lib: Widgets.src
          compiler/tkcompiler
          cd lib; $(MAKE)
***************
*** 31,38 ****
          cd frx; $(MAKE) install
          cd jpf; $(MAKE) install
          cd jtk; $(MAKE) install
! cd tkanim; $(MAKE) install
          cd safe; $(MAKE) install
  
  clean :
          -rm -f config.cache
--- 37,50 ----
          cd frx; $(MAKE) install
          cd jpf; $(MAKE) install
          cd jtk; $(MAKE) install
! # cd tkanim; $(MAKE) install
          cd safe; $(MAKE) install
+
+ installopt:
+ [ -d $(INSTALLDIR) ] || mkdir $(INSTALLDIR)
+ cd lib; $(MAKE) installopt
+ cd frx; $(MAKE) installopt
+ cd jpf; $(MAKE) installopt
  
  clean :
          -rm -f config.cache
diff -rc camltk41.orig/Makefile.config.in camltk41/Makefile.config.in
*** camltk41.orig/Makefile.config.in Mon Dec 2 14:14:09 1996
--- camltk41/Makefile.config.in Sat Jun 14 00:23:18 1997
***************
*** 30,33 ****
--- 30,36 ----
  COMPFLAGS=
  LINKFLAGS=
  
+ CAMLOPT=ocamlopt
+ CAMLOPTLIBR=$(CAMLOPT) -a
+
  ## End of configuration section
diff -rc camltk41.orig/frx/Makefile camltk41/frx/Makefile
*** camltk41.orig/frx/Makefile Mon Oct 28 10:42:25 1996
--- camltk41/frx/Makefile Sat Jun 14 00:31:00 1997
***************
*** 7,31 ****
        frx_dialog.cmo frx_mem.cmo frx_rpc.cmo frx_synth.cmo frx_selection.cmo \
        frx_after.cmo frx_fit.cmo frx_ctext.cmo frx_color.cmo
  
  all: libfrx.cma
  
  libfrx.cma: $(OBJS)
          $(CAMLLIBR) -o libfrx.cma $(OBJS)
  
  install: libfrx.cma
          cp *.cmi *.mli libfrx.cma $(INSTALLDIR)
  
  clean:
          rm -f *.cm*
  
  .SUFFIXES :
! .SUFFIXES : .mli .ml .cmi .cmo
  
  .mli.cmi:
          $(CAMLCOMP) $(COMPFLAGS) $<
  
  .ml.cmo:
          $(CAMLCOMP) $(COMPFLAGS) $<
  
  
  depend:
--- 7,44 ----
        frx_dialog.cmo frx_mem.cmo frx_rpc.cmo frx_synth.cmo frx_selection.cmo \
        frx_after.cmo frx_fit.cmo frx_ctext.cmo frx_color.cmo
  
+ OBJSX = $(OBJS:.cmo=.cmx)
+
  all: libfrx.cma
  
+ opt: libfrx.cmxa
+
  libfrx.cma: $(OBJS)
          $(CAMLLIBR) -o libfrx.cma $(OBJS)
  
+ libfrx.cmxa: $(OBJSX)
+ $(CAMLOPTLIBR) -o libfrx.cmxa $(OBJSX)
+
  install: libfrx.cma
          cp *.cmi *.mli libfrx.cma $(INSTALLDIR)
  
+ installopt: libfrx.cmxa
+ cp libfrx.cmxa libfrx.a $(INSTALLDIR)
+
  clean:
          rm -f *.cm*
  
  .SUFFIXES :
! .SUFFIXES : .mli .ml .cmi .cmx .cmo
  
  .mli.cmi:
          $(CAMLCOMP) $(COMPFLAGS) $<
  
  .ml.cmo:
          $(CAMLCOMP) $(COMPFLAGS) $<
+
+ .ml.cmx:
+ $(CAMLOPT) -c $(COMPFLAGS) $<
  
  
  depend:
diff -rc camltk41.orig/jpf/Makefile camltk41/jpf/Makefile
*** camltk41.orig/jpf/Makefile Fri Nov 29 16:11:38 1996
--- camltk41/jpf/Makefile Sat Jun 14 00:49:47 1997
***************
*** 4,23 ****
--- 4,35 ----
  
  OBJS= fileselect.cmo balloon.cmo
  
+ OBJSX = $(OBJS:.cmo=.cmx)
+
  TKLINKOPT=$(STATIC) \
            -ccopt -L../support -cclib -lcamltk41 \
            $(TKLIBS) $(X11_LIBS)
  
  all: libjpf.cma
  
+ opt: libjpf.cmxa
+
  test: balloontest
  
+ testopt: balloontest.opt
+
  libjpf.cma: $(OBJS)
          $(CAMLLIBR) -o libjpf.cma $(OBJS)
  
+ libjpf.cmxa: $(OBJSX)
+ $(CAMLOPTLIBR) -o libjpf.cmxa $(OBJSX)
+
  install: libjpf.cma
          cp *.cmi *.mli libjpf.cma $(INSTALLDIR)
  
+ installopt: libjpf.cmxa
+ cp libjpf.cmxa libjpf.a $(INSTALLDIR)
+
  clean:
          rm -f *.cm* *~ *test
  
***************
*** 27,42 ****
          $(CAMLC) -o balloontest -I ../support -I ../lib \
                  -custom tk41.cma libjpf.cma balloontest.cmo $(TKLINKOPT)
  
  balloontest.cmo : balloon.cmo libjpf.cma
  
  .SUFFIXES :
! .SUFFIXES : .mli .ml .cmi .cmo
  
  .mli.cmi:
          $(CAMLCOMP) $(COMPFLAGS) $<
  
  .ml.cmo:
          $(CAMLCOMP) $(COMPFLAGS) $<
  
  
  depend:
--- 39,63 ----
          $(CAMLC) -o balloontest -I ../support -I ../lib \
                  -custom tk41.cma libjpf.cma balloontest.cmo $(TKLINKOPT)
  
+ balloontest.opt: balloontest.cmx
+ $(CAMLOPT) -o balloontest.opt -I ../support -I ../lib \
+ tk41.cmxa libjpf.cmxa balloontest.cmx $(TKLINKOPT)
+
  balloontest.cmo : balloon.cmo libjpf.cma
  
+ balloontest.cmx : balloon.cmx libjpf.cmxa
+
  .SUFFIXES :
! .SUFFIXES : .mli .ml .cmi .cmx .cmo
  
  .mli.cmi:
          $(CAMLCOMP) $(COMPFLAGS) $<
  
  .ml.cmo:
          $(CAMLCOMP) $(COMPFLAGS) $<
+
+ .ml.cmx:
+ $(CAMLOPT) -c $(COMPFLAGS) $<
  
  
  depend:
diff -rc camltk41.orig/lib/Makefile camltk41/lib/Makefile
*** camltk41.orig/lib/Makefile Fri Nov 29 16:11:41 1996
--- camltk41/lib/Makefile Sat Jun 14 00:28:22 1997
***************
*** 12,24 ****
--- 12,32 ----
          ../support/textvariable.cmo ../support/timer.cmo \
          ../support/fileevent.cmo
  
+ SUPPORTX = $(SUPPORT:.cmo=.cmx)
+
  all : tk41.cma ocamltktop
  
+ opt : tk41.cmxa
+
  include ./modules
+ WIDGETOBJSX = $(WIDGETOBJS:.cmo=.cmx)
  
  tk41.cma : $(SUPPORT) $(WIDGETOBJS) tk.cmo
          $(CAMLLIBR) -o tk41.cma $(SUPPORT) tk.cmo $(WIDGETOBJS)
  
+ tk41.cmxa : $(SUPPORTX) $(WIDGETOBJSX) tk.cmx
+ $(CAMLOPTLIBR) -o tk41.cmxa $(SUPPORTX) tk.cmx $(WIDGETOBJSX)
+
  ## Until ocamltktop is fixed (next release), we in-line it
  ## (otherwise our trick with -ccopt is broken)
  
***************
*** 38,51 ****
          chmod 644 $(INSTALLDIR)/tk41.cma
          chmod 755 $(INSTALLDIR)/ocamltktop
  
  
  .SUFFIXES :
! .SUFFIXES : .mli .ml .cmi .cmo .mlp
  
  .mli.cmi:
          $(CAMLCOMP) $(COMPFLAGS) $<
  
  .ml.cmo:
          $(CAMLCOMP) $(COMPFLAGS) $<
  
  include .depend
--- 46,68 ----
          chmod 644 $(INSTALLDIR)/tk41.cma
          chmod 755 $(INSTALLDIR)/ocamltktop
  
+ installopt: tk41.cmxa
+ if test -d $(INSTALLDIR); then : ; else mkdir $(INSTALLDIR); fi
+ cp tk41.cmxa tk41.a $(INSTALLDIR)
+ chmod 644 $(INSTALLDIR)/tk41.cmxa
+ chmod 644 $(INSTALLDIR)/tk41.a
+
  
  .SUFFIXES :
! .SUFFIXES : .mli .ml .cmi .cmo .cmx .mlp
  
  .mli.cmi:
          $(CAMLCOMP) $(COMPFLAGS) $<
  
  .ml.cmo:
          $(CAMLCOMP) $(COMPFLAGS) $<
+
+ .ml.cmx:
+ $(CAMLOPT) -c $(COMPFLAGS) $<
  
  include .depend
diff -rc camltk41.orig/support/Makefile camltk41/support/Makefile
*** camltk41.orig/support/Makefile Mon Dec 2 16:00:15 1996
--- camltk41/support/Makefile Sat Jun 14 00:20:03 1997
***************
*** 4,9 ****
--- 4,13 ----
       textvariable.cmo timer.cmo fileevent.cmo \
       libcamltk41.a
  
+ opt: hashtblc.cmx support.cmx widget.cmx protocol.cmx \
+ textvariable.cmx timer.cmx fileevent.cmx \
+ libcamltk41.a
+
  COBJS=cltkCaml.o cltkEval.o cltkEvent.o cltkFile.o cltkMain.o \
        cltkMisc.o cltkTimer.o cltkVar.o cltkWait.o
  
***************
*** 31,37 ****
          rm -f *.cm* *.o *.a
  
  .SUFFIXES :
! .SUFFIXES : .mli .ml .cmi .cmo .mlp .c .o
  
  .mli.cmi:
          $(CAMLCOMP) $(COMPFLAGS) $<
--- 35,41 ----
          rm -f *.cm* *.o *.a
  
  .SUFFIXES :
! .SUFFIXES : .mli .ml .cmi .cmo .cmx .mlp .c .o
  
  .mli.cmi:
          $(CAMLCOMP) $(COMPFLAGS) $<
***************
*** 39,44 ****
--- 43,51 ----
  .ml.cmo:
          $(CAMLCOMP) $(COMPFLAGS) $<
  
+ .ml.cmx:
+ $(CAMLOPT) -c $(COMPFLAGS) $<
+
  .c.o:
          $(CAMLCOMP) $(CCFLAGS) $<
  
***************
*** 46,48 ****
--- 53,56 ----
          $(CAMLDEP) *.mli *.ml > .depend
  
  include .depend
+

-- 
Thorsten Ohl, Physics Department, TH Darmstadt --- PGP: AF 38 FF CE 03 8A 2E A7
http://crunch.ikp.physik.th-darmstadt.de/~ohl/ -------- 8F 2A C1 86 8C 06 32 6B



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:11 MET