replicated_pmap.h
Go to the documentation of this file.
1 /*
2  * This file is a part of TiledArray.
3  * Copyright (C) 2013 Virginia Tech
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * Justus Calvin
19  * Department of Chemistry, Virginia Tech
20  *
21  * replicated_pmap.h
22  * February 8, 2013
23  *
24  */
25 
26 #ifndef TILEDARRAY_PMAP_REPLICATED_PMAP_H__INCLUDED
27 #define TILEDARRAY_PMAP_REPLICATED_PMAP_H__INCLUDED
28 
29 #include <TiledArray/pmap/pmap.h>
30 
31 namespace TiledArray {
32 namespace detail {
33 
35 
37 class ReplicatedPmap : public Pmap {
38  protected:
39  // Import Pmap protected variables
40  using Pmap::procs_;
41  using Pmap::rank_;
42  using Pmap::size_;
43 
44  public:
46 
48 
51  ReplicatedPmap(World& world, size_type size) : Pmap(world, size) {
52  this->local_size_ = this->size_;
53  }
54 
55  virtual ~ReplicatedPmap() {}
56 
58 
61  virtual size_type owner(const size_type tile) const {
62  TA_ASSERT(tile < size_);
63  return rank_;
64  }
65 
67 
70  virtual bool is_local(const size_type tile) const {
71  TA_ASSERT(tile < size_);
72  return true;
73  }
74 
76 
78  virtual bool is_replicated() const { return true; }
79 
80  virtual const_iterator begin() const {
81  return Iterator(*this, 0, this->size_, 0, false);
82  }
83  virtual const_iterator end() const {
84  return Iterator(*this, 0, this->size_, this->size_, false);
85  }
86 
87 }; // class MapByRow
88 
89 } // namespace detail
90 } // namespace TiledArray
91 
92 #endif // TILEDARRAY_PMAP_REPLICATED_PMAP_H__INCLUDED
const size_type size_
< The rank of this process
Definition: pmap.h:62
ReplicatedPmap(World &world, size_type size)
Construct Blocked map.
virtual bool is_local(const size_type tile) const
Check that the tile is owned by this process.
Pmap::size_type size_type
< The number of tiles mapped among all processes
A Replicated process map.
virtual bool is_replicated() const
Replicated array status.
#define TA_ASSERT(EXPR,...)
Definition: error.h:39
const size_type procs_
The number of processes.
Definition: pmap.h:61
virtual const_iterator end() const
End local element iterator.
const size_type rank_
< The number of processes
Definition: pmap.h:60
Pmap iterator type.
Definition: pmap.h:161
size_type local_size_
Definition: pmap.h:65
size_type size() const
Size accessor.
Definition: pmap.h:102
const size_type rank_
The rank of this process.
Definition: pmap.h:60
std::size_t size_type
Size type.
Definition: pmap.h:57
friend class Iterator
Iterator type.
Definition: pmap.h:280
Process map.
Definition: pmap.h:55
const size_type size_
The number of tiles mapped among all processes.
Definition: pmap.h:62
virtual size_type owner(const size_type tile) const
Maps tile to the processor that owns it.
virtual const_iterator begin() const
Begin local element iterator.