| 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; |
| | 243 | |
| | 244 | if (F.isZero (alpha)){ |
| | 245 | for (size_t i = 0; i<m; ++i) |
| | 246 | fscal(F, n, beta, C + i*ldc, 1); |
| | 247 | return C; |
| | 248 | } |
| | 249 | |
| | 250 | size_t kmax = 0; |
| | 251 | size_t winolevel = w; |
| | 252 | FFLAS_BASE base; |
| | 253 | MatMulParameters (F, MIN(MIN(m,n),k), beta, kmax, base, |
| | 254 | winolevel, true); |
| 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] |
| | 461 | /** |
| | 462 | * MatMulParameters |
| | 463 | * |
| | 464 | * \brief Computes the threshold parameters for the cascade |
| | 465 | * Matmul algorithm |
| | 466 | * |
| | 467 | * |
| | 468 | * \param F Finite Field/Ring of the computation. |
| | 469 | * \param k Common dimension of A and B, in the product A x B |
| | 470 | * \param bet Computing AB + beta C |
| | 471 | * \param delayedDim Returns the size of blocks that can be multiplied |
| | 472 | * over Z with no overflow |
| | 473 | * \param base Returns the type of BLAS representation to use |
| | 474 | * \param winoRecLevel Returns the number of recursion levels of |
| | 475 | * Strassen-Winograd's algorithm to perform |
| | 476 | * \param winoLevelProvided tells whether the user forced the number of |
| | 477 | * recursive level of Winograd's algorithm |
| | 478 | * |
| | 479 | * See [Dumas, Giorgi, Pernet, arXiv cs/0601133] |
| | 480 | * http://arxiv.org/abs/cs.SC/0601133 |
| 461 | | static size_t DotProdBound (const Field& F, const size_t w, |
| 462 | | const typename Field::Element& beta, |
| 463 | | const FFLAS_BASE base); |
| 464 | | |
| | 483 | static void MatMulParameters (const Field& F, |
| | 484 | const size_t k, |
| | 485 | const typename Field::Element& beta, |
| | 486 | size_t& delayedDim, |
| | 487 | FFLAS_BASE& base, |
| | 488 | size_t& winoRecLevel, |
| | 489 | bool winoLevelProvided=false); |
| | 490 | |
| | 491 | |
| | 492 | /** |
| | 493 | * DotprodBound |
| | 494 | * |
| | 495 | * \brief computes the maximal size for delaying the modular reduction |
| | 496 | * in a dotproduct |
| | 497 | * |
| | 498 | * This is the default version assuming a conversion to a positive modular representation |
| | 499 | * |
| | 500 | * \param F Finite Field/Ring of the computation |
| | 501 | * \param winoRecLevel Number of recusrive Strassen-Winograd levels (if any, 0 otherwise) |
| | 502 | * \param beta Computing AB + beta C |
| | 503 | * \param base Type of floating point representation for delayed modular computations |
| | 504 | * |
| | 505 | */ |
| 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 | | |
| | 507 | static size_t DotProdBound (const Field& F, |
| | 508 | const size_t w, |
| | 509 | const typename Field::Element& beta, |
| | 510 | const FFLAS_BASE base); |
| | 511 | |
| | 512 | |
| | 513 | /** |
| | 514 | * Internal function for the bound computation |
| | 515 | * Generic implementation for positive representations |
| | 516 | */ |
| | 517 | template <class Field> |
| | 518 | static double computeFactor (const Field& F, const size_t w); |
| | 519 | |
| | 520 | |
| | 521 | /** |
| | 522 | * Winosteps |
| | 523 | * |
| | 524 | * \brief Computes the number of recursive levels to perform |
| | 525 | * |
| | 526 | * \param m the common dimension in the product AxB |
| | 527 | */ |
| 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 |
| | 530 | /** |
| | 531 | * BaseCompute |
| | 532 | * |
| | 533 | * \brief Determines the type of floating point representation to convert to, |
| | 534 | * for BLAS computations |
| | 535 | * \param F Finite Field/Ring of the computation |
| | 536 | * \param w Number of recursive levels in Winograd's algorithm |
| | 537 | */ |
| | 538 | template <class Field> |
| | 539 | static FFLAS_BASE BaseCompute (const Field& F, const size_t w); |
| | 540 | |
| | 541 | /** |
| | 542 | * TRSMBound |
| | 543 | * |
| | 544 | * \brief computes the maximal size for delaying the modular reduction |
| | 545 | * in a triangular system resolution |