Go to the documentation of this file.
26 #ifndef TILEDARRAY_PMAP_H__INCLUDED
27 #define TILEDARRAY_PMAP_H__INCLUDED
32 #include <madness/config.h>
34 TILEDARRAY_PRAGMA_GCC(diagnostic push)
35 TILEDARRAY_PRAGMA_GCC(diagnostic ignored
"-Wparentheses")
37 #include <boost/iterator/iterator_facade.hpp>
39 TILEDARRAY_PRAGMA_GCC(diagnostic pop)
63 std::vector<size_type>
71 Pmap& operator=(
const Pmap&) =
delete;
147 virtual void advance(
size_type& value,
bool increment)
const {
160 :
public boost::iterator_facade<Iterator, const size_type,
161 boost::bidirectional_traversal_tag> {
172 size_type idx,
bool checking,
bool use_pmap_advance =
false)
176 begin_idx_(begin_idx),
179 use_pmap_advance_(use_pmap_advance) {
180 if (idx_ != end_idx) {
182 idx_ == begin_idx_) {
183 while (idx_ < end_idx_ && !pmap_->
is_local(idx_)) {
194 : use_it_(true), it_(it) {
200 const Pmap* pmap_ =
nullptr;
205 std::vector<size_type>::const_iterator it_;
211 bool checking_ =
true;
212 bool use_pmap_advance_ =
false;
221 if (idx_ == end_idx_)
return;
222 if (!use_pmap_advance_) {
225 while (idx_ < end_idx_ && !pmap_->
is_local(idx_)) {
230 pmap_->advance(idx_,
true);
251 if (!use_pmap_advance_) {
254 while (idx_ > begin_idx_ && !pmap_->
is_local(idx_)) {
259 pmap_->advance(idx_,
false);
261 if (idx_ < begin_idx_)
271 bool equal(
Iterator const& other)
const {
272 TA_ASSERT(this->pmap_ == other.pmap_ && this->use_it_ == other.use_it_);
273 return use_it_ ? this->it_ == other.it_ : this->idx_ == other.idx_;
278 const size_type& dereference()
const {
return use_it_ ? *it_ : idx_; }
316 #endif // TILEDARRAY_PMAP_H__INCLUDED
Iterator const_iterator
Iterator type.
const const_iterator cbegin() const
Begin local element iterator.
Pmap(World &world, const size_type size)
Process map constructor.
friend class boost::iterator_core_access
virtual const_iterator begin() const
Begin local element iterator.
virtual size_type owner(const size_type tile) const =0
Maps tile to the processor that owns it.
const const_iterator cend() const
End local element iterator.
size_type rank() const
Process rank accessor.
virtual const_iterator end() const
End local element iterator.
#define TA_ASSERT(EXPR,...)
const size_type procs_
The number of processes.
Iterator(const Pmap &pmap, std::vector< size_type >::const_iterator it)
Creates an iterator over pmap.local_.
virtual bool is_replicated() const
Replicated array status.
std::vector< size_type > local_
A list of local tiles (may be empty, if not needed)
size_type size() const
Size accessor.
virtual bool known_local_size() const
Queries whether local size is known.
size_type local_size() const
Local size accessor.
const size_type rank_
The rank of this process.
virtual bool is_local(const size_type tile) const =0
Check that the tile is owned by this process.
std::size_t size_type
Size type.
friend class Iterator
Iterator type.
Iterator(const Pmap &pmap, size_type begin_idx, size_type end_idx, size_type idx, bool checking, bool use_pmap_advance=false)
Creates an iterator of an integer range [begin_idx,end_idx)
const size_type size_
The number of tiles mapped among all processes.
Pmap::size_type size_type
Key type.
size_type procs() const
Process count accessor.
bool empty() const
Check if there are any local elements.