[llvm-bugs] [Bug 39084] New: Fail to compile OpenMP array reduction

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 26 04:45:21 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=39084

            Bug ID: 39084
           Summary: Fail to compile OpenMP array reduction
           Product: OpenMP
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Clang Compiler Support
          Assignee: unassignedclangbugs at nondot.org
          Reporter: james.h.cownie at intel.com
                CC: llvm-bugs at lists.llvm.org

OpenMP 4.5 includes reductions on array sections, which should allow code like
this to work

int myroutine(double *a, double *sum, int n)
{
    int i;

#pragma omp for reduction(+:sum[:1])
    for(i=0;i<n;i++){
        sum[0] += a[i];
    }

    return 0;
}

However, clang objects to this because it cannot prove that *a is shared.
GCC however accepts it https://godbolt.org/z/4JwPYu , and it is useful. (See
https://stackoverflow.com/questions/52333881/is-it-possible-to-use-a-reduction-variable-from-a-passed-by-pointer-argument-ins/
for instance).

We should accept it as well. 
(There may be a clarification in OpenMP 5.0 that this should be legal. Even if
such a clarification is not forthcoming, not allowing it sees perverse.)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180926/4672c867/attachment.html>


More information about the llvm-bugs mailing list