35 #ifndef MADNESS_WORLD_WORLDPTR_H__INCLUDED
36 #define MADNESS_WORLD_WORLDPTR_H__INCLUDED
84 ProcessID local_rank()
const {
return (world_ != NULL ? world_->
rank() : -2); }
111 worldid_(w.id() + 1),
121 world_(other.world_),
122 worldid_(other.worldid_),
124 pointer_(other.pointer_)
134 template <
typename U>
136 world_(other.world_),
137 worldid_(other.worldid_),
139 pointer_(other.pointer_)
148 world_ = other.world_;
149 worldid_ = other.worldid_;
151 pointer_ = other.pointer_;
164 template <
typename U>
166 world_ = other.world_;
167 worldid_ = other.worldid_;
169 pointer_ = other.pointer_;
179 bool is_local()
const {
return local_rank() == rank_; }
185 bool has_owner()
const {
return (rank_ != -1) && (world_ != NULL); }
195 pointer
get()
const {
209 MADNESS_ASSERT(pointer_ != NULL);
223 MADNESS_ASSERT(pointer_ != NULL);
233 operator bool ()
const {
return pointer_; }
247 template <
typename U>
249 return (pointer_ == other.pointer_) && (rank_ == other.rank_)
250 && (worldid_ == other.worldid_);
259 template <
typename U>
261 return (pointer_ != other.pointer_) || (rank_ != other.rank_)
262 || (worldid_ != other.worldid_);
273 template <
typename U>
274 bool operator<(const WorldPtr<U>& other)
const {
275 return (worldid_ < other.worldid_) ||
276 ((worldid_ == worldid_) && ((rank_ < other.rank_) ||
277 ((rank_ == other.rank_) && (pointer_ < other.pointer_))));
286 MADNESS_ASSERT(world_ != NULL);
308 template <
typename U>
321 template <
class Archive>
327 template <
class Archive>
332 friend std::ostream& operator<<(std::ostream& out, const WorldPtr<T>& p) {
333 out <<
"WorldPointer(ptr=" << p.pointer_ <<
", rank=";
340 out << (p.worldid_ - 1);
355 template <
typename T>
360 template <
typename T,
typename U>
365 template <
typename T,
typename U>
366 bool operator<=(const WorldPtr<T>& left,
const WorldPtr<U>& right) {
367 return !(right < left);
370 template <
typename T,
typename U>
372 return !(left < right);
380 template <
typename,
typename>
381 struct ArchiveLoadImpl;
383 template <
typename,
typename>
384 struct ArchiveStoreImpl;
386 template <
typename Archive,
typename T>
393 template <
typename Archive,
typename T>
402 #endif // MADNESS_WORLD_WORLDPTR_H__INCLUDED
static void load(const Archive &ar, detail::WorldPtr< T > &p)
Definition: worldptr.h:388
void store_internal_(const Archive &ar) const
Definition: worldptr.h:328
WorldPtr(const WorldPtr< U > &other)
Copy conversion constructor.
Definition: worldptr.h:135
Interface templates for the archives (serialization)
void swap(WorldPtr< T > &l, WorldPtr< T > &r)
Swap the content of l with r.
Definition: worldptr.h:356
Definition: worldptr.h:50
Default store of a thingy via serialize(ar,t)
Definition: archive.h:708
static void store(const Archive &ar, const detail::WorldPtr< T > &p)
Definition: worldptr.h:395
U & reference
Definition: worldptr.h:51
WorldPtr(World &w, T *p)
World pointer constructor.
Definition: worldptr.h:109
static World * world_from_id(unsigned long id)
Convert world id to world pointer.
Definition: worldfwd.h:628
unsigned long worldidT
World ID type.
Definition: worldptr.h:67
ProcessID owner() const
Rank accessor.
Definition: worldptr.h:301
T * pointer
Definition: worldptr.h:88
worldidT get_worldid() const
World ID accessor.
Definition: worldptr.h:294
bool operator>(const WorldPtr< T > &left, const WorldPtr< U > &right)
Definition: worldptr.h:361
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
ptr_traits< T >::reference reference
Definition: worldptr.h:89
World & get_world() const
World accessor.
Definition: worldptr.h:285
pointer operator->() const
Pointer arrow operator.
Definition: worldptr.h:221
bool operator!() const
Boolean conversion operator.
Definition: worldptr.h:239
Default load of a thingy via serialize(ar,t)
Definition: archive.h:718
bool operator>=(const WorldPtr< T > &left, const WorldPtr< U > &right)
Definition: worldptr.h:371
WorldPtr()
Default constructor.
Definition: worldptr.h:96
bool operator!=(const WorldPtr< U > &other) const
Inequality comparison operator.
Definition: worldptr.h:260
A parallel world with full functionality wrapping an MPI communicator.
Definition: worldfwd.h:416
int ProcessID
Used to clearly identify process number/rank.
Definition: worldtypes.h:37
ProcessID rank() const
Returns the process rank in this world (same as MPI_Comm_rank()))
Definition: worldfwd.h:526
archive_array< unsigned char > wrap_opaque(const T *, unsigned int)
Factory function to wrap pointer to contiguous data as opaque (uchar) archive_array.
Definition: archive.h:827
bool has_owner() const
Check that the world pointer has an owner.
Definition: worldptr.h:185
WorldPtr(const WorldPtr< T > &other)
Copy constructor.
Definition: worldptr.h:120
A global pointer address, valid anywhere in the world.
Definition: worldptr.h:65
Implements MadnessException.
WorldPtr< T > & operator=(const WorldPtr< U > &other)
Copy conversion assignment operator.
Definition: worldptr.h:165
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
reference operator*() const
Dereference operator.
Definition: worldptr.h:207
void swap(mpfr::mpreal &x, mpfr::mpreal &y)
Definition: mpreal.h:3069
void reference
Definition: worldptr.h:56
bool operator==(const WorldPtr< U > &other) const
Equality comparison operator.
Definition: worldptr.h:248
void load_internal_(const Archive &ar)
Serialize/deserialize the world pointer.
Definition: worldptr.h:322
WorldPtr< T > & operator=(const WorldPtr< T > &other)
Copy assignment operator.
Definition: worldptr.h:147
bool is_local() const
Check that the world pointer references a local pointer.
Definition: worldptr.h:179
void swap(WorldPtr< U > &other)
Swap the content of this with other.
Definition: worldptr.h:309