/* * Copyright (C) FFLAS-FFPACK * Written by Pascal Giorgi * * This file is Free Software and part of FFLAS-FFPACK. * * ========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======== *. */ // declare that the call to openblas_set_numthread will be made here, hence don't do it // everywhere in the call stack #define __FFLASFFPACK_OPENBLAS_NT_ALREADY_SET 1 #if not defined(MG_DEFAULT) #define MG_DEFAULT MG_ACTIVE #endif #if not defined(STD_RECINT_SIZE) #define STD_RECINT_SIZE 8 #endif #include "fflas-ffpack/fflas-ffpack-config.h" #include #include #include #include using namespace std; #include "fflas-ffpack/fflas/fflas.h" #include "fflas-ffpack/utils/fflas_io.h" #include "fflas-ffpack/utils/timer.h" #include "fflas-ffpack/utils/args-parser.h" #include "givaro/modular-integer.h" #include "givaro/givcaster.h" #include "fflas-ffpack/paladin/parallel.h" #ifdef BENCH_RECINT #include "recint/recint.h" #endif #ifdef BENCH_FLINT #define __GMP_BITS_PER_MP_LIMB 64 extern "C" { #include "flint/longlong.h" #include "flint/long_extras.h" #include "flint/fmpz_mat.h" #include "flint/fmpz.h" #include "flint/flint.h" } #endif static size_t iters = 3 ; static Givaro::Integer q = -1 ; static unsigned long b = 512 ; static size_t m = 512 ; static size_t k = 512 ; static size_t n = 512 ; static int nbw = -1 ; static size_t seed= time(NULL); static Argument as[] = { { 'q', "-q Q", "Set the field characteristic (-1 for random).", TYPE_INTEGER , &q }, { 'b', "-b B", "Set the bitsize of the random characteristic.", TYPE_INT , &b }, { 'm', "-m M", "Set the dimension m of the matrix.", TYPE_INT , &m }, { 'k', "-k K", "Set the dimension k of the matrix.", TYPE_INT , &k }, { 'n', "-n N", "Set the dimension n of the matrix.", TYPE_INT , &n }, { 'w', "-w N", "Set the number of winograd levels (-1 for random).", TYPE_INT , &nbw }, { 'i', "-i R", "Set number of repetitions.", TYPE_INT , &iters }, { 's', "-s S", "Sets seed.", TYPE_INT , &seed }, END_OF_ARGUMENTS }; template int tmain(){ srand( (int)seed); srand48(seed); Givaro::Integer::seeding(seed); typedef Givaro::Modular Field; Givaro::Integer p; FFLAS::Timer chrono, TimFreivalds; double time=0.,timev=0.; #ifdef BENCH_FLINT double timeFlint=0.; #endif for (size_t loop=0;loop(ip,p); Givaro::Caster(p,ip); // to check consistency Field F(ip); size_t lda,ldb,ldc; lda=k; ldb=n; ldc=n; typename Field::RandIter Rand(F,seed); typename Field::Element_ptr A,B,C; A= FFLAS::fflas_new(F,m,lda); B= FFLAS::fflas_new(F,k,ldb); C= FFLAS::fflas_new(F,m,ldc); // for (size_t i=0;i(&p))); fmpz_mat_t AA,BB,CC,DD; fmpz_mat_init (AA, m, k); fmpz_mat_init (BB, k, n); fmpz_mat_init (CC, m, n); fmpz_mat_init (DD, m, n); fmpz_t aalpha, bbeta; fmpz_set_mpz(aalpha,*(reinterpret_cast(&alpha))); fmpz_set_mpz(bbeta,*(reinterpret_cast(&beta))); for (size_t i=0;i(A+i*lda+j))); for (size_t i=0;i(B+i*ldb+j))); for (size_t i=0;i(C+i*ldc+j))); chrono.clear();chrono.start(); // DD= A.B fmpz_mat_mul(DD,AA,BB); // CC = beta.C fmpz_mat_scalar_mul_fmpz(CC,CC,bbeta); // CC = CC + DD.alpha fmpz_mat_scalar_addmul_fmpz(CC,DD,aalpha); // CC = CC mod p for (size_t i=0;i(); #ifdef BENCH_RECINT r1 += tmain>(); #endif return r1; } /* -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ // vim:sts=4:sw=4:ts=4:et:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s