Debian Codegraph @

benchmarks/benchmark-lqup-mp.C

raw
1 /*
2 * Copyright (C) FFLAS-FFPACK
3 * Written by Pascal Giorgi <[email protected]>
4 *
5 * This file is Free Software and part of FFLAS-FFPACK.
6 *
7 * ========LICENCE========
8 * This file is part of the library FFLAS-FFPACK.
9 *
10 * FFLAS-FFPACK is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * ========LICENCE========
24 *.
25 */
26 #include "fflas-ffpack/fflas-ffpack-config.h"
27 #include <iostream>
28 #include <vector>
29 #include <string>
30 using namespace std;
31
32 #include "fflas-ffpack/utils/timer.h"
33 #include "fflas-ffpack/ffpack/ffpack.h"
34 #include "fflas-ffpack/utils/args-parser.h"
35 #include "givaro/modular-integer.h"
36
37 int main(int argc, char** argv){
38 srand((int)time(NULL));
39 srand48(time(NULL));
40
41 static size_t iters = 3 ;
42 static Givaro::Integer q = -1 ;
43 static unsigned long b = 512 ;
44 static size_t m = 512 ;
45 static size_t n = 512 ;
46 static Argument as[] = {
47 { 'q', "-q Q", "Set the field characteristic (-1 for random).", TYPE_INTEGER , &q },
48 { 'b', "-b B", "Set the bitsize of the random characteristic.", TYPE_INT , &b },
49 { 'm', "-m M", "Set the dimension m of the matrix.", TYPE_INT , &m },
50 { 'n', "-n N", "Set the dimension n of the matrix.", TYPE_INT , &n },
51 { 'i', "-i R", "Set number of repetitions.", TYPE_INT , &iters },
52 END_OF_ARGUMENTS
53 };
54 FFLAS::parseArguments(argc,argv,as);
55
56 size_t seed= time(NULL);
57 typedef Givaro::Modular<Givaro::Integer> Field;
58 FFLAS::Timer chrono;
59 double time=0.;
60 Givaro::Integer p;
61 Givaro::IntPrimeDom IPD;
62
63 for (size_t i=0;i<iters;i++) {
64
65 Givaro::Integer::random_exact_2exp(p, b);
66 IPD.prevprimein(p);
67 Field F(p);
68 size_t lda;
69 lda=n;
70
71 typename Field::RandIter Rand(F,seed);
72 Field::Element_ptr A;
73 A= FFLAS::fflas_new(F,m,lda);
74 size_t * P = FFLAS::fflas_new<size_t>(n) ;
75 size_t * Q = FFLAS::fflas_new<size_t>(m) ;
76
77 for (size_t ii=0;ii<m*lda;++ii)
78 Rand.random(A[ii]);
79
80 Givaro::Integer alpha;
81 alpha=1;
82 chrono.clear();chrono.start();
83 FFPACK::LUdivine (F, FFLAS::FflasUnit, FFLAS::FflasNoTrans, m, n, A, lda, P, Q);
84 chrono.stop();
85 time+=chrono.usertime();
86
87 FFLAS::fflas_delete(A);
88 FFLAS::fflas_delete(P);
89 FFLAS::fflas_delete(Q);
90 }
91 double Gflops=(2./3.*double(m)/1000.*double(m)/1000.*double(n)/1000.0) / chrono.usertime() * double(iters);
92 Gflops*=p.bitsize()/16.;
93 cout<<"Time: "<<time/iters<<" Gfops: "<<Gflops<<endl;
94
95
96 return 0;
97 }
98
99 /* -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
100 // vim:sts=4:sw=4:ts=4:et:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s