TiledArray::detail::DistributedStorage< T > Class Template Reference
Inheritance diagram for TiledArray::detail::DistributedStorage< T >:
Collaboration diagram for TiledArray::detail::DistributedStorage< T >:

Documentation

template<typename T>
class TiledArray::detail::DistributedStorage< T >

Distributed storage container.

Each element in this container is owned by a single node, but any node may request a copy of the element in the form of a Future . The owner of each element is defined by a process map (pmap), which is passed to the constructor. Elements do not need to be explicitly initialized because they will be added to the container when the element is first accessed, though you may manually initialize an element with the insert() function. All elements are stored in Future , which may be set only once.

Note
This object is derived from WorldObject , which means the order of construction of object must be the same on all nodes. This can easily be achieved by only constructing world objects in the main thread. DO NOT construct world objects within tasks where the order of execution is nondeterministic.

Definition at line 44 of file distributed_storage.h.

Public Types

typedef DistributedStorage< T > DistributedStorage_
 This object type. More...
 
typedef madness::WorldObject< DistributedStorage_WorldObject_
 Base object type. More...
 
typedef std::size_t size_type
 size type More...
 
typedef size_type key_type
 element key type More...
 
typedef T value_type
 Element type. More...
 
typedef Future< value_typefuture
 Element container type. More...
 
typedef Pmap pmap_interface
 Process map interface type. More...
 
typedef madness::ConcurrentHashMap< key_type, futurecontainer_type
 Local container type. More...
 
typedef container_type::accessor accessor
 Local element accessor type. More...
 
typedef container_type::const_accessor const_accessor
 Local element const accessor type. More...
 

Public Member Functions

 DistributedStorage (World &world, size_type max_size, const std::shared_ptr< pmap_interface > &pmap)
 
virtual ~DistributedStorage ()
 
const std::shared_ptr< pmap_interface > & pmap () const
 Process map accessor. More...
 
ProcessID owner (size_type i) const
 Element owner. More...
 
bool is_local (size_type i) const
 Local element query. More...
 
size_type size () const
 Number of local elements. More...
 
size_type max_size () const
 Max size accessor. More...
 
future get (size_type i) const
 Get local or remote element. More...
 
const futureget_local (const size_type i) const
 Get local element. More...
 
futureget_local (const size_type i)
 Get local element. More...
 
void set (size_type i, const value_type &value)
 Set element i with value. More...
 
void set (size_type i, const future &f)
 Set element i with a Future f. More...
 

Friends

struct DelayedSet
 

Member Typedef Documentation

◆ accessor

template<typename T >
typedef container_type::accessor TiledArray::detail::DistributedStorage< T >::accessor

Local element accessor type.

Definition at line 58 of file distributed_storage.h.

◆ const_accessor

template<typename T >
typedef container_type::const_accessor TiledArray::detail::DistributedStorage< T >::const_accessor

Local element const accessor type.

Definition at line 60 of file distributed_storage.h.

◆ container_type

template<typename T >
typedef madness::ConcurrentHashMap<key_type, future> TiledArray::detail::DistributedStorage< T >::container_type

Local container type.

Definition at line 56 of file distributed_storage.h.

◆ DistributedStorage_

This object type.

Definition at line 46 of file distributed_storage.h.

◆ future

template<typename T >
typedef Future<value_type> TiledArray::detail::DistributedStorage< T >::future

Element container type.

Definition at line 53 of file distributed_storage.h.

◆ key_type

template<typename T >
typedef size_type TiledArray::detail::DistributedStorage< T >::key_type

element key type

Definition at line 51 of file distributed_storage.h.

◆ pmap_interface

template<typename T >
typedef Pmap TiledArray::detail::DistributedStorage< T >::pmap_interface

Process map interface type.

Definition at line 54 of file distributed_storage.h.

◆ size_type

template<typename T >
typedef std::size_t TiledArray::detail::DistributedStorage< T >::size_type

size type

Definition at line 50 of file distributed_storage.h.

◆ value_type

template<typename T >
typedef T TiledArray::detail::DistributedStorage< T >::value_type

Element type.

Definition at line 52 of file distributed_storage.h.

◆ WorldObject_

template<typename T >
typedef madness::WorldObject<DistributedStorage_> TiledArray::detail::DistributedStorage< T >::WorldObject_

Base object type.

Definition at line 48 of file distributed_storage.h.

Constructor & Destructor Documentation

◆ DistributedStorage()

template<typename T >
TiledArray::detail::DistributedStorage< T >::DistributedStorage ( World &  world,
size_type  max_size,
const std::shared_ptr< pmap_interface > &  pmap 
)
inline

