From: "Török Edwin" <edwintorok@gmail.com>
To: "Jon Harrop" <jon@ffconsultancy.com>
Cc: <caml-list@inria.fr>
Subject: Re: Value types (Was: [Caml-list] ocamlopt LLVM support)
Date: Sun, 12 Dec 2010 20:22:17 +0200 [thread overview]
Message-ID: <20101212202217.4ee72dc3@deb0> (raw)
In-Reply-To: <039301cb9a26$9214c2e0$b63e48a0$@com>
On Sun, 12 Dec 2010 18:01:13 -0000
"Jon Harrop" <jon@ffconsultancy.com> wrote:
> Török Edwin wrote:
> > Do you really need to use Int64 for that though? Won't the 63-bit
> > version do?
>
> I'm running 32-bit.
That explains it, in a 32-bit chroot my modified version is still slow.
I thought that 32-bit systems are not that relevant anymore (except for
Windows, but then people start moving to 64-bit there also).
>
> > > I am unable to reproduce your results. Here, the time falls from
> > > 24s to 19.5s (using ocamlopt 3.12.0 on Intel x86) which is still
> > > 26× slower than HLVM.
>
> Sorry, I'm actually using an Opteron x86 (logged in from an Intel
> x86!).
>
> > Do you still have 'idiv' in the compiled code? See my attached
> > assembly, and compare it with yours please.
> > I was doing the test on 64-bit, with ocamlopt 3.11.2 and 3.12.0.
>
> I get what appear to be calls to C code:
>
> camlCollatz__collatzLen_1030:
> subl $8, %esp
> .L103:
> movl %eax, 4(%esp)
> movl %ebx, 0(%esp)
> pushl $camlCollatz__10
> pushl %ebx
> movl $caml_equal, %eax
> call caml_c_call
Yes, that is quite bad. I don't know how OCaml's code generator works,
but it looks like it calls the C implementation if the CPU doesn't
support the operation directly. And since this is 32-bit you need all
the extra pushes and movs to do actually call something.
If only it could inline those calls, then it could optimize away most
of the overhead (LLVM would help here again).
>
> > FWIW the original code took 2.8 seconds here, so only 4x slower
> > (this is an AMD Phenom II x6 1090T CPU). It probably depends how
> > fast/slow the 'idiv' is on your CPU.
>
> The performance of idiv is irrelevant here. The bottleneck may be
> those C calls but I don't understand why they are being generated.
I think for the same reason gcc has __udivdi3 in libgcc: there is no
direct way of executing a 64-bit divide on a 32-bit machine, and it
saves code space to do it in a function.
However that doesn't make much sense for mul and add, which don't need
that many instructions to implement on 32-bit.
>
> Cheers,
> Jon.
>
>
next prev parent reply other threads:[~2010-12-12 18:22 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-12 14:54 Jon Harrop
2010-12-12 15:55 ` Török Edwin
2010-12-12 17:14 ` Jon Harrop
2010-12-12 17:26 ` Török Edwin
2010-12-12 18:01 ` Jon Harrop
2010-12-12 18:22 ` Török Edwin [this message]
2010-12-12 19:09 ` Benedikt Meurer
2010-12-12 19:20 ` John Carr
2010-12-14 9:43 ` Value types Goswin von Brederlow
2010-12-12 19:55 ` Value types (Was: [Caml-list] ocamlopt LLVM support) Török Edwin
2010-12-12 22:05 ` Jon Harrop
2010-12-12 22:27 ` Török Edwin
2010-12-12 23:41 ` Jon Harrop
2010-12-13 2:13 ` Eray Ozkural
2010-12-12 21:50 ` Jon Harrop
2010-12-13 8:43 ` Alain Frisch
2010-12-15 10:29 ` Benedikt Meurer
2010-12-15 13:15 ` Jon Harrop
2010-12-14 9:54 ` Value types Goswin von Brederlow
2010-12-12 19:53 ` Value types (Was: [Caml-list] ocamlopt LLVM support) Brian Hurt
2010-12-12 20:39 ` Jon Harrop
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=20101212202217.4ee72dc3@deb0 \
--to=edwintorok@gmail.com \
--cc=caml-list@inria.fr \
--cc=jon@ffconsultancy.com \
/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