alphalinux.org high-perf list (1998-2001)
 help / color / mirror / Atom feed
* sqrt performance
@ 1999-03-03  2:26 esci
  1999-03-03  9:27 ` Andrei A. Dergatchev
  0 siblings, 1 reply; 9+ messages in thread
From: esci @ 1999-03-03  2:26 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 6314 bytes --]

The following uuencoded compressed tar file contains several

variations on coding the double square root equation from

reflection seismology.  The times are rather counterintuitive.

The run_"n" files contain data which may be plotted w/ the gnuplot

script, "plt" enclosed.

All examples were run using DU 4.0E and the software development 

tools from the most recent ASAP SDK.

In particular, the Digipaq Extended Math Library vsqrt() has

the poorest performance of all. (run_2 & run_5 using sub2.f 

and sub5.f respectively)

Interestingly, the straight forward loop unrolled twice w/

explicit temporaries matches the 25 cycles per result given

by Cray in "The Benchmarker's Guide to Single-processor

Optimization for CRAY T3E Systems" for the Cray vector libm

routines.

I am unable to assemble either of the sqrt routines posted 

by Kazushige Goto <goto@statabo.rim.or.jp>.  Some pathetic 

attempts on my part to modify the code for the DU assembler

succeeded in producing a .o file w/o any error messages, but

a simple "nm -og sqrt.o" causes nm(1) to dump core.  I have

a Linux box waiting to be assembled, but am trying to get some

programming done first.

Reducing the cycle count per result by even a little bit would

be of great value to me.  The 12 cycles quoted by Goto for his

code would be staggering.  Using Linux would be even better :-)

Reginald Beardsley

------------------------------------------------------------------------

              Exploration Software Consultants Inc.

Voice: 972-379-0557                      email: rhb@acm.org

Fax:   972-379-0558

------------------------------------------------------------------------

begin 644 tst.tar.gz

M'XL("#&7W#8``W1S="YT87(`[9UM<]NX$8#[]?0KT#0SD11'QCO`FW-G;JZ7

M?FF;F6NG7V](6]8ID257HG/VO^^"!"A*%I9V8MG'###CE0PL`1`M?FF;F6NG7V](6]8ID257HG/VO^^"!"A*%I9V8MG'###CE0PL`1`OSRX@4/IG

M_FEZ.5],_W3$0"G54A+W*IBH7BDS]:M["X%0K;6!-XII0AE71D'Z,2L5PL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+

MQB=J]`;:W-GIEN)N4Q(_1*KF8;056U1-4\<>[`5?G&Z/CNU8;=GZET99"BFD

MD$(*CPCI_%\Z_T=ZNO^3SO]]?4CG_]+YO[[._W3^+YW_2^'K0CK_E\[_]97_

DZ?Q?.O^7PM>%=/XOG?\C/>)_.O^7SO^E\'3A_VMYG/<`H```

`

end

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: sqrt performance
@ 1999-03-03 13:21 esci
  1999-03-03 18:51 ` Andrei A. Dergatchev
  0 siblings, 1 reply; 9+ messages in thread
From: esci @ 1999-03-03 13:21 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1109 bytes --]

[ snip]

>-.section       .rodata

>+#ifdef __ELF__

>+       .section .rodata

>+#else

>+       .rdata

>+#endif

[ snip]

 

Unfortunately this is exactly what I did ( I left off the #ifdef ).  I 

never tried linking after nm(1) core dumped.  It was late when I posted 

my notes yesterday and I was getting pretty befuddled.  The examples I

sent were rewrites of a kernel extracted from an application I'm working

on.  The results of my tuning efforts were so confusing I decided to 

build  new test environment (complete w/ its own bugs :-(

I plan to compile the C code as well as a FORTRAN translation today and

compare them.  I will also generate assembly using the C and FORTRAN codes

and see if I can figure out what to do to write assembly code that will

work both places.

Reginald Beardsley

------------------------------------------------------------------------

              Exploration Software Consultants Inc.

Voice: 972-379-0557                      email: rhb@acm.org

Fax:   972-379-0558

------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: sqrt performance
@ 1999-03-03 20:53 esci
  1999-03-03 21:40 ` Andrei A. Dergatchev
  1999-03-04  5:15 ` Michal Jaegermann
  0 siblings, 2 replies; 9+ messages in thread
From: esci @ 1999-03-03 20:53 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1929 bytes --]

[snip]

>Looking at the structure of your code I think it *should* be possible

>to get some acceleration exploiting regulatiry of sqrt argument:

>some_value*constant_for_this_cycle+delta^2*(i++)^2

>for i=1,N

>

>I'm thinking about division of one argument over other.

>Can you expect any relation of general nature like

>some_value*constant_for_this_cycle<<delta^2*(i++)^2

>or vice versa or anything in this style ?

All the values are monotonic, so you can speed things up a good bit by using

the previous result as the starting point in a Newtonian iteration. It gives

a factor of 3 speed up w/ g77 or NDP, but is slightly slower than the DU

library routine.  This was with 2 steps hard coded w/o conditional logic.

I only need 13 bits of accuracy as the result is an index into an array.

One of the things that is slowly sinking in is that my loop is too short,

typically under 100 iterations.  From what I'm seeing, I should be able to

get faster results by chaining a number of loops together.

BTW can anyone provide good references on sqrt() methods?  I looked in

Knuth and quite a few other math references but found little other than very

basic stuff (i.e. Newton's method)  Knuth has one algorithm posed as an

exercise (M40 == Mathematical, term project difficulty :-(

I'm currently looking into using a table driven Taylor's series expansion.

Hint's and suggestions *very* welcome.  I need to do this over the range

from 0 to 100,000,000  w/ the roots off by less than 1 (I actually need

integer roots for the indexing).  There ought to be a way to get this going 

a lot faster.

Reginald Beardsley

------------------------------------------------------------------------

              Exploration Software Consultants Inc.

Voice: 972-379-0557                      email: rhb@acm.org

Fax:   972-379-0558

------------------------------------------------------------------------

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

end of thread, other threads:[~1999-03-04 18:30 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-03-03  2:26 sqrt performance esci
1999-03-03  9:27 ` Andrei A. Dergatchev
1999-03-03 11:59   ` Kazushige Goto
  -- strict thread matches above, loose matches on Subject: below --
1999-03-03 13:21 esci
1999-03-03 18:51 ` Andrei A. Dergatchev
1999-03-03 20:53 esci
1999-03-03 21:40 ` Andrei A. Dergatchev
1999-03-04  5:15 ` Michal Jaegermann
1999-03-04 18:30   ` Joachim Wesner

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