Debian Codegraph @

benchmarks/benchmark-fsyr2k.C

raw
1 /*
2 * Copyright (C) 2020 the FFLAS-FFPACK group
3 *
4 * Written by Jean-Guillaume Dumas <[email protected]>
5 *
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
27
28 #include "fflas-ffpack/fflas-ffpack-config.h"
29
30 #include <iostream>
31 #include <givaro/modular-balanced.h>
32
33 #include "fflas-ffpack/config-blas.h"
34 #include "fflas-ffpack/fflas/fflas.h"
35 #include "fflas-ffpack/utils/timer.h"
36 #include "fflas-ffpack/utils/args-parser.h"
37
38 using namespace std;
39 using namespace FFLAS;
40
41
42 int main(int argc, char** argv) {
43
44 size_t iter = 3 ;
45 Givaro::Integer q = 131071 ;
46 size_t k = 2000 ;
47 size_t n = 2000 ;
48 int t=MAX_THREADS;
49 int NBK = -1;
50 bool up =true;
51
52 Argument as[] = {
53 { 'q', "-q Q", "Set the field characteristic (-1 for random).", TYPE_INTEGER , &q },
54 { 'k', "-k K", "Set the col dimension of A.", TYPE_INT , &k },
55 { 'n', "-n N", "Set the col dimension of B.", TYPE_INT , &n },
56 { 'i', "-i R", "Set number of repetitions.", TYPE_INT , &iter },
57 { 't', "-t T", "number of virtual threads to drive the partition.", TYPE_INT , &t },
58 { 'b', "-b B", "number of numa blocks per dimension for the numa placement", TYPE_INT , &NBK },
59 { 'u', "-u yes/no", "Updates an upper/lower triangular matrix.", TYPE_BOOL , &up },
60 END_OF_ARGUMENTS
61 };
62
63 parseArguments(argc,argv,as);
64
65 FFLAS_UPLO uplo = up?FflasUpper:FflasLower;
66
67 if (NBK==-1) NBK = t;
68 // typedef Givaro::Modular<Givaro::Integer> Field;
69 // typedef Givaro::Modular<int64_t> Field;
70 typedef Givaro::Modular<double> Field;
71 // typedef Givaro::Modular<float> Field;
72 // typedef Givaro::ModularBalanced<float> Field;
73 // typedef Givaro::ModularBalanced<double> Field;
74 // typedef Givaro::ModularBalanced<int64_t> Field;
75 // typedef Givaro::Modular<Givaro::Integer> Field;
76 typedef Field::Element Element;
77
78 Field F(q);
79
80 Timer chrono, TimFreivalds;
81 double time=0.0;
82
83 Element * A, * B, * C, * D;
84
85 Field::RandIter G(F);
86 A = fflas_new(F,n,k,Alignment::CACHE_PAGESIZE);
87 //#pragma omp parallel for collapse(2) schedule(runtime)
88 PAR_BLOCK { pfrand(F,G, n,k,A,n/size_t(NBK)); }
89
90 B = fflas_new(F,k,n,Alignment::CACHE_PAGESIZE);
91 //#pragma omp parallel for collapse(2) schedule(runtime)
92 PAR_BLOCK { pfrand(F,G, k,n,B,k/NBK); }
93
94 C = fflas_new(F,n,n,Alignment::CACHE_PAGESIZE);
95 //#pragma omp parallel for collapse(2) schedule(runtime)
96 PAR_BLOCK { pfzero(F, n,n,C,n/NBK); }
97
98 D = fflas_new(F,n,n,Alignment::CACHE_PAGESIZE);
99 //#pragma omp parallel for collapse(2) schedule(runtime)
100 PAR_BLOCK { pfzero(F, n,n,D,n/NBK); }
101
102 for (size_t i=0;i<=iter;++i){
103
104 chrono.clear();
105 if (i) chrono.start();
106
107 fsyr2k(F, uplo, FflasNoTrans, n,k, F.one, A, k, B, n, F.zero, C,n);
108
109 if (i) chrono.stop();
110 time+=chrono.usertime();
111
112 }
113 fflas_delete( A);
114 fflas_delete( B);
115 fflas_delete( C);
116
117 // -----------
118 std::cout << "Time: " << time / double(iter)
119 << " Gfops: " << 2.*(double(n)/1000.)*(double(n)/1000.)*(double(k)/1000.)/ time * double(iter);
120 FFLAS::writeCommandString(std::cout, as) << std::endl;
121 return 0;
122 }
123
124 /* -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
125 // vim:sts=4:sw=4:ts=4:et:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s