/* -*- C++ -*- * * --------------------------------------------------------------------- * $Id: testmaperf.cpp,v 1.1.2.3 2005/01/09 20:06:15 drory Exp $ * --------------------------------------------------------------------- * * Copyright (C) 2000-2002 Niv Drory * Claus A. Goessl * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * * --------------------------------------------------------------------- * */ //#define LTL_USE_SIMD #include #include #include #include #include using namespace ltl; using util::Timer; using std::cout; using std::endl; #define NRUNS 8*1024*1024 #define NRUNS_MAT 25e6 double test_fmadd_ltl( const int Nsize ); double test_fmadd_c( const int Nsize ); double test_matmul_ltl( const int Nsize ); double test_matmul_c( const int Nsize ); int get_rep_count( const int Nsize ); int get_rep_count( const int Nsize ) { float fac = float(Nsize); fac = 1./pow(fac,3.0); const int N = int(float(NRUNS_MAT)*fac); return N > 0 ? N : 1; } int main(int argc, char **argv) { int k=16; cout << "fmadd: " << endl; cout << "N C LTL" << endl; while( k<=NRUNS/8 ) { printf( "%8d %9.3E %9.3E\n", k, test_fmadd_c( k ), test_fmadd_ltl( k ) ); k *= 2; } cout << "matmul: " << endl; cout << "N C LTL" << endl; k = 16; while( k<=1024 ) { // cout << get_rep_count( k ) << endl; printf( "%8d %9.3E %9.3E\n", k, test_matmul_c( k ), test_matmul_ltl( k ) ); k *= 2; } } double test_fmadd_ltl( const int Nsize ) { MArray A(Nsize),B(Nsize),C(Nsize); A = 0.0; B = 1.23345; C = 643.345345; const int N = NRUNS/Nsize; Timer t; t.start(); for( int i=0; i A(Nsize,Nsize),B(Nsize,Nsize),C(Nsize,Nsize); A = 0.0; B = 1.23345; C = 0.345345; const Range All = Range::all(); const int N = get_rep_count( Nsize ); Timer t; t.start(); for( int l=0; l