Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
311 views
in Technique[技术] by (71.8m points)

c++ - How to globally set the default clause to none?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...