Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

update docs about GSL version #3

Closed
tadam opened this Issue · 14 comments

3 participants

@tadam

README says "Currently Math::GSL requires at least Perl 5.8 and GSL 1.8 to compile."
But Math::GSL::Integration supports Gauss-Legendre integration and have such lines in code:

*gsl_integration_glfixed_table_alloc = *Math::GSL::Integrationc::gsl_integration_glfixed_table_alloc;
*gsl_integration_glfixed_table_free = *Math::GSL::Integrationc::gsl_integration_glfixed_table_free;
*gsl_integration_glfixed = *Math::GSL::Integrationc::gsl_integration_glfixed;

(however, POD not updated)

And this appeared only in GSL version 1.14, as we may read in NEWS file from gsl sources.
So we must have at least version 1.14, not 1.8.

@leto
Owner

Interesting. I don't think that code has changed since the GSL 1.10/1.11 days. I would prefer to support the GSL that comes with peoples distros, not only the latest version. Have you verified that stuff fails with older GSL's ?

Also, there are no tests for these functions. If you could write some (make sure to check if the functions under test exist, else skip the tests), that would be awesome.

@tadam

Yes. Initially I have GSL 1.13 on Ubuntu Lucid.

tadam@lucid64:~/asdf/Math-GSL-0.25$ dpkg -l | grep gsl
ii libgsl0-dev 1.13+dfsg-1 GNU Scientific Library (GSL) -- development
ii libgsl0ldbl 1.13+dfsg-1 GNU Scientific Library (GSL) -- library pack

and I get this, when I try to build:

