我可以使用线程消毒剂对OpenMP程序? [英] Can I use Thread Sanitizer for OpenMP programs?

查看:156
本文介绍了我可以使用线程消毒剂对OpenMP程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请看下面的例子:

#include <iostream> 

int main () {
    int i = 0;
    #pragma omp parallel
    {
        #pragma omp critical
        {
            ++i;
        }
    }
    std::cout << i;
}

G ++ -fopenmp -fsanitize =线程编译和运行率

警告:ThreadSanitizer:数据竞争(PID = 9576)结果
      阅读大小4中的0x7ffdc170f600按线程T1:结果
      #0 main._omp_fn.0(a.out的+ 0x000000400d20)结果
      #1 gomp_thread_start /build/gcc/src/gcc-5.2.0/libgomp/team.c:118(libgomp.so.1 + 0x00000000f42d)

WARNING: ThreadSanitizer: data race (pid=9576)
Read of size 4 at 0x7ffdc170f600 by thread T1:
#0 main._omp_fn.0 (a.out+0x000000400d20)
#1 gomp_thread_start /build/gcc/src/gcc-5.2.0/libgomp/team.c:118 (libgomp.so.1+0x00000000f42d)

previous在0x7ffdc170f600大小4的写入由线程T2:结果
      #0 main._omp_fn.0(a.out的+ 0x000000400d35)结果
      #1 gomp_thread_start /build/gcc/src/gcc-5.2.0/libgomp/team.c:118(libgomp.so.1 + 0x00000000f42d)

Previous write of size 4 at 0x7ffdc170f600 by thread T2:
#0 main._omp_fn.0 (a.out+0x000000400d35)
#1 gomp_thread_start /build/gcc/src/gcc-5.2.0/libgomp/team.c:118 (libgomp.so.1+0x00000000f42d)

位置是栈主线程。

主题T1(TID = 9578,运行)
      #0 pthread_create的/build/gcc/src/gcc-5.2.0/libsanitizer/tsan/tsan_interceptors.cc:895(libtsan.so.0 + 0x000000027a37)结果
      #1 gomp_team_start /build/gcc/src/gcc-5.2.0/libgomp/team.c:796(libgomp.so.1 + 0x00000000f98f)结果
      #2 __libc_start_main(libc.so.6的+ 0x00000002060f)

Thread T1 (tid=9578, running) created by main thread at:
#0 pthread_create /build/gcc/src/gcc-5.2.0/libsanitizer/tsan/tsan_interceptors.cc:895 (libtsan.so.0+0x000000027a37)
#1 gomp_team_start /build/gcc/src/gcc-5.2.0/libgomp/team.c:796 (libgomp.so.1+0x00000000f98f)
#2 __libc_start_main (libc.so.6+0x00000002060f)

主题T2(TID = 9579,运行)
      #0 pthread_create的/build/gcc/src/gcc-5.2.0/libsanitizer/tsan/tsan_interceptors.cc:895(libtsan.so.0 + 0x000000027a37)结果
      #1 gomp_team_start /build/gcc/src/gcc-5.2.0/libgomp/team.c:796(libgomp.so.1 + 0x00000000f98f)结果
      #2 __libc_start_main(libc.so.6的+ 0x00000002060f)

Thread T2 (tid=9579, running) created by main thread at:
#0 pthread_create /build/gcc/src/gcc-5.2.0/libsanitizer/tsan/tsan_interceptors.cc:895 (libtsan.so.0+0x000000027a37)
#1 gomp_team_start /build/gcc/src/gcc-5.2.0/libgomp/team.c:796 (libgomp.so.1+0x00000000f98f)
#2 __libc_start_main (libc.so.6+0x00000002060f)

摘要:ThreadSanitizer:数据争??:0 main._omp_fn.0

SUMMARY: ThreadSanitizer: data race ??:0 main._omp_fn.0

据我所看到的,这是一个假阳性。有没有办法避免这种情况?

As far as I can see, this is a false positive. Is there a way to avoid this?

(有什么铿锵和libomp工作将被罚款了。)

(Something working with clang and libomp would be fine too.)

推荐答案

甚至与SUP pression你仍然会得到OpenMP运行时的误报,因为有运行中的一些同步机制,赞不能明白了。

even with the suppression you will still get false positives on the OpenMP runtime because there are some synchronization mechanism within the runtime that Tsan is not able to understand.

我们制作的OpenMP运行时,使赞理解这个同步点,并删除所有的误报。

We worked on the OpenMP runtime to make Tsan understand this synchronization points and remove all the false positives.

看看这个项目:

https://github.com/PRUNER/archer

让我知道如果你需要更多的帮助。

Let me know if you need more help.

最好的,

西蒙娜

这篇关于我可以使用线程消毒剂对OpenMP程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