Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation with g++ 11.3 compiler on Ubuntu 22.04 may cause severe floating point error #1

Open
zhong-yy opened this issue Aug 17, 2023 · 0 comments

Comments

@zhong-yy
Copy link
Owner

zhong-yy commented Aug 17, 2023

Originally, GraSphInv was tested with compilers g++ 9.3 and Intel oneAPI 2021/2022 on Ubuntu 20.04. However, the program compiled by a newer version of g++ (11.3.0) on Ubuntu 22.04 is found to produce sporadic large errors. Thanks to Keying Zhu for pointing out this.

For example, in Examples/Tibet50kmH_0_25x0_25/data/Crust_Correction/crystalline_crust_g_r calculated by the program compiled by g++ 11.3 on ubuntu 22.04, there are 5082 extremely large values which are inconsistent with the original file. It looks like
image

Then I tested Intel oneAPI 2023 compiler on Ubuntu 22.04 to see if this problem is specific to g++ compilers. In the Crust_Correction example, 1077 out of 20905 data points in file moho_g_r are different from the original file with a maximum absolute difference of 1.76 mGal and the rest of the data points are the same as the original files. I think this difference is still within an acceptable range in view of different implementation of C++ compilers and the inherent numerical inaccuracy of Gaussian Legendre quadrature. For the rest of files, e.g crystalline_crust_g_r, sediments_g_r, rm_sedim_cryst_g_r, rm_sedim_g_r, mantle_g_r are exactly the same as the original file (with maximum difference less than 1e-12).

I suspect that the large error caused by g++ 11.3.0 is due to compiler optimization. I will get around to test a lower level of compiler optimization by adding a statement set(CMAKE_BUILD_TYPE Debug) to file cmake.config.

@zhong-yy zhong-yy changed the title It seems that compilation with g++ 11.3 compiler on Ubuntu 22.04 may cause severe floating point error Compilation with g++ 11.3 compiler on Ubuntu 22.04 may cause severe floating point error Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant