MADNESS 0.10.1
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
madness::Cloud Class Reference

cloud class More...

#include <cloud.h>

Classes

struct  cloudtimer
 
struct  is_madness_function_vector
 
struct  is_madness_function_vector< std::vector< Function< T, NDIM > > >
 
struct  is_tuple
 
struct  is_tuple< std::tuple< T... > >
 
struct  is_vector
 
struct  is_vector< std::vector< Q > >
 

Public Types

typedef std::any cached_objT
 
typedef std::map< keyT, cached_objTcacheT
 
template<typename T >
using has_cloud_serialize = madness::meta::is_detected< member_cloud_serialize_t, T >
 
using keyT = madness::archive::ContainerRecordOutputArchive::keyT
 
template<typename T >
using member_cloud_serialize_t = decltype(std::declval< T >().cloud_store(std::declval< World & >(), std::declval< Cloud & >()))
 
typedef Recordlist< keyTrecordlistT
 
enum  ReplicationPolicy { Distributed , RankReplicated , NodeReplicated }
 
enum  StoragePolicy { StoreFunction , StoreFunctionPointer }
 
using valueT = std::vector< unsigned char >
 

Public Member Functions

 Cloud (madness::World &universe)
 
void clear ()
 
void clear_cache (World &subworld)
 
void clear_timings ()
 
template<typename T >
T consuming_load (madness::World &world, recordlistT &recordlist) const
 similar to load, but will consume the recordlist
 
template<typename T >
std::enable_if< is_vector< T >::value, T >::type do_load (World &world, recordlistT &recordlist) const
 
template<typename T >
std::enable_if<!is_vector< T >::value, T >::type do_load (World &world, recordlistT &recordlist) const
 
template<typename T >
T forward_load (madness::World &world, recordlistT &recordlist) const
 load a single object from the cloud, recordlist is consumed while loading elements
 
ReplicationPolicy get_replication_policy () const
 
StoragePolicy get_storing_policy () const
 
template<typename T >
T load (madness::World &world, const recordlistT recordlist) const
 load a single object from the cloud, recordlist is kept unchanged
 
template<typename T >
T load_tuple (madness::World &world, recordlistT &recordlist) const
 
std::tuple< size_t, double > print_size (World &universe)
 
void print_timings (World &universe) const
 
void replicate (const std::size_t chunk_size=INT_MAX)
 
void replicate_per_node (const std::size_t chunk_size=INT_MAX)
 
void set_debug (bool value)
 
void set_fence (bool value)
 
void set_force_load_from_cache (bool value)
 
void set_replication_policy (const ReplicationPolicy value)
 
void set_storing_policy (const StoragePolicy value)
 
template<typename T >
recordlistT store (madness::World &world, const T &source)
 
template<typename T >
recordlistT store_other (madness::World &world, const std::vector< T > &source)
 
template<typename... Ts>
recordlistT store_tuple (World &world, const std::tuple< Ts... > &input)
 store a tuple in multiple records
 

Private Types

template<typename T >
using is_parallel_serializable_object = std::is_base_of< archive::ParallelSerializableObject, T >
 
template<typename T >
using is_world_constructible = std::is_constructible< T, World & >
 

Private Member Functions

template<typename T >
T allocator (World &world) const
 
template<typename T >
void cache (madness::World &world, const T &obj, const keyT &record) const
 
bool is_cached (const keyT &key) const
 
bool is_in_container (const keyT &key) const
 checks if a (universe) container record is used
 
template<typename T >
T load_from_cache (madness::World &world, const keyT &record) const
 load an object from the cache, record is unchanged
 
template<typename T >
recordlistT store_other (madness::World &world, const T &source)
 

Private Attributes

std::atomic< long > cache_reads =0l
 
std::atomic< long > cache_stores =0l
 
cacheT cached_objects
 
madness::WorldContainer< keyT, valueTcontainer
 
bool debug = false
 prints debug output
 
bool dofence = true
 fences after load/store
 
