On Wed, Mar 6, 2013 at 10:19 AM, <[email protected]> wrote:
[snip]
> Is this really true? I would expect that Valgrind does all calculations at
> 64bit double precision and converts. This will result in truncation and/or
> under/overflow.
>
> My feeling is that unless the usually small numerical differences change your
> control flow, then just ignore the differences. The aim of testing with
> Valgrind isn't to validate numerical results, it is to validate memory use or
> performance or threading.
Erm... the problem is that this can cause major issues in numerical
simulations... ;-((
Below is a small example (yes yes... I know it's not 100% portable...
it should use at least |LDBL_DECIMAL_DIG| ... but I'm not going to
twist my mind for that unless there is demand for it) for AMD64/64bit:
-- snip --
#include <math.h>
#include <limits.h>
#include <stdlib.h>
#include <stdio.h>
int main(int ac, char *av[])
{
long double i;
unsigned long long numiterations=0ULL;
puts("# start.");
for(i=1.L ; i < 1.00000000001L ; i=nextafterl(i, 5.L))
{
numiterations++;
}
printf("# done (after %llu/0x%llx iterations).\n",
numiterations, numiterations);
return EXIT_SUCCESS;
}
-- snip --
(this is more or less reduced from real-world simulation code which
uses |nextafterl()|&co. to iterate over some variations of the input
values to weed-out stuff like singularities etc.)
The expected output looks like this:
-- snip --
# start.
# done (after 92233720/0x57f5ff8 iterations)
-- snip --
On valgrind it just hangs (e.g. if you pass in a |double| casted to
|long double| into |nextafterl()|'s first argument and then cast the
|long double| result to |double| then the result is usually identical
to the input value... as result the algorithm is stuck in an endless
loop).
----
Bye,
Roland
--
__ . . __
(o.\ \/ /.o) [email protected]
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
endpoint security space. For insight on selecting the right partner to
tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users