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

Categories

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

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

1 Answer

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...