Re: Indirect threading other than GCC? (Anton Ertl)
9 Dec 2001 21:55:46 -0500

          From comp.compilers

Related articles
Indirect threading other than GCC? (Heng Yuan) (2001-12-08)
Re: Indirect threading other than GCC? (2001-12-09)
Re: Indirect threading other than GCC? (Nicholas Geovanis) (2001-12-11)
Re: Indirect threading other than GCC? (2001-12-15)
| List of all articles for this month |

From: (Anton Ertl)
Newsgroups: comp.compilers
Date: 9 Dec 2001 21:55:46 -0500
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
References: 01-12-034
Keywords: C, optimize
Posted-Date: 09 Dec 2001 21:55:46 EST

  Heng Yuan <> writes:
[indirect threaded code]
>Also, how much faster does it improve upon switch threading? Assume
>that the cases are all consecutive integers starting from 1. The
>number of cases can be from several to hundreds.

Results for a micro-benchmark are available at
<>, but I would not
trust the results on CPUs with BTBs (the microbenchmark has
unrealistic prediction accuracy).

Results for real interpreters simulated on SimpleScalar with various
branch prediction schemes can be seen on
<>. There
is no direct comparison of indirect threaded code to switch dispatch
there, but the slowdown of indirect threaded code over direct threaded
code is less than 20% for Gforth (depending on the machine); my guess
is that it would be in the same area for Ocaml and somewhat less for
Yap. Anyway, the results for SimpleScalar with a mispredict penalty
of 4 cycles, for currently available branch predictors, are that
switch dispatch costs 4.1-6.6 cycles more than direct threaded code,
resulting in a slowdown factor of up to 2.02.

Another comparison is available at
<>. Gforth uses
direct threaded threaded code (with indirect threaded code less than
10% slower on that machine), whereas thisForth uses switch dispatch
and is 3-4 times slower; however, thisForth contains other
inefficiencies besides switch dispatch, so this result is only useful
as an upper bound on the speed difference.

- anton
M. Anton Ertl

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.