OpenMP设置全局共享默认值 [英] OpenMP Set Global Sharing Default

查看:630
本文介绍了OpenMP设置全局共享默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以告诉OpenMP不要在并行区域内默认共享变量,通过使用

  #pragma omp并行默认none 

但是有没有办法全局设置呢?看起来好像全局默认是,所有未声明为私有的都是共享的,至少在我的应用程序中,还有更多的东西应该是私有的,应该共享。



谢谢!

解决方案

OpenMP中的所有变量默认都是共享的。如果你想要一组私有变量,你需要在一个private子句中的并行pragma指令中指定这些变量。如果您使用

  #pragma omp parallel default无

您需要指定私有变量和共享变量。例如:

  #pragma omp并行默认(无)私有(i,j)共享(a,b)

参考文献:



[1] http://en.wikipedia.org/wiki/OpenMP#OpenMP_clauses



[2] https://computing.llnl.gov/tutorials/openMP/#Clauses指令


I know I can tell OpenMP not to share variables by default within a parallel region by using

#pragma omp parallel default none

But is there a way to set this globally? It seems as though the global default is that everything that isn't declared private is shared, and, at least in my application, there are many more things that should be private than should be shared.

Thanks!

解决方案

All variables in OpenMP are shared by default. If you want a set of private variables you will need to specify these variables in a parallel pragma directive in a private clause. If you use

#pragma omp parallel default none

You need to specify the private variables and shared variables. For instance:

#pragma omp parallel default(none) private(i,j) shared(a,b) 

References:

[1] http://en.wikipedia.org/wiki/OpenMP#OpenMP_clauses

[2] https://computing.llnl.gov/tutorials/openMP/#ClausesDirectives

这篇关于OpenMP设置全局共享默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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