public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/100059] New: [OpenMP] wrong code with 'declare target link' and a scalar variable
@ 2021-04-13  8:58 burnus at gcc dot gnu.org
  2021-04-13 13:16 ` [Bug middle-end/100059] " burnus at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-04-13  8:58 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100059
           Summary: [OpenMP] wrong code with 'declare target link' and a
                    scalar variable
           Product: gcc
           Version: 11.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
  Target Milestone: ---
            Target: nvptx-none

Created attachment 50578
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50578&action=edit
Testcase, compile with 'gcc -fopenmp' with an (nvptx) offloading enabled
compiler

The attached testcase has four global vars:
  int a[N], b[N], c[N];
  int i = 0;

which are used with:

  #pragma omp declare target link(a,c,b,i)  

and

  #pragma omp target map(to: i) map(tofrom: a, b, c) 
    update();

After the call, the one array is not updated but has the previous host value:
* For 'declare target link(a,c,b,i)': not updated array is 'b'
* For 'declare target link(a,b,c,i)': not updated array is 'c'

Namely, the testcase shows:
i=5: A=5, B=6, C=7    // Original host value
i=5: A=6, B=6, C=10   // target call to 'update': 'B' is not updated
i=5: A=7, B=8, C=13   // host update, OK


Additionally, when using 'for (int i' in 'update': The error only shows up if
there is 'i'
And it occurs for the item before 'i', namely:
  link(a,c,b,i) → 'b' is wrong
  link(a,c,i,b) → 'c' is wrong


The issue occurs with nvptx. It works without offloading and I think it works
with GCN (did not show up in the test logs, but I have not manually verified).

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

end of thread, other threads:[~2023-09-04 12:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-13  8:58 [Bug middle-end/100059] New: [OpenMP] wrong code with 'declare target link' and a scalar variable burnus at gcc dot gnu.org
2021-04-13 13:16 ` [Bug middle-end/100059] " burnus at gcc dot gnu.org
2021-04-13 13:37 ` burnus at gcc dot gnu.org
2021-04-13 14:11 ` burnus at gcc dot gnu.org
2021-04-13 16:39 ` burnus at gcc dot gnu.org
2022-03-29 10:23 ` burnus at gcc dot gnu.org
2023-09-04  9:37 ` tschwinge at gcc dot gnu.org
2023-09-04 12:57 ` [Bug other/100059] " tschwinge 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).