This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/59616] New: OpenMP standard conflict in parallel default clause
- From: "beamesleach at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 28 Dec 2013 19:36:43 +0000
- Subject: [Bug c/59616] New: OpenMP standard conflict in parallel default clause
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59616
Bug ID: 59616
Summary: OpenMP standard conflict in parallel default clause
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: beamesleach at gmail dot com
Created attachment 31528
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31528&action=edit
MWE exhibiting error in gcc's OMP predetermined sharing
I'm trying to get OpenMP directives to work under both GCC and Intel compilers,
but I've found a conflict, when using `default(none)` on an `omp parallel for`
directive.
I've been reading through relevant sections of the OpenMP 4.0 standard and I
haven't managed to pick out any obvious contradiction in the compilers'
behaviours, but I think the below compiler error makes the least sense and
might also be the easiest to fix:
$ gcc-4.8 test_ompmin.c -o omp -fopenmp -std=c99
test_ompmin.c:15:68: error: 'b' is predetermined 'shared' for 'shared'
# pragma omp parallel for schedule(static) default(none) shared(a,b,c)
^
test_ompmin.c is attached - a minimal working example designed to test out this
behaviour.
What's interesting, is g++ does not raise this error, only gcc. Neither do icc
or icpc raise the error; these both exhibit the same behaviour as g++ (they
compile test_ompmin.c fine, but raise an error if `b` is omitted from the
`shared` clause). I'm inclined to surmise that this is a bug in gcc's
implementation, as there are no relevant differences between C and C++ in the
OpenMP specification.
Compile commands that succeed:-
> g++-4.8 test_ompmin.c -o omp-gxx -fopenmp
> icc test_ompmin.c -o omp-icc -openmp -std=c99
> icpc test_ompmin.c -o omp-icpc -openmp
---------------------------------------------
GCC versions tested:
Mac OS X (Mavericks)
gcc 4.8.2 (built with Homebrew)
Linux 2.6.35 (Fedora 14)
gcc 4.5.1 (x86_64-redhat-linux)
---------------------------------------------
Below are sections I copied from the OpenMP specification (v4.0.0) that look
relevant:
2.14.1.1 - Data-sharing Attribute Rules for Variables Referenced in a Construct
===============================================================================
Certain variables and objects have predetermined data-sharing attributes as
follows:
C/C++
-----
- Objects with dynamic storage duration are shared.
- [ nothing specifically mentioning const variables... ]
Variables with predetermined data-sharing attributes may not be listed in
data-sharing attribute clauses, except for the cases listed below. For these
exceptions only, listing a predetermined variable in a data-sharing attribute
clause is allowed and overrides the variable's predetermined data-sharing
attributes.
- [...]
- Variables with `const`-qualified type having no mutable member may be
listed in a `firstprivate` clause, even if they are static data members.
2.14.3 - Data-Sharing Atribute Clauses
======================================
2.14.3.1 - `default` clause
---------------------------
The `default` clause explicitly determines the data-sharing attributes of
variables that are referenced in a `parallel`, `task` or `teams` construct and
would otherwise be implicitly determined.
The `default(none)` clause requires that each variable that is referenced in
the
construct, and that does not have a predetermined data-sharing attribute, must
have its data-sharing attribute explicitly determined by being listed in a
data-sharing attribute clause.
2.14.3.2 - `shared` clause
--------------------------
The `shared` clause declares one or more list items to be shared by tasks
generated by a `parallel`, `task` or `teams` construct.