* Alpha Optimization
@ 2002-09-10 23:55 Rui-Tao Dong
2002-09-11 2:16 ` Chris Eleveld
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Rui-Tao Dong @ 2002-09-10 23:55 UTC (permalink / raw)
To: axp-list
I haven't seen much traffic on the list for while. Here is a question
for you guys.
I am trying to divide two 8 bit images (A*256/B) as fast as possible.
I built a lookup table of all possible combinations of A & B (64KB)
and do the lookup on the images. On a 2.0GHz P4, it takes about
28msec on a 1280x1024x24 images. On the 1.0GHz ev68 (at Compaq
testdrive), it takes about 57msec, which is very disappointing. I was
expecting the Alpha to be much faster due to its larger L1 cache and
faster memory IO. The relevant code is below. I tried both gcc -O6
and ccc -O3.
pTab is the pre-constructed 256x256 lookup table, with numerator as
the row index and denominator as the column index.
typedef unsigned char pixel8;
for (l=0; l<100; ++l)
{
pixel8* pOut = output_buf;
const pixel8* pN = input_buf;
const pixel8* pD = white_buf;
int r;
for (r=0; r< HEIGHT; ++r)
{
int c;
for (c=0; c< WIDTH*3; ++c)
{
int i = ((*pN)<<8) + (*pD);
*pOut = pTab[i];
++pN;
++pD;
++pOut;
}
}
}
Any idea?
Regards,
--
Dr. Rui-Tao Dong Aria Systems, Inc.
(949)291-XXXX(Cell) P. O. Box 52123
rdong@cox.net Irvine, CA 92619
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Alpha Optimization
2002-09-10 23:55 Alpha Optimization Rui-Tao Dong
@ 2002-09-11 2:16 ` Chris Eleveld
2002-09-11 5:33 ` Thorsten Koch
2002-09-11 19:05 ` Nikita Schmidt
2 siblings, 0 replies; 7+ messages in thread
From: Chris Eleveld @ 2002-09-11 2:16 UTC (permalink / raw)
To: axp-list
To avoid unaligned accesses flatten the array out to 64 bit longs.
Either using bit shifting or as a larger array. I believe single byte
accesses are the worst on alpha but I could be wrong. Also there should
be some architecture switches to take advantage oft EV68 instructions
for dealing with bytes. I think. I'm certain someone here will correct
me if I'm way off base.
-----Original Message-----
From: axp-list-admin@redhat.com [mailto:axp-list-admin@redhat.com] On
Behalf Of Rui-Tao Dong
Sent: Tuesday, September 10, 2002 6:56 PM
To: axp-list@redhat.com
Subject: Alpha Optimization
I haven't seen much traffic on the list for while. Here is a question
for you guys.
I am trying to divide two 8 bit images (A*256/B) as fast as possible.
I built a lookup table of all possible combinations of A & B (64KB)
and do the lookup on the images. On a 2.0GHz P4, it takes about
28msec on a 1280x1024x24 images. On the 1.0GHz ev68 (at Compaq
testdrive), it takes about 57msec, which is very disappointing. I was
expecting the Alpha to be much faster due to its larger L1 cache and
faster memory IO. The relevant code is below. I tried both gcc -O6
and ccc -O3.
pTab is the pre-constructed 256x256 lookup table, with numerator as
the row index and denominator as the column index.
typedef unsigned char pixel8;
for (l=0; l<100; ++l)
{
pixel8* pOut = output_buf;
const pixel8* pN = input_buf;
const pixel8* pD = white_buf;
int r;
for (r=0; r< HEIGHT; ++r)
{
int c;
for (c=0; c< WIDTH*3; ++c)
{
int i = ((*pN)<<8) + (*pD);
*pOut = pTab[i];
++pN;
++pD;
++pOut;
}
}
}
Any idea?
Regards,
--
Dr. Rui-Tao Dong Aria Systems, Inc.
(949)291-XXXX(Cell) P. O. Box 52123
rdong@cox.net Irvine, CA 92619
_______________________________________________
Axp-list mailing list
Axp-list@redhat.com
https://listman.redhat.com/mailman/listinfo/axp-list
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Alpha Optimization
2002-09-10 23:55 Alpha Optimization Rui-Tao Dong
2002-09-11 2:16 ` Chris Eleveld
@ 2002-09-11 5:33 ` Thorsten Koch
2002-09-11 19:05 ` Nikita Schmidt
2 siblings, 0 replies; 7+ messages in thread
From: Thorsten Koch @ 2002-09-11 5:33 UTC (permalink / raw)
To: axp-list
Hello,
first this look like something that could use SSE Instruction
on a P4, so with the intel compiler or asm this may get much
faster on the P4.
Then it's all integer, something where the P4 is quite good
at, especially as you don't need to hold a lot of values
in regsters here. And you work on bytes, something that
disables the biggest advantage of the alpha, namely
the possibility to manipulate 64 bits at a time.
So it's kind of a one-legged race, and since the P4 is
build from the start one-legged, it excells.
For the alpha, you should enlarge everything to ints.
As far as I have tested, with current compilers, it is
not a goog idea to convert all accesses to pointers,
Just do pN[c] or something like that. The compilers have
more change to do anything with this kind of expression.
To really speed things up, you have to stuff 4 entries
in a long and do this at ones. But this needes some
serious bit fiddling.
Regards,
Thorsten
On Tue, Sep 10, 2002 at 04:55:49PM -0700, Rui-Tao Dong wrote:
>
> I haven't seen much traffic on the list for while. Here is a question
> for you guys.
>
> I am trying to divide two 8 bit images (A*256/B) as fast as possible.
> I built a lookup table of all possible combinations of A & B (64KB)
> and do the lookup on the images. On a 2.0GHz P4, it takes about
> 28msec on a 1280x1024x24 images. On the 1.0GHz ev68 (at Compaq
> testdrive), it takes about 57msec, which is very disappointing. I was
> expecting the Alpha to be much faster due to its larger L1 cache and
> faster memory IO. The relevant code is below. I tried both gcc -O6
> and ccc -O3.
>
> pTab is the pre-constructed 256x256 lookup table, with numerator as
> the row index and denominator as the column index.
>
> typedef unsigned char pixel8;
>
> for (l=0; l<100; ++l)
> {
> pixel8* pOut = output_buf;
> const pixel8* pN = input_buf;
> const pixel8* pD = white_buf;
> int r;
>
> for (r=0; r< HEIGHT; ++r)
> {
> int c;
> for (c=0; c< WIDTH*3; ++c)
> {
> int i = ((*pN)<<8) + (*pD);
> *pOut = pTab[i];
> ++pN;
> ++pD;
> ++pOut;
> }
> }
> }
>
> Any idea?
>
> Regards,
>
> --
>
> Dr. Rui-Tao Dong Aria Systems, Inc.
> (949)291-XXXX(Cell) P. O. Box 52123
> rdong@cox.net Irvine, CA 92619
>
>
>
> _______________________________________________
> Axp-list mailing list
> Axp-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/axp-list
--
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety."
-- Benjamin Franklin, 1759
___________________________________________________
Thorsten Koch / Konrad-Zuse-Zentrum für Informationstechnik Berlin
koch@zib.de / Takustraße 7, 14195 Berlin-Dahlem, Germany
______________/ Phone +49-30-84185-213, Fax -269
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Alpha Optimization
@ 2002-09-11 14:41 Donsbach, Jeff
0 siblings, 0 replies; 7+ messages in thread
From: Donsbach, Jeff @ 2002-09-11 14:41 UTC (permalink / raw)
To: axp-list
Before going through the work of changing the data types, try seeing what "ccc -fast" gets you. This will implicity use "-arch host" which should trigger use of byte instructions when compiled on ev56 and later.
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Alpha Optimization
@ 2002-09-11 14:53 Block, Kenneth
2002-09-11 15:54 ` Rui-Tao Dong
0 siblings, 1 reply; 7+ messages in thread
From: Block, Kenneth @ 2002-09-11 14:53 UTC (permalink / raw)
To: axp-list
You might try -fast for ccc, although for my experiments it did not help. I tried the change unsigned char to unsigned longs and that made it slower.
I think the issue here is that the P4 is very competitive for integer operations. As for caching, what are the cache sizes for the processors? For Alpha, I believe it is 64KB. For AMD, I believe it is 64K. What is it for the P4?
-----Original Message-----
From: Rui-Tao Dong [mailto:rdong@cox.net]
Sent: Tuesday, September 10, 2002 7:56 PM
To: axp-list@redhat.com
Subject: Alpha Optimization
I haven't seen much traffic on the list for while. Here is a question
for you guys.
I am trying to divide two 8 bit images (A*256/B) as fast as possible.
I built a lookup table of all possible combinations of A & B (64KB)
and do the lookup on the images. On a 2.0GHz P4, it takes about
28msec on a 1280x1024x24 images. On the 1.0GHz ev68 (at Compaq
testdrive), it takes about 57msec, which is very disappointing. I was
expecting the Alpha to be much faster due to its larger L1 cache and
faster memory IO. The relevant code is below. I tried both gcc -O6
and ccc -O3.
pTab is the pre-constructed 256x256 lookup table, with numerator as
the row index and denominator as the column index.
typedef unsigned char pixel8;
for (l=0; l<100; ++l)
{
pixel8* pOut = output_buf;
const pixel8* pN = input_buf;
const pixel8* pD = white_buf;
int r;
for (r=0; r< HEIGHT; ++r)
{
int c;
for (c=0; c< WIDTH*3; ++c)
{
int i = ((*pN)<<8) + (*pD);
*pOut = pTab[i];
++pN;
++pD;
++pOut;
}
}
}
Any idea?
Regards,
--
Dr. Rui-Tao Dong Aria Systems, Inc.
(949)291-XXXX(Cell) P. O. Box 52123
rdong@cox.net Irvine, CA 92619
_______________________________________________
Axp-list mailing list
Axp-list@redhat.com
https://listman.redhat.com/mailman/listinfo/axp-list
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Alpha Optimization
2002-09-11 14:53 Block, Kenneth
@ 2002-09-11 15:54 ` Rui-Tao Dong
0 siblings, 0 replies; 7+ messages in thread
From: Rui-Tao Dong @ 2002-09-11 15:54 UTC (permalink / raw)
To: axp-list
>>>>> "kenneth" == Kenneth Block <Block> writes:
kenneth> You might try -fast for ccc, although for my experiments it did not
kenneth> help. I tried the change unsigned char to unsigned longs and that made
kenneth> it slower.
I did try -fast and it made little difference. Change unsigned char
to unsigned longs is not an option as the conversion probably takes
more time.
kenneth> I think the issue here is that the P4 is very competitive
kenneth> for integer operations. As for caching, what are the cache
kenneth> sizes for the processors? For Alpha, I believe it is
kenneth> 64KB. For AMD, I believe it is 64K. What is it for the P4?
Actually, I don't know. I went through Intel's site and it talks only
about L2, but not L1. My Laptop (Mobile P3 866MHz) shows 16K I + 16K D
when Linux starts. I can't find that information from W2K on the P4.
I'll bring in a Linux CD tomorrow and test it out.
The other problem is test drive machines are always loaded (loadavg
~6). It'll certainly mess up the cache. The only unloaded Alpha I
have access to is the UDB at home :-).
I also remembered that OSF/DU/Tru64 had (still has?) better cache
management than Linux.
--
Rui-Tao Dong ~{6-HpLN~} <rdong@cox.net>, Mission Viejo, California
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Alpha Optimization
2002-09-10 23:55 Alpha Optimization Rui-Tao Dong
2002-09-11 2:16 ` Chris Eleveld
2002-09-11 5:33 ` Thorsten Koch
@ 2002-09-11 19:05 ` Nikita Schmidt
2 siblings, 0 replies; 7+ messages in thread
From: Nikita Schmidt @ 2002-09-11 19:05 UTC (permalink / raw)
To: axp-list
On Tuesday, 10 Sep, Rui-Tao Dong wrote:
> I am trying to divide two 8 bit images (A*256/B) as fast as possible.
> I built a lookup table of all possible combinations of A & B (64KB)
> and do the lookup on the images.
64K is a lot for a lookup table and will definitely cause on-chip cache
thrashing. It is often faster to compute than to look up. I don't know
how fast multiplication is on EV68, but there is a slim chance that
performance can be improved by replacing the division table with a table
of inverted values of B (scaled to be integer - say, 2^24/B) and
multiplying A by pTab[B] in the loop. The table will shrink to 1 KB,
hopefully letting enough space in the cache for the other buffers.
> I tried both gcc -O6 and ccc -O3.
Try ccc -fast and gcc -mcpu=ev67 (or -mcpu=ev6 if using gcc 2) -O6. This
will utilise more efficient byte loads available in EV6.
On Tuesday, 10 Sep, Chris Eleveld wrote:
> To avoid unaligned accesses flatten the array out to 64 bit longs.
> Either using bit shifting or as a larger array. I believe single byte
> accesses are the worst on alpha but I could be wrong.
Single byte reads were not too bad even in the original Alpha architecture -
hardly worse than bit shifting or byte extraction written in a high
level language. They were indeed slower than 32 and 64 bit loads. Byte
writes were pretty expensive though. EV6 has instructions for single byte
load/store.
> Also there should
> be some architecture switches to take advantage oft EV68 instructions
> for dealing with bytes. I think.
Yes, you are right.
Nikita
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2002-09-11 19:08 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-09-10 23:55 Alpha Optimization Rui-Tao Dong
2002-09-11 2:16 ` Chris Eleveld
2002-09-11 5:33 ` Thorsten Koch
2002-09-11 19:05 ` Nikita Schmidt
-- strict thread matches above, loose matches on Subject: below --
2002-09-11 14:41 Donsbach, Jeff
2002-09-11 14:53 Block, Kenneth
2002-09-11 15:54 ` Rui-Tao Dong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox