From: "Wes Bauske" <wsb@paralleldata.com>
To: axp-list@redhat.com
Subject: Re: XP1000 and Linux
Date: Mon, 22 Mar 1999 02:41:47 -0600 [thread overview]
Message-ID: <36F6024B.1C25B31C@paralleldata.com> (raw)
In-Reply-To: 36F5DA6B.9A846133@paralleldata.com
Wes Bauske wrote:
>
> Wes Bauske wrote:
> >
> >
> > I patched my gas with Richard's update. It does
> > accept wh64 opcodes now. I'll see about updating
> > the asm with it for the 8 way unrolled case. I
> > do have a comment about how gcc unrolls loops.
> > It may or may not be useful. In general, when I
> > hand code unrolled loops, what I thought was the
> > standard way to do this is apparently NOT how gcc
> > does it. The general form of unrolls I use in C:
> >
> > for(i=0; i < n-unroll+1; i+=unroll) {
> > a[i]=b[i];
> > .
> > .
> > .
> > a[i+unroll-1]=b[i+unroll-1];
> > }
> >
> > nleft=n%unroll;
> > if(nleft > 0)
> > for(i=n-nleft; i < n; i++) a[i]=b[i];
> >
> > It seems gcc inserts compares inside the main loop
> > to see when to leave it after each piece of the unroll
> > which seems like a waste of energy to me.
> >
> > Isn't the above form more efficient cpu-wise??
> > Seems so since it doesn't waste any cycles checking
> > when to quit in the loop you really care about.
> >
>
> An example of the main loop difference with the above
> technique vs what gcc generates:
>
> gcc:
>
> $L24:
> ldt $f1,0($2)
> addl $9,1,$9
> cmple $9,$4,$1
> stt $f1,0($3)
> beq $1,$L22
> ldt $f1,8($2)
> addl $9,1,$9
> cmple $9,$4,$1
> stt $f1,8($3)
> beq $1,$L22
> ldt $f1,16($2)
> addl $9,1,$9
> cmple $9,$4,$1
> stt $f1,16($3)
> beq $1,$L22
> ldt $f1,24($2)
> addl $9,1,$9
> cmple $9,$4,$1
> stt $f1,24($3)
> beq $1,$L22
> ldt $f1,32($2)
> addl $9,1,$9
> cmple $9,$4,$1
> stt $f1,32($3)
> beq $1,$L22
> ldt $f1,40($2)
> addl $9,1,$9
> cmple $9,$4,$1
> stt $f1,40($3)
> beq $1,$L22
> ldt $f1,48($2)
> addl $9,1,$9
> cmple $9,$4,$1
> stt $f1,48($3)
> beq $1,$L22
> ldt $f1,56($2)
> addq $2,64,$2
> addl $9,1,$9
> cmple $9,$4,$1
> stt $f1,56($3)
> addq $3,64,$3
> bne $1,$L24
>
> My example method:
> (assume for the example, that the value in $4 is a multiple of 8)
>
> $L24:
> wh64 ($3)
> ldt $f1,0($2)
> ldt $f2,8($2)
> ldt $f3,16($2)
> ldt $f4,24($2)
> ldt $f5,32($2)
> ldt $f6,40($2)
> ldt $f7,48($2)
> ldt $f8,56($2)
> stt $f1,0($3)
> stt $f2,8($3)
> stt $f3,16($3)
> stt $f4,24($3)
> stt $f5,32($3)
> stt $f6,40($3)
> stt $f7,48($3)
> addq $2,64,$2
> addl $9,8,$9
> cmple $9,$4,$1
> stt $f8,56($3)
> addq $3,64,$3
> bne $1,$L24
>
> Bottom opcodes may have better order. It's basically the
> bottom of the gcc code. Also, depending on memory latency,
> you can start the stt's before you get all the ldt's
> done, assuming you can do both an stt and an ldt in the
> same cycle.
>
> Seems that should perform quite a bit better than the
> gcc loop. Can gcc be setup to do this??
>
> If you seriously want to use wh64, you need to do a
> pre-process loop to handle the non-64 byte boundary
> at the front, and a post-process loop to handle the
> end.
>
> Just some thoughts.
>
> Wes
Tom sent me the asm from DUNIX cc.
There was very little cleanup code on the end of the loops.
Perhaps the compiler knew the loop variable was divisible
by four, which is the unroll amount since it was hard coded.
Looks like it uses conditionals to decide when to do wh64.
Also, the instruction count is similar to the suggested loop
style above if you exclude the wh64 stuff.
copy vector:
L$31:
ldl r31, 256(r2)
ldt f1, (r2)
lda r6, 159(r3)
lda r8, -64(sp)
ldt f10, 8(r2)
ldt f11, 16(r2)
cmplt r6, r10, r7
addl j, 4, j # r1, 4, r1
ldt f12, 24(r2)
cmoveq r7, r8, r6
cmplt j, r11, r16 # r1, r11, r16
lda r2, 32(r2)
lda r3, 32(r3)
wh64 (r6)
stt f1, -32(r3)
unop
stt f10, -24(r3)
stt f11, -16(r3)
unop
unop
stt f12, -8(r3)
bne r16, L$31
vector times scalar:
L$33:
ldt f1, (r2)
ldl r31, 256(r2)
lda r7, 159(r3)
lda r16, -64(sp)
ldt f10, 8(r2)
ldt f11, 16(r2)
cmplt r7, r4, r8
addl j, 4, j # r1, 4, r1
ldt f12, 24(r2)
cmoveq r8, r16, r7
cmplt j, r11, r17 # r1, r11, r17
lda r2, 32(r2)
lda r3, 32(r3)
mult f1, scalar, f1 # f1, f2, f1
wh64 (r7)
mult f10, scalar, f10 # f10, f2, f10
mult f11, scalar, f11 # f11, f2, f11
mult f12, scalar, f12 # f12, f2, f12
stt f1, -32(r3)
stt f10, -24(r3)
stt f11, -16(r3)
stt f12, -8(r3)
bne r17, L$33
Vector + Vector:
L$35:
ldl r31, 256(r2)
ldt f1, (r2)
lda r8, 159(r4)
lda r17, -64(sp)
ldt f11, 8(r2)
ldt f13, 16(r2)
cmplt r8, r10, r16
addl j, 4, j # r1, 4, r1
ldt f10, (r3)
ldt f12, 8(r3)
cmoveq r16, r17, r8
cmplt j, r11, r18 # r1, r11, r18
ldt f14, 16(r3)
ldt f15, 24(r2)
lda r2, 32(r2)
lda r3, 32(r3)
ldt f16, -8(r3)
ldl r31, 224(r3)
lda r4, 32(r4)
wh64 (r8)
addt f1, f10, f1
addt f11, f12, f11
addt f13, f14, f13
addt f15, f16, f15
stt f1, -32(r4)
stt f11, -24(r4)
stt f13, -16(r4)
unop
stt f15, -8(r4)
bne r18, L$35
Vector+scaled vector:
L$37:
ldt f1, (r3)
ldl r31, 256(r3)
lda r16, 159(r4)
lda r18, -64(sp)
ldt f10, 8(r3)
ldt f11, 16(r3)
cmplt r16, r5, r17
addl j, 4, j # r1, 4, r1
ldt f12, 24(r3)
ldt f13, (r2)
cmoveq r17, r18, r16
cmplt j, r11, r19 # r1, r11, r19
ldl r31, 256(r2)
ldt f14, 8(r2)
lda r2, 32(r2)
lda r3, 32(r3)
mult f1, scalar, f1 # f1, f2, f1
ldt f15, -16(r2)
ldt f16, -8(r2)
lda r4, 32(r4)
mult f10, scalar, f10 # f10, f2, f10
wh64 (r16)
mult f11, scalar, f11 # f11, f2, f11
mult f12, scalar, f12 # f12, f2, f12
addt f13, f1, f1
addt f14, f10, f10
addt f15, f11, f11
addt f16, f12, f12
stt f1, -32(r4)
stt f10, -24(r4)
stt f11, -16(r4)
unop
stt f12, -8(r4)
bne r19, L$37
Wes
next prev parent reply other threads:[~1999-03-22 8:56 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-03-22 0:21 XP1000 and Linux Stig Telfer
1999-03-22 0:55 ` Greg Lindahl
1999-03-22 2:10 ` Richard Henderson
1999-03-22 5:12 ` Wes Bauske
1999-03-22 5:51 ` Wes Bauske
1999-03-22 8:41 ` Wes Bauske [this message]
1999-03-22 14:38 ` Greg Lindahl
1999-03-22 17:03 ` Wes Bauske
1999-03-22 19:11 ` Keystroke loggers Aaron
1999-03-22 9:22 ` loop unrolling [Re: XP1000 and Linux] Richard Henderson
1999-03-22 17:14 ` Wes Bauske
1999-03-23 2:43 ` Richard Henderson
1999-03-23 4:57 ` Wes Bauske
1999-03-22 11:58 ` Newbie Needs Milo Help SteveCraft
1999-03-23 18:39 ` Ron Farrer
1999-03-23 7:05 ` ev6 tlb consistency Richard Henderson
1999-03-23 18:22 ` Wes Bauske
1999-03-23 19:38 ` Jay.Estabrook
1999-03-23 8:56 ` loop unrolling [Re: XP1000 and Linux] Harvey J. Stein
1999-03-24 5:05 ` Wes Bauske
-- strict thread matches above, loose matches on Subject: below --
1999-03-20 8:27 XP1000 and Linux Thomas Leitner
1999-03-20 9:00 ` Wes Bauske
1999-03-20 10:40 ` Thomas Leitner
1999-03-21 0:42 ` Wes Bauske
1999-03-21 3:25 ` Wes Bauske
1999-03-21 19:40 ` Greg Lindahl
1999-03-21 20:43 ` Wes Bauske
1999-03-21 21:07 ` Greg Lindahl
1999-03-22 3:03 ` Wes Bauske
1999-03-22 3:18 ` Greg Lindahl
1999-03-24 0:57 ` Bill Broadley
1999-03-24 1:12 ` Greg Lindahl
1999-03-24 1:26 ` Bill Broadley
1999-03-24 3:13 ` Greg Lindahl
1999-03-24 4:19 ` Maurice Hilarius
1999-03-24 5:02 ` Jay.Estabrook
1999-03-24 15:49 ` Greg Lindahl
1999-03-24 18:16 ` Wes Bauske
1999-03-18 18:26 John Jemiolo
1999-03-18 20:06 ` Wes Bauske
1999-03-18 23:16 ` Wes Bauske
1999-03-18 16:05 Hoover, Tony
1999-03-18 17:18 ` Wes Bauske
1999-03-18 7:00 Wes Bauske
1999-03-18 7:48 ` Bill Broadley
1999-03-18 16:58 ` Wes Bauske
1999-03-18 17:18 ` Greg Lindahl
1999-03-18 20:01 ` Wes Bauske
1999-03-18 20:58 ` Greg Lindahl
1999-03-18 21:30 ` Wes Bauske
1999-03-19 20:34 ` Maurice Hilarius
1999-03-19 21:03 ` Greg Lindahl
1999-03-19 23:35 ` Wes Bauske
1999-03-20 5:37 ` Bill Roman
1999-03-24 3:27 ` Maurice Hilarius
1999-03-18 10:17 ` Matti Aarnio
1999-03-18 14:35 ` Greg Lindahl
1999-03-18 17:29 ` Jay.Estabrook
1999-03-24 2:20 ` Maurice Hilarius
1999-03-24 17:56 ` Oleg Gusev
1999-03-24 20:09 ` Maurice Hilarius
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox