Uri Guttman <[EMAIL PROTECTED]> writes:
>>>>>> "NI" == Nick Ing-Simmons <[EMAIL PROTECTED]> writes:
>
> NI> The "overhead of op dispatch" is a self-proving issue - if you
> NI> have complex ops they are expensive to dispatch.
>
>but as someone else said, we can design our own ops to be as high level
>as we want. lowering the number of op calls is the key. that loop will
>be a bottleneck as it is in perl5 unless we optimize it now.
>
> NI> With a 16-bit opcode as-per-Uri that becomes:
>
> NI> while (1) *(table[*op_ptr++])();
>
> NI> (Assuming we don't need to check bounds 'cos we won't generate bad code...)
>
>i dropped the 16 bit idea in favor of an extension byte code that zhong
>mentioned. it has several wins, no ordering issues, it is pure 'byte'
>code.
>
> NI> One can then start adding decode to the loop:
>
> NI> while (1) {
> NI> op_t op = *op_ptr++;
> NI> switch(NUM_ARGS(op))
>
>no switch, a simple lookup table:
>
> op_cnt = op_counts[ op ] ;
Myths of 21st Century Computing #1:
"Memory lookups are cheap"
Most processors only have only one memory unit and it typically has
a long pipeline delay. But many have several units that can do
compare etc.
A lookup table may or may-not be faster/denser than a switch.
A lookup may take 9 cycles down a memory pipe while
ans = (op > 16) ? 2 : (op > 8) ? 1 : 0;
might super-scalar issue in 1 cycle. Code at high level and let
C compiler know what is best. C will give you a lookup if that
is best.
Memory ops need not be expensive if they pipeline well, but
making one memory op depend on the result of another is bad idea
e.g.
op = *op_ptr++;
arg1 = *op_ptr++;
arg2 = *op_ptr++;
May apear to happen in 3 cycles, as all the loads can be issued in a pipelined
manner and ++s issued in parallel. While
op = *op_ptr++;
ans = table[op];
could take seem to 18 cycles as can't start 2nd load till 1st one completes.
I have been meaning to try and prove my point with
a software-pipelined dispatch loop which is fetching one op,
decoding previous one and executing one before that.
--
Nick Ing-Simmons
who is looking for a new job see http://www.ni-s.u-net.com/