The GNU C/C++ compiler is asking that when a default(none) clause is present on
the '#pragma omp parallel for', and a chunk-size expression (in this case just
the variable csize) appears in a schedule clause, that the variable must appear
in a shared or private clause.  Other compilers do not require that this be
done.

$ cat bug2873.c
/* derived from RTED_OpenMP/C/SECTION_C/c_C_3_2_b.c
              c_C_3_2_c.c, c_C_3_2_e.c, c_C_3_2_f.c,
              c_E_5_k.c, c_E_5_l.c, c_E_5_m.c         */
#include <stdio.h>
#include <math.h>
int main() {
  double s, tmp;
  int n_thread,i, csize;
  int nt=4;
  double arr[100];

  omp_set_dynamic(0);
  omp_set_num_threads(nt);
  for (i=0;i<100;i++) arr[i]=(double) i;
  s = 0.0;
  tmp =  4.0*atan(1.0);
  tmp = sin(-0.25*tmp);
  csize = (int) (tmp*10.0);
  printf("tmp % 12.4f n_thread %d \n", tmp, csize);
#pragma omp parallel for default(none) shared(arr) reduction(+:s)
schedule(dynamic,csize)
  for (i=0;i<100;i++) s += arr[i];
  printf("s = %12.4f\n", s);
  return 0;
}

$ gcc --version
gcc (GCC) 4.2.1 20070719 (rpm:3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ gcc -fopenmp -c bug2873.c
bug2873.c: In function 'main':
bug2873.c:21: error: 'csize' not specified in enclosing parallel
bug2873.c:20: error: enclosing parallel
$


-- 
           Summary: CHUNKSIZE IN SCHEDULE CLAUSE SHOULD NOT NEED SCOPING IF
                    DEFAULT(NONE) PRESENT
           Product: gcc
           Version: 4.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: geir at cray dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33718

Reply via email to