Debian Codegraph @

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