|
From: Matthew B. <ma...@ma...> - 2004-01-15 14:26:57
|
I have a problem I am trying to debug via valgrind and I am seeing something really odd. I am getting a read from uninit error. ==11800== Use of uninitialised value of size 4 ==11800== at 0x80A6931: AddTemperature (c_part.c:2518) Looking at that line u->x += v_thermal*nu1*sqrt(-log(R2)/R2); I thought I would figure out which var is causing the problem, so I did this fubar = v_thermal; fubar *= nu1; fubar *=R2; fubar = u->x; fubar = v_thermal*nu1*sqrt(-log(R2)/R2); None of these report uninited vars. so I am guessing there is something odd happening with valgrind. I have compiled the code as follows mpicc -I/usr/local/mpich/include -I../mp -DLINUX -DMPICH -DBITFLAGS -g -Wimplicit -Wall -pedantic -Wno-long-long -c -o VT.o VT.c So, the compiler shouldn't be cutting out the useless code. I have tried this with both the 2.0.0 and 2.1.0 versions and get the same result. Any ideas would be helpful.. Thanks matt |
|
From: Olly B. <ol...@su...> - 2004-01-15 14:40:53
|
On Thu, Jan 15, 2004 at 07:24:20AM -0700, Matthew Bettencourt wrote:
> Looking at that line
> u->x += v_thermal*nu1*sqrt(-log(R2)/R2);
>
> I thought I would figure out which var is causing the problem, so I did this
> fubar = v_thermal;
> fubar *= nu1;
> fubar *=R2;
> fubar = u->x;
> fubar = v_thermal*nu1*sqrt(-log(R2)/R2);
>
>
> None of these report uninited vars. so I am guessing there is something
> odd happening with valgrind.
Are all these variables doubles or floats? Valgrind only tells you when
an uninitialised value is used in a way which can affect the program,
unless the value is floating point (in which case the problem is flagged
right away). This is done because a lot of legitimate code copies
uninitialised values (e.g. memcpy() of a structure complete with
uninitialised padding).
Cheers,
Olly
|
|
From: Tom H. <th...@cy...> - 2004-01-15 14:47:09
|
In message <400...@ma...>
Matthew Bettencourt <ma...@ma...> wrote:
> I have a problem I am trying to debug via valgrind and I am seeing
> something really odd. I am getting a read from uninit error.
>
> ==11800== Use of uninitialised value of size 4
> ==11800== at 0x80A6931: AddTemperature (c_part.c:2518)
>
> Looking at that line
> u->x += v_thermal*nu1*sqrt(-log(R2)/R2);
>
> I thought I would figure out which var is causing the problem, so I did this
> fubar = v_thermal;
> fubar *= nu1;
> fubar *=R2;
> fubar = u->x;
> fubar = v_thermal*nu1*sqrt(-log(R2)/R2);
Well those two code sequences aren't doing the same thing to start
with as you aren't adding u->x to the result of the multiplications
in the second one.
An easier way to find out what is uninitialised would be to add in
some client requests before calculation, like this:
VALGRIND_CHECK_DEFINED( u->x );
VALGRIND_CHECK_DEFINED( v_thermal );
VALGRIND_CHECK_DEFINED( nu1 );
VALGRIND_CHECK_DEFINED( R2 );
Then you should be able to tell from the report which of those lines
found uninitialised data.
> None of these report uninited vars. so I am guessing there is
> something odd happening with valgrind. I have compiled the code as
> follows
>
> mpicc -I/usr/local/mpich/include -I../mp -DLINUX -DMPICH -DBITFLAGS
> -g -Wimplicit -Wall -pedantic -Wno-long-long -c -o VT.o VT.c
>
> So, the compiler shouldn't be cutting out the useless code. I have
> tried this with both the 2.0.0 and 2.1.0 versions and get the same
> result. Any ideas would be helpful..
What's mpicc? Is it some special compiler that will be using SSE ops
and such like to do the calculation?
Tom
--
Tom Hughes (th...@cy...)
Software Engineer, Cyberscience Corporation
http://www.cyberscience.com/
|
|
From: Matthew B. <ma...@ma...> - 2004-01-15 15:02:15
|
I understand the math was different but I didn't care because I didn't use the final var. However, our suggestion of the VALGRIND_CHECK_DEFINED( v_thermal ); found my problem which is a good bit of info... (I have used my brute force approach before and it worked in the past but this is much better) As for your final question, mpicc is the message passing interface compiler, However, it just add include paths and libs to the standard compile line which uses, in this case, gcc-3.2 in the backend Thanks again for the info, valgrind has saved me soo much time over the last year since I discovered it. Matt Tom Hughes wrote: > In message <400...@ma...> > Matthew Bettencourt <ma...@ma...> wrote: > > >>I have a problem I am trying to debug via valgrind and I am seeing >>something really odd. I am getting a read from uninit error. >> >>==11800== Use of uninitialised value of size 4 >>==11800== at 0x80A6931: AddTemperature (c_part.c:2518) >> >>Looking at that line >> u->x += v_thermal*nu1*sqrt(-log(R2)/R2); >> >>I thought I would figure out which var is causing the problem, so I did this >> fubar = v_thermal; >> fubar *= nu1; >> fubar *=R2; >> fubar = u->x; >> fubar = v_thermal*nu1*sqrt(-log(R2)/R2); > > > Well those two code sequences aren't doing the same thing to start > with as you aren't adding u->x to the result of the multiplications > in the second one. > > An easier way to find out what is uninitialised would be to add in > some client requests before calculation, like this: > > VALGRIND_CHECK_DEFINED( u->x ); > VALGRIND_CHECK_DEFINED( v_thermal ); > VALGRIND_CHECK_DEFINED( nu1 ); > VALGRIND_CHECK_DEFINED( R2 ); > > Then you should be able to tell from the report which of those lines > found uninitialised data. > > >>None of these report uninited vars. so I am guessing there is >>something odd happening with valgrind. I have compiled the code as >>follows >> >> mpicc -I/usr/local/mpich/include -I../mp -DLINUX -DMPICH -DBITFLAGS >>-g -Wimplicit -Wall -pedantic -Wno-long-long -c -o VT.o VT.c >> >>So, the compiler shouldn't be cutting out the useless code. I have >>tried this with both the 2.0.0 and 2.1.0 versions and get the same >>result. Any ideas would be helpful.. > > > What's mpicc? Is it some special compiler that will be using SSE ops > and such like to do the calculation? > > Tom > |