bool force_load_from_cache = false
 forces load from cache (mainly for debugging)
 
bool is_replicated =false
 if contents of the container are replicated
 
recordlistT local_list_of_container_keys
 
std::atomic< long > reading_time =0l
 
ReplicationPolicy replication_policy = RankReplicated
 
std::atomic< long > replication_time =0l
 
StoragePolicy storage_policy = StoreFunctionPointer
 current policy for loading/storing/replicating
 
std::atomic< long > writing_time =0l
 
std::atomic< long > writing_time1 =0l
 

Detailed Description

cloud class

store and load data to/from the cloud into arbitrary worlds

Distributed data is always bound to a certain world. If it needs to be present in another world it can be serialized to the cloud and deserialized from there again. For an example see test_cloud.cc

Data is stored into a distributed container living in the universe. During storing a (replicated) list of records is returned that can be used to find the data in the container. If a combined object (a vector, tuple, etc) is stored a list of records will be generated. When loading the data from the world the record list will be used to deserialize all stored objects.

Note that there must be a fence after the destruction of subworld containers, as in:

create subworlds { dcT(subworld) do work } subworld.gop.fence();

Member Typedef Documentation

◆ cached_objT

typedef std::any madness::Cloud::cached_objT

◆ cacheT

◆ has_cloud_serialize

◆ is_parallel_serializable_object

template<typename T >
using madness::Cloud::is_parallel_serializable_object = std::is_base_of<archive::ParallelSerializableObject,T>
private

◆ is_world_constructible

template<typename T >
using madness::Cloud::is_world_constructible = std::is_constructible<T, World &>
private

◆ keyT

◆ member_cloud_serialize_t

template<typename T >
using madness::Cloud::member_cloud_serialize_t = decltype(std::declval<T>().cloud_store(std::declval<World&>(), std::declval<Cloud&>()))

◆ recordlistT

◆ valueT

using madness::Cloud::valueT = std::vector<unsigned char>

Member Enumeration Documentation

◆ ReplicationPolicy

Enumerator
Distributed 

no replication of the container, the container is distributed over the universe inter-node communication is required for subworlds to access the data

RankReplicated 

replicate the container over all universe ranks, such that subworlds can access the data locally will lead to increased memory footprint if there are many subworlds on a node

NodeReplicated 

replicate the container over all compute nodes, once per node, even if there are several ranks only intra-node communication is required to access the data

◆ StoragePolicy

These policies determine how the data is stored in the cloud and how it is replicated There are six possible combinations of storing and replication policies: StoreFunction + Distributed : Functions are stored in the cloud, subworlds need to communicate with all universe ranks to access them StoreFunction + RankReplicated : Functions are stored in the cloud, but subworlds can access them locally – high memory impact StoreFunction + NodeReplicated : Functions are stored in the cloud, but subworlds can access them through intra-node communication – low memory impact StoreFunctionPointer + Distributed : Pointers to functions are stored in the cloud, subworlds need to communicate with the universe to access function data StoreFunctionPointer + RankReplicated : Pointers to functions are stored in the cloud, subworlds need to communicate with the universe to access function data StoreFunctionPointer + NodeReplicated : Pointers to functions are stored in the cloud, subworlds need to communicate with the universe to access function data of the last three policies only (StoreFunctionPointer + RankReplicated) is recommended, as the function pointers do not have a memory impact. on large-memory machines the policy (StoreFunctionPointer + RankReplicated) is recommended, as everything is local after the initial replication step

Enumerator
StoreFunction 

store a madness function in the cloud – can have a large memory impact equivalent to a deep copy

StoreFunctionPointer 

store the pointer to the function in the cloud. Return type still is a Function<T,NDIM> with a pointer to the universe function impl. equivalent to a shallow copy

Constructor & Destructor Documentation

◆ Cloud()

madness::Cloud::Cloud ( madness::World universe)
inline
Parameters
[in]universethe universe world

Member Function Documentation

