How to globally set the default clause to none?

2019-01-28 02:44发布

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.

1条回答
放荡不羁爱自由
2楼-- · 2019-01-28 03:46

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

查看更多
登录 后发表回答