public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/106662] New: [OpenMP] 'for simd firstprivate(j) lastprivate(j)' with 'parallel shared(j)' gives unexpected result
@ 2022-08-17  9:00 burnus at gcc dot gnu.org
  0 siblings, 0 replies; only message in thread
From: burnus at gcc dot gnu.org @ 2022-08-17  9:00 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106662
           Summary: [OpenMP] 'for simd firstprivate(j) lastprivate(j)'
                    with 'parallel shared(j)' gives unexpected result
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: openmp, wrong-code
          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, sandra at gcc dot gnu.org
  Target Milestone: ---

[Lightly related to PR106504 - but that one uses 'parallel private' not
shared.]

The following program, converted to C++ from libgomp.fortran/pr27416-1.f90
and with 'simd' added to the workshare-loop construct,
yields:

* 22 with 'for' - i.e. the existing Fortran testcase, but C++-ified.
and independent of 'num_threads(1)'
* 22 with clang++-12
* 22 with icc 19
while
* 16 is obtained with GCC
  (as if 0 and not 6 is firstprivatized)


int
main()  
{       
  int j = 6;
  #pragma omp parallel num_threads (4) shared(j)
  {     
    int i;
    #pragma omp for simd firstprivate (j) lastprivate (j) // private(i)
    for (i = 1; i <= 16; ++i)
      if (i == 16)
        j = j + i;
  }     
  __builtin_printf("j = %i =?= %i\n", j, 6+16);
  if (j != 6+16)
    __builtin_abort();
  return 0;
}

Likewise with a combined construct:
  ...
  #pragma omp parallel for simd num_threads (4) firstprivate (j) lastprivate
(j)
    for (int i = 1; i <= 16; ++i)
  ...

And likewise with the equivalent Fortran code.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-08-17  9:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-17  9:00 [Bug middle-end/106662] New: [OpenMP] 'for simd firstprivate(j) lastprivate(j)' with 'parallel shared(j)' gives unexpected result burnus 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).