|
From: Saurabh T <sa...@ho...> - 2010-06-17 13:48:29
|
> My x86 (ie. 32 bit) code was calculating numbers differently when run > by itself (A) than when run thru valgrind (V). This is numerically > intensive code so I'm certain the differences are in the floating point > calculations. I understood that this could be due to the differences in > floating point arithmetic (80-bit on its own vs 64-bit thru valgrind). > > So > I rebuilt my entire code with -mfpmath=sse -msse2. This leads to > different answers (B) when run on its own from before, but still they > are different from valgrind (B != V). I recompiled valgrind with those > options in CPPFLAGS but to no avail - this didnt change the valgrind > output. > > Interestingly I also discovered that on x86_64, the > answers from the program match exactly those from valgrind (and these > are the same as from x86 valgrind = V). > > Basically, I cannot use > valgrind to debug the 32 bit code because it doesnt > take the same code path. How can I ensure that a given 32 bit x86 code > makes the same floating point calculations by itself as thru valgrind? Can anyone try and answer? Even if there's no way to ensure that the answers come out the same, I'd appreciate a definite response so I dont keep on a wild goose chase. saurabh _________________________________________________________________ Hotmail: Trusted email with powerful SPAM protection. https://signup.live.com/signup.aspx?id=60969 |
|
From: Dallman, J. <joh...@si...> - 2010-06-18 08:53:25
|
I don't have any trouble with FP math on 32-bit x86, but I take a different strategy from you. I set the x87 FP unit to use 64-bit doubles rather than 80-bit doubles, since that makes the results far more similar to 64-bit Linux, and other platforms that use 64-bit doubles. 32-bit Linux uses 80-bit evaluation on the x87 because that's the power-up default of the processor, and nobody changed it. The code for this I use is: #include <fpu_control.h> fpu_control_t desired = _FPU_DOUBLE | _FPU_RC_NEAREST ; _FPU_SETCW( desired); If you try this, drop those compiler options for using SSE and SSE2. best, -- John Dallman Parasolid Porting Engineer Siemens Product Lifecycle Management Software Industry Sector 46 Regent Street, Cambridge, CB2 1DP United Kingdom Tel: +44-1223-371554 joh...@si... www.siemens.com/plm > -----Original Message----- > From: Saurabh T [mailto:sa...@ho...] > Sent: Thursday, June 17, 2010 2:48 PM > To: ValgrindUsers > Subject: Re: [Valgrind-users] Different output from valgrind despite SSE > > > > > My x86 (ie. 32 bit) code was calculating numbers differently when run > > by itself (A) than when run thru valgrind (V). This is numerically > > intensive code so I'm certain the differences are in the floating > point > > calculations. I understood that this could be due to the differences > in > > floating point arithmetic (80-bit on its own vs 64-bit thru valgrind). > > > > So > > I rebuilt my entire code with -mfpmath=sse -msse2. This leads to > > different answers (B) when run on its own from before, but still they > > are different from valgrind (B != V). I recompiled valgrind with those > > options in CPPFLAGS but to no avail - this didnt change the valgrind > > output. > > > > Interestingly I also discovered that on x86_64, the > > answers from the program match exactly those from valgrind (and these > > are the same as from x86 valgrind = V). > > > > Basically, I cannot use > > valgrind to debug the 32 bit code because it doesnt > > take the same code path. How can I ensure that a given 32 bit x86 code > > makes the same floating point calculations by itself as thru valgrind? > > Can anyone try and answer? Even if there's no way to ensure that the > answers come out the same, I'd appreciate a definite response so I dont > keep on a wild goose chase. > > saurabh > > _________________________________________________________________ > Hotmail: Trusted email with powerful SPAM protection. > https://signup.live.com/signup.aspx?id=60969 > ------------------------------------------------------------------------ > ------ > ThinkGeek and WIRED's GeekDad team up for the Ultimate > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > lucky parental unit. See the prize list and enter to win: > http://p.sf.net/sfu/thinkgeek-promo > _______________________________________________ > Valgrind-users mailing list > Val...@li... > https://lists.sourceforge.net/lists/listinfo/valgrind-users |