Debian Codegraph @

benchmarks/benchmark-dgetri.C

raw
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 <vector>
25 #include <givaro/modular.h>
26
27 // #ifndef __FFLASFFPACK_HAVE_DGETRF
28 // #define __FFLASFFPACK_HAVE_DGETRF 1
29 // #endif
30
31 // #ifndef __FFLASFFPACK_HAVE_DGETRI
32 // #define __FFLASFFPACK_HAVE_DGETRI 1
33 // #endif
34 // #ifndef __FFLASFFPACK_HAVE_DTRTRI
35 // #define __FFLASFFPACK_HAVE_DTRTRI 1
36 // #endif
37 // #ifndef __FFLASFFPACK_AUTOIMPLEMENT_DGETRI
38 // #define __FFLASFFPACK_AUTOIMPLEMENT_DGETRI 1
39 // #endif
40
41 #include "fflas-ffpack/fflas-ffpack.h"
42 #include "fflas-ffpack/utils/timer.h"
43 #include "fflas-ffpack/utils/fflas_io.h"
44 #include "fflas-ffpack/utils/args-parser.h"
45
46 #ifdef __FFLASFFPACK_USE_OPENMP
47 typedef FFLAS::OMPTimer TTimer;
48 #else
49 typedef FFLAS::Timer TTimer;
50 #endif
51
52
53 using namespace std;
54
55 int main(int argc, char** argv) {
56
57 size_t iter = 1;
58 int q = 1009;
59 size_t n = 2000;
60 std::string file = "";
61
62 Argument as[] = {
63 { 'q', "-q Q", "Set the field characteristic (-1 for random).", TYPE_INT , &q },
64 { 'n', "-n N", "Set the dimension of the matrix.", TYPE_INT , &n },
65 { 'i', "-i R", "Set number of repetitions.", TYPE_INT , &iter },
66 { 'f', "-f FILE", "Set the input file (empty for random).", TYPE_STR , &file },
67 END_OF_ARGUMENTS
68 };
69
70 FFLAS::parseArguments(argc,argv,as);
71
72
73 typedef Givaro::Modular<double> Field;
74 typedef Field::Element Element;
75 vector<int> Piv(n,0);
76
77 Field F(q);
78 Field::Element * A;
79
80 TTimer chrono;
81 double time=0.0;
82
83 for (size_t i=0;i<iter;++i){
84 if (!file.empty()){
85 FFLAS::ReadMatrix (file.c_str(),F,n,n,A);
86 }
87 else {
88 A = FFLAS::fflas_new<Element>(n*n);
89 Field::RandIter G(F);
90 for (size_t j=0; j<(size_t)n*n; ++j)
91 G.random(*(A+j));
92 }
93
94 chrono.clear();
95 chrono.start();
96 clapack_dgetrf(CblasRowMajor,n,n,A,n,&Piv[0]);
97 clapack_dgetri(CblasRowMajor,n,A,n,&Piv[0]);
98
99 chrono.stop();
100
101 time+=chrono.usertime();
102 FFLAS::fflas_delete( A);
103 }
104
105 // -----------
106 // Standard output for benchmark - Alexis Breust 2014/11/14
107 std::cout << "Time: " << time / double(iter)
108 << " Gfops: " << (2.*double(n)/1000.*double(n)/1000.*double(n)/1000.0) / time * double(iter);
109 FFLAS::writeCommandString(std::cout, as) << std::endl;
110
111
112 return 0;
113 }
114
115 /* -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
116 // vim:sts=4:sw=4:ts=4:et:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s