pgcc 19.10 FLT_MAX

Note clear how to make FLT_MAX preprocessor variable visible.

#include <float.h>

PGC-S-0039-Use of undeclared variable FLT_MAX

set COMPGCCINCDIR=include-gcc48;
set GCCVERSION=40805;
STDINC =/opt/pgi/pgi-19.10/linux86-64-llvm/19.10/include-gcc48

No output from following command, expecting to be defined.

pgcc -dM <<<’’ | grep ‘FLT_MAX’

What flags are required?

Thanks,
Nick

Hi Nick,

Sorry if I’m unclear about you’re question, but I’m assuming that you’re seeing an error like the following?

% pgcc flt_max.c -I/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/
PGC-S-0039-Use of undeclared variable __FLT_MAX__ (flt_max.c: 6)
PGC/x86-64 Linux 19.10-0: compilation completed with severe errors

The problem here, is the GNU 4.8.5 float.h header files presume “FLT_MAX” gets predefined by the compiler but pgcc doesn’t predefine it. Instead, we ship our own “float.h” including it before the system float.h. However, if you put the GNU include file path on the compile line, the GNU float.h will get included first, so FLT_MAX isn’t defined.

Either don’t explicitly add the include path to the GNU headers (the path will get implicitly added in the correct order), or include the the path to the PGI version first.

% pgcc flt_max.c -I/opt/pgi/pgi-19.10/linux86-64-llvm/19.10/include-gcc48 -I/usr/lib/gcc/x86_64-redhat-linux/4.8.5/include/

Hope this helps,
Mat

That was it!

Thanks,
Nick

I am also having this issue but with NVHPC 20.9.
Where are the include files such as “float.h” for NVHPC?

  • Ron

Hi Ron,

“float.h” would be coming from your system’s GNU include files. We no longer ship our own wrapper “float.h” files since we now internally define things like “FLX_MAX”, like GNU does, so the wrapper is no longer needed.

What’s the actual error you’re seeing and which GNU version do you have installed?

-Mat

Hi,

The error was:

“hdiff_array.c”, line 223: error: identifier “DBL_MAX” is undefined
d_max_val1 = -DBL_MAX;

The file in question includes <float.h> and others.

In order to fix the issue, I had to manually add the include path to GNU to my CPATH environment variable:

export CPATH=${CPATH}:/usr/lib/gcc/x86_64-redhat-linux/8/include

(It looks like the GCC is version 8 - and this is on the EXPANSE system at SDSC which uses CentOS 8).

  • Ron

What’s the value if “GCCINC” in your NVHPC Compiler installation’s configuration file (Linux_x86_64/20.9/compilers/bin/localrc or the file set in $NVLOCALRC).

I just tried on a CentOS8 system and it worked fine for me, but GCCINC is set correctly in my localrc:

set GCCINC= /usr/lib/gcc/x86_64-redhat-linux/8/include /usr/local/include /usr/include;

% cat float.c
#include <float.h>
% nvc -V20.9 -dM float.c | grep DBL_MAX
#define __DBL_MAX_EXP__ 1024
#define __DBL_MAX_10_EXP__ 308
#define __DBL_MAX__ 1.7976931348623157e+308
#define __LDBL_MAX_EXP__ 16384
#define __LDBL_MAX_10_EXP__ 4932
#define __LDBL_MAX__ 1.18973149535723176502e+4932L
#define DBL_MAX_EXP __DBL_MAX_EXP__
#define LDBL_MAX_EXP __LDBL_MAX_EXP__
#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
#define DBL_MAX __DBL_MAX__
#define LDBL_MAX __LDBL_MAX__

-Mat

Hi,

Thanks!

Indeed it is set “weird” in localrc:

/cm/shared/apps/spack/gpu/opt/spack/linux-centos8-skylake_avx512/gcc-8.3.1/nvhpc-20.9-tpwyy4iik6rsikls5ikkvzrttcnc7ytd/Linux_x86_64/20.9/compilers/bin/locarc

set GCCINC= /cm/shared/apps/spack/gpu/opt/spack/linux-centos8-cascadelake/intel-19.0.5.281/openmpi-4.0.4-gnk7ocykjviwjr7hxocujrxfdoiswqih/include /cm/shared/apps/spack/gpu/opt/spack/linux-centos8-skylake_avx512/gcc-8.3.1/intel-19.0.5.281-on6hypwwqeum7akypqc2fahnowaukom4/include /usr/lib/gcc/x86_64-redhat-linux/8/include /usr/local/include /usr/include;

My guess is that the admins had intel loaded when they installed NVHPC.
That intel include folder is accessible though but in either case this looks like more of a question to the admins now.

Thanks again!

  • Ron

That is odd, but if you need a work around, you can create you’re own localrc (via “makelocal -d . -x”) and then set the environment variable “NVLOCALRC=/full/path/to/localrc”. Note that you can rename “localrc” to anything you want.