About default(none) and shared() directives

General OpenMP discussion
Forum rules
The OpenMP Forums are now closed to new posts. Please visit Stack Overflow if you are in need of help: https://stackoverflow.com/questions/tagged/openmp
Posts: 15
Joined: Fri May 11, 2012 1:47 am

About default(none) and shared() directives

Post by jgpallero »


First of all I should say that although I used OpenMP for a long time I stopped programming for a while and now I've returned, so I'm a bit rusty. This is the reason of my question.

Some time ago this piece of code was correct:

Code: Select all

int function(const int* list,const int N)
    int i=0,sum=0
#pragma omp parallel for default(none) shared(list) private(i) reduction(+:sum)
        sum += list[i];
    return sum;
Using GCC the code compiled the last time I did it without errors nor warnings. As it can be seen, although the default(none) directive was used, if a variable coming from a function argument was declared as const, it was not mandatory to declare it explicitly as shared(), but if the variable was a pointed its inclusion in the shared() clause it was mandatory.

But today I've tried to compile such an example using GCC 9.3 in Debian, which I think it uses OpenMP 5.0, and the compiler emits an error related to the variable N is not explicitly declared in shared(). So the question is if it the behavior was changed in the new OpenMP standards and now all king of variables must be declared explicitly in shared() when default(none) is used


Posts: 808
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh

Re: About default(none) and shared() directives

Post by MarkB »

I don't believe anything has changed in the standard - I guess that GCC just got better at picking up errors!