/* -*- mode: C++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */ // vim:sts=4:sw=4:ts=4:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s /* * Copyright (C) 2012 FFLAS-FFPACK group. * * Extirpé form a m4 macro by Brice Boyer (briceboyer) . * * * ========LICENCE======== * This file is part of the library FFLAS-FFPACK. * * FFLAS-FFPACK is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ========LICENCE======== * */ //#define LinBoxSrcOnly #define DOUBLE_TO_FLOAT_CROSSOVER 0 #include "fflas-ffpack/fflas-ffpack-config.h" #include "fflas-ffpack/utils/fflas_randommatrix.h" #include #include #include #include #include "fflas-ffpack/utils/timer.h" #include "fflas-ffpack/fflas/fflas.h" template bool balanced(const Field & ) { return false; } template bool balanced(const Givaro::ModularBalanced&) { return true; } #ifdef __GIVARO_USE_OPENMP typedef Givaro::OMPTimer TTimer; #else typedef Givaro::Timer TTimer; #endif #define GFOPS(n,t) (2.0/t*(double)n/1000.0*(double)n/1000.0*(double)n/1000.0) #include int main () { using namespace std; typedef FIELD Field; Field F(17); typedef Field::Element Element ; size_t n=512, nmax=4000, prec=512, nbest=0, count=0; TTimer chrono; bool bound=false; Element * A = FFLAS::fflas_new (F,nmax,nmax); Element * B = FFLAS::fflas_new (F,nmax,nmax); Element * C = FFLAS::fflas_new (F,nmax,nmax); FFPACK::RandomMatrix (F, nmax, nmax, A, nmax); FFPACK::RandomMatrix (F, nmax, nmax, B, nmax); FFPACK::RandomMatrix (F, nmax, nmax, C, nmax); time_t result = std::time(NULL); cerr << std::endl << "---------------------------------------------------------------------" << std::endl << std::asctime(std::localtime(&result)) << std::endl << "Threshold for finite field Strassen-Winograd matrix multiplication" ; F.write(cerr << " (using ") << ')' << endl << endl; cerr << "fgemm: n Classic Winograd 1 level" << std::endl; cerr << " seconds Gfops seconds Gfops" << std::endl; FFLAS::MMHelper ClassicH(F,0, FFLAS::ParSeqHelper::Sequential()); FFLAS::MMHelper WinogradH(F,1, FFLAS::ParSeqHelper::Sequential()); //warm up computation FFLAS::fgemm(F, FFLAS::FflasNoTrans, FFLAS::FflasNoTrans, n, n, n, F.mOne, A, n, B, n, F.one, C, n, ClassicH); do { double classicTime, winogradTime; int iter=3; chrono.start(); for (int i=0;i winogradTime ){ count++; if (count > 1){ nbest = n; bound = true; prec = prec >> 1; n -= prec; } } else{ count=0; if (bound) prec=prec>>1; n+=prec; } } while ((prec > 32 ) && (n < nmax)); cerr<