tadam@lucid64:~/asdf/Math-GSL-0.25$ perl Build.PL
Checking for GSL..Found GSL version 1.13
Checking if cc supports "-Wall"...yes
Checking if cc supports "-Wno-unused-function"...yes
Checking if cc supports "-Wno-unused-value"...yes
Checking if cc supports "-Wno-unused-function"...yes
Checking if cc supports "-Wno-unused-variable"...yes
Checking if cc supports "-g"...yes
Creating new 'MYMETA.yml' with configuration results
Creating new 'Build' script for 'Math-GSL' version '0.25'
Have a great day!
tadam@lucid64:~/asdf/Math-GSL-0.25$ ./Build
Building Math-GSL
xs/Integration_wrap.c: In function ‘_wrap_gsl_integration_glfixed_table_n_set’:
xs/Integration_wrap.c:6914: error: ‘gsl_integration_glfixed_table’ undeclared (first use in this function)
xs/Integration_wrap.c:6914: error: (Each undeclared identifier is reported only once
xs/Integration_wrap.c:6914: error: for each function it appears in.)
xs/Integration_wrap.c:6914: error: ‘arg1’ undeclared (first use in this function)
xs/Integration_wrap.c:6914: error: expected expression before ‘)’ token
xs/Integration_wrap.c:6930: error: expected expression before ‘)’ token
xs/Integration_wrap.c: In function ‘_wrap_gsl_integration_glfixed_table_n_get’:
xs/Integration_wrap.c:6951: error: ‘gsl_integration_glfixed_table’ undeclared (first use in this function)
xs/Integration_wrap.c:6951: error: ‘arg1’ undeclared (first use in this function)
xs/Integration_wrap.c:6951: error: expected expression before ‘)’ token
xs/Integration_wrap.c:6965: error: expected expression before ‘)’ token
xs/Integration_wrap.c: In function ‘_wrap_gsl_integration_glfixed_table_x_set’:
xs/Integration_wrap.c:6979: error: ‘gsl_integration_glfixed_table’ undeclared (first use in this function)
xs/Integration_wrap.c:6979: error: ‘arg1’ undeclared (first use in this function)
xs/Integration_wrap.c:6979: error: expected expression before ‘)’ token
xs/Integration_wrap.c:6995: error: expected expression before ‘)’ token
xs/Integration_wrap.c: In function ‘_wrap_gsl_integration_glfixed_table_x_get’:
xs/Integration_wrap.c:7016: error: ‘gsl_integration_glfixed_table’ undeclared (first use in this function)
xs/Integration_wrap.c:7016: error: ‘arg1’ undeclared (first use in this function)
xs/Integration_wrap.c:7016: error: expected expression before ‘)’ token
xs/Integration_wrap.c:7030: error: expected expression before ‘)’ token
xs/Integration_wrap.c: In function ‘_wrap_gsl_integration_glfixed_table_w_set’:
xs/Integration_wrap.c:7044: error: ‘gsl_integration_glfixed_table’ undeclared (first use in this function)
xs/Integration_wrap.c:7044: error: ‘arg1’ undeclared (first use in this function)
xs/Integration_wrap.c:7044: error: expected expression before ‘)’ token
xs/Integration_wrap.c:7060: error: expected expression before ‘)’ token
xs/Integration_wrap.c: In function ‘_wrap_gsl_integration_glfixed_table_w_get’:
xs/Integration_wrap.c:7081: error: ‘gsl_integration_glfixed_table’ undeclared (first use in this function)
xs/Integration_wrap.c:7081: error: ‘arg1’ undeclared (first use in this function)
xs/Integration_wrap.c:7081: error: expected expression before ‘)’ token
xs/Integration_wrap.c:7095: error: expected expression before ‘)’ token
xs/Integration_wrap.c: In function ‘_wrap_gsl_integration_glfixed_table_precomputed_set’:
xs/Integration_wrap.c:7109: error: ‘gsl_integration_glfixed_table’ undeclared (first use in this function)
xs/Integration_wrap.c:7109: error: ‘arg1’ undeclared (first use in this function)
xs/Integration_wrap.c:7109: error: expected expression before ‘)’ token
xs/Integration_wrap.c:7125: error: expected expression before ‘)’ token
xs/Integration_wrap.c: In function ‘_wrap_gsl_integration_glfixed_table_precomputed_get’:
xs/Integration_wrap.c:7146: error: ‘gsl_integration_glfixed_table’ undeclared (first use in this function)
xs/Integration_wrap.c:7146: error: ‘arg1’ undeclared (first use in this function)
xs/Integration_wrap.c:7146: error: expected expression before ‘)’ token
xs/Integration_wrap.c:7160: error: expected expression before ‘)’ token
xs/Integration_wrap.c: In function ‘_wrap_new_gsl_integration_glfixed_table’:
xs/Integration_wrap.c:7175: error: ‘gsl_integration_glfixed_table’ undeclared (first use in this function)
xs/Integration_wrap.c:7175: error: ‘result’ undeclared (first use in this function)
xs/Integration_wrap.c:7181: error: expected expression before ‘)’ token
xs/Integration_wrap.c: In function ‘_wrap_delete_gsl_integration_glfixed_table’:
xs/Integration_wrap.c:7192: error: ‘gsl_integration_glfixed_table’ undeclared (first use in this function)
xs/Integration_wrap.c:7192: error: ‘arg1’ undeclared (first use in this function)
xs/Integration_wrap.c:7192: error: expected expression before ‘)’ token
xs/Integration_wrap.c:7205: error: expected expression before ‘)’ token
xs/Integration_wrap.c: In function ‘_wrap_gsl_integration_glfixed_table_alloc’:
xs/Integration_wrap.c:7223: error: ‘gsl_integration_glfixed_table’ undeclared (first use in this function)
xs/Integration_wrap.c:7223: error: ‘result’ undeclared (first use in this function)
xs/Integration_wrap.c:7234: error: expected expression before ‘)’ token
xs/Integration_wrap.c: In function ‘_wrap_gsl_integration_glfixed_table_free’:
xs/Integration_wrap.c:7247: error: ‘gsl_integration_glfixed_table’ undeclared (first use in this function)
xs/Integration_wrap.c:7247: error: ‘arg1’ undeclared (first use in this function)
xs/Integration_wrap.c:7247: error: expected expression before ‘)’ token
xs/Integration_wrap.c:7260: error: expected expression before ‘)’ token
xs/Integration_wrap.c:7261: warning: implicit declaration of function ‘gsl_integration_glfixed_table_free’
xs/Integration_wrap.c: In function ‘_wrap_gsl_integration_glfixed’:
xs/Integration_wrap.c:7277: error: ‘gsl_integration_glfixed_table’ undeclared (first use in this function)
xs/Integration_wrap.c:7277: error: ‘arg4’ undeclared (first use in this function)
xs/Integration_wrap.c:7277: error: expected expression before ‘)’ token
xs/Integration_wrap.c:7347: error: expected expression before ‘)’ token
xs/Integration_wrap.c:7348: warning: implicit declaration of function ‘gsl_integration_glfixed’
xs/Integration_wrap.c:7348: error: expected ‘)’ before ‘const’
xs/Integration_wrap.c:7348: error: expected ‘)’ before ‘arg4’
error building .o file from 'xs/Integration_wrap.c' at inc/GSLBuilder.pm line 182.
tadam@lucid64:~/asdf/Math-GSL-0.25$

After this I builded GSL version 1.14 and 1.15. Math::GSL builds normally with these versions of GSL.

@tadam

I think, that Integration_wrap.c contains code about gsl_integration_glfixed_table because SWIG was runned for one of the latest version of GSL.
I'm not SWIG experienced user. But if I will find the way how to generate the sources where gsl_integration_glfixed_* stuff (and maybe some other) will be included only if you have the latest versions of GSL, then I will submit a patch.

