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