Using only system math libraries

Hello,

I am investigating some odd numerical differences in a large legacy CFD solver when compiling with GCC 7.4 or PGI 19.4. The differences are too large to be simply hand-waved away as accumulated rounding error, but also too small to clearly indicate a bug.

I notice that the PGI compiled executable pulls from both the system libm and libpgmath. As a sanity check I would like to prepare a PGI compiled executable that only uses the system libm. Is this possible through some compiler or linker flag?

Thanks,

-David

Hi David,

No, sorry. pgmath is our main math library. libm is only there since a few of the pgmath routines will call a small portion of libm, but overall libm is not really used.

I would suggest that you try compiling with “-Kieee”. This will have the pgmath use our precise routines (< .25 ULPs).

By default, we use what we call our “fast” routines though these are still fairly accurate with a max error of <2 ULPs. A few of the routines, also include “relaxed” versions and can get >2 ULPS, but these are only enabled with the “-Mfpreleaxed” flag.

Hope this helps,
Mat

Hi Mat,

Thanks for the confirmation. I’ve got a build in the queue right now with -Kieee, so fingers crossed it works.

-David

Hi David,

Just want to add a sideline comment as I am facing a similar situation as you. One thing I have noticed is that the pgfortran’s matmul (which was used intensively in our code) will give slightly different values depending on whether the array is dynamically or statically defined, while GNU fortran does not have this behaviour.

Hope it helps.

Cheers,

moulin