From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,a997f8105715a8bb X-Google-Attributes: gid1164f8,public X-Google-Thread: fee84,a997f8105715a8bb X-Google-Attributes: gidfee84,public From: fred@extasy.enet.dec.com (Fred Kleinsorge) Subject: Re: char access is not so fast (:-<) Date: 1995/05/05 Message-ID: <3oda9h$f2g@nntpd.lkg.dec.com>#1/1 X-Deja-AN: 102112676 distribution: comp references: organization: Digital Equipment Corporation reply-to: fred@extasy.enet.dec.com (Fred Kleinsorge) newsgroups: comp.unix.osf.osf1,comp.sys.dec In article , danpop@afsmail.cern.ch (Dan Pop) writes: >In kuge@strl.nhk.or.jp (Tetsuro >KUGE) writes: > >>Hi, speedsters (^^;), >> >>It is seemed the access to char *array on Alpha CPU >>is NOT so faster than the "slower" chips of Sparc etc. >> >>On the Alpha server 4/275 with OSF/1 V.3.0B, >>the cc opitons -O* does not improve the situation (:-<). >> >>Is it my misunderstanding ? > >It's not your misunderstanding, it's the Alpha architecture not being >able to access bytes. The only data sizes that can be directly >accessed >by Alpha are 32 and 64 bit. For characters and short int's there is a >certain overhead, as the accesses have to be implemented in software >(with >more than one instruction :-) > The Alpha rchitecture doesn't deal with bytes, it deals with blocks of 4 or 8 bytes at minimum. It leaves the handling of bytes to the compilers. How good the generated code from the compiler is depends on: the quality of the compiler, the quality of the source code, and the constraints on the code and the compiler. The compilers have gotten better about partial word manipulation, but in general you will always get better performance if your code is written to deal in terms of 32 or 64 bit ints, and do the byte manipulation by hand. The general problem is that the generated code tends to be "safe" that is, it's guaranteed to work, and not generate alignment faults. So what you see is code that will have sequences like: LDQ_U R21, (R0) EXTBL R21, R0, R0 Just to simply fetch a byte in a foo[bar] array type operation. In general the generated code is fast enough for most purposes, and getting better. However, in performance critical code, like the inner loop of say a image operation - you can get 2x performance increases by using pointers to int32 or int64 data, and shifting, masking, and ORing by hand. Most of the performance win comes from doing aligned fetching of the data once, and then doing operations on that block of data in registers. -- +--------------------------------------+ Fred Kleinsorge | All opinions expressed are mine, and | kleinsorge@star.enet.dec.com | may not reflect those of my employer | +--------------------------------------+