Discrepancies between ICC and GCC on pointers

General OpenMP discussion

Discrepancies between ICC and GCC on pointers

Postby torbjoernk » Wed Apr 11, 2012 2:55 pm

Hi all,

to get into OpenMP I implemented a version of a matrix vector multiplication for sparse matrices in CRS. Compiling it with GCC 4.6.3 on 64bit Linux works fine (besides two unimportant warnings about some formatting stuff in a `printf` call).

However, compiling the same with ICC 12.1.0 on 64bit Linux, gives the following error:
Code: Select all
matxvec_sparse.cpp(79): error: "default_n_row" must be specified in a variable list at enclosing OpenMP parallel pragma
    #pragma omp parallel \
    ^
with the definition of the variable and pointer in question
Code: Select all
int default_n_row = 4;
int *n_row = &default_n_row;
and the OpenMP directive defined as
Code: Select all
#pragma omp parallel \
  default(none) \
  shared(n_row, aval, acolind, arowpt, vval, yval) \
  private(x, y)
{
  #pragma omp for \
    schedule(static)
  for ( x = 0; x < *n_row; x++ ) {
    yval[x] = 0;
    for ( y = arowpt[x]; y < arowpt[x+1]; y++ ) {
      yval[x] += aval[y] * vval[ acolind[y] ];
    }
  }
} /* end PARALLEL */


I'm aware, that the variable the shared pointer `n_row` is referencing, is neither shared nor private. At least, that's my understanding of defining `default(none)` and explicitly some shared and private variables.

If I add `default_n_row` to the list of shared variables, ICC is happy and does its work. GCC does not care.

I've compiled with
Code: Select all
c++ -fopenmp -O0 -g -std=c++0x -Wall -o matxvec_sparse matxvec_sparse.cpp
and
Code: Select all
icc -openmp -O0 -g -std=c++0x -Wall -restrict -o matxvec_sparse matxvec_sparse.cpp


Is my code causing an undefined behaviour according to the OpenMP specification and thus I'm lucky it works with GCC or is one of the compilers not following the OpenMP specification?

The full code I'm using can be found on GitHub: https://github.com/torbjoernk/openMP-Ex ... sparse.cpp

Cheers,
Torbjörn

Side note: I opened a question about that on SO: http://stackoverflow.com/questions/1010 ... g-succeeds
torbjoernk
 
Posts: 1
Joined: Wed Apr 11, 2012 2:49 pm

Re: Discrepancies between ICC and GCC on pointers

Postby ftinetti » Wed Apr 11, 2012 6:27 pm

Hi,

So far, I have just a comment on
I'm aware, that the variable the shared pointer `n_row` is referencing, is neither shared nor private. At least, that's my understanding of defining `default(none)` and explicitly some shared and private variables.

I think it is not possible that a variable is neither shared nor private. Furthermore, the 3.1 Spec. defines:
The default(none) clause requires that each variable that is referenced in the
construct, and that does not have a predetermined data-sharing attribute, must have its
data-sharing attribute explicitly determined by being listed in a data-sharing attribute
clause.

i.e. default(none) "forces" you to explicitly determine the data-sharing attribute of each variable referenced in the construct not having a predetermined data-sharing attribute. Thus, I think the question could "reduced" to why 'default_n_row' is considered to be referenced in the construct... maybe the compiler vendor?

HTH,

Fernando.
ftinetti
 
Posts: 582
Joined: Wed Feb 10, 2010 2:44 pm

Re: Discrepancies between ICC and GCC on pointers

Postby MarkB » Thu Apr 12, 2012 3:39 am

I think this is a bug in ICC. There is no requirement to specify a data-sharing attribute for pointees inside a parallel region. I suspect that the problem occurs because the compiler has substituted *n_row with default_n_row before interpreting the OpenMP directive.
I've seen similar bugs before, where compilers complain that some internally generated variable name hasn't been declared shared or private.
MarkB
 
Posts: 450
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh


Return to Using OpenMP

Who is online

Users browsing this forum: Google [Bot] and 12 guests

cron