fml  0.1-0
Fused Matrix Library
trreduce.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_PAR_INTERNALS_TRREDUCE_H
6 #define FML_PAR_INTERNALS_TRREDUCE_H
7 #pragma once
8 
9 
10 #include "../comm.hh"
11 
12 
13 namespace fml
14 {
15  namespace mpi
16  {
17  template <typename REAL>
18  void tr_pack(char uplo, int m, int n, REAL *x, int ldx)
19  {
20  const int minmn = std::min(m, n);
21 
22  // pack upper triangle
23  if (uplo == 'U' || uplo == 'u')
24  {
25  int pos = 1;
26  for (int j=1; j<n; j++)
27  {
28  for (int i=0; i<j; i++)
29  x[pos++] = x[i + ldx*j];
30  }
31  }
32  }
33 
34  template <typename REAL>
35  void tr_unpack(char uplo, int m, int n, REAL *x, int ldx)
36  {
37  const int minmn = std::min(m, n);
38 
39  // pack upper triangle
40  if (uplo == 'U' || uplo == 'u')
41  {
42  int pos = 1;
43  for (int j=minmn-1; j>0; j--)
44  {
45  for (int i=minmn-1; i>=j; i--)
46  ret_pt[i + minmn*j] = alpha * ret_pt[--pos];
47  }
48  }
49  }
50 
51  template <typename REAL>
52  void tr_allreduce(comm &r, int m, int n, REAL *data, MPI_Op op)
53  {
54 
55  r.allreduce(len, data, op);
56 
57  }
58  }
59 }
60 
61 
62 #endif
fml
Core namespace.
Definition: dimops.hh:10