From b8167a1788283e0c7f4560d69683ba621fa627c7 Mon Sep 17 00:00:00 2001 From: Alex Cunningham Date: Wed, 17 Mar 2010 13:19:48 +0000 Subject: [PATCH] Changed blas inclusion to be smarter about what os is used, removed old GSL code --- configure.ac | 43 +++++++++++++++---------------------------- cpp/Makefile.am | 16 +++++++++------- cpp/NoiseModel.cpp | 22 ---------------------- 3 files changed, 24 insertions(+), 57 deletions(-) diff --git a/configure.ac b/configure.ac index e74dcb007..ec66fca68 100644 --- a/configure.ac +++ b/configure.ac @@ -25,32 +25,6 @@ AC_ARG_ENABLE([debug], AM_CONDITIONAL([DEBUG], [test x$debug = xtrue]) -# search for gsl -#AM_PATH_GSL(1.1) - -# enable using GSL for linalg -#AC_ARG_ENABLE([gsl], -# [ --enable-gsl Enable the GSL library], -# [case "${enableval}" in -# yes) gsl=true ;; -# no) gsl=false ;; -# *) AC_MSG_ERROR([bad value ${enableval} for --enable-gsl]) ;; -# esac],[gsl=false]) -# -#AM_CONDITIONAL([GSL], [test x$gsl = xtrue]) - - -# enable using ATLAS for BLAS -#AC_ARG_ENABLE([atlas], -# [ --enable-atlas Enable ATLAS optimized BLAS], -# [case "${enableval}" in -# yes) atlas=true ;; -# no) atlas=false ;; -# *) AC_MSG_ERROR([bad value ${enableval} for --enable-atlas]) ;; -# esac],[atlas=false]) -# -#AM_CONDITIONAL([ATLAS], [test x$atlas = xtrue]) - # search for a blas implementation AX_BLAS() @@ -63,8 +37,21 @@ AC_ARG_ENABLE([blas], *) AC_MSG_ERROR([bad value ${enableval} for --enable-blas]) ;; esac],[blas=false]) -AM_CONDITIONAL([USE_BLAS_MACOS], [test x$blas = xtrue && test -f "/System/Library/Frameworks/vecLib.framework/Headers/cblas.h"]) -AM_CONDITIONAL([USE_BLAS_LINUX], [test x$blas = xtrue && USE_BLAS_MAC = false]) +AC_CANONICAL_HOST +# We need to determine what os we are on to determine if we need to do +# special things because we are on a mac +case $host_os in + darwin* ) + # Do something specific for mac + ISMAC=true + ;; + *) + ISMAC=false + ;; +esac + +AM_CONDITIONAL([USE_BLAS_MACOS], [test x$blas = xtrue && test x$ISMAC = xtrue]) +AM_CONDITIONAL([USE_BLAS_LINUX], [test x$blas = xtrue && test x$ISMAC = xfalse]) # Checks for programs. AC_PROG_CXX diff --git a/cpp/Makefile.am b/cpp/Makefile.am index 7c956ca76..d760325c2 100644 --- a/cpp/Makefile.am +++ b/cpp/Makefile.am @@ -293,17 +293,19 @@ include_HEADERS = $(headers) AM_CXXFLAGS += -I.. AM_LDFLAGS = -L../CppUnitLite -lCppUnitLite $(BOOST_LDFLAGS) $(boost_serialization) #-L. -lgtsam -# adding cblas implementation +# adding cblas implementation - split into a default linux version using the +# autotools script, and a mac version that is hardcoded +# NOTE: the GT_USE_CBLAS is just used as a means of detecting when blas is available if USE_BLAS_LINUX -AM_CXXFLAGS += -DCBLAS -libgtsam_la_CPPFLAGS += -DCBLAS -AM_LDFLAGS += $(BLAS_LIBS) $(LIBS) $(FLIBS) # -lcblas -latlas -libgtsam_la_LDFLAGS += $(BLAS_LIBS) $(LIBS) $(FLIBS) # -lcblas -latlas +AM_CXXFLAGS += -DGT_USE_CBLAS +libgtsam_la_CPPFLAGS += -DGT_USE_CBLAS +AM_LDFLAGS += $(BLAS_LIBS) $(LIBS) $(FLIBS) +libgtsam_la_LDFLAGS += $(BLAS_LIBS) $(LIBS) $(FLIBS) endif if USE_BLAS_MACOS -AM_CXXFLAGS += -DYA_BLAS -DYA_LAPACK -DYA_BLASMULT -I/System/Library/Frameworks/vecLib.framework/Headers -libgtsam_la_CPPFLAGS += -DYA_BLAS -DYA_LAPACK -DYA_BLASMULT -I/System/Library/Frameworks/vecLib.framework/Headers +AM_CXXFLAGS += -DGT_USE_CBLAS -DYA_BLAS -DYA_LAPACK -DYA_BLASMULT -I/System/Library/Frameworks/vecLib.framework/Headers +libgtsam_la_CPPFLAGS += -DGT_USE_CBLAS -DYA_BLAS -DYA_LAPACK -DYA_BLASMULT -I/System/Library/Frameworks/vecLib.framework/Headers AM_LDFLAGS += -lcblas -latlas libgtsam_la_LDFLAGS += -framework vecLib -lcblas -latlas endif diff --git a/cpp/NoiseModel.cpp b/cpp/NoiseModel.cpp index f9965d92c..911ca1de7 100644 --- a/cpp/NoiseModel.cpp +++ b/cpp/NoiseModel.cpp @@ -11,11 +11,6 @@ #include #include -#ifdef GSL -#include // needed for gsl blas -#include -#endif - #include #include #include @@ -43,22 +38,6 @@ namespace noiseModel { // __attribute__ ((noinline)) // uncomment to prevent inlining when profiling static void updateAb(Matrix& Ab, int j, const Vector& a, const Vector& rd) { size_t m = Ab.size1(), n = Ab.size2()-1; -#ifdef GSL - // Ab(0:m,j+1:n) = Ab(0:m,j+1:n) - a(0:m)*rd(j+1:end)' - // get a view for Ab - gsl_matrix_view Abg = gsl_matrix_view_array(Ab.data().begin(), m, n+1); - gsl_matrix_view Abg_view = gsl_matrix_submatrix (&(Abg.matrix), 0, j+1, m, n-j); - - // get a view for a - gsl_vector_const_view ag = gsl_vector_const_view_array(a.data().begin(), m); - - // get a view for r - gsl_vector_const_view rdg = gsl_vector_const_view_array(rd.data().begin()+j+1, n-j); - - // rank one update - gsl_blas_dger (-1.0, &(ag.vector), &(rdg.vector), &(Abg_view.matrix)); - -#else for (int i = 0; i < m; i++) { // update all rows double ai = a(i); @@ -68,7 +47,6 @@ static void updateAb(Matrix& Ab, int j, const Vector& a, const Vector& rd) { for (int j2 = j + 1; j2 < n+1; j2++, Aij++, rptr++) *Aij -= ai * (*rptr); } -#endif }