Makes an initialized, empty container with default data distribution (no communication) A unique ID is associated with every distributed container within a world. In order to avoid synchronization when making a container, we have to assume that all processes execute this constructor in the same order (does not apply to the non-initializing, default constructor).

Parameters
worldThe world where the distributed container lives
max_sizeThe maximum capacity of this container
pmapThe process map for the container (default = null pointer)

Definition at line 127 of file distributed_storage.h.

◆ ~DistributedStorage()

template<typename T >
virtual TiledArray::detail::DistributedStorage< T >::~DistributedStorage ( )
inlinevirtual

Definition at line 142 of file distributed_storage.h.

Member Function Documentation

◆ get()

template<typename T >
future TiledArray::detail::DistributedStorage< T >::get ( size_type  i) const
inline

Get local or remote element.

Parameters
iThe element to get
Returns
A future to element i
Exceptions
TiledArray::ExceptionIf i is greater than or equal to max_size() .

Definition at line 202 of file distributed_storage.h.

Here is the caller graph for this function:

◆ get_local() [1/2]

template<typename T >
future& TiledArray::detail::DistributedStorage< T >::get_local ( const size_type  i)
inline

Get local element.

Parameters
iThe element to get
Returns
A reference to element i
Exceptions
TiledArray::ExceptionIf i is greater than or equal to max_size() or i is not local.

Definition at line 238 of file distributed_storage.h.

◆ get_local() [2/2]

template<typename T >
const future& TiledArray::detail::DistributedStorage< T >::get_local ( const size_type  i) const
inline

Get local element.

Parameters
iThe element to get
Returns
A const reference to element i
Exceptions
TiledArray::ExceptionIf i is greater than or equal to max_size() or i is not local.

Definition at line 223 of file distributed_storage.h.

Here is the caller graph for this function:

◆ is_local()

template<typename T >
bool TiledArray::detail::DistributedStorage< T >::is_local ( size_type  i) const
inline

Local element query.

Check if element i belongs to this node. The element may or may not be stored. Use find to determine if an element is present.

Parameters
iThe element to check.
Returns
true when the element is stored locally, otherwise false.

Definition at line 175 of file distributed_storage.h.

Here is the caller graph for this function:

◆ max_size()

template<typename T >
size_type TiledArray::detail::DistributedStorage< T >::max_size ( ) const
inline

Max size accessor.

The maximum size is the total number of elements that can be held by this container on all nodes, not on each node.

Returns
The maximum number of elements.
Exceptions
nothing

Definition at line 194 of file distributed_storage.h.

Here is the caller graph for this function:

◆ owner()

template<typename T >
ProcessID TiledArray::detail::DistributedStorage< T >::owner ( size_type  i) const
inline

Element owner.

Returns
The process that owns element i

Definition at line 163 of file distributed_storage.h.

Here is the caller graph for this function:

◆ pmap()

template<typename T >
const std::shared_ptr<pmap_interface>& TiledArray::detail::DistributedStorage< T >::pmap ( ) const
inline

Process map accessor.

Returns
A shared pointer to the process map.
Exceptions
nothing

Definition at line 158 of file distributed_storage.h.

◆ set() [1/2]

template<typename T >
void TiledArray::detail::DistributedStorage< T >::set ( size_type  i,
const future f 
)
inline

Set element i with a Future f.

The owner of i may be local or remote. If i is remote, a task is spawned on the owning node after the local future has been assigned. If i is not already in the container, it will be inserted.

Parameters
iThe element to be set
fThe future for element i
Exceptions
madness::MadnessExceptionIf i has already been set.
TiledArray::ExceptionIf i is greater than or equal to max_size() .

Definition at line 272 of file distributed_storage.h.

◆ set() [2/2]

template<typename T >
void TiledArray::detail::DistributedStorage< T >::set ( size_type  i,
const value_type value 
)
inline

Set element i with value.

Parameters
iThe element to be set
valueThe value of element i
Exceptions
TiledArray::ExceptionIf i is greater than or equal to max_size() .
madness::MadnessExceptionIf i has already been set.

Definition at line 254 of file distributed_storage.h.

Here is the caller graph for this function:

◆ size()

template<typename T >
size_type TiledArray::detail::DistributedStorage< T >::size ( ) const
inline

Number of local elements.

No communication.

Returns
The number of local elements stored by the container.
Exceptions
nothing

Definition at line 186 of file distributed_storage.h.

Friends And Related Function Documentation

◆ DelayedSet

template<typename T >
friend struct DelayedSet
friend

Definition at line 114 of file distributed_storage.h.


The documentation for this class was generated from the following file: