| 1 |
/* Copyright (c) FFLAS-FFPACK |
| 2 |
* Written by Clément Pernet <[email protected]> |
| 3 |
* ========LICENCE======== |
| 4 |
* This file is part of the library FFLAS-FFPACK. |
| 5 |
* |
| 6 |
* FFLAS-FFPACK is free software: you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU Lesser General Public |
| 8 |
* License as published by the Free Software Foundation; either |
| 9 |
* version 2.1 of the License, or (at your option) any later version. |
| 10 |
* |
| 11 |
* This library is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
* Lesser General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU Lesser General Public |
| 17 |
* License along with this library; if not, write to the Free Software |
| 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 |
* ========LICENCE======== |
| 20 |
*/ |
| 21 |
|
| 22 |
#include "fflas-ffpack/fflas-ffpack-config.h" |
| 23 |
#include <iostream> |
| 24 |
#include <givaro/modular.h> |
| 25 |
|
| 26 |
#define __FFLASFFPACK_HAVE_DTRTRI 1 |
| 27 |
|
| 28 |
#include "fflas-ffpack/fflas-ffpack.h" |
| 29 |
#include "fflas-ffpack/utils/timer.h" |
| 30 |
#include "fflas-ffpack/utils/fflas_io.h" |
| 31 |
#include "fflas-ffpack/utils/args-parser.h" |
| 32 |
|
| 33 |
#ifdef __FFLASFFPACK_USE_OPENMP |
| 34 |
typedef FFLAS::OMPTimer TTimer; |
| 35 |
#else |
| 36 |
typedef FFLAS::Timer TTimer; |
| 37 |
#endif |
| 38 |
|
| 39 |
|
| 40 |
using namespace std; |
| 41 |
|
| 42 |
int main(int argc, char** argv) { |
| 43 |
|
| 44 |
size_t iter = 1; |
| 45 |
int q = 1009; |
| 46 |
size_t n = 2000; |
| 47 |
std::string file = ""; |
| 48 |
|
| 49 |
Argument as[] = { |
| 50 |
{ 'q', "-q Q", "Set the field characteristic (-1 for random).", TYPE_INT , &q }, |
| 51 |
{ 'n', "-n N", "Set the dimension of the matrix.", TYPE_INT , &n }, |
| 52 |
{ 'i', "-i R", "Set number of repetitions.", TYPE_INT , &iter }, |
| 53 |
{ 'f', "-f FILE", "Set the input file (empty for random).", TYPE_STR , &file }, |
| 54 |
END_OF_ARGUMENTS |
| 55 |
}; |
| 56 |
|
| 57 |
FFLAS::parseArguments(argc,argv,as); |
| 58 |
|
| 59 |
typedef Givaro::Modular<double> Field; |
| 60 |
typedef Field::Element Element; |
| 61 |
|
| 62 |
Field F(q); |
| 63 |
Element * A; |
| 64 |
|
| 65 |
TTimer chrono; |
| 66 |
double time=0.0; |
| 67 |
|
| 68 |
Field::RandIter G(F); |
| 69 |
for (size_t i=0;i<iter;++i){ |
| 70 |
if (!file.empty()){ |
| 71 |
FFLAS::ReadMatrix (file.c_str(),F,n,n,A); |
| 72 |
} else { |
| 73 |
A = FFLAS::fflas_new<Element>(n*n); |
| 74 |
for (size_t j=0; j<(size_t) n*n; ++j) |
| 75 |
G.random(*(A+j)); |
| 76 |
for (size_t k=0;k<(size_t)n;++k) |
| 77 |
while (F.isZero( G.random(*(A+k*(n+1))))); |
| 78 |
} |
| 79 |
|
| 80 |
chrono.clear(); |
| 81 |
chrono.start(); |
| 82 |
clapack_dtrtri(CblasRowMajor,CblasUpper, CblasNonUnit,n,A,n); |
| 83 |
chrono.stop(); |
| 84 |
|
| 85 |
time+=chrono.usertime(); |
| 86 |
FFLAS::fflas_delete( A); |
| 87 |
|
| 88 |
} |
| 89 |
|
| 90 |
// ----------- |
| 91 |
// Standard output for benchmark - Alexis Breust 2014/11/14 |
| 92 |
std::cout << "Time: " << time / double(iter) |
| 93 |
<< " Gfops: " << (2.*double(n)/1000.*double(n)/1000.*double(n)/1000.0) / time * double(iter) / 3.; |
| 94 |
FFLAS::writeCommandString(std::cout, as) << std::endl; |
| 95 |
|
| 96 |
return 0; |
| 97 |
} |
| 98 |
/* -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 99 |
// vim:sts=4:sw=4:ts=4:et:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s |