| 315 | /// |
| 316 | template <class TM, class TV_ROW, class TV_COL> |
| 317 | BlockJacobiPrecond<TM, TV_ROW, TV_COL> :: |
| 318 | BlockJacobiPrecond (shared_ptr<const SparseMatrix<TM,TV_ROW,TV_COL>> amat, |
| 319 | shared_ptr<Table<int>> ablocktable, bool cumulate_block_diags) |
| 320 | : BaseBlockJacobiPrecond(ablocktable), mat(amat), |
| 321 | invdiag(ablocktable->Size()) |
| 322 | { |
| 323 | static Timer t("BlockJacobiPrecond ctor"); RegionTimer reg(t); |
| 324 | static Timer tinv("BlockJacobiPrecond ctor inv"); |
| 325 | static Timer tget("BlockJacobiPrecond ctor get"); |
| 326 | static Timer tprep("BlockJacobiPrecond ctor prep"); |
| 327 | static Timer tpar("BlockJacobiPrecond ctor par"); |
| 328 | cout << IM(3) << "BlockJacobi Preconditioner, constructor called, #blocks = " << blocktable->Size() << endl; |
| 329 | |
| 330 | |
| 331 | // double prevtime = WallTime(); |
| 332 | |
| 333 | |
| 334 | // find nze element in all blocks together |
| 335 | /* |
| 336 | nze = 0; |
| 337 | for (auto block : *blocktable) |
| 338 | for (auto row : block) |
| 339 | nze += amat.GetRowIndices(row).Size(); |
| 340 | */ |
| 341 | nze = |
| 342 | ParallelReduce (blocktable->Size(), |
| 343 | [&] (size_t i) |
| 344 | { |
| 345 | size_t nze = 0; |
| 346 | for (auto row : (*blocktable)[i]) |
| 347 | nze += amat->GetRowIndices(row).Size(); |
| 348 | return nze; |
| 349 | }, |
| 350 | [] (size_t a, size_t b) { return a+b; }, |
| 351 | size_t(0)); |
| 352 | |
| 353 | /* |
| 354 | size_t totmem = 0; |
| 355 | for (auto i : Range (*blocktable)) |
| 356 | totmem += sqr ((*blocktable)[i].Size()); |
| 357 | */ |
| 358 | size_t totmem = |
| 359 | ParallelReduce (blocktable->Size(), |
| 360 | [&] (size_t i) { return sqr ((*blocktable)[i].Size()); }, |
| 361 | [] (size_t a, size_t b) { return a+b; }, |
| 362 | size_t(0)); |
| 363 | |
| 364 | bigmem.SetSize(totmem); |
| 365 | |
| 366 | cout << IM(5) << "avg entrysize: " << blocktable->AsArray().Size()/blocktable->Size() << endl; |
| 367 | cout << IM(5) << "avg entrysize^2: " << totmem/blocktable->Size() << endl; |
| 368 | |
| 369 | totmem = 0; |
| 370 | for (auto i : Range (*blocktable)) |
| 371 | { |
| 372 | size_t bs = (*blocktable)[i].Size(); |
| 373 | new ( & invdiag[i] ) FlatMatrix<TM> (bs, bs, bigmem.Addr(totmem)); |
| 374 | totmem += sqr (bs); |
nothing calls this directly
no test coverage detected