<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - OpenMP: default(none) implementation is standard-incompliant."
href="https://bugs.llvm.org/show_bug.cgi?id=40397">40397</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>OpenMP: default(none) implementation is standard-incompliant.
</td>
</tr>
<tr>
<th>Product</th>
<td>OpenMP
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Clang Compiler Support
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>lebedev.ri@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Initially was <a href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88967">https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88967</a>
<a href="https://godbolt.org/z/8WHddH">https://godbolt.org/z/8WHddH</a>
void foo(int *x);
void test1(int * const begin, const int len) {
#pragma omp parallel default(none)
#pragma omp for
for(int x = 0; x < len; x++)
foo(begin + x);
}
gcc 8.2, clang trunk is ok with that code.
gcc trunk says:
<source>: In function 'void test1(int*, int)':
<source>:5:9: error: 'len' not specified in enclosing 'parallel'
5 | #pragma omp for
| ^~~
<source>:4:9: error: enclosing 'parallel'
4 | #pragma omp parallel default(none)
| ^~~
<source>:7:9: error: 'begin' not specified in enclosing 'parallel'
7 | foo(begin + x);
| ^~~~~
<source>:4:9: error: enclosing 'parallel'
4 | #pragma omp parallel default(none)
| ^~~
Compiler returned: 1
Since 'default(none)' is specified, i fail to see how they are not specified..
I'm also not really seeing the reasoning in the openmp 4.0 "2.14.3.1 default
clause".
Did this change in newer openmp versions?
Reply from Jakub Jelinek:
It indeed changed, already in OpenMP 4.0 actually, but I've been long hoping
that the change will be reverted in later OpenMP standards, in the end that is
not what is going to happen.
OpenMP 3.1 and earlier had:
"Variables with const-qualified type having no mutable member are shared."
among the predetermined data sharing of variables for C/C++, and
"Variables with const-qualified type having no mutable member may be listed in
a
C/C++ firstprivate clause."
as an exception to the rule that variables with predetermined data sharing may
not be specified in OpenMP data sharing clauses.
That is gone in OpenMP 4.0, these variables are not predetermined anymore, so
with default(none) they must be specified in data sharing clauses if they are
referenced in the region. They can be specified in both shared and
firstprivate clauses now, e.g. lastprivate/reduction/linear aren't suitable
because they all need to write into the variable. If you want to write code
that will work with both OpenMP 3.1 and OpenMP 4.0+ (including 5.0, which
hasn't changed in this area), you need to use firstprivate(begin, len) in your
example, that used to be valid in OpenMP 3.1 due to the above exception and
keeps to be valid now.
I've asked the ifort/clang maintainers about why they keep violating the
standard, but haven't heard back from them. And I must say I was trying hard
to readd the above rule + exception, but haven't succeeded.
The exact wording why the above needs to be refused is:
"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."
As it is not predetermined (anymore) and is not explicitly determined either,
it violates the requirement above.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>