public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Patrick Alken <patrick.alken@Colorado.EDU>
To: "gsl-discuss@sourceware.org" <gsl-discuss@sourceware.org>
Subject: GSL v2.0 discussion
Date: Fri, 04 Apr 2014 17:02:00 -0000	[thread overview]
Message-ID: <533EE585.40301@colorado.edu> (raw)
In-Reply-To: <533EE354.4050204@colorado.edu>


Hello all,

   There have been a lot of new features added to GSL since the last 
release 1.16, some of which have modified underlying data structures 
(breaking binary compatibility) and even some API changes. For this 
reason I don't want to make another 1.x release, but I know at the same 
time many people were hoping that 2.0 would interface with advanced 
linear algebra libraries (like libflame or lapack).

My current todo list before the next release is:
1) import interp2d code (mostly done just needs some further testing)
2) Hermite interpolation (shouldn't take long once I find some time)

Adding libflame or lapack to the todo list would delay the next release 
significantly. But I want to open this discussion again (it has been 
discussed several times previously on this list).

One method of doing this is to make 3 new libraries:
1) libgsllinalg - contains all the current GSL implementations of the 
linear algebra routines
2) libgslflame - contains wrapper routines with the same interfaces that 
gsl_linalg has now, but calls the relevant libflame routine
3) libgsllapack - contains wrapper routines with the same interfaces of 
gsl_linalg, but calls the relevant lapack routine

This way the user can decide which linear algebra library they want at 
link time, while maintaining a common API for everything. If the user 
wants to use the current GSL routines, they would link with -lgsl 
-lgslcblas -lgsllinalg

If they want libflame, they would link with -lgsl -lgslcblas -lgslflame 
-lflame

If they want lapack, they would link with -lgsl -lgslcblas -lgsllapack 
-llapack

A second method of doing this is to decide at compile time which linear 
algebra library to use (ie: autoconf could detect if lapack or flame is 
installed and then compile the library accordingly making the correct 
calls to the lapack/flame routines). This has the advantage of keeping 
the -lgsl -lgslcblas link libraries the same, the user would just need 
to add -llapack or -lflame.

*Potential issues*

1. Workspace sizes

Many of the flame/lapack routines require workspaces of different sizes 
than each other and the corresponding GSL routines. The easiest way to 
handle this would be to dynamically allocate workspace inside the 
wrapper functions of the gslflame and gsllapack libraries, which is not 
too appealing.

Another way to handle it is to have gsl_linalg_alloc() routines for all 
functions which would figure out the right workspace size for whatever 
library you are using. This would require a lot of code changes for 
current users, also not too appealing.

2. Errors

LAPACK tends to handle errors pretty well, and returns error codes from 
each function which could be interpreted by the GSL wrapper and passed 
on to the user.

libFLAME however seems to lack an error handling mechanism and calls 
abort() when it encounters an error (I have not looked deeply into the 
source but this is based on previous discussions on this list). Calling 
abort() is a very poor way to handle this and GSL users could be 
frustrated by this. I don't want to get into the business of 
forking/rewriting the flame error handling stuff so I don't see any easy 
solution to this.

3. Global state

This is another advantage of LAPACK over libflame - libflame requires a 
global initialization call to initialize a small number of global 
variables. This means that a) each wrapper function for libflame would 
need to check if that memory is initialized and if not call the function 
or b) GSL needs to provide a global init/free call. I don't like either 
of these options. (a) is bad because there is no simple way for the user 
to free that memory from their program. (b) is bad because global states 
are just ugly and bad design imo.

4. Fortran vs C

One main disadvantage of LAPACK is the ordering of memory in fortran, 
which would require transposing matrices prior to the lapack call, and 
then transposing back afterward. This isn't such a big problem in terms 
of efficiency but its still a headache.

*Summary*

I would like feedback from everyone on the following points:

1. Should we try to add lapack/flame interfaces for the 2.0 release or 
wait until 3.0? I personally probably won't have a lot of time to work 
on this for several months.

2. Is it better to select gsllinalg/lapack/flame at compile time or link 
time?

3. Whats the best way to handle the memory workspace requirements (add 
_alloc functions to all gsl_linalg routines or dynamic allocation)?

4. What should we do about error handling in libflame? Just accept the 
abort() behavior?

5. Is there a strong preference for doing wrappers for both lapack and 
flame? Should we only interface to lapack, due to the difficulties with 
flame (global state, abort() error handling)? Should we only interface 
to flame due to its more modern design?

Patrick


       reply	other threads:[~2014-04-04 17:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <533EE354.4050204@colorado.edu>
2014-04-04 17:02 ` Patrick Alken [this message]
2014-04-04 17:41   ` Jean-François Caron
2014-04-04 20:31   ` Rhys Ulerich
2014-04-04 20:52     ` Patrick Alken
2014-04-04 21:07       ` Patrick Alken
2014-04-14 14:08         ` Rhys Ulerich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=533EE585.40301@colorado.edu \
    --to=patrick.alken@colorado.edu \
    --cc=gsl-discuss@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).