fml  0.1-0
Fused Matrix Library
parhelpers.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_PARHELPERS_H
6 #define FML_PAR_PARHELPERS_H
7 #pragma once
8 
9 
10 #include <stdexcept>
11 
12 #include "../_internals/types.hh"
13 
14 #include "comm.hh"
15 #include "parmat.hh"
16 
17 #include "../cpu/cpumat.hh"
18 
19 
20 namespace parhelpers
21 {
22  template <typename REAL>
23  void par2cpu(parmat<REAL> &par, cpumat<REAL> &cpu)
24  {
25  // copy local piece then allreduce
26  }
27 
28  template <typename REAL>
29  cpumat<REAL> par2cpu(parmat<REAL> &par)
30  {
31  cpumat<REAL> cpu(par.nrows(), par.ncols());
32  par2cpu(par, cpu);
33 
34  return cpu;
35  }
36 
37 
38 
39  template <typename REAL>
40  void cpu2par(cpumat<REAL> &cpu, parmat<REAL> &mpi)
41  {
42  // copy from cpu
43  }
44 
45  template <typename REAL>
46  mpimat<REAL> cpu2mpi(cpumat<REAL> &cpu, grid g, int bf_rows=16, int bf_cols=16)
47  {
48  mpimat<REAL> mpi(g, cpu.nrows(), cpu.ncols(), bf_rows, bf_cols);
49  cpu2mpi(cpu, mpi);
50 
51  return mpi;
52  }
53 }
54 
55 
56 #endif
grid
2-dimensional MPI process grid.
Definition: grid.hh:64
mpimat
Matrix class for data distributed over MPI in the 2-d block cyclic format.
Definition: mpimat.hh:38
parmat
Definition: parmat.hh:21
unimat::nrows
len_t nrows() const
Number of rows.
Definition: unimat.hh:31
unimat::ncols
len_t ncols() const
Number of columns.
Definition: unimat.hh:33
mpihelpers::cpu2mpi
void cpu2mpi(const cpumat< REAL_IN > &cpu, mpimat< REAL_OUT > &mpi)
Copy data from a CPU object to an MPI object.
Definition: mpihelpers.hh:229
cpumat
Matrix class for data held on a single CPU.
Definition: cpumat.hh:34