Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Re: profiles of gcc available
@ 1996-11-12 22:51 Toon Moene
  1996-11-13  4:48 ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Toon Moene @ 1996-11-12 22:51 UTC (permalink / raw)


Thanks, Jim

However, all this information rather overwhelms me - perhaps we can  
simplify things a bit.  A compiler is (roughly) some program that  
reads a text file (i.e. a stream of bytes), transforms that to an  
intermediate representation (tree structure, in gcc's case),  
manipulates that tree of structures (optimisation passes) and writes  
the assembler output (again a stream of bytes).  Now neither bytes,  
nor the members of the various structures used in gcc internally,  
are necessarily long- or quadwords (i.e. 32 or 64 bit quantities).   
Combine that with the knowledge that not many ALPHA implementations  
support the byte/word extension (BWX) that allows direct word and  
byte load/store, and you'll arrive at the conclusion that the ALPHA  
chips are not well suited for compilation in the way gcc (and most  
compilers) do it.  I must add to this that every day I am more and  
more amazed at the compile speeds that I get using *Digital* Fortran  
on our 21064's ...

A simple example suffices - compile the following on your x86 box  
and on an ALPHA, say with -O2:

void copy(char *s, char *d)
{
        while (*d++ = *s++)
                ;
}

This code uses three instructions in the loop on my m68k machine -  
including the jump (which is one more than necessary).  I would be  
surprised if the number of instructions on an ALPHA would be less  
than ten.  On the granddaddy of supercomputers, the Cray Y-MP, it  
takes over 80 instructions.

Cheers,
Toon.

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: profiles of gcc available
@ 1996-11-13 22:40 Przemek Klosowski
  0 siblings, 0 replies; 5+ messages in thread
From: Przemek Klosowski @ 1996-11-13 22:40 UTC (permalink / raw)


A simple example suffices - compile the following on your x86 box  
   and on an ALPHA, say with -O2:

   void copy(char *s, char *d)
   {
	   while (*d++ = *s++)
		   ;
   }

   This code uses three instructions in the loop on my m68k machine -  
   including the jump (which is one more than necessary).  I would be  
   surprised if the number of instructions on an ALPHA would be less  
   than ten.  On the granddaddy of supercomputers, the Cray Y-MP, it  
   takes over 80 instructions.

That is an interesting exercise in watching compiler microoptimization.
On Intel, gcc 2.7.2 -O2, this is translated to
.L7:
        movb (%ecx),%al
        movb %al,(%edx)
        incl %ecx
        incl %edx
        testb %al,%al
        jne .L7

Since there is no autoincrement mode on Intel, the increments have to be there.
I don't know enough of Intel assembly language to tell if it can be improved upon.

BTW, gcc without optimization does a jump to a jump at the end of the loop; the
rest of the code is identical.

On Alpha/Linux, using the same version of gcc, the above code is
$34:
        ldq_u $3,0($16)
        ldq_u $2,0($17)
        extbl $3,$16,$3
        mskbl $2,$17,$2
        insbl $3,$17,$1
        addq $16,1,$16
        bis $1,$2,$1
        stq_u $1,0($17)
        addq $17,1,$17
        bne $3,$34

while on Alpha/Digital using DEC cc:

 #    3         while (*d++ = *s++)
        .set     noat
        lda     $28, 1($16)
        ldq_u   $0, 0($16)
        extqh   $0, $28, $0
        sra     $0, 56, $0
        .set     at
        .set     noat
        ldq_u   $28, 0($17)
        insbl   $0, $17, $1
        mskbl   $28, $17, $28
        bis     $28, $1, $28
        stq_u   $28, 0($17)
        .set     at
        addq    $17, 1, $17
        addq    $16, 1, $16
        beq     $0, $33
        .align  3
$32:
        .loc    2 4
 #    4                 ;
        .set     noat
        lda     $28, 1($16)
        ldq_u   $0, 0($16)
        extqh   $0, $28, $0
        sra     $0, 56, $0
        .set     at
        .set     noat
        ldq_u   $28, 0($17)
        insbl   $0, $17, $2
        mskbl   $28, $17, $28
        bis     $28, $2, $28
        stq_u   $28, 0($17)
        .set     at
        addq    $17, 1, $17
        addq    $16, 1, $16
        bne     $0, $32
        .loc    2 5
 #    5 }
$33:

Funny, the DEC version doesn't strike me as faster, even if it fills
latencies/scheduling better (I haven't timed it, though).

	p

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 5+ messages in thread
* Re: profiles of gcc available
@ 1996-11-13 16:41 Toon Moene
  0 siblings, 0 replies; 5+ messages in thread
From: Toon Moene @ 1996-11-13 16:41 UTC (permalink / raw)


>  The thing is, see, is gcc really doesn't spend that much
>  time playing with the bytes.  According to Jim's profiles,
>  4.5% of the time is spent playing with incoming bytes
>  (yylex); after that we always play with tokens (ints).
>  Unfortunately there is no single output function making
>  it hard to say exactly how much time is spent that way,
>  but I don't think I'm off in saying it isn't much.

Agree with that - I didn't realise this would put yylex on top of  
the list if byte manipulations were the real problem; my language of  
choice predates automatic lexers by two decades, and I didn't  
really kept up with the field after the card readers were scrapped  
around here :-)

>> Now neither bytes,
>> nor the members of the various structures used in gcc internally,  
>> are necessarily long- or quadwords (i.e. 32 or 64 bit quantities).   

>  I suppose they needn't have been but they are.  Virtually
>  everything done inside of gcc once things are parsed are
>  with pointers and longs.

Well, I don't mean to argue this to death, but in _my_ copy of gcc,  
the first two fields in the RTX structure are 16 and 8 bits wide,  
followed by 7 one bit flags.

>  No, the thing to do to make gcc faster is not to worry
>  about the I/O, but to improve the algorithms used in the
>  optimization phases.

Sure, but I hoped to pinpoint a *common* cause for the difference  
between gcc on the Alpha and on the i386, given that Jim's  
experiment shows that no *single* routine is responsible.

Cheers,
Toon.

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 5+ messages in thread
* profiles of gcc available
@ 1996-11-12 13:36 Jim Nance
  0 siblings, 0 replies; 5+ messages in thread
From: Jim Nance @ 1996-11-12 13:36 UTC (permalink / raw)


Hi all,
    Yesterday there were some posts about the poor compile times
of gcc runing on the Alpha.  I have compiled the linux kernel with
gprof'ed gcc, and I have the results tabulated at the URL:

http://sailboat.acs.uncwil.edu/~jlnance/gcc/gcc.html

I really don't know enough about how gcc works to interpret these profiles,
other than to say that nothing is obviously broken.  If some gcc guru
would like to take a look at them, and grace the list with some wisdom,
I would appreciate it.

Thanks,

Jim

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1996-11-13 22:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-11-12 22:51 profiles of gcc available Toon Moene
1996-11-13  4:48 ` Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
1996-11-13 22:40 Przemek Klosowski
1996-11-13 16:41 Toon Moene
1996-11-12 13:36 Jim Nance

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox