Seti@Home optimized science apps and information
 
Welcome, Guest. Please login or register.
Did you miss your activation email?
23 Nov 2008, 02:14:07 pm

Login with username, password and session length
 
If you've registered already but never got your activation email, please click here.
 
 
Seti@Home optimized science apps and information  |  Optimized Seti@Home apps  |  Windows  |  Topic: Bug report science function 0 Members and 0 Guests are viewing this topic. « previous next »
Pages: [1] Go Down Print
Author Topic: Bug report science function  (Read 782 times)
nanobyte
Knave
*
Offline Offline

Posts: 2


View Profile
Bug report science function
« on: 10 Jul 2008, 06:49:25 pm »

I am under the impression that the compiler has generated code that effectively ignores results in the chirp function.


Version:
Windows optimized S@H Enhanced application by Alex Kan
Version info: SSSE3x (Intel, Core 2-optimized v8-nographics) V5.13 by Alex Kan
SSSE3x Win32 Build 41 , Ported by : Jason G, Raistmer, JDWhale

I use the 'pe explorer/disassembler' and Intel VTune to analyze the assembly source. VTune names this routine 'v_vChirpData'.

When disassembled, the function at 401b0c has a section where the following instruction sequence is used.

At address: 401c77
                movaps  xmm0,xmm4
                addpd   xmm0,xmm3
                subpd   xmm0,xmm4
                subpd   xmm3,xmm0

In this sequence, xmm3 is always zero.

Based on a similar sequence, several other registers are eventually zeroed as well. This undermines the logic in the entire routine.

Could you please verify this against the source code ?

nanobyte.
Logged
Jason G
Global Moderator
Knight who says 'Ni!'
*****
Online Online

Posts: 2265


View Profile
Re: Bug report science function
« Reply #1 on: 11 Jul 2008, 12:50:10 am »

Hi there,
    That stretch of code is among the intrinsic portion of the function, and is part of the code that just grabs the 'sign bit',  so it should be +/- zero .  I believe this is a necessary, and intentional part for the rounding action needed for the chirp , angle reduction to within the range -0.5 to 0.5.

This is one of the few places in the code where extreme precision is required, so double precision is used)  and a 'bug' as such would manifest probably with horrible consequences. If I am correct then what the compiler has done there is replicate the source faithfully (from the intrinsics), and sequences of adds & subs are generally faster to use within critical loops than other possible methods.  I hope that helps.

Thanks, Jason

[See Alex's much better answer  Grin]
« Last Edit: 11 Jul 2008, 01:31:52 am by Jason G » Logged
Alex Kan
Code Wizard
Knight o' the Realm
*****
Offline Offline

Posts: 29



View Profile
Re: Bug report science function
« Reply #2 on: 11 Jul 2008, 01:27:39 am »

When disassembled, the function at 401b0c has a section where the following instruction sequence is used.

At address: 401c77
                movaps  xmm0,xmm4
                addpd   xmm0,xmm3
                subpd   xmm0,xmm4
                subpd   xmm3,xmm0

In this sequence, xmm3 is always zero.

Based on a similar sequence, several other registers are eventually zeroed as well. This undermines the logic in the entire routine.

Could you please verify this against the source code ?

This is the intended behavior.

Your observation would be true if all floating-point operations were carried out with infinite precision. However, since each operation rounds off to a fixed precision, addition and subtraction are not actually associative. Despite its outward appearances, that instruction sequence does not set xmm3 to zero—it actually generates the fractional part of the value originally contained in xmm3. Specifically, the first three instructions round xmm3 to the nearest integer value using magic numbers (chosen to push all the fractional bits off the end of the mantissa), then place the rounded value into xmm0. Subtracting xmm0 from xmm3 yields the fractional part.

Overzealous compiler optimization based on arithmetic associativity breaks techniques relying on floating-point rounding behavior, like Kahan summation and the code above. Fortunately, the Intel compiler has not done anything of the sort here.
« Last Edit: 11 Jul 2008, 02:40:41 am by Alex Kan » Logged
nanobyte
Knave
*
Offline Offline

Posts: 2


View Profile
Re: Bug report science function
« Reply #3 on: 11 Jul 2008, 02:15:34 am »

Clear explanation, thank you very much. I am relieved that this behaviour was given thought.
You did an excellent job on the code.

best regards,
nanobyte
Logged
Pages: [1] Go Up Print 
Seti@Home optimized science apps and information  |  Optimized Seti@Home apps  |  Windows  |  Topic: Bug report science function « previous next »
Jump to:  


Quote!
Those who cannot remember the past are condemned to repeat it.
- George Santayana

 
Site Statistics
Total Members:1,072
Total Posts:10,839
Total Topics:447
Downloads
Apps
Windows R-1.x25,148
Windows R-2.020,356
Windows R-2.236,628
Linux 32bit 1.x6,574
Linux 32bit 2.24,406
Linux 64bit 2.21,784
Alpha/IA64204
FreeBSD629
HPUX346
Subtotal:94,896
Source packs:4,071
Tool/WU packs:7,931
Total:157,888
GBs dl'd:282.03
Pages served
Today:2,715
Total:3,359,731
(since 6/26/2006)
173 Donations to S@H
U.S. Dollars:3,196.59
Euros:863.90
Last 24h:$ 0.00
Avg./24h:$ 6.62
Estim. total:$ 4,319.66
Latest Member:
Luke@SETI
 
 
Seti@Home optimized science apps and information | Powered by Enigma 2.0 (RC1).
© 2003-2008, LSP Dev Team. All Rights Reserved.
Seti@Home optimized science apps and information Forums | Powered by SMF.
© 2005, Simple Machines LLC. All Rights Reserved.
Powered by MySQL Powered by PHP Valid XHTML 1.0! Valid CSS!