[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-gsl] fgsl: single precision float version of gsl
From: |
Feng Chen |
Subject: |
[Help-gsl] fgsl: single precision float version of gsl |
Date: |
Wed, 8 Feb 2012 15:58:06 -0600 |
I was looking for a solution similar to the question asked here:
http://lists.gnu.org/archive/html/help-gsl/2007-12/msg00000.html
As the original poster pointed out, -Ddouble=float won't work, it stops and
complaining "long float". After some searches I decide to just do it the
brutal way and it worked for me. So I would like to share it here (and
maybe get better suggestions).
First, cd gsl-1.15, edit configure.ac, change
AC_INIT([gsl],[1.15])
to
AC_INIT([fgsl],[1.15])
Then, run:
autoconf
./configure
(or, for my case, ./configure --prefix=/home/me/local)
Now, type this one-liner to do search/replace:
find . -print0 | xargs -0 perl -pi -e 's/long
double/LONG-DOUBLE/g;s/_double/_DOUbLE/g;s/double/float/g;s/_DOUbLE/_double/g;s/LONG-DOUBLE/long
double/g;s/libgsl/libfgsl/g'
Now you can do:
make
make install
===================================================================
To use it, instead of
#include <gsl/gsl_linalg.h>
We do:
#include <fgsl/gsl_linalg.h>
When linking, instead of linking with libgsl.a or -lgsl, link with
libfgsl.a or -lfgsl.
It's not a clean solution but if you want float instead of double in a
certain scope, it works quite well.
As someone has warned, certain packages require higher precision to work,
so be wise when using this hack. :)
ps: I also changed the optimization level for gcc when I compile the lib,
instead of using the default -g -O2, when I was in the first step editing
configure.ac, I added a line to make it looks like:
AC_LANG(C)
AC_PROG_CC
AC_PROG_CPP
CFLAGS="-O3 -mtune=native -fgraphite-identity -floop-interchange
-floop-strip-mine -floop-block -ftree-loop-distribution"
Here "-O3 -mtune" or "-O3 -msse2" is important to vectorize the loops (most
of us have machines that support SSE2, huge speed difference). Or, use:
-O2 -ftree-vectorize -msse2 -ftree-vectorizer-verbose=5
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Help-gsl] fgsl: single precision float version of gsl,
Feng Chen <=