Dear users,
I have some questions regarding my code and checking it with helgrind.
I'm using valgrind-3.5.0, g++ (SUSE Linux) 4.4.1 [gcc-4_4-branch
revision 150839] on openSuse 11.2 (x86_64).
here is some piece of code I tested with helgrind:
unsigned const nSH_min = lMin*lMin;
// ... some code ...
292:#pragma omp parallel for shared(noiseAmpSH,noiseAmpxyz,positions,
norm, coord),private(l,m, nSH,result, p, vesh)
293: for (unsigned n=0; n<numRows; n++){
294: nSH=n+nSH_min;
295: l=static_cast<unsigned>(floor(sqrt(nSH)));
296: m=nSH-l*(l+1);
297: // Create vector spherical harmonic object.
298: vesh = new VectorExteriorSphericalHarmonics(l,m,6371.2);
299: vesh->normalize(norm, 1.0);
300:
301: for (unsigned j=0; j<numPos; j++){
302: p = (*positions)[j];
303: // calculate Gradient
304: vesh->evaluate(p, coord, result);
305: result = (*noiseAmpSH)[n]*result;
306:#pragma omp critical
307: {
308: ((*noiseAmpxyz)[j])[0]+=result[0];
309: ((*noiseAmpxyz)[j])[1]+=result[1];
310: ((*noiseAmpxyz)[j])[2]+=result[2];
311: } // omp critical
312: } // for (j...)
313:
314: delete vesh;
315: } // for (n...)
I attached the complete logfile but there are two major questions I
want to ask and point to the corresponding log-output:
1)
==29368== Possible data race during write of size 8 at 0x7feffddc0 by thread #2
==29368== at 0x4C289B9: ??? (in
/usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368== This conflicts with a previous read of size 8 by thread #1
==29368== at 0x4C288AD: ??? (in
/usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x4C2893C: pthread_create@* (in
/usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x68F6C69: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x406CBC: main (cmpNoiseAmp.cpp:292)
==29368==
How can there be a data race when the parallel region is opened? What
happens in line 292 that can create such thing?
2)
==29368== Possible data race during read of size 8 at 0x749bfb8 by thread #1
==29368== at 0x403574: main.omp_fn.0 (cmpNoiseAmp.cpp:308)
==29368== by 0x406CC4: main (cmpNoiseAmp.cpp:292)
==29368== This conflicts with a previous write of size 8 by thread #2
==29368== at 0x40357F: main.omp_fn.0 (cmpNoiseAmp.cpp:308)
==29368== by 0x68F6871: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x4C289C5: ??? (in
/usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368==
I put the write-statement in line 308-310 in a critical section. How
can there be a data race? The variable noiseAmpxyz is the only shared
avriable that is written to (as far as I can see it).
I appreciate any comments and suggestions.
Kind regards,
Reyko Schachtschneider
--
GMX DSL Doppel-Flat ab 19,99 Euro/mtl.! Jetzt mit
gratis Handy-Flat! http://portal.gmx.net/de/go/dsl
==29368== Helgrind, a thread error detector
==29368== Copyright (C) 2007-2009, and GNU GPL'd, by OpenWorks LLP et al.
==29368== Using Valgrind-3.5.0 and LibVEX; rerun with -h for copyright info
==29368== Command: ./cmpNoiseAmp --datadir=/home/rschacht/Data/ErrorDistribution/DataSource/Vector/SVD --outputdir=/home/rschacht/Data/ErrorDistribution/NoiseAmp/Ellipse --centerdist=35 --griddir=/home/rschacht//Data/Grids/Icosahedron/Elliptical --cutoff=346 --geometry=2 --majoraxis=3750 --minoraxis=3750
==29368== Parent PID: 29367
==29368==
==29368== Thread #2 was created
==29368== at 0x6FFFE8E: clone (in /lib64/libc-2.10.1.so)
==29368== by 0x6D198B3: T.101 (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6D19DCB: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.10.1.so)
==29368== by 0x4C28899: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x4C2893C: pthread_create@* (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x68F6C69: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x406CBC: main (cmpNoiseAmp.cpp:292)
==29368==
==29368== Thread #1 is the program's root thread
==29368==
==29368== Possible data race during write of size 8 at 0x7feffddc0 by thread #2
==29368== at 0x4C289B9: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368== This conflicts with a previous read of size 8 by thread #1
==29368== at 0x4C288AD: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x4C2893C: pthread_create@* (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x68F6C69: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x406CBC: main (cmpNoiseAmp.cpp:292)
==29368==
==29368== Possible data race during read of size 8 at 0x7feffddc0 by thread #1
==29368== at 0x4C288BB: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x4C2893C: pthread_create@* (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x68F6C69: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x406CBC: main (cmpNoiseAmp.cpp:292)
==29368== This conflicts with a previous write of size 8 by thread #2
==29368== at 0x4C289B9: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368==
==29368== Thread #4 was created
==29368== at 0x6FFFE8E: clone (in /lib64/libc-2.10.1.so)
==29368== by 0x6D198B3: T.101 (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6D19DCB: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.10.1.so)
==29368== by 0x4C28899: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x4C2893C: pthread_create@* (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x68F6C69: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x406CBC: main (cmpNoiseAmp.cpp:292)
==29368==
==29368== Possible data race during write of size 4 at 0x7494ea0 by thread #1
==29368== at 0x68F7DF3: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x68F6CAC: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x406CBC: main (cmpNoiseAmp.cpp:292)
==29368== This conflicts with a previous read of size 4 by thread #4
==29368== at 0x68F7EAD: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x68F6863: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x4C289C5: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368==
==29368== Possible data race during write of size 4 at 0x7494e64 by thread #1
==29368== at 0x68F7DFC: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x68F6CAC: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x406CBC: main (cmpNoiseAmp.cpp:292)
==29368== This conflicts with a previous read of size 4 by thread #4
==29368== at 0x68F7EA0: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x68F6863: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x4C289C5: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368==
==29368== Possible data race during read of size 4 at 0x7494e64 by thread #2
==29368== at 0x68F7DB8: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x68F6863: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x4C289C5: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368== This conflicts with a previous write of size 4 by thread #1
==29368== at 0x68F7DFC: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x68F6CAC: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x406CBC: main (cmpNoiseAmp.cpp:292)
==29368==
==29368== Possible data race during read of size 8 at 0x749bfb8 by thread #1
==29368== at 0x403574: main.omp_fn.0 (cmpNoiseAmp.cpp:308)
==29368== by 0x406CC4: main (cmpNoiseAmp.cpp:292)
==29368== This conflicts with a previous write of size 8 by thread #2
==29368== at 0x40357F: main.omp_fn.0 (cmpNoiseAmp.cpp:308)
==29368== by 0x68F6871: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x4C289C5: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368==
==29368== Possible data race during write of size 8 at 0x749bfb8 by thread #1
==29368== at 0x40357F: main.omp_fn.0 (cmpNoiseAmp.cpp:308)
==29368== by 0x406CC4: main (cmpNoiseAmp.cpp:292)
==29368== This conflicts with a previous write of size 8 by thread #2
==29368== at 0x40357F: main.omp_fn.0 (cmpNoiseAmp.cpp:308)
==29368== by 0x68F6871: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x4C289C5: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368==
==29368== Possible data race during read of size 8 at 0x749bfc0 by thread #1
==29368== at 0x403590: main.omp_fn.0 (cmpNoiseAmp.cpp:309)
==29368== by 0x406CC4: main (cmpNoiseAmp.cpp:292)
==29368== This conflicts with a previous write of size 8 by thread #2
==29368== at 0x40359B: main.omp_fn.0 (cmpNoiseAmp.cpp:309)
==29368== by 0x68F6871: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x4C289C5: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368==
==29368== Possible data race during write of size 8 at 0x749bfc0 by thread #1
==29368== at 0x40359B: main.omp_fn.0 (cmpNoiseAmp.cpp:309)
==29368== by 0x406CC4: main (cmpNoiseAmp.cpp:292)
==29368== This conflicts with a previous write of size 8 by thread #2
==29368== at 0x40359B: main.omp_fn.0 (cmpNoiseAmp.cpp:309)
==29368== by 0x68F6871: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x4C289C5: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368==
==29368== Possible data race during read of size 8 at 0x749bfc8 by thread #1
==29368== at 0x4035A7: main.omp_fn.0 (cmpNoiseAmp.cpp:310)
==29368== by 0x406CC4: main (cmpNoiseAmp.cpp:292)
==29368== This conflicts with a previous write of size 8 by thread #2
==29368== at 0x4035B2: main.omp_fn.0 (cmpNoiseAmp.cpp:310)
==29368== by 0x68F6871: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x4C289C5: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368==
==29368== Possible data race during write of size 8 at 0x749bfc8 by thread #1
==29368== at 0x4035B2: main.omp_fn.0 (cmpNoiseAmp.cpp:310)
==29368== by 0x406CC4: main (cmpNoiseAmp.cpp:292)
==29368== This conflicts with a previous write of size 8 by thread #2
==29368== at 0x4035B2: main.omp_fn.0 (cmpNoiseAmp.cpp:310)
==29368== by 0x68F6871: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x4C289C5: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368==
==29368== Thread #3 was created
==29368== at 0x6FFFE8E: clone (in /lib64/libc-2.10.1.so)
==29368== by 0x6D198B3: T.101 (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6D19DCB: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.10.1.so)
==29368== by 0x4C28899: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x4C2893C: pthread_create@* (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x68F6C69: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x406CBC: main (cmpNoiseAmp.cpp:292)
==29368==
==29368== Possible data race during read of size 8 at 0x749bfb8 by thread #3
==29368== at 0x403574: main.omp_fn.0 (cmpNoiseAmp.cpp:308)
==29368== by 0x68F6871: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x4C289C5: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368== This conflicts with a previous write of size 8 by thread #1
==29368== at 0x40357F: main.omp_fn.0 (cmpNoiseAmp.cpp:308)
==29368== by 0x406CC4: main (cmpNoiseAmp.cpp:292)
==29368==
==29368== Possible data race during write of size 8 at 0x749bfb8 by thread #3
==29368== at 0x40357F: main.omp_fn.0 (cmpNoiseAmp.cpp:308)
==29368== by 0x68F6871: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x4C289C5: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368== This conflicts with a previous write of size 8 by thread #1
==29368== at 0x40357F: main.omp_fn.0 (cmpNoiseAmp.cpp:308)
==29368== by 0x406CC4: main (cmpNoiseAmp.cpp:292)
==29368==
==29368== Possible data race during read of size 8 at 0x749bfc0 by thread #3
==29368== at 0x403590: main.omp_fn.0 (cmpNoiseAmp.cpp:309)
==29368== by 0x68F6871: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x4C289C5: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368== This conflicts with a previous write of size 8 by thread #1
==29368== at 0x40359B: main.omp_fn.0 (cmpNoiseAmp.cpp:309)
==29368== by 0x406CC4: main (cmpNoiseAmp.cpp:292)
==29368==
==29368== Possible data race during write of size 8 at 0x749bfc0 by thread #3
==29368== at 0x40359B: main.omp_fn.0 (cmpNoiseAmp.cpp:309)
==29368== by 0x68F6871: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x4C289C5: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368== This conflicts with a previous write of size 8 by thread #1
==29368== at 0x40359B: main.omp_fn.0 (cmpNoiseAmp.cpp:309)
==29368== by 0x406CC4: main (cmpNoiseAmp.cpp:292)
==29368==
==29368== Possible data race during read of size 8 at 0x749bfc8 by thread #3
==29368== at 0x4035A7: main.omp_fn.0 (cmpNoiseAmp.cpp:310)
==29368== by 0x68F6871: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x4C289C5: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368== This conflicts with a previous write of size 8 by thread #1
==29368== at 0x4035B2: main.omp_fn.0 (cmpNoiseAmp.cpp:310)
==29368== by 0x406CC4: main (cmpNoiseAmp.cpp:292)
==29368==
==29368== Possible data race during write of size 8 at 0x749bfc8 by thread #3
==29368== at 0x4035B2: main.omp_fn.0 (cmpNoiseAmp.cpp:310)
==29368== by 0x68F6871: ??? (in /usr/lib64/libgomp.so.1.0.0)
==29368== by 0x4C289C5: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==29368== by 0x6D1965C: start_thread (in /lib64/libpthread-2.10.1.so)
==29368== by 0x6FFFECC: clone (in /lib64/libc-2.10.1.so)
==29368== This conflicts with a previous write of size 8 by thread #1
==29368== at 0x4035B2: main.omp_fn.0 (cmpNoiseAmp.cpp:310)
==29368== by 0x406CC4: main (cmpNoiseAmp.cpp:292)
==29368==
==29368==
==29368== More than 10000000 total errors detected. I'm not reporting any more.
==29368== Final error counts will be inaccurate. Go fix your program!
==29368== Rerun with --error-limit=no to disable this cutoff. Note
==29368== that errors may occur in your program without prior warning from
==29368== Valgrind, because errors are no longer being displayed.
==29368==
==29368==
==29368== For counts of detected and suppressed errors, rerun with: -v
==29368== Use --history-level=approx or =none to gain increased speed, at
==29368== the cost of reduced accuracy of conflicting-access information
==29368== ERROR SUMMARY: 10000000 errors from 17 contexts (suppressed: 0 from 0)
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users