如何全局将default子句设置为none? [英] How to globally set the default clause to none?

查看:378
本文介绍了如何全局将default子句设置为none?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以告诉OpenMP在默认情况下不要在并行区域内共享变量

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.

推荐答案

默认情况下,OpenMP中的所有变量都是共享的.如果要一组私有变量,则需要在private子句的并行编译指示中指定这些变量.如果您使用

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) 

参考文献:

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

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

这篇关于如何全局将default子句设置为none?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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