@leto
Owner

CPAN releases have generated XS code shipped in the xs/ directory. If you remove any/all XS files (or clone the git repo, which doesn't have them), they will be rebuilt during the build (which requires SWIG to be installed). So it seems that currently Math::GSL is shipping XS generated from a post-1.14 GSL. Currently the build system knows about when certain GSL subsystems got added, and can conditionally deal with those, but Math::GSL doesn't know how to conditionally compile certain functions that get added. If you have ideas of the best way to handle this, I am all ears.

@leto
Owner

One thing to note clearly is that only files in pod/ or swig/ should be modified, everything in xs/ is generated, and modifications will be lost the next time the corresponding pod/* or swig/* file is changed.

@tadam

Yes, I understand this.

If we use SWIG 2.x, then we can use extended version of %rename ( http://swig.org/Doc2.0/SWIG.html#SWIG_advanced_renaming ):

tadam@tadam:~/devel/math--gsl$ git diff
diff --git a/swig/Integration.i b/swig/Integration.i
index e09249e..b2284ab 100644
--- a/swig/Integration.i
+++ b/swig/Integration.i
@@ -1,7 +1,8 @@
%module "Math::GSL::Integration"
%include "typemaps.i"

%include "gsl_typemaps.i"

+%rename("%(regex:/^gsl_integration_glfixed/$ignore/)s") "";
+%rename("%(regex:/^gsl_integration_cquad/$ignore/)s") "";
%{
#include "gsl/gsl_integration.h"
#include "gsl/gsl_math.

After this SWIG will produce code without these declarations.
For a testing I have generated such code with GSL 1.15 and tried this code to build Math::GSL with GSL 1.13. It builds ok.

So, if we want to support old builds of GSL, but also want to include new features from GSL as much as possible (even if these features are not yet documented and tested), I see the following plan:
1) Decide which oldest version of GSL we want to support (for example, GSL 1.8).
2) Store in anything format which new declarations comes with GSL 1.9, 1.10 and so on.
3) Depending on the information from 2) we must generate one or more version of concrete .i file. The older version will contain all needed %rename's and the newer version will contain no one %rename.
4) SWIG will generate one or more version for the xs and .pm files.
5) When someone will build release from CPAN, GSLBuiler.pm depending on GSL version and using information from 2) will take proper version of xs and .pm files.
6) For newer supported GSL features POD documentation will have a remark that it is supported only with GSL version >= X.
This plan supposes, that CPAN releaser will have the SWIG 2.X and some of the latest GSL version.

@leto
Owner
@pjotrp

Looks to me like that will overcomplicate the source tree - leading to maintenance issues later. I face the same problem with BioLib. Why not maintain a stable 'branch' for 1.8. And create a new branch for the latest version of the GSL? Stable versions move on too, and at some point you can just drop support. If anyone is inclined to support the older version - he/she is free to do so. Point is, you should maintain the tree for your own purposes. Otherwise it will bring unnecessary grief.

@leto
Owner
@tadam

I think that both plans are good and it is a maintainer's responsibility for choosing one of the plans.

Are you willing to start a branch for this?

Yes, I am going to write needed code on weekends.

@tadam

I created a branch 'gsl-multiversion', there is commit for support multiple versions of GSL
tadam@6b1150c
I leaved some comments for clarity.

However, it supports only versions 1.11 - 1.15. Is it enough to support GSL since 1.11?
I tried to build Math::GSL with early versions, but tests were unsuccessful.

Indeed GSL 1.11 also isn't very good, because Math::GSL::VectorComplex uses gsl_vector_complex_add_constant() function and this function appeared only in GSL 1.12. But no tests for this piece of code, therefore Math::GSL builds successfully with GSL 1.11. We just need to check the rest code on such cases and fix it if possible.

P. S. Math::GSL tarball with all these bindings take up 8.9 Mb versus 1.9 Mb with one version of bindings.

@leto
Owner
@leto
Owner

This branch passes the test suite for me on GSL 1.14

```Test Summary Report

t/Matrix.t (Wstat: 0 Tests: 238 Failed: 0)
TODO passed: 209-212
t/Vector.t (Wstat: 0 Tests: 142 Failed: 0)
TODO passed: 141-142
Files=52, Tests=3634, 6 wallclock secs ( 0.83 usr 0.05 sys + 4.41 cusr 1.17 csys = 6.46 CPU)
Result: PASS


If we are concerned about the size of our distribution tarball, we could gzip the generated XS code in the distribution, but I am not sure how much benefit we will get out of that. In any case, something like that should be in a different pull request.
@leto
Owner

I think we have updated the docs about which versions are required, and I just merged the branch that supports multiple GSL versions, so I am closing this issue.

@leto leto closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.