Show
Ignore:
Timestamp:
06/06/08 19:09:43 (6 months ago)
Author:
pernet
Message:

* Upgrade to fflas-ffpack v 1.3.3
* rename all the modular-balance into modular-balanced
* fix the few remaining compilation warning with gcc-4.3

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/linbox/linbox/fflas/fflas.h

    r2898 r2962  
    2424#include "linbox/config-blas.h" 
    2525#include "linbox/field/unparametric.h" 
    26  
     26#include "linbox/field/modular-double.h" 
     27#include "linbox/field/modular-float.h" 
     28#include "linbox/field/modular-balanced-double.h" 
     29#include "linbox/field/modular-balanced-float.h" 
    2730namespace LinBox { 
    2831#else 
    2932#include "config-blas.h" 
    30 #include "unparametric.h" 
     33#include "fflas-ffpack/unparametric.h" 
     34#include "fflas-ffpack/modular-positive.h" 
     35#include "fflas-ffpack/modular-balanced.h" 
    3136#endif 
    3237         
     
    5863         * FflasDouble: to use the double precision BLAS 
    5964         * FflasFloat: to use the single precison BLAS 
    60          * FflasFloat: for any other domain, that can not be converted to floating point integers 
     65         * FflasGeneric: for any other domain, that can not be converted to floating point integers 
    6166         */ 
    6267        enum FFLAS_BASE      { FflasDouble = 151, FflasFloat = 152, FflasGeneric = 153}; 
     
    238243 
    239244                if (!(m && n && k)) return C; 
    240                  
    241                 FFLAS_BASE base = BaseCompute<typename Field::Element> ()(F, w); 
    242                 size_t d = DotProdBound (F, w, beta, base); 
    243                 //std::cerr<<"d = "<<d<<std::endl; 
     245 
     246                if (F.isZero (alpha)){ 
     247                        for (size_t i = 0; i<m; ++i) 
     248                                fscal(F, n, beta, C + i*ldc, 1); 
     249                        return C; 
     250                } 
     251                 
     252                size_t kmax = 0; 
     253                size_t winolevel = w; 
     254                FFLAS_BASE base; 
     255                MatMulParameters (F, MIN(MIN(m,n),k), beta, kmax, base, 
     256                                  winolevel, true); 
    244257                WinoMain (F, ta, tb, m, n, k, alpha, A, lda, B, ldb, beta, 
    245                                  C, ldc, d, w, base); 
     258                                 C, ldc, kmax, winolevel, base); 
    246259                return C; 
    247260                }; 
     
    262275               const size_t k, 
    263276               const typename Field::Element alpha, 
    264                const typename Field::Element* A,  
    265                const size_t lda, 
    266                const typename Field::Element* B, 
    267                const size_t ldb,  
     277               const typename Field::Element* A, const size_t lda, 
     278               const typename Field::Element* B, const size_t ldb,  
    268279               const typename Field::Element beta, 
    269                typename Field::Element* C,  
    270                const size_t ldc){ 
     280               typename Field::Element* C, const size_t ldc){ 
    271281 
    272282                if (!(m && n && k)) return C; 
    273  
    274                 size_t w, kmax=0; 
     283                if (F.isZero (alpha)){ 
     284                        for (size_t i = 0; i<m; ++i) 
     285                                fscal(F, n, beta, C + i*ldc, 1); 
     286                        return C; 
     287                } 
     288                 
     289                size_t w, kmax; 
    275290                FFLAS_BASE base; 
    276291 
    277                 setMatMulParam<typename Field::Element> ()(F, MIN(MIN(m,n),k), beta, 
    278                                                            w, base, kmax); 
     292                MatMulParameters (F, MIN(MIN(m,n),k), beta, kmax, base, w); 
    279293 
    280294                WinoMain (F, ta, tb, m, n, k, alpha, A, lda, B, ldb, beta, 
     
    447461        } 
    448462 
    449         /** @brief Bound for the delayed modulus matrix multiplication 
    450          * 
    451          *  @param F  - the finite field 
    452          *  @param w  - the number of recursive levels of Winograds algorithm being used 
    453          *  @param beta - for the computation of C <- AB + beta C 
    454          * 
    455          *  Compute the maximal dimension k, such that a matrix multiplication (m,k)x(k,n) 
    456          *  can be performed over Z without overflow of the 53 bits of the double 
    457          *  mantissa. 
    458          *  See [Dumas, Gautier, Pernet ISSAC'2002] 
     463        /** 
     464         * MatMulParameters 
     465         * 
     466         * \brief Computes the threshold parameters for the cascade 
     467         *        Matmul algorithm 
     468         * 
     469         *  
     470         * \param F Finite Field/Ring of the computation. 
     471         * \param k Common dimension of A and B, in the product A x B 
     472         * \param bet Computing AB + beta C 
     473         * \param delayedDim Returns the size of blocks that can be multiplied 
     474         *                   over Z with no overflow 
     475         * \param base Returns the type of BLAS representation to use 
     476         * \param winoRecLevel Returns the number of recursion levels of 
     477         *                     Strassen-Winograd's algorithm to perform 
     478         * \param winoLevelProvided tells whether the user forced the number of 
     479         *                          recursive level of Winograd's algorithm 
     480         * 
     481         * See [Dumas, Giorgi, Pernet, arXiv cs/0601133] 
     482         * http://arxiv.org/abs/cs.SC/0601133 
    459483         */ 
    460484        template <class Field> 
    461         static size_t DotProdBound (const Field& F, const size_t w, 
    462                                     const typename Field::Element& beta, 
    463                                     const FFLAS_BASE base); 
    464  
     485        static void MatMulParameters (const Field& F, 
     486                                      const size_t k, 
     487                                      const typename Field::Element& beta, 
     488                                      size_t& delayedDim, 
     489                                      FFLAS_BASE& base, 
     490                                      size_t& winoRecLevel, 
     491                                      bool winoLevelProvided=false); 
     492 
     493         
     494        /** 
     495         * DotprodBound 
     496         * 
     497         * \brief  computes the maximal size for delaying the modular reduction 
     498         *         in a dotproduct 
     499         * 
     500         * This is the default version assuming a conversion to a positive modular representation 
     501         *  
     502         * \param F Finite Field/Ring of the computation 
     503         * \param winoRecLevel Number of recusrive Strassen-Winograd levels (if any, 0 otherwise) 
     504         * \param beta Computing AB + beta C 
     505         * \param base Type of floating point representation for delayed modular computations 
     506         *  
     507         */ 
    465508        template <class Field> 
    466         static size_t DotProdBoundCompute (const Field& F, const size_t w, 
    467                                            const typename Field::Element& beta, 
    468                                            const FFLAS_BASE base); 
    469          
    470  
     509        static size_t DotProdBound (const Field& F, 
     510                             const size_t w,  
     511                             const typename Field::Element& beta, 
     512                             const FFLAS_BASE base); 
     513         
     514 
     515        /** 
     516         * Internal function for the bound computation 
     517         * Generic implementation for positive representations 
     518         */ 
     519        template <class Field> 
     520        static double computeFactor (const Field& F, const size_t w); 
     521         
     522 
     523        /** 
     524         * Winosteps 
     525         * 
     526         * \brief Computes the number of recursive levels to perform 
     527         * 
     528         * \param m the common dimension in the product AxB 
     529         */ 
    471530        static size_t WinoSteps (const size_t m); 
    472531         
    473         //      template <class Element> 
    474 //      class callDotProdBoundCompute; 
    475  
    476         /** @brief Bound for the delayed modulus triangular system solving 
    477          * 
    478          *  @param F  - the finite field 
     532        /** 
     533         * BaseCompute 
     534         * 
     535         * \brief Determines the type of floating point representation to convert to, 
     536         *        for BLAS computations 
     537         * \param F Finite Field/Ring of the computation 
     538         * \param w Number of recursive levels in Winograd's algorithm 
     539         */ 
     540        template <class Field> 
     541        static FFLAS_BASE BaseCompute (const Field& F, const size_t w); 
     542                 
     543        /** 
     544         * TRSMBound 
     545         * 
     546         * \brief  computes the maximal size for delaying the modular reduction 
     547         *         in a triangular system resolution 
    479548         * 
    480549         *  Compute the maximal dimension k, such that a unit diagonal triangular 
    481550         *  system of dimension k can be solved over Z without overflow of the 
    482          *  53 bits of the double mantissa. 
    483          *  See [Dumas, Giorgi, Pernet ISSAC'2004] 
     551         *  underlying floating point representation. 
     552         *  See [Dumas, Giorgi, Pernet 06, arXiv:cs/0601133 ] 
     553         *  
     554         * \param F Finite Field/Ring of the computation 
     555         *  
    484556         */ 
    485557        template <class Field> 
    486558        static size_t TRSMBound (const Field& F); 
    487  
    488         template <class Element> 
    489         class callTRSMBound; 
    490  
    491         /** @brief Set the optimal parameters for the Matrix Multiplication 
    492          */ 
    493         template <class Element> 
    494         class setMatMulParam; 
    495  
    496         template <class Element> 
    497         class BaseCompute; 
    498559 
    499560        template <class Field> 
     
    557618                              const size_t kmax, const size_t w, const FFLAS_BASE base); 
    558619 
    559  
    560         template<class Element> 
    561         class callWinoMain; 
    562  
    563         template<class Element> 
    564         class callClassicMatmul; 
    565  
    566         template<class Element> 
    567         class callFsquare; 
    568  
    569         template<class Element> 
    570         class callMatVectProd; 
    571                  
    572620        // Specialized routines for ftrsm 
    573621        template <class Element>