* Re: sqrt.s
@ 1999-02-28 0:31 esci
0 siblings, 0 replies; 6+ messages in thread
From: esci @ 1999-02-28 0:31 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 857 bytes --]
I shall shortly find out. I have a "real life" application that makes
heavy use of sqrt(). I will provide comparisons against the DU implementation.
The values for which roots are being taken increase monotonicly, so there
shouldn't be too much penalty for the lookup table because of locality of
reference. Of course, I still have to reduce the overall memory traffic
to something the 164 can handle, which *is* proving to be difficult.
BTW I'd appreciate a copy of the paper by Dave Mosberger-Tang, if anyone
has it available.
Reginald Beardsley
------------------------------------------------------------------------
Exploration Software Consultants Inc.
Voice: 972-379-0557 email: rhb@acm.org
Fax: 972-379-0558
------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: sqrt.s
@ 1999-02-28 11:11 Andrei A. Dergatchev
0 siblings, 0 replies; 6+ messages in thread
From: Andrei A. Dergatchev @ 1999-02-28 11:11 UTC (permalink / raw)
Hi,
>Seems there are a number of us interested in real-life performace
>of square root calculations.
Well, I would say "in axp-linux performance" :-) No necessary sqrt
particularly, but indeed it might be an useful example. I have a Monte-
Carlo code with quite considerable amount of "normalization"
operations too. But it's in Borland Pascal and I'm not sure if I'll
ever have a time to rewrite it :-(
[snip]
>I've got access to both a DU box and a linux one and will be happy
>both trying to contribute and test any new ideas... I'll send a piece
>of code tomorrow if anyone's interested!
Yes, please. Or put it somewhere in the Internet if it's possible to
reduce a list traffic ?
>Regards,
>
>Erik
Rgds,
Andrei
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: sqrt.s
@ 1999-02-28 10:16 Erik Lindahl
0 siblings, 0 replies; 6+ messages in thread
From: Erik Lindahl @ 1999-02-28 10:16 UTC (permalink / raw)
Hi,
Seems there are a number of us interested in real-life performace
of square root calculations.
I'm doing molecular dynamics on biological systems consisting of
10000-100000 atoms. The computational heavy part is the inner
loops (written in fortran of course) where I have to calculate the
inverse square root of the distance between pairs of particles.
The problem is reduced by using neighbourlists for each atom, but
this might trash the cache. We're currently using a fortran
implementation
of a table look-up & iteration routine directly calculating 1/sqrt(r).
The sqrt routine is still taking about 25% of the total runtime.
However, we're not using any vectorized version... There might
be something to win by not having to reload the table.
I've got access to both a DU box and a linux one and will be happy
both trying to contribute and test any new ideas... I'll send a piece
of code tomorrow if anyone's interested!
Regards,
Erik
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: sqrt.s
@ 1999-02-28 1:01 Andrei A. Dergatchev
0 siblings, 0 replies; 6+ messages in thread
From: Andrei A. Dergatchev @ 1999-02-28 1:01 UTC (permalink / raw)
Hi,
[snip]
> Of course, I still have to reduce the overall memory traffic
> to something the 164 can handle, which *is* proving to be difficult.
??? Can you elaborate on that - what do you use to run this application
than - a multiprocessor system or what ?
> BTW I'd appreciate a copy of the paper by Dave Mosberger-Tang, if
anyone
> has it available.
http://www.mostang.com/~davidm/papers/expo97/paper/
or do you want a .ps file ?
I was heavily impressed seeing ~1000 counts for sqrt (using -lm without
optimization, ~350 counts with -O) repeating his examples.
Unfortunately, I don't have DU to make comparisons :-(
>
> Reginald Beardsley
>
>
------------------------------------------------------------------------
> Exploration Software Consultants Inc.
>
> Voice: 972-379-0557 email: rhb@acm.org
> Fax: 972-379-0558
>
------------------------------------------------------------------------
Rgds,
Andrei
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: sqrt.s
@ 1999-02-27 18:06 Michal Jaegermann
0 siblings, 0 replies; 6+ messages in thread
From: Michal Jaegermann @ 1999-02-27 18:06 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 926 bytes --]
I see all the time these square root routines with big lookup
tables and impressive cycle counts. I cannot help not to wonder
what will be impact of such tables in a "real life". While
benchmarking one is performing square root operations in a tight
loop; everything fits in a cache and a performance is impressive.
But in reality these things are not used that way and it will
be, usually, lots of other code around. If one starts taking
cache, or even worse - page, hits because of lookups then a performance
can worsen considerably.
I still remember a paper by Dave Mosberger-Tang, from a few years
ago, about optimizing on Alpha where he showed that local calculations
may be much prefererable to distant lookups. I do not have measurements
for a different computation strategies of sqrt in real code as opposed
to small loops. But does anybody attempted some investigations of
that kind?
Michal
^ permalink raw reply [flat|nested] 6+ messages in thread
* sqrt.S
@ 1999-02-21 16:23 Robert Harley
0 siblings, 0 replies; 6+ messages in thread
From: Robert Harley @ 1999-02-21 16:23 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 5894 bytes --]
/* > sqrt.S
* Purpose: Fast double precision square root in Alpha ASM.
* Copyright: (c) Robert J. Harley, 19-Oct-1998
* Contact: Robert.Harley@inria.fr
* Legalese: This code is subject to the GNU General Public License (v2).
*/
/* Integer registers. */
#define ea $1
#define ta $2
#define wm $3
#define wp $4
#define pt $5
#define ux $6
#define ua $7
#define pc $8
#define v $22
#define v2 $23
#define tmp $24
#define exp $25
#define ra $26
#define pv $27
#define at $28
#define gp $29
#define sp $30
#define zero $31
/* Floating-point registers. */
#define dX $f0
#define d0_5 $f10
#define d1_5 $f11
#define dB $f12
#define dT $f13
#define dZ $f14
#define dTmp $f15
#define dA $f16
#define dZero $f31
/* Delay one integer slot (E0 or E1). */
#define NOP bis $31, $31, $31
/* Delay one floating-point slot (FA or FM). */
#define FNOP cpys $f31, $f31, $f31
/* No delay, for alignment (invalidated at slotting). */
#define UNOP ldq_u $31, 0($30)
.set noreorder
.section .rodata
#define BLA(n) .long n<<16 | 126<<23
.type tab, @object
.size tab, 256
.align 5
tab:
BLA(127)
BLA(125)
BLA(123)
BLA(121)
BLA(119)
BLA(118)
BLA(116)
BLA(114)
BLA(113)
BLA(111)
BLA(109)
BLA(108)
BLA(106)
BLA(105)
BLA(103)
BLA(102)
BLA(100)
BLA(99)
BLA(97)
BLA(96)
BLA(95)
BLA(93)
BLA(92)
BLA(91)
BLA(90)
BLA(88)
BLA(87)
BLA(86)
BLA(85)
BLA(84)
BLA(83)
BLA(82)
BLA(80)
BLA(79)
BLA(78)
BLA(77)
BLA(76)
BLA(75)
BLA(74)
BLA(73)
BLA(72)
BLA(71)
BLA(70)
BLA(70)
BLA(69)
BLA(68)
BLA(67)
BLA(66)
BLA(65)
BLA(64)
BLA(63)
BLA(63)
BLA(62)
BLA(61)
BLA(60)
BLA(59)
BLA(59)
BLA(58)
BLA(57)
BLA(56)
BLA(56)
BLA(55)
BLA(54)
BLA(53)
#undef BLA
.align 4
consts:
.s_floating 1.5
.s_floating 0.5
.t_floating 0.70710678118654757273731092936941422522068023681640625
.text
.globl sqrt
.ent sqrt
.align 5
sqrt:
.frame sp, 24, ra, 0
subq sp, 24, sp
ldgp gp, .-sqrt(pv)
stt dA, 0(sp)
.prologue 1
.align 4
lda pc, consts
lda exp, 1022
ldq ua, 0(sp)
sll exp, 52, exp
lda pt, tab
lds d1_5, 0(pc)
srl ua, 46, ta
lds d0_5, 4(pc)
and ta, 63, ta
sll ua, 12, ux
s4addq ta, pt, pt
srl ux, 12, ux
lds dX, 0(pt)
bis ux, exp, ux
ble ua, pm_zero_or_negative
stq ux, 0(sp)
mult dX, dX, dTmp
srl ua, 52, ea
ldt dZ, 0(sp)
beq ea, positive_denormal
lda tmp, -2047(ea)
addq ea, 1, ta
addt dZ, dZ, dB
mult dZ, dTmp, dZ
beq tmp, pos_nan_or_inf
bic ta, 1, ta
lda ta, -1024(ta)
subt d1_5, dZ, dT
mult dZ, dT, dZ
ldt dTmp, 8(pc)
mult dX, dT, dX
sll ua, 52, wp
mult dZ, dT, dZ
UNOP
subt d1_5, dZ, dT
UNOP
sll ta, 51, ta
UNOP
mult dX, dT, dX
blbs ea, skip
addt dB, dB, dB
sll ua, 53, wp
mult dX, dTmp, dX
UNOP
skip:
mult dB, dX, dT
mult dX, d0_5, dX
mult dT, dT, dZ
subt dB, dZ, dZ
mult dX, dZ, dX
addt dX, dT, dX
stt dX, 0(sp)
FNOP
ldq ux, 0(sp)
subq ux, exp, v
mulq v, v, v2
addq ux, ta, ux
stq ux, 8(sp)
addq ux, 1, ux
subq wp, v, wm
stq ux, 0(sp)
subq ux, 2, ux
stq ux, 16(sp)
addq wp, v, wp
UNOP
subq v2, wm, wm
subq v2, wp, wp
sra wm, 63, wm
cmple zero, wp, wp
addq wm, wp, wm
s8addq wm, sp, wm
ldt dX, 8(wm)
addq sp, 24, sp
ret zero, (ra), 1
.align 4
pm_zero_or_negative:
positive_denormal:
pos_nan_or_inf:
cpys dZero, dZero, dX /* Junk for now. */
addq sp, 24, sp
ret zero, (ra), 1
.end sqrt
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~1999-02-28 11:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-02-28 0:31 sqrt.s esci
-- strict thread matches above, loose matches on Subject: below --
1999-02-28 11:11 sqrt.s Andrei A. Dergatchev
1999-02-28 10:16 sqrt.s Erik Lindahl
1999-02-28 1:01 sqrt.s Andrei A. Dergatchev
1999-02-27 18:06 sqrt.s Michal Jaegermann
1999-02-21 16:23 sqrt.S Robert Harley
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox