/usr/include/fflas-ffpack/ffpack/ffpack_ludivine_mp.inl is in fflas-ffpack-common 2.2.2-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | /* -*- mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
// vim:sts=8:sw=8:ts=8:noet:sr:cino=>s,f0,{0,g0,(0,\:0,t0,+0,=s
/*
* Copyright (C) 2014 the FFLAS-FFPACK group
*
* Written by Pascal Giorgi <pascal.giorgi@lirmm.fr>
*
*
* ========LICENCE========
* This file is part of the library FFLAS-FFPACK.
*
* FFLAS-FFPACK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* ========LICENCE========
*.
*/
#ifndef __FFPACK_ludivine_mp_INL
#define __FFPACK_ludivine_mp_INL
#include <givaro/modular-integer.h>
#include <givaro/givinteger.h>
#ifdef BENCH_PERF_LQUP_MP
#define BENCH_PERF_FGEMM_MP
#endif
#include "fflas-ffpack/field/rns-integer-mod.h"
#include "fflas-ffpack/field/rns-integer.h"
#include "fflas-ffpack/fflas/fflas.h"
#include "fflas-ffpack/ffpack/ffpack_ludivine.inl"
namespace FFPACK {
template <>
inline size_t
LUdivine (const Givaro::Modular<Givaro::Integer>& F,
const FFLAS::FFLAS_DIAG Diag, const FFLAS::FFLAS_TRANSPOSE trans,
const size_t M, const size_t N,
typename Givaro::Integer* A, const size_t lda,
size_t*P, size_t *Q,
const FFPACK::FFPACK_LU_TAG LuTag,
const size_t cutoff
)
{
#ifdef BENCH_PERF_LQUP_MP
double t_init=0, t_lqup=0, t_mod=0, t_rec=0;
FFLAS::Timer chrono;
chrono.start();
#endif
Givaro::Integer p;
F.cardinality(p);
size_t logp=p.bitsize();
size_t K = std::max(M,N);
// compute bit size of feasible prime
size_t _k=std::max(K+1,logp/20), lk=0;
while ( _k ) {_k>>=1; ++lk;}
size_t prime_bitsize= (53-lk)>>1;
// construct rns basis
Givaro::Integer maxC= (p-1)*(p-1)*(p-1)*uint64_t(K);
uint64_t n_pr =uint64_t(ceil(double(maxC.bitsize())/double(prime_bitsize)));
maxC=(p-1)*(p-1)*uint64_t(K)*(1<<prime_bitsize)*n_pr;
FFPACK::rns_double RNS(maxC, prime_bitsize, true);
FFPACK::RNSIntegerMod<FFPACK::rns_double> Zp(p, RNS);
#ifdef BENCH_PERF_LQUP_MP
chrono.stop();
t_init+=chrono.usertime();
chrono.clear();chrono.start();
#endif
// compute A in RNS
FFPACK::rns_double::Element_ptr Ap;
Ap = FFLAS::fflas_new(Zp,M,N);
FFLAS::finit_rns(Zp,M,N,(logp/16)+(logp%16?1:0),A,lda,Ap);
#ifdef BENCH_PERF_LQUP_MP
chrono.stop();
t_mod+=chrono.usertime();
chrono.clear();chrono.start();
#endif
// call lqup in rns
size_t R=FFPACK::LUdivine(Zp, Diag, trans, M, N, Ap, N, P, Q, LuTag, cutoff);
//std::cout<<"LUDivine RNS done"<<std::endl;
#ifdef BENCH_PERF_LQUP_MP
chrono.stop();
t_lqup+=chrono.usertime();
chrono.clear();chrono.start();
#endif
// reconstruct the result
FFLAS::fconvert_rns(Zp,M,N,F.zero,A,lda,Ap);
#ifdef BENCH_PERF_LQUP_MP
chrono.stop();
t_rec+=chrono.usertime();
chrono.clear();chrono.start();
#endif
// reduce it modulo p
FFLAS::freduce (F,M,N,A,lda);
#ifdef BENCH_PERF_LQUP_MP
chrono.stop();
//t_rec+=chrono.usertime();
cout<<"LUDIVINE RNS PERF:"<<endl;
cout<<" --- RNS basis size: "<<Zp.size() <<endl;
cout<<" *** init : "<<t_init<<endl;
cout<<" *** rns mod : "<<t_mod<<endl;
cout<<" *** rns lqup : "<<t_lqup<<" ( igemm="<<Zp.t_igemm<<" ftrsm="<<Zp.t_trsm<<" scal="<<Zp.t_scal
<<" modp="<<Zp.t_modp<<endl;
cout<<" *** rns rec : "<<t_rec<<endl;
cout<<" *** mod : "<<chrono.usertime()<<endl;
#endif
FFLAS::fflas_delete(Ap);
return R;
}
} // namespace FFPACK
#endif
|