From d5d569b242d9eb6c45ca0c8fbf08855c12b04874 Mon Sep 17 00:00:00 2001 From: conrad Date: Wed, 9 Feb 2022 11:40:27 +1000 Subject: [PATCH] remove use of ATLAS --- CMakeLists.txt | 17 - README.md | 38 +- docs.html | 2 +- include/armadillo | 3 - include/armadillo_bits/arma_config.hpp | 7 - include/armadillo_bits/auxlib_meat.hpp | 255 ++--------- include/armadillo_bits/config.hpp | 11 - include/armadillo_bits/config.hpp.cmake | 11 - include/armadillo_bits/def_atlas.hpp | 136 ------ include/armadillo_bits/include_atlas.hpp | 44 -- include/armadillo_bits/mul_gemm.hpp | 28 +- include/armadillo_bits/mul_gemv.hpp | 55 +-- include/armadillo_bits/mul_herk.hpp | 38 +- include/armadillo_bits/mul_syrk.hpp | 36 +- include/armadillo_bits/op_dot_meat.hpp | 22 +- include/armadillo_bits/op_norm_meat.hpp | 12 +- include/armadillo_bits/translate_atlas.hpp | 509 --------------------- 17 files changed, 64 insertions(+), 1160 deletions(-) delete mode 100644 include/armadillo_bits/def_atlas.hpp delete mode 100644 include/armadillo_bits/include_atlas.hpp delete mode 100644 include/armadillo_bits/translate_atlas.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index fb701171..34685928 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,6 @@ set(ARMA_USE_WRAPPER true) set(ARMA_USE_LAPACK false) set(ARMA_USE_BLAS false) -set(ARMA_USE_ATLAS false) set(ARMA_USE_HDF5_ALT false) set(ARMA_USE_ARPACK false) set(ARMA_USE_EXTERN_RNG false) @@ -326,7 +325,6 @@ else() include(ARMA_FindMKL) include(ARMA_FindOpenBLAS) - include(ARMA_FindATLAS) include(ARMA_FindBLAS) include(ARMA_FindLAPACK) @@ -336,7 +334,6 @@ else() message(STATUS " MKL_FOUND = ${MKL_FOUND}" ) message(STATUS " OpenBLAS_FOUND = ${OpenBLAS_FOUND}" ) - message(STATUS " ATLAS_FOUND = ${ATLAS_FOUND}" ) message(STATUS " BLAS_FOUND = ${BLAS_FOUND}" ) message(STATUS " LAPACK_FOUND = ${LAPACK_FOUND}" ) @@ -379,11 +376,6 @@ else() else() - if(OpenBLAS_FOUND AND ATLAS_FOUND) - message(STATUS "") - message(STATUS "*** NOTE: found both OpenBLAS and ATLAS; ATLAS will not be used") - endif() - if(OpenBLAS_FOUND AND BLAS_FOUND) message(STATUS "") message(STATUS "*** NOTE: found both OpenBLAS and BLAS; BLAS will not be used") @@ -413,14 +405,6 @@ else() else() - if(ATLAS_FOUND) - set(ARMA_USE_ATLAS true) - set(ARMA_ATLAS_INCLUDE_DIR ${ATLAS_INCLUDE_DIR}) - set(ARMA_LIBS ${ARMA_LIBS} ${ATLAS_LIBRARIES}) - - message(STATUS "ATLAS_INCLUDE_DIR = ${ATLAS_INCLUDE_DIR}") - endif() - if(BLAS_FOUND) set(ARMA_USE_BLAS true) set(ARMA_LIBS ${ARMA_LIBS} ${BLAS_LIBRARIES}) @@ -533,7 +517,6 @@ message(STATUS "*** Result of configuration:") message(STATUS "*** ARMA_USE_WRAPPER = ${ARMA_USE_WRAPPER}") message(STATUS "*** ARMA_USE_LAPACK = ${ARMA_USE_LAPACK}") message(STATUS "*** ARMA_USE_BLAS = ${ARMA_USE_BLAS}") -message(STATUS "*** ARMA_USE_ATLAS = ${ARMA_USE_ATLAS}") message(STATUS "*** ARMA_USE_HDF5_ALT = ${ARMA_USE_HDF5_ALT}") message(STATUS "*** ARMA_USE_ARPACK = ${ARMA_USE_ARPACK}") message(STATUS "*** ARMA_USE_EXTERN_RNG = ${ARMA_USE_EXTERN_RNG}") diff --git a/README.md b/README.md index d549451a..41fd89f6 100644 --- a/README.md +++ b/README.md @@ -30,16 +30,15 @@ Copyright 2017-2022 Data61 / CSIRO 8. [Windows: Compiling and Linking](#8-windows-compiling-and-linking) 9. [Support for OpenBLAS and Intel MKL](#9-support-for-openblas-and-intel-mkl) -10. [Support for ATLAS](#10-support-for-atlas) -11. [Caveat on use of C++11 auto Keyword](#11-caveat-on-use-of-c11-auto-keyword) -12. [Support for OpenMP](#12-support-for-openmp) +10. [Caveat on use of C++11 auto Keyword](#10-caveat-on-use-of-c11-auto-keyword) +11. [Support for OpenMP](#11-support-for-openmp) -13. [Documentation of Functions and Classes](#13-documentation-of-functions-and-classes) -14. [API Stability and Versioning](#14-api-stability-and-versioning) -15. [Bug Reports and Frequently Asked Questions](#15-bug-reports-and-frequently-asked-questions) +12. [Documentation of Functions and Classes](#12-documentation-of-functions-and-classes) +13. [API Stability and Versioning](#13-api-stability-and-versioning) +14. [Bug Reports and Frequently Asked Questions](#14-bug-reports-and-frequently-asked-questions) -16. [MEX Interface to Octave/Matlab](#16-mex-interface-to-octavematlab) -17. [Related Software Using Armadillo](#17-related-software-using-armadillo) +15. [MEX Interface to Octave/Matlab](#15-mex-interface-to-octavematlab) +16. [Related Software Using Armadillo](#16-related-software-using-armadillo) --- @@ -358,16 +357,7 @@ Comment out the line containing: --- -### 10: Support for ATLAS - -If OpenBLAS is not available, Armadillo can use the ATLAS library for faster versions -of a subset of LAPACK and BLAS functions. -LAPACK should still be installed to obtain full functionality. -The minimum recommended version of ATLAS is 3.10. - ---- - -### 11: Caveat on use of C++11 auto Keyword +### 10: Caveat on use of C++11 auto Keyword Use of the C++11 `auto` keyword is not recommended with Armadillo objects and expressions. @@ -376,7 +366,7 @@ that are not properly handled by `auto`. --- -### 12: Support for OpenMP +### 11: Support for OpenMP Armadillo can use OpenMP to automatically speed up computationally expensive element-wise functions such as exp(), log(), cos(), etc. @@ -387,7 +377,7 @@ For GCC and Clang compilers, use the following options to enable both C++11 and --- -### 13: Documentation of Functions and Classes +### 12: Documentation of Functions and Classes The documentation of Armadillo functions and classes is available at: http://arma.sourceforge.net/docs.html @@ -397,7 +387,7 @@ Use a web browser to view it. --- -### 14: API Stability and Versioning +### 13: API Stability and Versioning Each release of Armadillo has its public API (functions, classes, constants) described in the accompanying API documentation (docs.html) specific @@ -432,7 +422,7 @@ implementation details, and may change or be removed without notice. --- -### 15: Bug Reports and Frequently Asked Questions +### 14: Bug Reports and Frequently Asked Questions Armadillo has gone through extensive testing and has been successfully used in production environments. However, as with almost all software, @@ -452,14 +442,14 @@ http://arma.sourceforge.net/faq.html --- -### 16: MEX Interface to Octave/Matlab +### 15: MEX Interface to Octave/Matlab The `mex_interface` folder contains examples of how to interface Octave/Matlab with C++ code that uses Armadillo matrices. --- -### 17: Related Software Using Armadillo +### 16: Related Software Using Armadillo * ensmallen: fast non-linear numerical optimisation library http://ensmallen.org/ diff --git a/docs.html b/docs.html index 65b5f1af..6aee64b1 100644 --- a/docs.html +++ b/docs.html @@ -696,7 +696,7 @@ it is possible to use other types instead, eg. fmat
  • -Functions which use LAPACK or ATLAS (generally matrix decompositions) are only valid for the following types: +Functions which use LAPACK (generally matrix decompositions) are only valid for the following types: mat, dmat, fmat, cx_mat, cx_dmat, cx_fmat

  • diff --git a/include/armadillo b/include/armadillo index 0edff89a..9a8d5c7d 100644 --- a/include/armadillo +++ b/include/armadillo @@ -73,7 +73,6 @@ #endif -#include "armadillo_bits/include_atlas.hpp" #include "armadillo_bits/include_hdf5.hpp" #include "armadillo_bits/include_superlu.hpp" @@ -124,14 +123,12 @@ namespace arma #include "armadillo_bits/def_blas.hpp" #include "armadillo_bits/def_lapack.hpp" - #include "armadillo_bits/def_atlas.hpp" #include "armadillo_bits/def_arpack.hpp" #include "armadillo_bits/def_superlu.hpp" #include "armadillo_bits/def_hdf5.hpp" #include "armadillo_bits/translate_blas.hpp" #include "armadillo_bits/translate_lapack.hpp" - #include "armadillo_bits/translate_atlas.hpp" #include "armadillo_bits/translate_arpack.hpp" #include "armadillo_bits/translate_superlu.hpp" diff --git a/include/armadillo_bits/arma_config.hpp b/include/armadillo_bits/arma_config.hpp index 184bd584..ca6c8a3f 100644 --- a/include/armadillo_bits/arma_config.hpp +++ b/include/armadillo_bits/arma_config.hpp @@ -44,13 +44,6 @@ struct arma_config #endif - #if defined(ARMA_USE_ATLAS) - static constexpr bool atlas = true; - #else - static constexpr bool atlas = false; - #endif - - #if defined(ARMA_USE_LAPACK) static constexpr bool lapack = true; #else diff --git a/include/armadillo_bits/auxlib_meat.hpp b/include/armadillo_bits/auxlib_meat.hpp index d94e2af8..25865894 100644 --- a/include/armadillo_bits/auxlib_meat.hpp +++ b/include/armadillo_bits/auxlib_meat.hpp @@ -30,25 +30,7 @@ auxlib::inv(Mat& A) if(A.is_empty()) { return true; } - #if defined(ARMA_USE_ATLAS) - { - arma_debug_assert_atlas_size(A); - - podarray ipiv(A.n_rows); - - int info = 0; - - arma_extra_debug_print("atlas::clapack_getrf()"); - info = atlas::clapack_getrf(atlas::CblasColMajor, A.n_rows, A.n_cols, A.memptr(), A.n_rows, ipiv.memptr()); - - if(info != 0) { return false; } - - arma_extra_debug_print("atlas::clapack_getri()"); - info = atlas::clapack_getri(atlas::CblasColMajor, A.n_rows, A.memptr(), A.n_rows, ipiv.memptr()); - - return (info == 0); - } - #elif defined(ARMA_USE_LAPACK) + #if defined(ARMA_USE_LAPACK) { arma_debug_assert_blas_size(A); @@ -89,7 +71,7 @@ auxlib::inv(Mat& A) #else { arma_ignore(A); - arma_stop_logic_error("inv(): use of ATLAS or LAPACK must be enabled"); + arma_stop_logic_error("inv(): use of LAPACK must be enabled"); return false; } #endif @@ -166,27 +148,7 @@ auxlib::inv_sympd(Mat& A) if(A.is_empty()) { return true; } - #if defined(ARMA_USE_ATLAS) - { - arma_debug_assert_atlas_size(A); - - int info = 0; - - arma_extra_debug_print("atlas::clapack_potrf()"); - info = atlas::clapack_potrf(atlas::CblasColMajor, atlas::CblasLower, A.n_rows, A.memptr(), A.n_rows); - - if(info != 0) { return false; } - - arma_extra_debug_print("atlas::clapack_potri()"); - info = atlas::clapack_potri(atlas::CblasColMajor, atlas::CblasLower, A.n_rows, A.memptr(), A.n_rows); - - if(info != 0) { return false; } - - A = symmatl(A); - - return true; - } - #elif defined(ARMA_USE_LAPACK) + #if defined(ARMA_USE_LAPACK) { arma_debug_assert_blas_size(A); @@ -213,7 +175,7 @@ auxlib::inv_sympd(Mat& A) #else { arma_ignore(A); - arma_stop_logic_error("inv_sympd(): use of ATLAS or LAPACK must be enabled"); + arma_stop_logic_error("inv_sympd(): use of LAPACK must be enabled"); return false; } #endif @@ -361,33 +323,7 @@ auxlib::det(eT& out_val, Mat& A) if(A.is_empty()) { out_val = eT(1); return true; } - #if defined(ARMA_USE_ATLAS) - { - arma_debug_assert_atlas_size(A); - - podarray ipiv(A.n_rows); - - arma_extra_debug_print("atlas::clapack_getrf()"); - const int info = atlas::clapack_getrf(atlas::CblasColMajor, A.n_rows, A.n_cols, A.memptr(), A.n_rows, ipiv.memptr()); - - if(info < 0) { return false; } - - // on output A appears to be L+U_alt, where U_alt is U with the main diagonal set to zero - eT val = A.at(0,0); - for(uword i=1; i < A.n_rows; ++i) { val *= A.at(i,i); } - - int sign = +1; - for(uword i=0; i < A.n_rows; ++i) - { - // NOTE: no adjustment required, as the clapack version of getrf() assumes counting from 0 - if( int(i) != ipiv.mem[i] ) { sign *= -1; } - } - - out_val = (sign < 0) ? eT(-val) : eT(val); - - return true; - } - #elif defined(ARMA_USE_LAPACK) + #if defined(ARMA_USE_LAPACK) { arma_debug_assert_blas_size(A); @@ -421,7 +357,7 @@ auxlib::det(eT& out_val, Mat& A) { arma_ignore(out_val); arma_ignore(A); - arma_stop_logic_error("det(): use of ATLAS or LAPACK must be enabled"); + arma_stop_logic_error("det(): use of LAPACK must be enabled"); return false; } #endif @@ -446,44 +382,7 @@ auxlib::log_det(eT& out_val, typename get_pod_type::result& out_sign, Mat ipiv(A.n_rows); - - arma_extra_debug_print("atlas::clapack_getrf()"); - const int info = atlas::clapack_getrf(atlas::CblasColMajor, A.n_rows, A.n_cols, A.memptr(), A.n_rows, ipiv.memptr()); - - if(info < 0) { return false; } - - // on output A appears to be L+U_alt, where U_alt is U with the main diagonal set to zero - - sword sign = (is_cx::no) ? ( (access::tmp_real( A.at(0,0) ) < T(0)) ? -1 : +1 ) : +1; - eT val = (is_cx::no) ? std::log( (access::tmp_real( A.at(0,0) ) < T(0)) ? A.at(0,0)*T(-1) : A.at(0,0) ) : std::log( A.at(0,0) ); - - for(uword i=1; i < A.n_rows; ++i) - { - const eT x = A.at(i,i); - - sign *= (is_cx::no) ? ( (access::tmp_real(x) < T(0)) ? -1 : +1 ) : +1; - val += (is_cx::no) ? std::log( (access::tmp_real(x) < T(0)) ? x*T(-1) : x ) : std::log(x); - } - - for(uword i=0; i < A.n_rows; ++i) - { - if( int(i) != ipiv.mem[i] ) // NOTE: no adjustment required, as the clapack version of getrf() assumes counting from 0 - { - sign *= -1; - } - } - - out_val = val; - out_sign = T(sign); - - return true; - } - #elif defined(ARMA_USE_LAPACK) + #if defined(ARMA_USE_LAPACK) { arma_debug_assert_blas_size(A); @@ -529,7 +428,7 @@ auxlib::log_det(eT& out_val, typename get_pod_type::result& out_sign, Mat::result& out_val, Mat& A) if(A.is_empty()) { out_val = T(0); return true; } - #if defined(ARMA_USE_ATLAS) - { - arma_debug_assert_atlas_size(A); - - int info = 0; - - arma_extra_debug_print("atlas::clapack_potrf()"); - info = atlas::clapack_potrf(atlas::CblasColMajor, atlas::CblasLower, A.n_rows, A.memptr(), A.n_rows); - - if(info != 0) { return false; } - - T val = std::log( access::tmp_real(A.at(0,0)) ); - - for(uword i=1; i < A.n_rows; ++i) { val += std::log( access::tmp_real(A.at(i,i)) ); } - - out_val = T(2) * val; - - return true; - } - #elif defined(ARMA_USE_LAPACK) + #if defined(ARMA_USE_LAPACK) { arma_debug_assert_blas_size(A); @@ -592,7 +472,7 @@ auxlib::log_det_sympd(typename get_pod_type::result& out_val, Mat& A) { arma_ignore(out_val); arma_ignore(A); - arma_stop_logic_error("det(): use of ATLAS or LAPACK must be enabled"); + arma_stop_logic_error("det(): use of LAPACK must be enabled"); return false; } #endif @@ -621,39 +501,24 @@ auxlib::lu(Mat& L, Mat& U, podarray& ipiv, const Base& return true; } - #if defined(ARMA_USE_ATLAS) || defined(ARMA_USE_LAPACK) + #if defined(ARMA_USE_LAPACK) { - #if defined(ARMA_USE_ATLAS) - { - arma_debug_assert_atlas_size(U); - - ipiv.set_size( (std::min)(U_n_rows, U_n_cols) ); - - arma_extra_debug_print("atlas::clapack_getrf()"); - int info = atlas::clapack_getrf(atlas::CblasColMajor, U_n_rows, U_n_cols, U.memptr(), U_n_rows, ipiv.memptr()); - - if(info < 0) { return false; } - } - #elif defined(ARMA_USE_LAPACK) - { - arma_debug_assert_blas_size(U); - - ipiv.set_size( (std::min)(U_n_rows, U_n_cols) ); - - blas_int info = 0; - - blas_int n_rows = blas_int(U_n_rows); - blas_int n_cols = blas_int(U_n_cols); - - arma_extra_debug_print("lapack::getrf()"); - lapack::getrf(&n_rows, &n_cols, U.memptr(), &n_rows, ipiv.memptr(), &info); - - if(info < 0) { return false; } - - // take into account that Fortran counts from 1 - arrayops::inplace_minus(ipiv.memptr(), blas_int(1), ipiv.n_elem); - } - #endif + arma_debug_assert_blas_size(U); + + ipiv.set_size( (std::min)(U_n_rows, U_n_cols) ); + + blas_int info = 0; + + blas_int n_rows = blas_int(U_n_rows); + blas_int n_cols = blas_int(U_n_cols); + + arma_extra_debug_print("lapack::getrf()"); + lapack::getrf(&n_rows, &n_cols, U.memptr(), &n_rows, ipiv.memptr(), &info); + + if(info < 0) { return false; } + + // take into account that Fortran counts from 1 + arrayops::inplace_minus(ipiv.memptr(), blas_int(1), ipiv.n_elem); L.copy_size(U); @@ -680,7 +545,7 @@ auxlib::lu(Mat& L, Mat& U, podarray& ipiv, const Base& } #else { - arma_stop_logic_error("lu(): use of ATLAS or LAPACK must be enabled"); + arma_stop_logic_error("lu(): use of LAPACK must be enabled"); return false; } #endif @@ -2455,18 +2320,7 @@ auxlib::chol_simple(Mat& X) { arma_extra_debug_sigprint(); - #if defined(ARMA_USE_ATLAS) - { - arma_debug_assert_atlas_size(X); - - int info = 0; - - arma_extra_debug_print("atlas::clapack_potrf()"); - info = atlas::clapack_potrf(atlas::CblasColMajor, atlas::CblasUpper, X.n_rows, X.memptr(), X.n_rows); - - return (info == 0); - } - #elif defined(ARMA_USE_LAPACK) + #if defined(ARMA_USE_LAPACK) { arma_debug_assert_blas_size(X); @@ -2483,7 +2337,7 @@ auxlib::chol_simple(Mat& X) { arma_ignore(X); - arma_stop_logic_error("chol(): use of ATLAS or LAPACK must be enabled"); + arma_stop_logic_error("chol(): use of LAPACK must be enabled"); return false; } #endif @@ -2498,22 +2352,7 @@ auxlib::chol(Mat& X, const uword layout) { arma_extra_debug_sigprint(); - #if defined(ARMA_USE_ATLAS) - { - arma_debug_assert_atlas_size(X); - - int info = 0; - - arma_extra_debug_print("atlas::clapack_potrf()"); - info = atlas::clapack_potrf(atlas::CblasColMajor, ((layout == 0) ? atlas::CblasUpper : atlas::CblasLower), X.n_rows, X.memptr(), X.n_rows); - - if(info != 0) { return false; } - - X = (layout == 0) ? trimatu(X) : trimatl(X); // trimatu() and trimatl() return the same type - - return true; - } - #elif defined(ARMA_USE_LAPACK) + #if defined(ARMA_USE_LAPACK) { arma_debug_assert_blas_size(X); @@ -2535,7 +2374,7 @@ auxlib::chol(Mat& X, const uword layout) arma_ignore(X); arma_ignore(layout); - arma_stop_logic_error("chol(): use of ATLAS or LAPACK must be enabled"); + arma_stop_logic_error("chol(): use of LAPACK must be enabled"); return false; } #endif @@ -4208,18 +4047,7 @@ auxlib::solve_square_fast(Mat& out, Mat ipiv(A_n_rows + 2); // +2 for paranoia: old versions of Atlas might be trashing memory - - arma_extra_debug_print("atlas::clapack_gesv()"); - int info = atlas::clapack_gesv(atlas::CblasColMajor, A_n_rows, B_n_cols, A.memptr(), A_n_rows, ipiv.memptr(), out.memptr(), A_n_rows); - - return (info == 0); - } - #elif defined(ARMA_USE_LAPACK) + #if defined(ARMA_USE_LAPACK) { arma_debug_assert_blas_size(A); @@ -4238,7 +4066,7 @@ auxlib::solve_square_fast(Mat& out, Mat& out, Mat(atlas::CblasColMajor, atlas::CblasLower, A_n_rows, B_n_cols, A.memptr(), A_n_rows, out.memptr(), B_n_rows); - - return (info == 0); - } - #elif defined(ARMA_USE_LAPACK) + #if defined(ARMA_USE_LAPACK) { arma_debug_assert_blas_size(A, out); @@ -4610,7 +4427,7 @@ auxlib::solve_sympd_fast_common(Mat& out, Mat - #include - } - #else - #define ARMA_STR1(x) x - #define ARMA_STR2(x) ARMA_STR1(x) - - #define ARMA_CBLAS ARMA_STR2(ARMA_ATLAS_INCLUDE_DIR)ARMA_STR2(cblas.h) - #define ARMA_CLAPACK ARMA_STR2(ARMA_ATLAS_INCLUDE_DIR)ARMA_STR2(clapack.h) - - extern "C" - { - #include ARMA_INCFILE_WRAP(ARMA_CBLAS) - #include ARMA_INCFILE_WRAP(ARMA_CLAPACK) - } - - #undef ARMA_STR1 - #undef ARMA_STR2 - #undef ARMA_CBLAS - #undef ARMA_CLAPACK - #endif -#endif diff --git a/include/armadillo_bits/mul_gemm.hpp b/include/armadillo_bits/mul_gemm.hpp index 8b2ece94..ccf08c8c 100644 --- a/include/armadillo_bits/mul_gemm.hpp +++ b/include/armadillo_bits/mul_gemm.hpp @@ -239,7 +239,7 @@ class gemm_emul //! \brief -//! Wrapper for ATLAS/BLAS dgemm function, using template arguments to control the arguments passed to dgemm. +//! Wrapper for BLAS dgemm function, using template arguments to control the arguments passed to dgemm. //! Matrix 'C' is assumed to have been set to the correct size (ie. taking into account transposes) template @@ -272,31 +272,7 @@ class gemm } else { - #if defined(ARMA_USE_ATLAS) - { - arma_extra_debug_print("atlas::cblas_gemm()"); - - arma_debug_assert_atlas_size(A,B); - - atlas::cblas_gemm - ( - atlas::CblasColMajor, - (do_trans_A) ? ( is_cx::yes ? CblasConjTrans : atlas::CblasTrans ) : atlas::CblasNoTrans, - (do_trans_B) ? ( is_cx::yes ? CblasConjTrans : atlas::CblasTrans ) : atlas::CblasNoTrans, - C.n_rows, - C.n_cols, - (do_trans_A) ? A.n_rows : A.n_cols, - (use_alpha) ? alpha : eT(1), - A.mem, - (do_trans_A) ? A.n_rows : C.n_rows, - B.mem, - (do_trans_B) ? C.n_cols : ( (do_trans_A) ? A.n_rows : A.n_cols ), - (use_beta) ? beta : eT(0), - C.memptr(), - C.n_rows - ); - } - #elif defined(ARMA_USE_BLAS) + #if defined(ARMA_USE_BLAS) { arma_extra_debug_print("blas::gemm()"); diff --git a/include/armadillo_bits/mul_gemv.hpp b/include/armadillo_bits/mul_gemv.hpp index d166d85a..41536dd0 100644 --- a/include/armadillo_bits/mul_gemv.hpp +++ b/include/armadillo_bits/mul_gemv.hpp @@ -209,7 +209,7 @@ class gemv_emul_helper //! \brief -//! Partial emulation of ATLAS/BLAS gemv(). +//! Partial emulation of BLAS gemv(). //! 'y' is assumed to have been set to the correct size (ie. taking into account the transpose) template @@ -293,7 +293,7 @@ class gemv_emul //! \brief -//! Wrapper for ATLAS/BLAS gemv function, using template arguments to control the arguments passed to gemv. +//! Wrapper for BLAS gemv function, using template arguments to control the arguments passed to gemv. //! 'y' is assumed to have been set to the correct size (ie. taking into account the transpose) template @@ -315,56 +315,7 @@ class gemv } else { - #if defined(ARMA_USE_ATLAS) - { - arma_debug_assert_atlas_size(A); - - if(is_cx::no) - { - // use gemm() instead of gemv() to work around a speed issue in Atlas 3.8.4 - - arma_extra_debug_print("atlas::cblas_gemm()"); - - atlas::cblas_gemm - ( - atlas::CblasColMajor, - (do_trans_A) ? ( is_cx::yes ? CblasConjTrans : atlas::CblasTrans ) : atlas::CblasNoTrans, - atlas::CblasNoTrans, - (do_trans_A) ? A.n_cols : A.n_rows, - 1, - (do_trans_A) ? A.n_rows : A.n_cols, - (use_alpha) ? alpha : eT(1), - A.mem, - A.n_rows, - x, - (do_trans_A) ? A.n_rows : A.n_cols, - (use_beta) ? beta : eT(0), - y, - (do_trans_A) ? A.n_cols : A.n_rows - ); - } - else - { - arma_extra_debug_print("atlas::cblas_gemv()"); - - atlas::cblas_gemv - ( - atlas::CblasColMajor, - (do_trans_A) ? ( is_cx::yes ? CblasConjTrans : atlas::CblasTrans ) : atlas::CblasNoTrans, - A.n_rows, - A.n_cols, - (use_alpha) ? alpha : eT(1), - A.mem, - A.n_rows, - x, - 1, - (use_beta) ? beta : eT(0), - y, - 1 - ); - } - } - #elif defined(ARMA_USE_BLAS) + #if defined(ARMA_USE_BLAS) { arma_extra_debug_print("blas::gemv()"); diff --git a/include/armadillo_bits/mul_herk.hpp b/include/armadillo_bits/mul_herk.hpp index 7e0bf5be..c1b72834 100644 --- a/include/armadillo_bits/mul_herk.hpp +++ b/include/armadillo_bits/mul_herk.hpp @@ -326,7 +326,7 @@ class herk if(A.is_vec()) { - // work around poor handling of vectors by herk() in ATLAS 3.8.4 and standard BLAS + // work around poor handling of vectors by herk() in standard BLAS herk_vec::apply(C,A,alpha,beta); @@ -340,41 +340,7 @@ class herk } else { - #if defined(ARMA_USE_ATLAS) - { - if(use_beta == true) - { - typedef typename std::complex eT; - - // use a temporary matrix, as we can't assume that matrix C is already symmetric - Mat D(C.n_rows, C.n_cols, arma_nozeros_indicator()); - - herk::apply_blas_type(D,A,alpha); - - // NOTE: assuming beta=1; this is okay for now, as currently glue_times only uses beta=1 - arrayops::inplace_plus(C.memptr(), D.memptr(), C.n_elem); - - return; - } - - atlas::cblas_herk - ( - atlas::CblasColMajor, - atlas::CblasUpper, - (do_trans_A) ? CblasConjTrans : atlas::CblasNoTrans, - C.n_cols, - (do_trans_A) ? A.n_rows : A.n_cols, - (use_alpha) ? alpha : T(1), - A.mem, - (do_trans_A) ? A.n_rows : C.n_cols, - (use_beta) ? beta : T(0), - C.memptr(), - C.n_cols - ); - - herk_helper::inplace_conj_copy_upper_tri_to_lower_tri(C); - } - #elif defined(ARMA_USE_BLAS) + #if defined(ARMA_USE_BLAS) { if(use_beta == true) { diff --git a/include/armadillo_bits/mul_syrk.hpp b/include/armadillo_bits/mul_syrk.hpp index d5309c1f..0fdb105c 100644 --- a/include/armadillo_bits/mul_syrk.hpp +++ b/include/armadillo_bits/mul_syrk.hpp @@ -286,7 +286,7 @@ class syrk if(A.is_vec()) { - // work around poor handling of vectors by syrk() in ATLAS 3.8.4 and standard BLAS + // work around poor handling of vectors by syrk() in standard BLAS syrk_vec::apply(C,A,alpha,beta); @@ -301,39 +301,7 @@ class syrk } else { - #if defined(ARMA_USE_ATLAS) - { - if(use_beta == true) - { - // use a temporary matrix, as we can't assume that matrix C is already symmetric - Mat D(C.n_rows, C.n_cols, arma_nozeros_indicator()); - - syrk::apply_blas_type(D,A,alpha); - - // NOTE: assuming beta=1; this is okay for now, as currently glue_times only uses beta=1 - arrayops::inplace_plus(C.memptr(), D.memptr(), C.n_elem); - - return; - } - - atlas::cblas_syrk - ( - atlas::CblasColMajor, - atlas::CblasUpper, - (do_trans_A) ? atlas::CblasTrans : atlas::CblasNoTrans, - C.n_cols, - (do_trans_A) ? A.n_rows : A.n_cols, - (use_alpha) ? alpha : eT(1), - A.mem, - (do_trans_A) ? A.n_rows : C.n_cols, - (use_beta) ? beta : eT(0), - C.memptr(), - C.n_cols - ); - - syrk_helper::inplace_copy_upper_tri_to_lower_tri(C); - } - #elif defined(ARMA_USE_BLAS) + #if defined(ARMA_USE_BLAS) { if(use_beta == true) { diff --git a/include/armadillo_bits/op_dot_meat.hpp b/include/armadillo_bits/op_dot_meat.hpp index e2d02b63..f7e9205b 100644 --- a/include/armadillo_bits/op_dot_meat.hpp +++ b/include/armadillo_bits/op_dot_meat.hpp @@ -114,13 +114,7 @@ op_dot::direct_dot(const uword n_elem, const eT* const A, const eT* const B) } else { - #if defined(ARMA_USE_ATLAS) - { - arma_extra_debug_print("atlas::cblas_dot()"); - - return atlas::cblas_dot(n_elem, A, B); - } - #elif defined(ARMA_USE_BLAS) + #if defined(ARMA_USE_BLAS) { arma_extra_debug_print("blas::dot()"); @@ -149,13 +143,7 @@ op_dot::direct_dot(const uword n_elem, const eT* const A, const eT* const B) } else { - #if defined(ARMA_USE_ATLAS) - { - arma_extra_debug_print("atlas::cblas_cx_dot()"); - - return atlas::cblas_cx_dot(n_elem, A, B); - } - #elif defined(ARMA_USE_BLAS) + #if defined(ARMA_USE_BLAS) { arma_extra_debug_print("blas::dot()"); @@ -451,12 +439,6 @@ op_cdot::direct_cdot(const uword n_elem, const eT* const A, const eT* const B) return result[0]; } - #elif defined(ARMA_USE_ATLAS) - { - // TODO: use dedicated atlas functions cblas_cdotc_sub() and cblas_zdotc_sub() and retune threshold - - return op_cdot::direct_cdot_arma(n_elem, A, B); - } #else { return op_cdot::direct_cdot_arma(n_elem, A, B); diff --git a/include/armadillo_bits/op_norm_meat.hpp b/include/armadillo_bits/op_norm_meat.hpp index 658c7656..a86fa6f1 100644 --- a/include/armadillo_bits/op_norm_meat.hpp +++ b/include/armadillo_bits/op_norm_meat.hpp @@ -233,11 +233,7 @@ op_norm::vec_norm_1_direct_std(const Mat& X) } else { - #if defined(ARMA_USE_ATLAS) - { - return atlas::cblas_asum(N,A); - } - #elif defined(ARMA_USE_BLAS) + #if defined(ARMA_USE_BLAS) { return blas::asum(N,A); } @@ -534,11 +530,7 @@ op_norm::vec_norm_2_direct_std(const Mat& X) } else { - #if defined(ARMA_USE_ATLAS) - { - result = atlas::cblas_nrm2(N,A); - } - #elif defined(ARMA_USE_BLAS) + #if defined(ARMA_USE_BLAS) { result = blas::nrm2(N,A); } diff --git a/include/armadillo_bits/translate_atlas.hpp b/include/armadillo_bits/translate_atlas.hpp deleted file mode 100644 index 1b01350c..00000000 --- a/include/armadillo_bits/translate_atlas.hpp +++ /dev/null @@ -1,509 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 -// -// Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au) -// Copyright 2008-2016 National ICT Australia (NICTA) -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ------------------------------------------------------------------------ - - -#ifdef ARMA_USE_ATLAS - - -//! \namespace atlas namespace for ATLAS functions (imported from the global namespace) -namespace atlas - { - - template - inline static const eT& tmp_real(const eT& X) { return X; } - - template - inline static const T tmp_real(const std::complex& X) { return X.real(); } - - - - template - arma_inline - eT - cblas_asum(const int N, const eT* X) - { - arma_type_check((is_supported_blas_type::value == false)); - - if(is_float::value) - { - typedef float T; - return eT( arma_wrapper(cblas_sasum)(N, (const T*)X, 1) ); - } - else - if(is_double::value) - { - typedef double T; - return eT( arma_wrapper(cblas_dasum)(N, (const T*)X, 1) ); - } - - return eT(0); - } - - - - template - arma_inline - eT - cblas_nrm2(const int N, const eT* X) - { - arma_type_check((is_supported_blas_type::value == false)); - - if(is_float::value) - { - typedef float T; - return eT( arma_wrapper(cblas_snrm2)(N, (const T*)X, 1) ); - } - else - if(is_double::value) - { - typedef double T; - return eT( arma_wrapper(cblas_dnrm2)(N, (const T*)X, 1) ); - } - - return eT(0); - } - - - - template - arma_inline - eT - cblas_dot(const int N, const eT* X, const eT* Y) - { - arma_type_check((is_supported_blas_type::value == false)); - - if(is_float::value) - { - typedef float T; - return eT( arma_wrapper(cblas_sdot)(N, (const T*)X, 1, (const T*)Y, 1) ); - } - else - if(is_double::value) - { - typedef double T; - return eT( arma_wrapper(cblas_ddot)(N, (const T*)X, 1, (const T*)Y, 1) ); - } - - return eT(0); - } - - - - template - arma_inline - eT - cblas_cx_dot(const int N, const eT* X, const eT* Y) - { - arma_type_check((is_supported_blas_type::value == false)); - - if(is_cx_float::value) - { - typedef typename std::complex T; - - T out; - arma_wrapper(cblas_cdotu_sub)(N, (const T*)X, 1, (const T*)Y, 1, &out); - - return eT(out); - } - else - if(is_cx_double::value) - { - typedef typename std::complex T; - - T out; - arma_wrapper(cblas_zdotu_sub)(N, (const T*)X, 1, (const T*)Y, 1, &out); - - return eT(out); - } - - return eT(0); - } - - - - template - inline - void - cblas_gemv - ( - const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, - const int M, const int N, - const eT alpha, - const eT *A, const int lda, - const eT *X, const int incX, - const eT beta, - eT *Y, const int incY - ) - { - arma_type_check((is_supported_blas_type::value == false)); - - if(is_float::value) - { - typedef float T; - arma_wrapper(cblas_sgemv)(Order, TransA, M, N, (const T)tmp_real(alpha), (const T*)A, lda, (const T*)X, incX, (const T)tmp_real(beta), (T*)Y, incY); - } - else - if(is_double::value) - { - typedef double T; - arma_wrapper(cblas_dgemv)(Order, TransA, M, N, (const T)tmp_real(alpha), (const T*)A, lda, (const T*)X, incX, (const T)tmp_real(beta), (T*)Y, incY); - } - else - if(is_cx_float::value) - { - typedef std::complex T; - arma_wrapper(cblas_cgemv)(Order, TransA, M, N, (const T*)&alpha, (const T*)A, lda, (const T*)X, incX, (const T*)&beta, (T*)Y, incY); - } - else - if(is_cx_double::value) - { - typedef std::complex T; - arma_wrapper(cblas_zgemv)(Order, TransA, M, N, (const T*)&alpha, (const T*)A, lda, (const T*)X, incX, (const T*)&beta, (T*)Y, incY); - } - } - - - - template - inline - void - cblas_gemm - ( - const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, - const enum CBLAS_TRANSPOSE TransB, const int M, const int N, - const int K, const eT alpha, const eT *A, - const int lda, const eT *B, const int ldb, - const eT beta, eT *C, const int ldc - ) - { - arma_type_check((is_supported_blas_type::value == false)); - - if(is_float::value) - { - typedef float T; - arma_wrapper(cblas_sgemm)(Order, TransA, TransB, M, N, K, (const T)tmp_real(alpha), (const T*)A, lda, (const T*)B, ldb, (const T)tmp_real(beta), (T*)C, ldc); - } - else - if(is_double::value) - { - typedef double T; - arma_wrapper(cblas_dgemm)(Order, TransA, TransB, M, N, K, (const T)tmp_real(alpha), (const T*)A, lda, (const T*)B, ldb, (const T)tmp_real(beta), (T*)C, ldc); - } - else - if(is_cx_float::value) - { - typedef std::complex T; - arma_wrapper(cblas_cgemm)(Order, TransA, TransB, M, N, K, (const T*)&alpha, (const T*)A, lda, (const T*)B, ldb, (const T*)&beta, (T*)C, ldc); - } - else - if(is_cx_double::value) - { - typedef std::complex T; - arma_wrapper(cblas_zgemm)(Order, TransA, TransB, M, N, K, (const T*)&alpha, (const T*)A, lda, (const T*)B, ldb, (const T*)&beta, (T*)C, ldc); - } - } - - - - template - inline - void - cblas_syrk - ( - const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE Trans, - const int N, const int K, const eT alpha, - const eT* A, const int lda, const eT beta, eT* C, const int ldc - ) - { - arma_type_check((is_supported_blas_type::value == false)); - - if(is_float::value) - { - typedef float T; - arma_wrapper(cblas_ssyrk)(Order, Uplo, Trans, N, K, (const T)alpha, (const T*)A, lda, (const T)beta, (T*)C, ldc); - } - else - if(is_double::value) - { - typedef double T; - arma_wrapper(cblas_dsyrk)(Order, Uplo, Trans, N, K, (const T)alpha, (const T*)A, lda, (const T)beta, (T*)C, ldc); - } - } - - - - template - inline - void - cblas_herk - ( - const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo, const enum CBLAS_TRANSPOSE Trans, - const int N, const int K, const T alpha, - const std::complex* A, const int lda, const T beta, std::complex* C, const int ldc - ) - { - arma_type_check((is_supported_blas_type::value == false)); - - if(is_float::value) - { - typedef float TT; - typedef std::complex cx_TT; - - arma_wrapper(cblas_cherk)(Order, Uplo, Trans, N, K, (const TT)alpha, (const cx_TT*)A, lda, (const TT)beta, (cx_TT*)C, ldc); - } - else - if(is_double::value) - { - typedef double TT; - typedef std::complex cx_TT; - - arma_wrapper(cblas_zherk)(Order, Uplo, Trans, N, K, (const TT)alpha, (const cx_TT*)A, lda, (const TT)beta, (cx_TT*)C, ldc); - } - } - - - - template - inline - int - clapack_getrf - ( - const enum CBLAS_ORDER Order, const int M, const int N, - eT *A, const int lda, int *ipiv - ) - { - arma_type_check((is_supported_blas_type::value == false)); - - if(is_float::value) - { - typedef float T; - return arma_wrapper(clapack_sgetrf)(Order, M, N, (T*)A, lda, ipiv); - } - else - if(is_double::value) - { - typedef double T; - return arma_wrapper(clapack_dgetrf)(Order, M, N, (T*)A, lda, ipiv); - } - else - if(is_cx_float::value) - { - typedef std::complex T; - return arma_wrapper(clapack_cgetrf)(Order, M, N, (T*)A, lda, ipiv); - } - else - if(is_cx_double::value) - { - typedef std::complex T; - return arma_wrapper(clapack_zgetrf)(Order, M, N, (T*)A, lda, ipiv); - } - - return -1; - } - - - - template - inline - int - clapack_getri - ( - const enum CBLAS_ORDER Order, const int N, eT *A, - const int lda, const int *ipiv - ) - { - arma_type_check((is_supported_blas_type::value == false)); - - if(is_float::value) - { - typedef float T; - return arma_wrapper(clapack_sgetri)(Order, N, (T*)A, lda, ipiv); - } - else - if(is_double::value) - { - typedef double T; - return arma_wrapper(clapack_dgetri)(Order, N, (T*)A, lda, ipiv); - } - else - if(is_cx_float::value) - { - typedef std::complex T; - return arma_wrapper(clapack_cgetri)(Order, N, (T*)A, lda, ipiv); - } - else - if(is_cx_double::value) - { - typedef std::complex T; - return arma_wrapper(clapack_zgetri)(Order, N, (T*)A, lda, ipiv); - } - - return -1; - } - - - - template - inline - int - clapack_gesv - ( - const enum CBLAS_ORDER Order, - const int N, const int NRHS, - eT* A, const int lda, int* ipiv, - eT* B, const int ldb - ) - { - arma_type_check((is_supported_blas_type::value == false)); - - if(is_float::value) - { - typedef float T; - return arma_wrapper(clapack_sgesv)(Order, N, NRHS, (T*)A, lda, ipiv, (T*)B, ldb); - } - else - if(is_double::value) - { - typedef double T; - return arma_wrapper(clapack_dgesv)(Order, N, NRHS, (T*)A, lda, ipiv, (T*)B, ldb); - } - else - if(is_cx_float::value) - { - typedef std::complex T; - return arma_wrapper(clapack_cgesv)(Order, N, NRHS, (T*)A, lda, ipiv, (T*)B, ldb); - } - else - if(is_cx_double::value) - { - typedef std::complex T; - return arma_wrapper(clapack_zgesv)(Order, N, NRHS, (T*)A, lda, ipiv, (T*)B, ldb); - } - - return -1; - } - - - - template - inline - int - clapack_potrf(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo, const int N, eT *A, const int lda) - { - arma_type_check((is_supported_blas_type::value == false)); - - if(is_float::value) - { - typedef float T; - return arma_wrapper(clapack_spotrf)(Order, Uplo, N, (T*)A, lda); - } - else - if(is_double::value) - { - typedef double T; - return arma_wrapper(clapack_dpotrf)(Order, Uplo, N, (T*)A, lda); - } - else - if(is_cx_float::value) - { - typedef std::complex T; - return arma_wrapper(clapack_cpotrf)(Order, Uplo, N, (T*)A, lda); - } - else - if(is_cx_double::value) - { - typedef std::complex T; - return arma_wrapper(clapack_zpotrf)(Order, Uplo, N, (T*)A, lda); - } - - return -1; - } - - - - template - inline - int - clapack_potri(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo, const int N, eT *A, const int lda) - { - arma_type_check((is_supported_blas_type::value == false)); - - if(is_float::value) - { - typedef float T; - return arma_wrapper(clapack_spotri)(Order, Uplo, N, (T*)A, lda); - } - else - if(is_double::value) - { - typedef double T; - return arma_wrapper(clapack_dpotri)(Order, Uplo, N, (T*)A, lda); - } - else - if(is_cx_float::value) - { - typedef std::complex T; - return arma_wrapper(clapack_cpotri)(Order, Uplo, N, (T*)A, lda); - } - else - if(is_cx_double::value) - { - typedef std::complex T; - return arma_wrapper(clapack_zpotri)(Order, Uplo, N, (T*)A, lda); - } - - return -1; - } - - - - template - inline - int - clapack_posv(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo, const int N, const int NRHS, eT *A, const int lda, eT *B, const int ldb) - { - arma_type_check((is_supported_blas_type::value == false)); - - if(is_float::value) - { - typedef float T; - return arma_wrapper(clapack_sposv)(Order, Uplo, N, NRHS, (T*)A, lda, (T*)B, ldb); - } - else - if(is_double::value) - { - typedef double T; - return arma_wrapper(clapack_dposv)(Order, Uplo, N, NRHS, (T*)A, lda, (T*)B, ldb); - } - else - if(is_cx_float::value) - { - typedef std::complex T; - return arma_wrapper(clapack_cposv)(Order, Uplo, N, NRHS, (T*)A, lda, (T*)B, ldb); - } - else - if(is_cx_double::value) - { - typedef std::complex T; - return arma_wrapper(clapack_zposv)(Order, Uplo, N, NRHS, (T*)A, lda, (T*)B, ldb); - } - - return -1; - } - } - -#endif