[Bug middle-end/106504] New: [OpenMP] 'for simd linear(i:1)' should be rejected with 'parallel private(i)'
burnus at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Aug 2 11:02:12 GMT 2022
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106504
Bug ID: 106504
Summary: [OpenMP] 'for simd linear(i:1)' should be rejected
with 'parallel private(i)'
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Keywords: accepts-invalid, diagnostic, openmp
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: burnus at gcc dot gnu.org
CC: jakub at gcc dot gnu.org
Target Milestone: ---
The following program is a bit odd – and prints at runtime 10 for one thread –
and 6 for all others.
And I believe it is invalid for the reason given below:
Pre-remark: the 'for simd' directive has a predetermined 'linear(i:1)',
which can also be explicitly be specified without affecting the program.
------------------------------------
#include <stdio.h>
int main()
{
int i;
#pragma omp parallel private (i)
{
i = 6;
#pragma omp for simd
for (i = 1; i < 10; i++)
;
printf ("%i\n", i);
}
return 0;
}
----------------------------------
I think the following applies:
"17.2 Clauses on Combined and Composite Constructs"
"If a list item of the linear clause is the iteration variable of a *simd* or
worksharing-loop SIMD construct and it is not declared in the construct, the
effect on the outer leaf constructs is as if the list item was specified in a
*lastprivate* clause on the combined or composite construct with the rules
specified above applied."
And:
"Restrictions to the *lastprivate* clause are as follows:
* A list item must not appear in a *lastprivate* clause on a work-distribution
construct if the corresponding region binds to the region of a
parallelism-generating construct in which the list item is private."
More information about the Gcc-bugs
mailing list