mptensor v0.6.0
Parallel Library for Tensor Network Methods
Loading...
Searching...
No Matches
blacsgrid.hpp
Go to the documentation of this file.
1/*
2 mptensor - Parallel Library for Tensor Network Methods
3
4 Copyright 2016 Satoshi Morita
5
6 mptensor is free software: you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation, either version 3 of the
9 License, or (at your option) any later version.
10
11 mptensor is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with mptensor. If not, see
18 <https://www.gnu.org/licenses/>.
19*/
20
29#ifndef _BLACSGRID_HPP_
30#define _BLACSGRID_HPP_
31#ifndef _NO_MPI
32
33#include <mpi.h>
34#include <vector>
35
36namespace mptensor {
37inline namespace matrix {
38namespace scalapack {
39
40class BlacsGrid {
41 private:
42 // std::vector<int> pnum2mpirank;
43 // std::vector<int> mpirank2pnum;
44 void init_grid(const MPI_Comm &comm, int nprow, int npcol);
45 static bool is_initialized;
46
47 public:
48 BlacsGrid(const MPI_Comm &comm);
49
50 static void init();
51 static void exit();
52
54 int ictxt;
58 int mpirank(int prow, int pcol) const;
59 int mpirank() const;
60 void show() const;
61};
62
63inline int BlacsGrid::mpirank(int prow, int pcol) const {
64 return prow * npcol + pcol;
65 // return Cblacs_pnum(ictxt, prow, pcol);
66 // This equibalence is checked in BlacsGrid::init_grid()
67
68 // int pnum = Cblacs_pnum(ictxt, prow, pcol);
69 // return pnum2mpirank[pnum];
70}
71
72inline int BlacsGrid::mpirank() const { return myrank; }
73
74} // namespace scalapack
75} // inline namespace matrix
76} // namespace mptensor
77
78#endif // _NO_MPI
79#endif // _BLACSGRID_HPP_
Definition blacsgrid.hpp:40
int mpirank() const
Definition blacsgrid.hpp:72
int mpisize
Definition blacsgrid.hpp:57
int mypcol
Definition blacsgrid.hpp:56
int nprow
Definition blacsgrid.hpp:55
static void exit()
Definition blacsgrid.cc:142
MPI_Comm comm
Definition blacsgrid.hpp:53
void show() const
Definition blacsgrid.cc:152
int myprow
Definition blacsgrid.hpp:56
int myrank
Definition blacsgrid.hpp:57
int ictxt
Definition blacsgrid.hpp:54
int mypnum
Definition blacsgrid.hpp:56
static void init()
Definition blacsgrid.cc:111
int npcol
Definition blacsgrid.hpp:55
std::complex< double > complex
Definition complex.hpp:38
Definition complex.hpp:34