-
Notifications
You must be signed in to change notification settings - Fork 21
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
GSL integration produces different results if adding a printing statement to the integrand in X-PSI installed in Lisa #270
Comments
If you have a suggestion to test the gsl_integration_cquad (or marginal_integrand) function separate from X-PSI, I'll try it |
I found this: |
@sguillot : I was thinking of making a simple Cython program that runs this same GSL integration (over the same marginal_integrand function) with the same input parameters I shared above. And see if that integration still gives a different result depending on whether or not having that print statement inside the integrand. Before the integration, we need probably also call the @ychatonnier: Thanks for sharing this discussion! I think have also before encountered/heard about issues like this. Unlike there, however, our code goes back to "non-working" when taking the print statement away. |
Looks like in Lisa this problem only occurs when installing X-PSI using Intel-compiler. If installing using GCC, I get the correct answer without additional printings. I am still working on a simple test program. I noticed I still need to find out the values saved in a.data, a.n, a.SCALE, a.A, and a.star before calling this function and see if they are always the same. EDIT: Values of these input parameters seem to be always the same, and the following:
For |
test_gsl.zip Based on running this test in Lisa, it seems that the problem is indeed something related to GSL, or how it works together with Intel-compilers. If compiling the test program with I also tried different versions of GSL in Lisa, one already existing in the cluster (version called On the other hand, in Snellius cluster Intel compiler seems to still work fine with GSL (i.e. no printf tricks needed), at least with the GSL version 2.5 that already natively exists there, and also with the latest GSL version (2.7.1) installed from the source (same that did not work for Lisa). When installing that in Snellius, however, I had to add some additional "-fPIC" and "-host" flags Intel compiler version should be the same both in Lisa and Snellius ( |
So after a lot of testing, it appears the problem is caused by over-aggressive optimization, caused by numerical issues in the integrand function of X-PSI, when using Intel-compilers on Intel CPUs (which are used in Lisa but not in Snellius). The suggested solution to make integration and likelihood calculation work on all systems is provided in the linked pull request. |
This might be hardware specific problem, but reporting it still here (have not managed to re-produce this same problem in other systems than in Lisa cluster so far):
The integration over this function:
xpsi/xpsi/likelihoods/default_background_marginalisation.pyx
Line 80 in 4760c72
using GSL
gsl_integration_cquad
function here:xpsi/xpsi/likelihoods/default_background_marginalisation.pyx
Line 503 in 4760c72
gives a different result, depending on whether a print statement (just
printf("????")
) is added somewhere inside or before the for-loop of that function. Without adding the print statement, the result is in contradiction with the result obtained in other systems. After adding the print statement the result agrees with what is obtained elsewhere.Here are the input values for the
gsl_integration_cquad
function (same in both cases):lower,upper,epsabs,epsrel,w=0.00452244, 0.00638843, 0.00000000, 0.00000001, 1227.38282439
And here are the output values without the print statement in Lisa:
result, abserr, nevals = 0.00000000, 0.00000000, 33
And here are the output values with the print statement in Lisa, and always in other systems:
result, abserr, nevals = 0.00023387, 0.00000000, 299
This difference causes a big effect on the final result since in the former case, likelihood evaluation is not performed to the end, but a negative number close to minus infinity is returned instead (there is an if-condition requiring that the
result
variable must be larger than zero).This problem happens when running
examples/examples_modeling_tutorial/TestRun_BB.py
in Lisa with X-PSI version 2.0.0-rc, GSL version 2.7, and Cython version 0.29.32.Would need to still separate the function from X-PSI to test if the problem exists also without X-PSI.
The text was updated successfully, but these errors were encountered: