Preprocessed C++ OpenMP code broken with v13.10 compiler

Background: to add instrumentation to OpenMP codes, we first preprocess the compilation unit and then add instrumentation to the preprocessed file using the source-to-source translator OPARI2 . We then compile the file as usual. This worked fine for C, C++, and Fortran codes.

Now, with v13.10, the workflow fails for C++ OpenMP codes. This is because pgCC adds ‘–preinclude omp.h’ to the call of pgcpp1 during the preprocessing and again during compilation. This leads to lots of ‘invalid redeclaration’ errors.

To reproduce:

pgCC -V

pgCC 13.10-0 64-bit target on x86-64 Linux -tp x64 
The Portland Group - PGI Compilers and Tools
Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.



# foo.cpp
int main()
{
    return 0;
}



$ pgCC -E foo.cpp -mp -o foo.i
$ pgCC -o foo -mp foo.i
"/opt/pgi/linux86-64/13.10/include/omp.h", line 21: error: invalid
          redeclaration of type name "omp_nest_lock" (declared at line 21)
  struct omp_nest_lock {
         ^

"/opt/pgi/linux86-64/13.10/include/omp.h", line 26: error: invalid
          redeclaration of type name "omp_nest_lock_t" (declared at line 26)
  typedef struct omp_nest_lock omp_nest_lock_t;
                               ^

"/opt/pgi/linux86-64/13.10/include/omp.h", line 28: error: invalid
          redeclaration of type name "omp_sched_t" (declared at line 34)
  typedef enum omp_sched_t
               ^

"/opt/pgi/linux86-64/13.10/include/omp.h", line 30: error: "omp_sched_static"
          has already been declared in the current scope
  	omp_sched_static = 1,
  	^

"/opt/pgi/linux86-64/13.10/include/omp.h", line 31: error: "omp_sched_dynamic"
          has already been declared in the current scope
  	omp_sched_dynamic = 2,
  	^

"/opt/pgi/linux86-64/13.10/include/omp.h", line 32: error: "omp_sched_guided"
          has already been declared in the current scope
  	omp_sched_guided = 3,
  	^

"/opt/pgi/linux86-64/13.10/include/omp.h", line 33: error: "omp_sched_auto"
          has already been declared in the current scope
  	omp_sched_auto = 4
  	^

"/opt/pgi/linux86-64/13.10/include/omp.h", line 56: error: more than one
          instance of overloaded function "omp_init_nest_lock" has "C" linkage
  extern void omp_init_nest_lock(omp_nest_lock_t *s);
              ^

"/opt/pgi/linux86-64/13.10/include/omp.h", line 57: error: more than one
          instance of overloaded function "omp_destroy_nest_lock" has "C"
          linkage
  extern void omp_destroy_nest_lock(omp_nest_lock_t *s);
              ^

"/opt/pgi/linux86-64/13.10/include/omp.h", line 58: error: more than one
          instance of overloaded function "omp_set_nest_lock" has "C" linkage
  extern void omp_set_nest_lock(omp_nest_lock_t *s);
              ^

"/opt/pgi/linux86-64/13.10/include/omp.h", line 59: error: more than one
          instance of overloaded function "omp_unset_nest_lock" has "C" linkage
  extern void omp_unset_nest_lock(omp_nest_lock_t *s);
              ^

"/opt/pgi/linux86-64/13.10/include/omp.h", line 60: error: more than one
          instance of overloaded function "omp_test_nest_lock" has "C" linkage
  extern int omp_test_nest_lock(omp_nest_lock_t *s);
             ^

"/opt/pgi/linux86-64/13.10/include/omp.h", line 72: error: more than one
          instance of overloaded function "omp_set_schedule" has "C" linkage
  extern void omp_set_schedule(omp_sched_t,int);
              ^

"/opt/pgi/linux86-64/13.10/include/omp.h", line 73: error: more than one
          instance of overloaded function "omp_get_schedule" has "C" linkage
  extern void omp_get_schedule(omp_sched_t *,int *);
              ^

"/opt/pgi/linux86-64/13.10/include/omp.h", line 82: error: invalid
          redeclaration of type name "__cplus_omp_init_lock_t" (declared at
          line 82)
    class __cplus_omp_init_lock_t {
          ^

15 errors detected in the compilation of "foo.i".

Unfortunately, this new feature breaks all tools relying on preprocessing. We and the users of our performance analysis tools would appreciate to switch back to the previous behavior. The affected systems are recent Cray installations.

Thanks,
Christian

Sorry for the in convenience. In release 14.1 , we have the new flag --no_preinclude
You can use that when you recompile openmp preprocessed files.

Thanks, that would help!

Christian

I encounter the same problem with a PGI 14.1 compiler. However, my pgCC compiler says that --no_preinclude is an unknown switch. Also the man pages do not mention this option or a similar one. (I also tried similar forms with varying configurations of dashes and underscores) Is this option only available on specific systems or do I need to consider something special during installation?

My compiler version:

$ pgCC --version

pgCC 14.1-0 64-bit target on x86-64 Linux -tp x64 
The Portland Group - PGI Compilers and Tools
Copyright (c) 2014, NVIDIA CORPORATION.  All rights reserved.

Its output:

$ pgCC --no_preinclude
pgCC-Error-Unknown switch: --no_preinclude

Apologies Daniel. It looks like Deb forgot an “s”. The flag is “–no_preincludes”

% pgCC --no_preincludes -help
Reading rcfile /proj/pgi/linux86-64/14.1/bin/.pgcpprc
--no_preincludes    Ignore all preincluded files: used for compiling preprocessed files
  • Mat