[llvm-bugs] [Bug 46357] New: clang++ throws errors when the redefinition struct in user-defined reduction in CPP file

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 16 19:28:16 PDT 2020


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

            Bug ID: 46357
           Summary: clang++ throws errors when the redefinition struct in
                    user-defined reduction in CPP file
           Product: OpenMP
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Clang Compiler Support
          Assignee: unassignedclangbugs at nondot.org
          Reporter: yangzh.fnst at cn.fujitsu.com
                CC: llvm-bugs at lists.llvm.org

Hi,
This code throws errors when I use it in CPP file with clang++.  In this code,
struct point which used in declare reduction has been defined. I think it
should be ok in CPP.

Example udr.1.c
This code comes from
https://www.openmp.org/wp-content/uploads/openmp-examples-5.0.0.pdf

#include <stdio.h>
#include <limits.h>

struct point {
  int x;
  int y;
};

void minproc ( struct point *out, struct point *in )
{
  if ( in->x < out->x ) out->x = in->x;
  if ( in->y < out->y ) out->y = in->y;
}

void maxproc ( struct point *out, struct point *in )
{
  if ( in->x > out->x ) out->x = in->x;
  if ( in->y > out->y ) out->y = in->y;
}

#pragma omp declare reduction(min : struct point : \
        minproc(&omp_out, &omp_in)) \
    initializer( omp_priv = { INT_MAX, INT_MAX } )

#pragma omp declare reduction(max : struct point : \
        maxproc(&omp_out, &omp_in)) \
    initializer( omp_priv = { 0, 0 } )

void find_enclosing_rectangle ( int n, struct point points[] )
{
  struct point minp = { INT_MAX, INT_MAX }, maxp = {0,0};
  int i;

#pragma omp parallel for reduction(min:minp) reduction(max:maxp)
  for ( i = 0; i < n; i++ ) {
     minproc(&minp, &points[i]);
     maxproc(&maxp, &points[i]);
  }
  printf("min = (%d, %d)\n", minp.x, minp.y);
  printf("max = (%d, %d)\n", maxp.x, maxp.y);
}

command:
clang++ -fopenmp -S Example_udr.1.cpp

-- 
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/20200617/47a64ce9/attachment.html>


More information about the llvm-bugs mailing list