fml  0.1-0
Fused Matrix Library
mpi_utils.hh
1 // This file is part of fml which is released under the Boost Software
2 // License, Version 1.0. See accompanying file LICENSE or copy at
3 // https://www.boost.org/LICENSE_1_0.txt
4 
5 #ifndef FML_MPI_INTERNALS_MPI_UTILS_H
6 #define FML_MPI_INTERNALS_MPI_UTILS_H
7 #pragma once
8 
9 
10 #include "bcutils.hh"
11 
12 class grid;
13 
14 
15 namespace fml
16 {
17  namespace mpi_utils
18  {
19  // zero specified triangle
20  template <typename REAL>
21  void tri2zero(const char uplo, const bool diag, const grid &g,
22  const len_t m, const len_t n, REAL *A, const int *desc)
23  {
24  const int mb = desc[fml::bcutils::DESC_MB];
25  const int nb = desc[fml::bcutils::DESC_NB];
26 
27  const len_t m_local = fml::bcutils::numroc(desc[fml::bcutils::DESC_M], mb, g.myrow(), 0, g.nprow());
28  const len_t n_local = fml::bcutils::numroc(desc[fml::bcutils::DESC_N], nb, g.mycol(), 0, g.npcol());
29 
30  for (len_t j=0; j<n_local; j++)
31  {
32  for (len_t i=0; i<m_local; i++)
33  {
34  const int gi = fml::bcutils::l2g(i, mb, g.nprow(), g.myrow());
35  const int gj = fml::bcutils::l2g(j, nb, g.npcol(), g.mycol());
36 
37  if ((gi < m && gj < n) && ((diag && gi == gj) || (uplo == 'U' && gi < gj) || (uplo == 'L' && gi > gj)))
38  A[i + m_local*j] = (REAL) 0.0;
39  }
40  }
41  }
42  }
43 }
44 
45 
46 #endif
fml
Core namespace.
Definition: dimops.hh:10