Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
644 Discussions

GCC thread sanitizer and MKL with Intel OpenMP

paul_f
New Contributor I
212 Views

I got redirected here from the Intel® oneAPI Math Kernel Library forum.

 

Is thread sanitizer supposed to work with Intel OpenMP?

 

I get thousands of errors. Possibly genuine errors as our code is old and has just about never been tested for thread hazards. We're using GCC 5.3 and GCC 13.2. Using the Intel compilers isn't really an option at the moment (it's a fairly big project and we have to integrate with several other projects).

 

One of my coleagues and myself have been investigating. He's been trying to use LLVM OpenMP (which I believe Intel OpenMP is based on) and is starting to get things to work when LLVM OpenMP is built for thread sanitizer.

0 Kudos
2 Replies
Alex_Y_Intel
Moderator
70 Views

Can you please provide a reproducer to demonstrate what you're trying to achieve? 
Just based on your description and limited information--it might work, since GCC sanitizer is ported from LLVM, it should be similar to LLVM sanitizer in Intel compiler. If you give it a try and see any errors, you can give us more information on what the errors are. 

0 Kudos
paul_f
New Contributor I
33 Views

Our product is huge so I can't reproduce anything from that.

 

I can reproduce errors with one of the Valgrind DRD tests.

https://sourceware.org/git/?p=valgrind.git;a=blob;f=drd/tests/omp_matinv.c;h=cd402ab0f4e9f3917bdf9cb74381e1946137bc74;hb=HEAD

 

I know that this test should run cleanly.

 

If I compile it with

gcc -g -o test omp_matinv.c -fopenmp -fsanitize=thread -Wl,--as-needed -L/path/to/lib/Linux_x86_64 -liomp5 -pthread -lm -Wl,-rpath,/path/to/lib/Linux_x86_64

And run it with

./test -t 15 -q 30

 

That gives me 8 data races like

WARNING: ThreadSanitizer: data race (pid=441552)
Read of size 8 at 0x7da000004598 by main thread:
#0 gj /home/paulf/test/omp_matinv.c:188 (test+0x000000401a8d)
#1 invert_matrix /home/paulf/test/omp_matinv.c:238 (test+0x000000401d88)
#2 main /home/paulf/test/omp_matinv.c:327 (test+0x00000040217f)

Previous write of size 8 at 0x7da000004598 by thread T1:
#0 gj._omp_fn.1 /home/paulf/test/omp_matinv.c:220 (test+0x000000402716)
#1 __kmp_invoke_microtask <null> (libiomp5.so+0x0000000b0d12)

 

I get similar things with both GCC 5.3 and 13.2.

0 Kudos
Reply