public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/106504] New: [OpenMP] 'for simd linear(i:1)' should be rejected with 'parallel private(i)'
@ 2022-08-02 11:02 burnus at gcc dot gnu.org
  2022-08-10  7:40 ` [Bug middle-end/106504] " jakub at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: burnus at gcc dot gnu.org @ 2022-08-02 11:02 UTC (permalink / raw)
  To: gcc-bugs

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."

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug middle-end/106504] [OpenMP] 'for simd linear(i:1)' should be rejected with 'parallel private(i)'
  2022-08-02 11:02 [Bug middle-end/106504] New: [OpenMP] 'for simd linear(i:1)' should be rejected with 'parallel private(i)' burnus at gcc dot gnu.org
@ 2022-08-10  7:40 ` jakub at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-08-10  7:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106504

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
There have been discussions about this in several F2Fs.
For linear it is desirable to allow private outer var because linear
is the implicit behavior of simd iterators and people want to be able to use
them
even if they are private outer (say even simple
void foo (int *a) { int i;
#pragma omp simd
for (i = 0; i < 16; i++)
a[i] = i;
}
would be then invalid).
Some people wanted to just drop the requirements even for lastprivate etc.
(silently not assign to outer var).

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-10  7:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-02 11:02 [Bug middle-end/106504] New: [OpenMP] 'for simd linear(i:1)' should be rejected with 'parallel private(i)' burnus at gcc dot gnu.org
2022-08-10  7:40 ` [Bug middle-end/106504] " jakub at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).