◆ allocator()

template<typename T >
T madness::Cloud::allocator ( World world) const
inlineprivate

References T().

◆ cache()

template<typename T >
void madness::Cloud::cache ( madness::World world,
const T obj,
const keyT record 
) const
inlineprivate

References cached_objects.

◆ clear()

void madness::Cloud::clear ( )
inline

◆ clear_cache()

void madness::Cloud::clear_cache ( World subworld)
inline

◆ clear_timings()

void madness::Cloud::clear_timings ( )
inline

◆ consuming_load()

template<typename T >
T madness::Cloud::consuming_load ( madness::World world,
recordlistT recordlist 
) const
inline

similar to load, but will consume the recordlist

Parameters
[in]worldthe subworld the objects are loaded to
[in]recordlistthe list of records where the objects are stored

References reading_time.

Referenced by madness::MacroTask< taskT >::MacroTaskInternal::get_output().

◆ do_load() [1/2]

template<typename T >
std::enable_if< is_vector< T >::value, T >::type madness::Cloud::do_load ( World world,
recordlistT recordlist 
) const
inline

load a vector from the cloud, pop records from recordlist

Parameters
[in,out]worlddestination world
[in,out]recordlistlist of records to load from (reduced by the first few elements)

References T(), and target().

◆ do_load() [2/2]

template<typename T >
std::enable_if<!is_vector< T >::value, T >::type madness::Cloud::do_load ( World world,
recordlistT recordlist 
) const
inline

load a single object from the cloud, pop record from recordlist

Parameters
[in,out]worlddestination world
[in,out]recordlistlist of records to load from (reduced by the first element)

References madness::cache, container, debug, force_load_from_cache, madness::World::id(), is_cached(), is_replicated, MADNESS_CHECK, MADNESS_EXCEPTION, madness::print(), storage_policy, StoreFunctionPointer, T(), and target().

◆ forward_load()

template<typename T >
T madness::Cloud::forward_load ( madness::World world,
recordlistT recordlist 
) const
inline

load a single object from the cloud, recordlist is consumed while loading elements

References T(), and target().

Referenced by madness::CCIntermediatePotentials::cloud_load(), madness::Info::cloud_load(), madness::CCPair::cloud_load(), custom_serialize_tester::cloud_load(), and load_tuple().

◆ get_replication_policy()

ReplicationPolicy madness::Cloud::get_replication_policy ( ) const
inline

◆ get_storing_policy()

StoragePolicy madness::Cloud::get_storing_policy ( ) const
inline

References storage_policy.

◆ is_cached()

bool madness::Cloud::is_cached ( const keyT key) const
inlineprivate

References cached_objects.

Referenced by do_load().

◆ is_in_container()

bool madness::Cloud::is_in_container ( const keyT key) const
inlineprivate

checks if a (universe) container record is used

currently implemented with a local copy of the recordlist, might be reimplemented with container.find(), which would include blocking communication.

References local_list_of_container_keys.

Referenced by store_other().

◆ load()

template<typename T >
T madness::Cloud::load ( madness::World world,
const recordlistT  recordlist 
) const
inline

load a single object from the cloud, recordlist is kept unchanged

Parameters
[in]worldthe subworld the objects are loaded to
[in]recordlistthe list of records where the objects are stored

References reading_time.

Referenced by chunk_example(), main(), madness::MacroTask< taskT >::MacroTaskInternal::run(), simple_example(), test_copy_function_from_other_world_through_cloud(), test_custom_serialization(), and test_custom_worldobject().

◆ load_from_cache()

template<typename T >
T madness::Cloud::load_from_cache ( madness::World world,
const keyT record 
) const
inlineprivate

load an object from the cache, record is unchanged

References cache_reads, cached_objects, debug, madness::World::id(), MADNESS_EXCEPTION, madness::print(), madness::World::rank(), T(), and target().

◆ load_tuple()

template<typename T >
T madness::Cloud::load_tuple ( madness::World world,
recordlistT recordlist 
) const
inline

