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

Reply via email to