13#ifndef SRC_MADNESS_WORLD_CLOUD_H_
14#define SRC_MADNESS_WORLD_CLOUD_H_
40 static const char*
value() {
return typeid(T).
name();}
57 struct type_name<
std::vector<Function<double,1>>> {
static const char*
value() {
return "std::vector<Function<double,1>>"; } };
59 struct type_name<
std::vector<Function<double,2>>> {
static const char*
value() {
return "std::vector<Function<double,2>>"; } };
61 struct type_name<
std::vector<Function<double,3>>> {
static const char*
value() {
return "std::vector<Function<double,3>>"; } };
63 struct type_name<
std::vector<Function<double,4>>> {
static const char*
value() {
return "std::vector<Function<double,4>>"; } };
65 struct type_name<
std::vector<Function<double,5>>> {
static const char*
value() {
return "std::vector<Function<double,5>>"; } };
67 struct type_name<
std::vector<Function<double,6>>> {
static const char*
value() {
return "std::vector<Function<double,6>>"; } };
69template<
typename keyT>
80 for (
auto &l2 : list2.
list)
list.push_back(l2);
101 template <
typename T>
104 template <
typename T>
108 template <
typename T>
111 template <
typename T>
114 template<
typename T, std::
size_t NDIM>
117 template<
typename T, std::
size_t NDIM>
120 template<
typename keyQ,
typename valueT>
123 template<
typename keyQ,
typename valueT>
126 template<
typename T, std::
size_t NDIM>
146 std::size_t hashtype =
typeid(T).hash_code();
167template <
typename keyT,
typename hashfunT = Hash<keyT>>
172 std::shared_ptr<std::map<keyT, ProcessID>>
table;
182 auto it =
table->find(key);
183 if (it !=
table->end())
return it->second;
184 if (
nproc == 1)
return 0;
189 print(
"CloudOwnerPmap::table", tag,
"size=",
table->size(),
"(nproc=",
nproc,
")");
190 for (
const auto& kv : *
table) {
191 std::ostringstream os;
192 os <<
" key=0x" << std::hex << kv.first << std::dec <<
" owner=" << kv.second;
252 "batch chunk size must be positive and fit an MPI count");
281 std::vector<SafeMPI::Request>
reqs;
285 std::map<int, std::shared_ptr<PendingRecv>>
pending_;
310 void on_reply(
int tag, std::size_t size, std::size_t chunk);
350 using valueT = std::vector<unsigned char>;
351 typedef std::map<keyT, cached_objT>
cacheT;
367 default: os <<
"UnknownStoragePolicy";
break;
373 std::ostringstream os;
398 template <
typename T>
401 template <
typename T>
418 print(
"You need to call clear_cache(subworld) before destroying the cloud");
419 print(
"\n------------------------------\n");
420 std::string msg=
"deferred destruction of cloud with non-empty cache";
421 std::cerr << msg << std::endl;
432 if (universe.
rank() != 0)
return;
459 std::cout <<
"Cloud::validate_distribution(): distribution type mismatch, container is " << disttype
479 double byte2gbyte=1.0/(1024*1024*1024);
480 double global_memsize=
stats[
"memory_global_GB"].template get<double>();
481 double max_record_size=
stats[
"max_record_size"].template get<double>();
482 double min_memsize=
stats[
"memory_min_GB"].template get<double>();
483 double max_memsize=
stats[
"memory_max_GB"].template get<double>();
484 double global_size=
stats[
"container_size_global"].template get<double>();
486 if (universe.
rank()==0) {
487 print(
"Cloud memory:");
489 print(
"size of cloud (total)");
490 print(
" number of records: ",global_size);
491 print(
" memory in GBytes: ",global_memsize);
492 print(
"size of cloud (average per node)");
493 print(
" number of records: ",
double(global_size)/universe.
size());
494 print(
" memory in GBytes: ",global_memsize/universe.
size());
495 print(
"min/max of node");
496 print(
" memory in GBytes: ",min_memsize,max_memsize);
497 print(
" max record size in GBytes:",max_record_size*byte2gbyte);
521 std::size_t memsize=0;
522 std::size_t max_record_size=0;
524 memsize+=item.second.size();
525 max_record_size=std::max(max_record_size,item.second.size());
529 std::size_t batch_memsize=0;
531 batch_memsize+=item.second.size();
532 max_record_size=std::max(max_record_size,item.second.size());
534 memsize+=batch_memsize;
535 std::size_t global_memsize=memsize;
536 std::size_t max_memsize=memsize;
537 std::size_t min_memsize=memsize;
540 universe.
gop.
sum(global_memsize);
541 universe.
gop.
max(max_memsize);
542 universe.
gop.
max(max_record_size);
543 universe.
gop.
min(min_memsize);
546 double byte2gbyte=1.0/(1024*1024*1024);
549 double uchar2gbyte=byte2gbyte*
sizeof(
unsigned char);
553 auto global_size=local_size;
554 universe.
gop.
sum(global_size);
556 universe.
gop.
sum(batch_global_size);
557 std::size_t batch_global_memsize=batch_memsize;
558 universe.
gop.
sum(batch_global_memsize);
560 j[
"container_size_global"] = global_size;
561 j[
"batch_container_size_global"] = batch_global_size;
562 j[
"batch_memory_global_GB"] = batch_global_memsize*uchar2gbyte;
563 j[
"memory_global_GB"] = global_memsize*uchar2gbyte;
564 j[
"memory_min_GB"] = min_memsize*uchar2gbyte;
565 j[
"memory_max_GB"] = max_memsize*uchar2gbyte;
566 j[
"memory_rss_GB_max"] = rss;
567 j[
"memory_rss_GB_av"] = rss_av/universe.
size();
568 j[
"max_record_size"] = max_record_size;
576 double ctime_max = double(
copy_time)*1.e-6;
577 double ctime_acc = double(
copy_time)*1.e-6;
578 double ctime_av = double(
copy_time)*1.e-6;
582 universe.
gop.
max(rtime_max);
583 universe.
gop.
sum(rtime_acc);
584 rtime_av = rtime_acc/universe.
size();
585 universe.
gop.
max(ctime_max);
586 universe.
gop.
sum(ctime_acc);
587 ctime_av = ctime_acc/universe.
size();
594 universe.
gop.
sum(cstores);
596 j[
"reading_time_max_s"] = rtime_max;
597 j[
"reading_time_acc_s"] = rtime_acc;
598 j[
"reading_time_av_s"] = rtime_av;
599 j[
"copy_time_max_s"] = ctime_max;
600 j[
"copy_time_acc_s"] = ctime_acc;
601 j[
"copy_time_av_s"] = ctime_av;
602 j[
"writing_time_s"] = wtime;
603 j[
"replication_time_s"] = ptime;
604 j[
"target_replication_time_s"] = tptime;
605 j[
"cache_reads"] = creads;
606 j[
"cache_stores"] = cstores;
616 double rtime_max=timings[
"reading_time_max_s"].template get<double>();
617 double rtime_av=timings[
"reading_time_av_s"].template get<double>();
618 double rtime_acc=timings[
"reading_time_acc_s"].template get<double>();
622 double wtime=timings[
"writing_time_s"].template get<double>();
623 double ptime=timings[
"replication_time_s"].template get<double>();
624 double tptime=timings[
"target_replication_time_s"].template get<double>();
625 long creads=timings[
"cache_reads"].template get<long>();
626 long cstores=timings[
"cache_stores"].template get<long>();
628 auto precision = std::cout.precision();
629 std::cout << std::fixed << std::setprecision(1);
630 print(
"cloud storing wall time ", wtime);
631 print(
"cloud replication wall time ", ptime);
632 print(
"target replication wall time ", tptime);
633 print(
"cloud max reading time (all procs) ", rtime_max, std::defaultfloat);
634 print(
"cloud average reading cpu time (all procs) ", rtime_av, std::defaultfloat);
635 print(
"cloud accumulated reading cpu time (all procs) ", rtime_acc, std::defaultfloat);
636 std::cout << std::setprecision(precision) << std::scientific;
637 print(
"cloud cache stores ",
long(cstores));
638 print(
"cloud cache loads ",
long(creads));
642 double byte2gbyte=1.0/(1024*1024*1024);
643 double global_memsize=
stats[
"memory_global_GB"].template get<double>();
644 double max_record_size=
stats[
"max_record_size"].template get<double>();
645 double min_memsize=
stats[
"memory_min_GB"].template get<double>();
646 double max_memsize=
stats[
"memory_max_GB"].template get<double>();
647 double global_size=
stats[
"container_size_global"].template get<double>();
649 print(
"Cloud memory:");
650 print(
" size of cloud (total)");
651 print(
" number of records: ",global_size);
652 print(
" memory in GBytes: ",global_memsize);
656 print(
" min/max of node");
657 print(
" memory in GBytes: ",min_memsize,max_memsize);
658 print(
" max record size in GBytes:",max_record_size*byte2gbyte);
661 const double b_size =
stats.value(
"batch_container_size_global", 0.0);
663 print(
" owner-pinned batches");
664 print(
" number of records: ", b_size);
665 print(
" memory in GBytes: ",
stats.value(
"batch_memory_global_GB", 0.0));
696 template<
typename T, std::
size_t NDIM>
705 fimpl->replicate(
false);
708 fimpl->replicate_on_hosts(
true);
710 fimpl->undo_replicate(
false);
726 loop_types<DistributeFunctor, double, float, double_complex, float_complex>(std::tuple<DistributionType>(dt),wo);
743 return forward_load<T>(world, rlist);
755 return forward_load<T>(world, recordlist);
766 return load_tuple<T>(world, recordlist);
769 target.cloud_load(world, *
this, recordlist);
772 return do_load<T>(world, recordlist);
795 template<
typename T, std::
size_t NDIM>
797 const ProcessID owner,
const keyT record,
const bool fence =
true) {
799 print(
"Cloud contents are replicated and read-only!");
808 std::size_t fsize = batch.size();
810 for (std::size_t i = 0; i < fsize; ++i) par & batch[i];
820 print(
"Cloud contents are replicated and read-only!");
833 recordlist+=
source.cloud_store(world,*
this);
871 if (
debug and (world.
rank()==0))
print(
"replication_per_node ended after ",cpu1-cpu0,
" seconds");
873 MADNESS_EXCEPTION(
"cloud replication_per_node failed, presumably because some data is larger than 2GB",1);
888 std::list<keyT> keylist;
890 keylist.push_back(it->first);
894 if (rank == world.
rank()) {
895 std::size_t keylistsize = keylist.size();
898 for (
auto key : keylist) {
902 auto data = acc->second;
903 std::size_t sz=
data.size();
909 for (std::size_t start=0; start<sz; start+=chunk_size) {
910 std::size_t remainder = std::min(sz - start, chunk_size);
917 std::size_t keylistsize = 0;
919 for (
size_t i=0; i<keylistsize; i++) {
926 for (std::size_t start=0; start<sz; start+=chunk_size) {
927 std::size_t remainder=std::min(sz-start,chunk_size);
937 if (
debug and (world.
rank()==0))
print(
"replication ended after ",cpu1-cpu0,
" seconds");
956 template<
typename>
struct is_tuple : std::false_type { };
957 template<
typename ...T>
struct is_tuple<
std::tuple<T...>> : std::true_type { };
959 template<
typename Q>
struct is_vector : std::false_type { };
960 template<
typename Q>
struct is_vector<
std::vector<Q>> : std::true_type { };
991 if (
auto obj = std::any_cast<T>(&
cached_objects.find(record)->second))
return *obj;
1037 return {acc->second.data(), acc->second.
size()};
1038 return {
nullptr, 0};
1055 template<
typename T, std::
size_t NDIM>
1058 const bool cache_result =
false)
const {
1059 typedef std::vector<Function<T, NDIM>>
vecfuncT;
1060 if (
is_cached(record))
return load_from_cache<vecfuncT>(subworld, record);
1067 "deserialize_batch_p2p: the owner does not hold this batch record");
1072 std::size_t fsize = 0;
1074 batch.resize(fsize);
1075 for (std::size_t i = 0; i < fsize; ++i) par & batch[i];
1083 template<
typename T, std::
size_t NDIM>
1085 const keyT record,
const bool cache_result =
false)
const {
1086 typedef std::vector<Function<T, NDIM>>
vecfuncT;
1087 if (
is_cached(record))
return load_from_cache<vecfuncT>(subworld, record);
1089 record, cache_result);
1104 template<
typename T>
1113 template<
typename T>
1118 if (is_already_present) std::cout <<
"skipping ";
1121 <<
" to record " << record << std::endl;
1123 std::cout <<
"storing object of " <<
type_name<T>::value() <<
" to record " << record << std::endl;
1126 if (
source.is_compressed() and T::dimT>3)
print(
"WARNING: storing compressed hi-dim `function");
1130 if (is_already_present) {
1162 template<
typename T>
1163 typename std::enable_if<is_vector<T>::value, T>
::type
1165 std::size_t sz = do_load<std::size_t>(world, recordlist);
1167 for (std::size_t i = 0; i < sz; ++i) {
1168 target[i] = do_load<typename T::value_type>(world, recordlist);
1177 template<
typename T>
1178 typename std::enable_if<!is_vector<T>::value, T>
::type
1180 keyT record = recordlist.pop_front_and_return();
1183 if (
is_cached(record))
return load_from_cache<T>(world, record);
1195 std::shared_ptr<implT> impl;
1201 print(
"failed to load function pointer from cloud, maybe the target is out of scope?");
1202 print(
"record:", record,
"world:", world.
id());
1228 template<
typename T>
1235 if (
debug and world.
rank()==0) std::cout <<
"done with vector storing; container size "
1241 template<
typename... Ts>
1244 auto storeaway = [&](
const auto &
arg) {
1247 auto l = [&](Ts
const &...
arg) {
1248 ((storeaway(
arg)), ...);
1250 std::apply(l, input);
1258 template<
typename T>
1260 if (
debug) std::cout <<
"loading tuple of type " <<
typeid(T).
name() <<
" to world " << world.
id() << std::endl;
1262 std::apply([&](
auto &&... args) {
1263 ((args =
forward_load<
typename std::remove_reference<
decltype(args)>
::type>(world, recordlist)), ...);
1274 if (owner ==
u.rank()) {
1280 auto p = std::make_shared<PendingRecv>();
1296 if (it->Test()) it =
sends_.erase(it);
1305 if (ptr_size.first ==
nullptr) {
1312 const std::size_t n = ptr_size.second;
1322 for (std::size_t off = 0; off < n; off += chunk) {
1323 const std::size_t len = std::min(chunk, n - off);
1324 sends_.push_back(
u.mpi.Isend(ptr_size.first + off,
int(len),
MPI_BYTE, requester, tag));
1334 std::shared_ptr<PendingRecv>
p;
1347 p->not_found =
true;
1351 p->buf.resize(size);
1354 for (std::size_t off = 0; off < size; off += chunk) {
1355 const std::size_t len = std::min(chunk, size - off);
1356 p->reqs.push_back(
u.mpi.Irecv(
p->buf.data() + off,
int(len),
MPI_BYTE,
p->owner, tag));
1362 std::shared_ptr<PendingRecv>
p;
1372 p->fut.set(std::move(
p->buf));
Point-to-point transfer of serialized function batches between universe ranks.
Definition cloud.h:229
static void set_batch_chunk_bytes(const std::size_t n)
Set the chunk size, for tests only.
Definition cloud.h:250
void on_trigger(batch_keyT record, ProcessID requester, int tag)
Definition cloud.h:1301
static std::size_t batch_chunk_bytes_
1 GiB
Definition cloud.h:298
BatchTransport(World &universe, Cloud *cloud)
Definition cloud.h:258
Cloud * cloud_
back-reference (not owned)
Definition cloud.h:270
std::map< int, std::shared_ptr< PendingRecv > > pending_
Definition cloud.h:285
std::mutex sends_mtx_
Definition cloud.h:289
static constexpr int BATCH_TAG_CAP
Definition cloud.h:234
int alloc_tag()
Definition cloud.h:292
void finish_recv(int tag)
requester side, worker task: await the background-progressed Irecv and set the future
Definition cloud.h:1361
static constexpr std::size_t BATCH_NOT_FOUND
reply size meaning "the owner does not hold this record"; see on_trigger
Definition cloud.h:237
std::mutex pending_mtx_
Definition cloud.h:284
void reap_sends()
Definition cloud.h:1293
std::atomic< int > next_tag_
Definition cloud.h:271
void on_reply(int tag, std::size_t size, std::size_t chunk)
requester side, comm thread: size the buffer, post the Irecvs, enqueue finish_recv
Definition cloud.h:1332
static std::size_t batch_chunk_bytes()
bytes per MPI message in a batch transfer; a larger payload is split into several
Definition cloud.h:244
Future< batch_bytesT > request(batch_keyT record)
Future to the serialized bytes of record, fetched from its owner.
Definition cloud.h:1271
std::list< SafeMPI::Request > sends_
Definition cloud.h:290
static constexpr int BATCH_TAG_BASE
Definition cloud.h:233
Process map for the cloud's batch container.
Definition cloud.h:168
CloudOwnerPmap(World &world, const hashfunT &hf=hashfunT())
Definition cloud.h:175
ProcessID owner(const keyT &key) const override
Maps key to processor.
Definition cloud.h:181
void print_table(const std::string &tag="") const
Definition cloud.h:188
void set_owner(const keyT &key, const ProcessID owner)
collective: every rank must register the same (key, owner) pair
Definition cloud.h:179
hashfunT hashfun
Definition cloud.h:171
std::shared_ptr< std::map< keyT, ProcessID > > table
Definition cloud.h:172
const int nproc
Definition cloud.h:170
cloud class
Definition cloud.h:338
bool is_cached(const keyT &key) const
Definition cloud.h:997
void print_batch_owner_map(World &universe, const std::string &tag="") const
Definition cloud.h:431
Future< batch_bytesT > request_batch_bytes_async(const keyT record) const
start fetching record from its owner; the trigger is in flight on return
Definition cloud.h:1044
bool use_cache
Definition cloud.h:344
void clear()
Definition cloud.h:675
void replicate_per_node(const std::size_t chunk_size=INT_MAX)
Definition cloud.h:858
bool is_in_container(const keyT &key) const
checks if a (universe) container record is used
Definition cloud.h:1098
bool force_load_from_cache
forces load from cache (mainly for debugging)
Definition cloud.h:343
bool debug
prints debug output
Definition cloud.h:340
std::atomic< long > writing_time1
Definition cloud.h:951
nlohmann::json get_statistics(World &world) const
return a json object with the cloud settings and statistics
Definition cloud.h:503
std::enable_if< is_vector< T >::value, T >::type do_load(World &world, recordlistT &recordlist) const
Definition cloud.h:1164
std::atomic< long > batch_find_time
waiting on the p2p transfer, microseconds
Definition cloud.h:944
recordlistT store_other(madness::World &world, const std::vector< T > &source)
Definition cloud.h:1229
std::any cached_objT
Definition cloud.h:348
recordlistT store(madness::World &world, const T &source)
Definition cloud.h:818
T load_tuple(madness::World &world, recordlistT &recordlist) const
Definition cloud.h:1259
std::is_base_of< archive::ParallelSerializableObject, T > is_parallel_serializable_object
Definition cloud.h:962
~Cloud()
Definition cloud.h:415
madness::archive::ContainerRecordOutputArchive::keyT keyT
Definition cloud.h:349
std::atomic< long > replication_time
Definition cloud.h:952
Recordlist< keyT > recordlistT
Definition cloud.h:352
StoragePolicy storage_policy
are the functions (WorldObjects) stored in the cloud or only pointers to them
Definition cloud.h:380
std::is_constructible< T, World & > is_world_constructible
Definition cloud.h:964
valueT try_get_local_batch_bytes(const keyT record) const
bytes of a batch record held by this rank, empty if it holds none
Definition cloud.h:1022
std::atomic< long > target_replication_time
Definition cloud.h:948
nlohmann::json gather_timings(World &universe) const
Definition cloud.h:572
friend std::string to_string(const StoragePolicy sp)
Definition cloud.h:372
recordlistT store_other(madness::World &world, const T &source)
Definition cloud.h:1114
bool is_replicated
if contents of the container are replicated
Definition cloud.h:341
void set_force_load_from_cache(bool value)
Definition cloud.h:440
decltype(std::declval< T >().cloud_store(std::declval< World & >(), std::declval< Cloud & >())) member_cloud_serialize_t
Definition cloud.h:399
void replicate(const std::size_t chunk_size=INT_MAX)
Definition cloud.h:878
recordlistT local_list_of_container_keys
Definition cloud.h:393
DistributionType cloud_replication_policy
cloud is a container: replication policy for the cloud container: distributed, node-replicated,...
Definition cloud.h:383
void print_size(World &universe)
Definition cloud.h:477
std::unique_ptr< BatchTransport > batch_transport_
constructed after batch_container so it is destroyed first, as WorldObject lifetimes require
Definition cloud.h:391
std::atomic< long > reading_time
Definition cloud.h:942
ProcessID batch_owner(const keyT record) const
the owner of a batch record; a pmap lookup, no communication
Definition cloud.h:1004
void clear_timings()
Definition cloud.h:684
recordlistT store_tuple(World &world, const std::tuple< Ts... > &input)
store a tuple in multiple records
Definition cloud.h:1242
void set_debug(bool value)
Definition cloud.h:425
void register_batch_owner(const keyT record, const ProcessID owner)
Register the owner of a batch record; local map insert, no communication.
Definition cloud.h:782
nlohmann::json gather_memory_statistics(World &universe) const
get size of the cloud container
Definition cloud.h:519
std::enable_if<!is_vector< T >::value, T >::type do_load(World &world, recordlistT &recordlist) const
Definition cloud.h:1179
T load(madness::World &world, const recordlistT recordlist) const
load a single object from the cloud, recordlist is kept unchanged
Definition cloud.h:738
madness::WorldContainer< keyT, valueT > batch_container
Definition cloud.h:389
std::shared_ptr< CloudOwnerPmap< keyT > > batch_pmap
Definition cloud.h:388
void cache(madness::World &world, const T &obj, const keyT &record) const
Definition cloud.h:982
void set_fence(bool value)
Definition cloud.h:436
std::atomic< long > cache_reads
Definition cloud.h:953
std::pair< const unsigned char *, std::size_t > try_get_local_batch_ptr(const keyT record) const
stable pointer and size of a local batch record, {nullptr,0} if this rank holds none
Definition cloud.h:1034
std::vector< Function< T, NDIM > > fetch_batch_p2p(madness::World &subworld, const keyT record, const bool cache_result=false) const
fetch a batch stored by store_batch; resolves without MPI when this rank owns it
Definition cloud.h:1084
friend std::ostream & operator<<(std::ostream &os, const StoragePolicy &sp)
Definition cloud.h:363
static void print_timings(const nlohmann::json timings)
Definition cloud.h:615
std::list< WorldObjectBase * > world_object_base_list
Definition cloud.h:396
static void print_memory_statistics(const nlohmann::json stats)
Definition cloud.h:641
DistributionType get_replication_policy() const
is the cloud container replicated: per rank, per node, or distributed
Definition cloud.h:452
Cloud(madness::World &universe)
Definition cloud.h:407
cacheT cached_objects
Definition cloud.h:392
void clear_cache(World &subworld)
Definition cloud.h:669
keyT store_batch(madness::World &world, const std::vector< Function< T, NDIM > > &batch, const ProcessID owner, const keyT record, const bool fence=true)
Store a batch of functions as one owner-pinned record.
Definition cloud.h:796
std::atomic< long > copy_time
Definition cloud.h:947
StoragePolicy get_storing_policy() const
storing policy refers to storing functions or pointers to functions
Definition cloud.h:473
std::vector< Function< T, NDIM > > deserialize_batch_p2p(madness::World &subworld, Future< batch_bytesT > fut, const keyT record, const bool cache_result=false) const
turn the bytes of a p2p transfer into the batch of functions
Definition cloud.h:1056
std::atomic< long > batch_deserialize_time
deserializing the bytes, microseconds
Definition cloud.h:945
void replicate_according_to_policy(const std::size_t chunk_size=INT_MAX)
Definition cloud.h:841
T load_from_cache(madness::World &world, const keyT &record) const
load an object from the cache, record is unchanged
Definition cloud.h:988
madness::meta::is_detected< member_cloud_serialize_t, T > has_cloud_serialize
Definition cloud.h:402
std::vector< unsigned char > valueT
Definition cloud.h:350
void set_replication_policy(const DistributionType value)
is the cloud container replicated: per rank, per node, or distributed
Definition cloud.h:445
void distribute_targets(const DistributionType dt=Distributed)
distribute/node/rank replicate the targets of all world objects stored in the cloud
Definition cloud.h:721
bool dofence
fences after load/store
Definition cloud.h:342
void print_timings(World &universe) const
backwards compatibility
Definition cloud.h:611
bool validate_replication_policy() const
Definition cloud.h:456
T allocator(World &world) const
Definition cloud.h:1105
std::atomic< long > writing_time
Definition cloud.h:950
void set_storing_policy(const StoragePolicy value)
storing policy refers to storing functions or pointers to functions
Definition cloud.h:468
madness::WorldContainer< keyT, valueT > container
Definition cloud.h:385
T forward_load(madness::World &world, recordlistT &recordlist) const
load a single object from the cloud, recordlist is consumed while loading elements
Definition cloud.h:760
StoragePolicy
Definition cloud.h:354
@ StoreFunctionPointer
Definition cloud.h:357
@ StoreFunction
Definition cloud.h:355
std::map< keyT, cached_objT > cacheT
Definition cloud.h:351
T consuming_load(madness::World &world, recordlistT &recordlist) const
similar to load, but will consume the recordlist
Definition cloud.h:751
std::atomic< long > batch_store_time
store_batch wall time, microseconds
Definition cloud.h:943
std::atomic< long > cache_stores
Definition cloud.h:954
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition funcimpl.h:970
A multiresolution adaptive numerical function.
Definition mra.h:144
A future is a possibly yet unevaluated value.
Definition future.h:370
T & get(bool dowork=true) &
Gets the value, waiting if necessary.
Definition future.h:571
A tensor is a multidimensional array.
Definition tensor.h:318
Makes a distributed container with specified attributes.
Definition worlddc.h:1231
bool find(accessor &acc, const keyT &key)
Write access to LOCAL value by key. Returns true if found, false otherwise (always false for remote).
Definition worlddc.h:1395
std::size_t size() const
Returns the number of local entries (no communication)
Definition worlddc.h:1543
implT::const_accessor const_accessor
Definition worlddc.h:1241
Interface to be provided by any process map.
Definition worlddc.h:125
virtual void print() const
Definition worlddc.h:142
void max(T *buf, size_t nelem)
Inplace global max while still processing AM & tasks.
Definition worldgop.h:902
void fence(bool debug=false)
Synchronizes all processes in communicator AND globally ensures no pending AM or tasks.
Definition worldgop.cc:176
void min(T *buf, size_t nelem)
Inplace global min while still processing AM & tasks.
Definition worldgop.h:896
void sum(T *buf, size_t nelem)
Inplace global sum while still processing AM & tasks.
Definition worldgop.h:890
void Bcast(T *buffer, int count, int root) const
MPI broadcast an array of count elements.
Definition worldmpi.h:416
Implements most parts of a globally addressable object (via unique ID).
Definition world_object.h:491
void process_pending()
To be called from derived constructor to process pending messages.
Definition world_object.h:787
detail::task_result_type< memfnT >::futureT send(ProcessID dest, memfnT memfn) const
Definition world_object.h:858
A parallel world class.
Definition world.h:134
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition world.h:344
static void await(SafeMPI::Request &request, bool dowork=true)
Wait for a MPI request to complete.
Definition world.h:558
WorldMpiInterface & mpi
MPI interface.
Definition world.h:213
ProcessID size() const
Returns the number of processes in this World (same as MPI_Comm_size()).
Definition world.h:354
unsigned long id() const
Definition world.h:324
WorldGopInterface & gop
Global operations.
Definition world.h:216
void set_dofence(bool dofence)
Set the flag for fencing around a read/write operation.
Definition parallel_archive.h:302
Definition parallel_dc_archive.h:14
long keyT
Definition parallel_dc_archive.h:16
An archive for storing local or parallel data wrapping a BinaryFstreamOutputArchive.
Definition parallel_archive.h:321
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
Tensor< typename Tensor< T >::scalar_type > arg(const Tensor< T > &t)
Return a new tensor holding the argument of each element of t (complex types only)
Definition tensor.h:2643
static const double v
Definition hatom_sf_dirac.cc:20
static double u(double r, double c)
Definition he.cc:20
#define MADNESS_CHECK(condition)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition madness_exception.h:182
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
#define MADNESS_CHECK_THROW(condition, msg)
Check a condition — even in a release build the condition is always evaluated so it can have side eff...
Definition madness_exception.h:207
Definition array_addons.h:50
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:13
void hash_range(hashT &seed, It first, It last)
Definition worldhash.h:280
double get_rss_usage_in_GB()
Definition ranks_and_hosts.cpp:18
static double cpu_time()
Returns the cpu time in seconds relative to an arbitrary origin.
Definition timers.h:128
DistributionType
some introspection of how data is distributed
Definition worlddc.h:84
@ NodeReplicated
even if there are several ranks per node
Definition worlddc.h:87
@ Distributed
no replication of the container, the container is distributed over the world
Definition worlddc.h:85
@ RankReplicated
replicate the container over all world ranks
Definition worlddc.h:86
std::vector< unsigned char > batch_bytesT
Definition cloud.h:204
void hash_combine(hashT &seed, const T &v)
Combine hash values.
Definition worldhash.h:260
static class madness::twoscale_cache_class cache[kmax+1]
DistributionType validate_distribution_type(const dcT &dc)
check distribution type of WorldContainer – global communication
Definition worlddc.h:347
void print(const T &t, const Ts &... ts)
Print items to std::cout (items separated by spaces) and terminate with a new line.
Definition print.h:227
NDIM const Function< R, NDIM > & g
Definition mra.h:2620
double wall_time()
Returns the wall time in seconds relative to an arbitrary origin.
Definition timers.cc:48
std::string type(const PairType &n)
Definition PNOParameters.h:18
vector< functionT > vecfuncT
Definition corepotential.cc:58
static bool print_timings
Definition SCF.cc:108
std::string name(const FuncType &type, const int ex=-1)
Definition ccpairfunction.h:28
madness::hashT hash_value(const std::array< T, N > &a)
Hash std::array with madness hash.
Definition array_addons.h:78
madness::archive::ContainerRecordOutputArchive::keyT batch_keyT
Definition cloud.h:201
Definition hatom_sf_dirac.cc:91
Definition test_ccpairfunction.cc:22
bool not_found
owner reported it does not hold the record
Definition cloud.h:279
ProcessID owner
Definition cloud.h:277
int tag
Definition cloud.h:278
std::vector< SafeMPI::Request > reqs
one per chunk, posted in on_reply
Definition cloud.h:281
Future< batch_bytesT > fut
set by finish_recv
Definition cloud.h:282
batch_bytesT buf
sized in on_reply
Definition cloud.h:280
functor to distribute/rank/node-replicate a function, passed in as a pointer to WorldObjectBase
Definition cloud.h:697
DistributionType dt
Definition cloud.h:698
int operator()(WorldObjectBase *wo) const
Definition cloud.h:700
DistributeFunctor(const DistributionType dt)
Definition cloud.h:699
std::atomic< long > & rtime
Definition cloud.h:970
World & world
Definition cloud.h:968
double wall0
Definition cloud.h:969
~cloudtimer()
Definition cloud.h:974
cloudtimer(World &world, std::atomic< long > &readtime)
Definition cloud.h:972
static keyT compute_record(const std::vector< T > &arg)
Definition cloud.h:130
keyT pop_front_and_return()
Definition cloud.h:89
static keyT compute_record(const Function< T, NDIM > &arg)
Definition cloud.h:115
Recordlist(const Recordlist &other)
Definition cloud.h:77
Recordlist(const keyT &key)
Definition cloud.h:75
static keyT compute_record(const std::shared_ptr< T > &arg)
Definition cloud.h:136
static keyT compute_record(const T &arg)
Definition cloud.h:139
std::size_t size() const
Definition cloud.h:95
madness::meta::is_detected< member_id_t, T > has_member_id
Definition cloud.h:105
decltype(std::declval< T >().id()) member_id_t
Definition cloud.h:102
friend std::ostream & operator<<(std::ostream &os, const Recordlist &arg)
Definition cloud.h:153
Recordlist & operator+=(const Recordlist &list2)
Definition cloud.h:79
static keyT compute_record(const WorldContainer< keyQ, valueT > &arg)
Definition cloud.h:121
decltype(std::declval< T >().hash()) member_hash_t
Definition cloud.h:109
static keyT compute_record(const std::shared_ptr< WorldContainer< keyQ, valueT > > &arg)
Definition cloud.h:124
std::list< keyT > list
Definition cloud.h:71
Recordlist & operator+=(const keyT &key)
Definition cloud.h:84
static keyT compute_record(const FunctionImpl< T, NDIM > *arg)
Definition cloud.h:118
static keyT compute_record(const std::shared_ptr< madness::FunctionImpl< T, NDIM > > &arg)
Definition cloud.h:127
static keyT compute_record(const Tensor< T > &arg)
Definition cloud.h:133
madness::meta::is_detected< member_hash_t, T > has_member_hash
Definition cloud.h:112
Recordlist()
Definition cloud.h:73
Base class for WorldObject.
Definition world_object.h:345
World & get_world() const
Definition world_object.h:446
class to temporarily redirect output to cout
Definition print.h:300
static const char * value()
Definition cloud.h:44
static const char * value()
Definition cloud.h:46
static const char * value()
Definition cloud.h:48
static const char * value()
Definition cloud.h:50
static const char * value()
Definition cloud.h:52
static const char * value()
Definition cloud.h:54
static const char * value()
Definition cloud.h:57
static const char * value()
Definition cloud.h:59
static const char * value()
Definition cloud.h:61
static const char * value()
Definition cloud.h:63
static const char * value()
Definition cloud.h:65
static const char * value()
Definition cloud.h:67
A utility to get the name of a type as a string from chatGPT.
Definition cloud.h:39
static const char * value()
Definition cloud.h:40
#define MPI_BYTE
Definition stubmpi.h:77
double source(const coordT &r)
Definition testperiodic.cc:48
static madness::WorldMemInfo stats
Definition worldmem.cc:64
int ProcessID
Used to clearly identify process number/rank.
Definition worldtypes.h:43
FLOAT target(const FLOAT &x)
Definition y.cc:295