load a tuple from the cloud, pop records from recordlist

Parameters
[in,out]worlddestination world
[in,out]recordlistlist of records to load from (reduced by the first few elements)

References debug, forward_load(), madness::World::id(), madness::name(), T(), target(), and madness::type().

◆ print_size()

std::tuple< size_t, double > madness::Cloud::print_size ( World universe)
inline

◆ print_timings()

void madness::Cloud::print_timings ( World universe) const
inline

◆ replicate()

void madness::Cloud::replicate ( const std::size_t  chunk_size = INT_MAX)
inline

◆ replicate_per_node()

void madness::Cloud::replicate_per_node ( const std::size_t  chunk_size = INT_MAX)
inline

◆ set_debug()

void madness::Cloud::set_debug ( bool  value)
inline

◆ set_fence()

void madness::Cloud::set_fence ( bool  value)
inline

References dofence.

◆ set_force_load_from_cache()

void madness::Cloud::set_force_load_from_cache ( bool  value)
inline

References force_load_from_cache.

Referenced by main(), and test_custom_worldobject().

◆ set_replication_policy()

void madness::Cloud::set_replication_policy ( const ReplicationPolicy  value)
inline

References replication_policy.

◆ set_storing_policy()

void madness::Cloud::set_storing_policy ( const StoragePolicy  value)
inline

◆ store()

template<typename T >
recordlistT madness::Cloud::store ( madness::World world,
const T source 
)
inline

◆ store_other() [1/2]

template<typename T >
recordlistT madness::Cloud::store_other ( madness::World world,
const std::vector< T > &  source 
)
inline

◆ store_other() [2/2]

template<typename T >
recordlistT madness::Cloud::store_other ( madness::World world,
const T source 
)
inlineprivate

◆ store_tuple()

template<typename... Ts>
recordlistT madness::Cloud::store_tuple ( World world,
const std::tuple< Ts... > &  input 
)
inline

store a tuple in multiple records

References madness::arg(), store(), and v.

Referenced by store().

Member Data Documentation

◆ cache_reads

std::atomic<long> madness::Cloud::cache_reads =0l
mutableprivate

◆ cache_stores

std::atomic<long> madness::Cloud::cache_stores =0l
mutableprivate

◆ cached_objects

cacheT madness::Cloud::cached_objects
private

◆ container

madness::WorldContainer<keyT, valueT> madness::Cloud::container
mutableprivate

◆ debug

bool madness::Cloud::debug = false
private

◆ dofence

bool madness::Cloud::dofence = true
private

fences after load/store

Referenced by set_fence(), store(), store_other(), and store_other().

◆ force_load_from_cache

bool madness::Cloud::force_load_from_cache = false
private

forces load from cache (mainly for debugging)

Referenced by do_load(), and set_force_load_from_cache().

◆ is_replicated

bool madness::Cloud::is_replicated =false
private

if contents of the container are replicated

Referenced by do_load(), print_size(), replicate(), and store().

◆ local_list_of_container_keys

recordlistT madness::Cloud::local_list_of_container_keys
private

◆ reading_time

std::atomic<long> madness::Cloud::reading_time =0l
mutableprivate

◆ replication_policy

ReplicationPolicy madness::Cloud::replication_policy = RankReplicated
private

◆ replication_time

std::atomic<long> madness::Cloud::replication_time =0l
mutableprivate

◆ storage_policy

StoragePolicy madness::Cloud::storage_policy = StoreFunctionPointer
private

current policy for loading/storing/replicating

Referenced by do_load(), get_storing_policy(), set_storing_policy(), and store_other().

◆ writing_time

std::atomic<long> madness::Cloud::writing_time =0l
mutableprivate

Referenced by clear_timings(), print_timings(), and store().

◆ writing_time1

std::atomic<long> madness::Cloud::writing_time1 =0l
mutableprivate

Referenced by clear_timings(), and store_other().


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