/usr/include/fflas-ffpack/fflas/fflas_ftrsm_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 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 | /* -*- 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========
*.
*/
/** @file fflas/fflas_ftrsm_mp.inl
* @brief triangular system with matrix right hand side over multiprecision domain (either over Z or over Z/pZ)
*/
#ifndef __FFPACK_ftrsm_mp_INL
#define __FFPACK_ftrsm_mp_INL
#include <cmath>
#include <givaro/modular-integer.h>
#include <givaro/givinteger.h>
#include "fflas-ffpack/fflas/fflas_bounds.inl"
#include "fflas-ffpack/fflas/fflas_level3.inl"
#include "fflas-ffpack/field/rns-integer-mod.h"
#include "fflas-ffpack/field/rns-integer.h"
namespace FFLAS {
inline void ftrsm (const Givaro::Modular<Givaro::Integer> & F,
const FFLAS_SIDE Side,
const FFLAS_UPLO Uplo,
const FFLAS_TRANSPOSE TransA,
const FFLAS_DIAG Diag,
const size_t M, const size_t N,
const Givaro::Integer alpha,
const Givaro::Integer * A, const size_t lda,
Givaro::Integer * B, const size_t ldb){
#ifdef BENCH_PERF_TRSM_MP
double t_init=0, t_trsm=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;
if (Side == FFLAS::FflasLeft)
K=M;
else
K=N;
if (K==0) return;
// compute bit size of feasible prime
size_t _k=std::max(K,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);
size_t n_pr =maxC.bitsize()/prime_bitsize;
maxC=(p-1)*(p-1)*uint64_t(K)*(1<<prime_bitsize)*uint64_t(n_pr);
FFPACK::rns_double RNS(maxC, prime_bitsize, true);
FFPACK::RNSIntegerMod<FFPACK::rns_double> Zp(p, RNS);
#ifdef BENCH_PERF_TRSM_MP
chrono.stop();
t_init+=chrono.usertime();
chrono.clear();chrono.start();
#endif
// compute A and B in RNS
FFPACK::rns_double::Element_ptr Ap,Bp;
Ap = FFLAS::fflas_new(Zp,K,K);
Bp = FFLAS::fflas_new(Zp,M,N);
if (Side == FFLAS::FflasLeft){
finit_rns(Zp,K,K,(logp/16)+(logp%16?1:0),A,lda,Ap);
finit_rns(Zp,M,N,(logp/16)+(logp%16?1:0),B,ldb,Bp);
}
else {
finit_trans_rns(Zp,K,K,(logp/16)+(logp%16?1:0),A,lda,Ap);
finit_trans_rns(Zp,M,N,(logp/16)+(logp%16?1:0),B,ldb,Bp);
}
#ifdef BENCH_PERF_TRSM_MP
chrono.stop();
t_mod+=chrono.usertime();
chrono.clear();chrono.start();
#endif
// call ftrsm in rns
//ftrsm(Zp, Side, Uplo, TransA, Diag, M, N, Zp.one, Ap, K, Bp, N);
if (Side == FFLAS::FflasLeft)
ftrsm(Zp, Side, Uplo, TransA, Diag, M, N, Zp.one, Ap, K, Bp, N);
else {
if (Uplo == FFLAS::FflasUpper)
ftrsm(Zp, FFLAS::FflasLeft, FFLAS::FflasLower, TransA, Diag, N, M, Zp.one, Ap, K, Bp, M);
else
ftrsm(Zp, FFLAS::FflasLeft, FFLAS::FflasUpper, TransA, Diag, N, M, Zp.one, Ap, K, Bp, M);
}
#ifdef BENCH_PERF_TRSM_MP
chrono.stop();
t_trsm+=chrono.usertime();
chrono.clear();chrono.start();
#endif
// reconstruct the result
if (Side == FFLAS::FflasLeft)
fconvert_rns(Zp,M,N,F.zero,B,ldb,Bp);
else{
fconvert_trans_rns(Zp,M,N,F.zero,B,ldb,Bp);
}
// reduce it modulo p
freduce (F, M, N, B, ldb);
// scale it with alpha
if (!F.isOne(alpha))
fscalin(F,M,N,alpha,B,ldb);
#ifdef BENCH_PERF_TRSM_MP
chrono.stop();
t_rec+=chrono.usertime();
cout<<"FTRSM RNS PERF:"<<endl;
cout<<" *** init : "<<t_init<<endl;
cout<<" *** rns mod : "<<t_mod<<endl;
cout<<" *** rns trsm : "<<t_trsm<<" ( igemm="<<Zp.t_igemm<<" scal="<<Zp.t_scal<<" modp="<<Zp.t_modp<<endl;;
cout<<" *** rns rec : "<<t_rec<<endl;
#endif
FFLAS::fflas_delete(Ap);
FFLAS::fflas_delete(Bp);
}
/* bb: do not use CBLAS_ORDER, or make it compatible with MLK */
inline void cblas_imptrsm(const enum FFLAS_ORDER Order,
const enum FFLAS_SIDE Side,
const enum FFLAS_UPLO Uplo,
const enum FFLAS_TRANSPOSE TransA,
const enum FFLAS_DIAG Diag,
const int M, const int N, const FFPACK::rns_double_elt alpha,
FFPACK::rns_double_elt_cstptr A, const int lda,
FFPACK::rns_double_elt_ptr B, const int ldb) {}
#ifndef DOXYGEN_SHOULD_SKIP_THIS
namespace Protected {
template<>
inline size_t TRSMBound (const FFPACK::RNSIntegerMod<FFPACK::rns_double> &F)
{
return 1;
}
template <>
inline size_t DotProdBoundClassic (const FFPACK::RNSIntegerMod<FFPACK::rns_double>& F,
const FFPACK::rns_double_elt& beta)
{
Givaro::Integer p,b,M;
F.cardinality(p);
p--;
F.convert(b,beta);
M=F.rns()._M;
uint64_t kmax= (M-b*p)/(p*p);
return (size_t)std::max(uint64_t(1),kmax);
//return kmax;
}
#ifndef __FTRSM_MP_FAST
#define __FFLAS_MULTIPRECISION
#define __FFLAS__LEFT
#define __FFLAS__UP
#define __FFLAS__NOTRANSPOSE
#define __FFLAS__NONUNIT
#include "fflas_ftrsm_src.inl"
#undef __FFLAS__LEFT
#undef __FFLAS__UP
#undef __FFLAS__NOTRANSPOSE
#undef __FFLAS__NONUNIT
#define __FFLAS__LEFT
#define __FFLAS__UP
#define __FFLAS__NOTRANSPOSE
#define __FFLAS__UNIT
#include "fflas_ftrsm_src.inl"
#undef __FFLAS__LEFT
#undef __FFLAS__UP
#undef __FFLAS__NOTRANSPOSE
#undef __FFLAS__UNIT
#define __FFLAS__LEFT
#define __FFLAS__UP
#define __FFLAS__TRANSPOSE
#define __FFLAS__NONUNIT
#include "fflas_ftrsm_src.inl"
#undef __FFLAS__LEFT
#undef __FFLAS__UP
#undef __FFLAS__TRANSPOSE
#undef __FFLAS__NONUNIT
#define __FFLAS__LEFT
#define __FFLAS__UP
#define __FFLAS__TRANSPOSE
#define __FFLAS__UNIT
#include "fflas_ftrsm_src.inl"
#undef __FFLAS__LEFT
#undef __FFLAS__UP
#undef __FFLAS__TRANSPOSE
#undef __FFLAS__UNIT
#define __FFLAS__LEFT
#define __FFLAS__LOW
#define __FFLAS__NOTRANSPOSE
#define __FFLAS__NONUNIT
#include "fflas_ftrsm_src.inl"
#undef __FFLAS__LEFT
#undef __FFLAS__LOW
#undef __FFLAS__NOTRANSPOSE
#undef __FFLAS__NONUNIT
#define __FFLAS__LEFT
#define __FFLAS__LOW
#define __FFLAS__NOTRANSPOSE
#define __FFLAS__UNIT
#include "fflas_ftrsm_src.inl"
#undef __FFLAS__LEFT
#undef __FFLAS__LOW
#undef __FFLAS__NOTRANSPOSE
#undef __FFLAS__UNIT
#define __FFLAS__LEFT
#define __FFLAS__LOW
#define __FFLAS__TRANSPOSE
#define __FFLAS__NONUNIT
#include "fflas_ftrsm_src.inl"
#undef __FFLAS__LEFT
#undef __FFLAS__LOW
#undef __FFLAS__TRANSPOSE
#undef __FFLAS__NONUNIT
#define __FFLAS__LEFT
#define __FFLAS__LOW
#define __FFLAS__TRANSPOSE
#define __FFLAS__UNIT
#include "fflas_ftrsm_src.inl"
#undef __FFLAS__LEFT
#undef __FFLAS__LOW
#undef __FFLAS__TRANSPOSE
#undef __FFLAS__UNIT
#define __FFLAS__RIGHT
#define __FFLAS__UP
#define __FFLAS__NOTRANSPOSE
#define __FFLAS__NONUNIT
#include "fflas_ftrsm_src.inl"
#undef __FFLAS__RIGHT
#undef __FFLAS__UP
#undef __FFLAS__NOTRANSPOSE
#undef __FFLAS__NONUNIT
#define __FFLAS__RIGHT
#define __FFLAS__UP
#define __FFLAS__NOTRANSPOSE
#define __FFLAS__UNIT
#include "fflas_ftrsm_src.inl"
#undef __FFLAS__RIGHT
#undef __FFLAS__UP
#undef __FFLAS__NOTRANSPOSE
#undef __FFLAS__UNIT
#define __FFLAS__RIGHT
#define __FFLAS__UP
#define __FFLAS__TRANSPOSE
#define __FFLAS__NONUNIT
#include "fflas_ftrsm_src.inl"
#undef __FFLAS__RIGHT
#undef __FFLAS__UP
#undef __FFLAS__TRANSPOSE
#undef __FFLAS__NONUNIT
#define __FFLAS__RIGHT
#define __FFLAS__UP
#define __FFLAS__TRANSPOSE
#define __FFLAS__UNIT
#include "fflas_ftrsm_src.inl"
#undef __FFLAS__RIGHT
#undef __FFLAS__UP
#undef __FFLAS__TRANSPOSE
#undef __FFLAS__UNIT
#define __FFLAS__RIGHT
#define __FFLAS__LOW
#define __FFLAS__NOTRANSPOSE
#define __FFLAS__NONUNIT
#include "fflas_ftrsm_src.inl"
#undef __FFLAS__RIGHT
#undef __FFLAS__LOW
#undef __FFLAS__NOTRANSPOSE
#undef __FFLAS__NONUNIT
#define __FFLAS__RIGHT
#define __FFLAS__LOW
#define __FFLAS__NOTRANSPOSE
#define __FFLAS__UNIT
#include "fflas_ftrsm_src.inl"
#undef __FFLAS__RIGHT
#undef __FFLAS__LOW
#undef __FFLAS__NOTRANSPOSE
#undef __FFLAS__UNIT
#define __FFLAS__RIGHT
#define __FFLAS__LOW
#define __FFLAS__TRANSPOSE
#define __FFLAS__NONUNIT
#include "fflas_ftrsm_src.inl"
#undef __FFLAS__RIGHT
#undef __FFLAS__LOW
#undef __FFLAS__TRANSPOSE
#undef __FFLAS__NONUNIT
#define __FFLAS__RIGHT
#define __FFLAS__LOW
#define __FFLAS__TRANSPOSE
#define __FFLAS__UNIT
#include "fflas_ftrsm_src.inl"
#undef __FFLAS__RIGHT
#undef __FFLAS__LOW
#undef __FFLAS__TRANSPOSE
#undef __FFLAS__UNIT
#endif // #ifdef __FTRSM_MP_FAST
} // end of namespace protected
#endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS
} // END OF NAMESPACE FFLAS
#endif
|