caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Ian Oversby" <oversby@hotmail.com>
To: oandrieu@nerim.net
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Question on writing efficient Ocaml.
Date: Thu, 28 Dec 2006 16:03:55 +0000	[thread overview]
Message-ID: <BAY114-F26A1A24544A01523B4693CA9C70@phx.gbl> (raw)
In-Reply-To: <15946.213.30.139.86.1167315231.squirrel@webmail.nerim.net>

Hi Olivier,

Thanks for the response.

> > Hi,
>
> > I've written some Ocaml code to solve the problem of placing 8 queens on 
>a
> > board so that none of them attack each-other.  I've also written a C++
> > equivalent which is running much more quickly than the Ocaml.  I assume
> > I've
> > made some basic errors with the Ocaml - does anyone have any suggestions
> > as
> > to what?
>
>there is room for improvement: for instance the type definitions of posn
>and board at the very beginning of the program introduce some unneeded
>boxing of values.

Does this mean that unboxing is inefficient in OCaml?  I've written an 
alternative version of the C++ that returns NULL instead of out of bound 
values which was close to the same speed so it would be a little 
disappointing if I couldn't achieve something similar in OCaml with Some / 
None.  Let me try to convert the OCaml to use out of bounds board values 
instead to see if that solves the speed problem.

>You might want to compare with this solution of the queens problem in 
>ocaml:
>   http://caml.inria.fr/pub/old_caml_site/Examples/oc/basics/queens.ml

I've written a queens solver along the same lines which is much faster than 
my other example as it makes many fewer calls and constructs fewer (and 
simpler) boards.

> > I compiled the Ocaml with the following command:
> >
> > ocamlopt -noassert -unsafe -ccopt -O3 -ccopt -fomit-frame-pointer q.ml 
>-o
> > q.exe
>
>the "-ccopt -O3 -ccopt -fomit-frame-pointer" are completely pointless: the
>ocaml compiler does not generate C code, it generates asm !

Well, that is certainly good to know.  Thanks very much :)

>--
>   Olivier

Ian

_________________________________________________________________
MSN Hotmail is evolving – check out the new Windows Live Mail 
http://ideas.live.com


       reply	other threads:[~2006-12-28 16:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <15946.213.30.139.86.1167315231.squirrel@webmail.nerim.net>
2006-12-28 16:03 ` Ian Oversby [this message]
2006-12-28 17:00   ` Richard Jones
2006-12-28 22:23   ` Jon Harrop
2006-12-29  9:42     ` Ian Oversby
2006-12-28 11:42 Ian Oversby
2006-12-28 16:26 ` [Caml-list] " Jon Harrop
2006-12-28 17:13   ` skaller
2006-12-29  6:05     ` Jacques Garrigue
2006-12-29 11:15       ` Mattias Engdegård
2007-01-06  0:52         ` Nathaniel Gray
2007-01-06  1:01           ` Philippe Wang
2007-01-06  1:15           ` brogoff
2007-01-06  2:27             ` Martin Jambon
2007-01-08 22:23               ` Nathaniel Gray
2006-12-29  1:23 ` Andrej Bauer
2006-12-29  9:58   ` Ian Oversby
2006-12-29  2:07 ` Jon Harrop
2007-01-03 16:43   ` Serge Aleynikov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BAY114-F26A1A24544A01523B4693CA9C70@phx.gbl \
    --to=oversby@hotmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=oandrieu@nerim.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).