Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/125.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 线程\u本地是否适用于OpenMP线程?_C++_Openmp_Thread Local Storage - Fatal编程技术网

C++ 线程\u本地是否适用于OpenMP线程?

C++ 线程\u本地是否适用于OpenMP线程?,c++,openmp,thread-local-storage,C++,Openmp,Thread Local Storage,如果我使用thread\u local int x=0,每个OpenMP线程会看到自己的x实例吗?因为在中搜索thread\u local没有找到任何东西,我想没有,但很高兴听到其他消息 如果不能保证,是否可以将其与threadprivateas组合使用 thread_local int x = 0; #pragma omp threadprivate(x) 还是我需要类似的东西 #ifdef USE_OPENMP int x = 0; #pragma omp threadprivate(x)

如果我使用
thread\u local int x=0
,每个OpenMP线程会看到自己的
x
实例吗?因为在中搜索
thread\u local
没有找到任何东西,我想没有,但很高兴听到其他消息

如果不能保证,是否可以将其与
threadprivate
as组合使用

thread_local int x = 0;
#pragma omp threadprivate(x)
还是我需要类似的东西

#ifdef USE_OPENMP
int x = 0;
#pragma omp threadprivate(x)
#else
thread_local int x = 0;
#endif
相反

编辑:High Performance Mark在评论中给出了5.1草案的链接,其中写道

出现在
threadprivate
指令中的变量或带有
\u Thread\u local
(在C++中)或
Thread\u local
(在C++中)存储类说明符的变量是threadprivate


没有一个答案会比勾选“保证”更好。如果某些东西在我的机器上工作,对于特定的编译器版本,等等,并不意味着它一般都能工作。@HighPerformanceMark很棒,谢谢!没有一个答案会比勾选“保证”更好。如果某些东西在我的机器上工作,对于特定的编译器版本,等等,并不意味着它一般都能工作。@HighPerformanceMark很棒,谢谢!