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);
351 using valueT = std::vector<unsigned char>;
352 typedef std::map<keyT, cached_objT>
cacheT;
368 default: os <<
"UnknownStoragePolicy";
break;
374 std::ostringstream os;
399 template <
typename T>
402 template <
typename T>
419 print(
"You need to call clear_cache(subworld) before destroying the cloud");
420 print(
"\n------------------------------\n");
421 std::string msg=
"deferred destruction of cloud with non-empty cache";
422 std::cerr << msg << std::endl;
433 if (universe.
rank() != 0)
return;
460 std::cout <<
"Cloud::validate_distribution(): distribution type mismatch, container is " << disttype
480 double byte2gbyte=1.0/(1024*1024*1024);
481 double global_memsize=
stats[
"memory_global_GB"].template get<double>();
482 double max_record_size=
stats[
"max_record_size"].template get<double>();
483 double min_memsize=
stats[
"memory_min_GB"].template get<double>();
484 double max_memsize=
stats[
"memory_max_GB"].template get<double>();
485 double global_size=
stats[
"container_size_global"].template get<double>();
487 if (universe.
rank()==0) {
488 print(
"Cloud memory:");
490 print(
"size of cloud (total)");
491 print(
" number of records: ",global_size);
492 print(
" memory in GBytes: ",global_memsize);
493 print(
"size of cloud (average per node)");
494 print(
" number of records: ",
double(global_size)/universe.
size());
495 print(
" memory in GBytes: ",global_memsize/universe.
size());
496 print(
"min/max of node");
497 print(
" memory in GBytes: ",min_memsize,max_memsize);
498 print(
" max record size in GBytes:",max_record_size*byte2gbyte);
522 std::size_t memsize=0;
523 std::size_t max_record_size=0;
525 memsize+=item.second.size();
526 max_record_size=std::max(max_record_size,item.second.size());
530 std::size_t batch_memsize=0;
532 batch_memsize+=item.second.size();
533 max_record_size=std::max(max_record_size,item.second.size());
535 memsize+=batch_memsize;
536 std::size_t global_memsize=memsize;
537 std::size_t max_memsize=memsize;
538 std::size_t min_memsize=memsize;
541 universe.
gop.
sum(global_memsize);
542 universe.
gop.
max(max_memsize);
543 universe.
gop.
max(max_record_size);
544 universe.
gop.
min(min_memsize);
547 double byte2gbyte=1.0/(1024*1024*1024);
550 double uchar2gbyte=byte2gbyte*
sizeof(
unsigned char);
554 auto global_size=local_size;
555 universe.
gop.
sum(global_size);
557 universe.
gop.
sum(batch_global_size);
558 std::size_t batch_global_memsize=batch_memsize;
559 universe.
gop.
sum(batch_global_memsize);
561 j[
"container_size_global"] = global_size;
562 j[
"batch_container_size_global"] = batch_global_size;
563 j[
"batch_memory_global_GB"] = batch_global_memsize*uchar2gbyte;
564 j[
"memory_global_GB"] = global_memsize*uchar2gbyte;
565 j[
"memory_min_GB"] = min_memsize*uchar2gbyte;
566 j[
"memory_max_GB"] = max_memsize*uchar2gbyte;
567 j[
"memory_rss_GB_max"] = rss;
568 j[
"memory_rss_GB_av"] = rss_av/universe.
size();
569 j[
"max_record_size"] = max_record_size;
577 double ctime_max = double(
copy_time)*1.e-6;
578 double ctime_acc = double(
copy_time)*1.e-6;
579 double ctime_av = double(
copy_time)*1.e-6;
583 universe.
gop.
max(rtime_max);
584 universe.
gop.
sum(rtime_acc);
585 rtime_av = rtime_acc/universe.
size();
586 universe.
gop.
max(ctime_max);
587 universe.
gop.
sum(ctime_acc);
588 ctime_av = ctime_acc/universe.
size();
595 universe.
gop.
sum(cstores);
597 j[
"reading_time_max_s"] = rtime_max;
598 j[
"reading_time_acc_s"] = rtime_acc;
599 j[
"reading_time_av_s"] = rtime_av;
600 j[
"copy_time_max_s"] = ctime_max;
601 j[
"copy_time_acc_s"] = ctime_acc;
602 j[
"copy_time_av_s"] = ctime_av;
603 j[
"writing_time_s"] = wtime;
604 j[
"replication_time_s"] = ptime;
605 j[
"target_replication_time_s"] = tptime;
606 j[
"cache_reads"] = creads;
607 j[
"cache_stores"] = cstores;
617 double rtime_max=timings[
"reading_time_max_s"].template get<double>();
618 double rtime_av=timings[
"reading_time_av_s"].template get<double>();
619 double rtime_acc=timings[
"reading_time_acc_s"].template get<double>();
623 double wtime=timings[
"writing_time_s"].template get<double>();
624 double ptime=timings[
"replication_time_s"].template get<double>();
625 double tptime=timings[
"target_replication_time_s"].template get<double>();
626 long creads=timings[
"cache_reads"].template get<long>();
627 long cstores=timings[
"cache_stores"].template get<long>();
629 auto precision = std::cout.precision();
630 std::cout << std::fixed << std::setprecision(1);
631 print(
"cloud storing wall time ", wtime);
632 print(
"cloud replication wall time ", ptime);
633 print(
"target replication wall time ", tptime);
634 print(
"cloud max reading time (all procs) ", rtime_max, std::defaultfloat);
635 print(
"cloud average reading cpu time (all procs) ", rtime_av, std::defaultfloat);
636 print(
"cloud accumulated reading cpu time (all procs) ", rtime_acc, std::defaultfloat);
637 std::cout << std::setprecision(precision) << std::scientific;
638 print(
"cloud cache stores ",
long(cstores));
639 print(
"cloud cache loads ",
long(creads));
643 double byte2gbyte=1.0/(1024*1024*1024);
644 double global_memsize=
stats[
"memory_global_GB"].template get<double>();
645 double max_record_size=
stats[
"max_record_size"].template get<double>();
646 double min_memsize=
stats[
"memory_min_GB"].template get<double>();
647 double max_memsize=
stats[
"memory_max_GB"].template get<double>();
648 double global_size=
stats[
"container_size_global"].template get<double>();
650 print(
"Cloud memory:");
651 print(
" size of cloud (total)");
652 print(
" number of records: ",global_size);
653 print(
" memory in GBytes: ",global_memsize);
657 print(
" min/max of node");
658 print(
" memory in GBytes: ",min_memsize,max_memsize);
659 print(
" max record size in GBytes:",max_record_size*byte2gbyte);
662 const double b_size =
stats.value(
"batch_container_size_global", 0.0);
664 print(
" owner-pinned batches");
665 print(
" number of records: ", b_size);
666 print(
" memory in GBytes: ",
stats.value(
"batch_memory_global_GB", 0.0));
697 template<
typename T, std::
size_t NDIM>
706 fimpl->replicate(
false);
709 fimpl->replicate_on_hosts(
true);
711 fimpl->undo_replicate(
false);
727 loop_types<DistributeFunctor, double, float, double_complex, float_complex>(std::tuple<DistributionType>(dt),wo);
744 return forward_load<T>(world, rlist);
756 return forward_load<T>(world, recordlist);
767 return load_tuple<T>(world, recordlist);
770 target.cloud_load(world, *
this, recordlist);
773 return do_load<T>(world, recordlist);
796 template<
typename T, std::
size_t NDIM>
798 const ProcessID owner,
const keyT record,
const bool fence =
true) {
800 print(
"Cloud contents are replicated and read-only!");
809 std::size_t fsize = batch.size();
811 for (std::size_t i = 0; i < fsize; ++i) par & batch[i];
821 print(
"Cloud contents are replicated and read-only!");
834 recordlist+=
source.cloud_store(world,*
this);
872 if (
debug and (world.
rank()==0))
print(
"replication_per_node ended after ",cpu1-cpu0,
" seconds");
874 MADNESS_EXCEPTION(
"cloud replication_per_node failed, presumably because some data is larger than 2GB",1);
890 std::list<keyT> keylist;
892 keylist.push_back(it->first);
896 if (rank == world.
rank()) {
897 std::size_t keylistsize = keylist.size();
900 for (
auto key : keylist) {
904 auto data = acc->second;
905 std::size_t sz=
data.size();
911 for (std::size_t start=0; start<sz; start+=chunk_size) {
912 std::size_t remainder = std::min(sz - start, chunk_size);
919 std::size_t keylistsize = 0;
921 for (
size_t i=0; i<keylistsize; i++) {
928 for (std::size_t start=0; start<sz; start+=chunk_size) {
929 std::size_t remainder=std::min(sz-start,chunk_size);
939 if (
debug and (world.
rank()==0))
print(
"replication ended after ",cpu1-cpu0,
" seconds");
958 template<
typename>
struct is_tuple : std::false_type { };
959 template<
typename ...T>
struct is_tuple<
std::tuple<T...>> : std::true_type { };
961 template<
typename Q>
struct is_vector : std::false_type { };
962 template<
typename Q>
struct is_vector<
std::vector<Q>> : std::true_type { };
993 if (
auto obj = std::any_cast<T>(&
cached_objects.find(record)->second))
return *obj;
1039 return {acc->second.data(), acc->second.
size()};
1040 return {
nullptr, 0};
1057 template<
typename T, std::
size_t NDIM>
1060 const bool cache_result =
false)
const {
1061 typedef std::vector<Function<T, NDIM>>
vecfuncT;
1062 if (
is_cached(record))
return load_from_cache<vecfuncT>(subworld, record);
1069 "deserialize_batch_p2p: the owner does not hold this batch record");
1074 std::size_t fsize = 0;
1076 batch.resize(fsize);
1077 for (std::size_t i = 0; i < fsize; ++i) par & batch[i];
1085 template<
typename T, std::
size_t NDIM>
1087 const keyT record,
const bool cache_result =
false)
const {
1088 typedef std::vector<Function<T, NDIM>>
vecfuncT;
1089 if (
is_cached(record))
return load_from_cache<vecfuncT>(subworld, record);
1091 record, cache_result);
1106 template<
typename T>
1115 template<
typename T>
1120 if (is_already_present) std::cout <<
"skipping ";
1123 <<
" to record " << record << std::endl;
1125 std::cout <<
"storing object of " <<
type_name<T>::value() <<
" to record " << record << std::endl;
1128 if (
source.is_compressed() and T::dimT>3)
print(
"WARNING: storing compressed hi-dim `function");
1132 if (is_already_present) {
1164 template<
typename T>
1165 typename std::enable_if<is_vector<T>::value, T>
::type
1167 std::size_t sz = do_load<std::size_t>(world, recordlist);
1169 for (std::size_t i = 0; i < sz; ++i) {
1170 target[i] = do_load<typename T::value_type>(world, recordlist);
1179 template<
typename T>
1180 typename std::enable_if<!is_vector<T>::value, T>
::type
1182 keyT record = recordlist.pop_front_and_return();
1185 if (
is_cached(record))
return load_from_cache<T>(world, record);
1197 std::shared_ptr<implT> impl;
1203 print(
"failed to load function pointer from cloud, maybe the target is out of scope?");
1204 print(
"record:", record,
"world:", world.
id());
1233 template<
typename T>
1240 if (
debug and world.
rank()==0) std::cout <<
"done with vector storing; container size "
1246 template<
typename... Ts>
1249 auto storeaway = [&](
const auto &
arg) {
1252 auto l = [&](Ts
const &...
arg) {
1253 ((storeaway(
arg)), ...);
1255 std::apply(l, input);
1263 template<
typename T>
1265 if (
debug) std::cout <<
"loading tuple of type " <<
typeid(T).
name() <<
" to world " << world.
id() << std::endl;
1267 std::apply([&](
auto &&... args) {
1268 ((args =
forward_load<
typename std::remove_reference<
decltype(args)>
::type>(world, recordlist)), ...);
1279 if (owner ==
u.rank()) {
1285 auto p = std::make_shared<PendingRecv>();
1301 if (it->Test()) it =
sends_.erase(it);
1310 if (ptr_size.first ==
nullptr) {
1317 const std::size_t n = ptr_size.second;
1327 for (std::size_t off = 0; off < n; off += chunk) {
1328 const std::size_t len = std::min(chunk, n - off);
1329 sends_.push_back(
u.mpi.Isend(ptr_size.first + off,
int(len),
MPI_BYTE, requester, tag));
1339 std::shared_ptr<PendingRecv>
p;
1352 p->not_found =
true;
1356 p->buf.resize(size);
1359 for (std::size_t off = 0; off < size; off += chunk) {
1360 const std::size_t len = std::min(chunk, size - off);
1361 p->reqs.push_back(
u.mpi.Irecv(
p->buf.data() + off,
int(len),
MPI_BYTE,
p->owner, tag));
1367 std::shared_ptr<PendingRecv>
p;
1377 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:1306
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:1366
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:1298
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:1337
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:1276
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:999
void print_batch_owner_map(World &universe, const std::string &tag="") const
Definition cloud.h:432
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:1046
bool use_cache
Definition cloud.h:345
void clear()
Definition cloud.h:676
void replicate_per_node(const std::size_t chunk_size=INT_MAX)
Definition cloud.h:859
bool is_in_container(const keyT &key) const
checks if a (universe) container record is used
Definition cloud.h:1100
bool force_load_from_cache
forces load from cache (mainly for debugging)
Definition cloud.h:344
bool debug
prints debug output
Definition cloud.h:340
std::atomic< long > writing_time1
Definition cloud.h:953
nlohmann::json get_statistics(World &world) const
return a json object with the cloud settings and statistics
Definition cloud.h:504
std::enable_if< is_vector< T >::value, T >::type do_load(World &world, recordlistT &recordlist) const
Definition cloud.h:1166
std::atomic< long > batch_find_time
waiting on the p2p transfer, microseconds
Definition cloud.h:946
recordlistT store_other(madness::World &world, const std::vector< T > &source)
Definition cloud.h:1234
std::any cached_objT
Definition cloud.h:349
recordlistT store(madness::World &world, const T &source)
Definition cloud.h:819
T load_tuple(madness::World &world, recordlistT &recordlist) const
Definition cloud.h:1264
std::is_base_of< archive::ParallelSerializableObject, T > is_parallel_serializable_object
Definition cloud.h:964
~Cloud()
Definition cloud.h:416
madness::archive::ContainerRecordOutputArchive::keyT keyT
Definition cloud.h:350
std::atomic< long > replication_time
Definition cloud.h:954
Recordlist< keyT > recordlistT
Definition cloud.h:353
StoragePolicy storage_policy
are the functions (WorldObjects) stored in the cloud or only pointers to them
Definition cloud.h:381
std::is_constructible< T, World & > is_world_constructible
Definition cloud.h:966
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:1024
std::atomic< long > target_replication_time
Definition cloud.h:950
nlohmann::json gather_timings(World &universe) const
Definition cloud.h:573
friend std::string to_string(const StoragePolicy sp)
Definition cloud.h:373
recordlistT store_other(madness::World &world, const T &source)
Definition cloud.h:1116
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:441
decltype(std::declval< T >().cloud_store(std::declval< World & >(), std::declval< Cloud & >())) member_cloud_serialize_t
Definition cloud.h:400
void replicate(const std::size_t chunk_size=INT_MAX)
Definition cloud.h:879
recordlistT local_list_of_container_keys
Definition cloud.h:394
DistributionType cloud_replication_policy
cloud is a container: replication policy for the cloud container: distributed, node-replicated,...
Definition cloud.h:384
void print_size(World &universe)
Definition cloud.h:478
std::unique_ptr< BatchTransport > batch_transport_
constructed after batch_container so it is destroyed first, as WorldObject lifetimes require
Definition cloud.h:392
std::atomic< long > reading_time
Definition cloud.h:944
ProcessID batch_owner(const keyT record) const
the owner of a batch record; a pmap lookup, no communication
Definition cloud.h:1006
void clear_timings()
Definition cloud.h:685
recordlistT store_tuple(World &world, const std::tuple< Ts... > &input)
store a tuple in multiple records
Definition cloud.h:1247
void set_debug(bool value)
Definition cloud.h:426
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:783
nlohmann::json gather_memory_statistics(World &universe) const
get size of the cloud container
Definition cloud.h:520
std::enable_if<!is_vector< T >::value, T >::type do_load(World &world, recordlistT &recordlist) const
Definition cloud.h:1181
T load(madness::World &world, const recordlistT recordlist) const
load a single object from the cloud, recordlist is kept unchanged
Definition cloud.h:739
madness::WorldContainer< keyT, valueT > batch_container
Definition cloud.h:390
std::shared_ptr< CloudOwnerPmap< keyT > > batch_pmap
Definition cloud.h:389
void cache(madness::World &world, const T &obj, const keyT &record) const
Definition cloud.h:984
void set_fence(bool value)
Definition cloud.h:437
std::atomic< long > cache_reads
Definition cloud.h:955
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:1036
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:1086
friend std::ostream & operator<<(std::ostream &os, const StoragePolicy &sp)
Definition cloud.h:364
static void print_timings(const nlohmann::json timings)
Definition cloud.h:616
bool is_rank_replicated
if every rank holds its own copy of the container (see replicate())
Definition cloud.h:342
std::list< WorldObjectBase * > world_object_base_list
Definition cloud.h:397
static void print_memory_statistics(const nlohmann::json stats)
Definition cloud.h:642
DistributionType get_replication_policy() const
is the cloud container replicated: per rank, per node, or distributed
Definition cloud.h:453
Cloud(madness::World &universe)
Definition cloud.h:408
cacheT cached_objects
Definition cloud.h:393
void clear_cache(World &subworld)
Definition cloud.h:670
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:797
std::atomic< long > copy_time
Definition cloud.h:949
StoragePolicy get_storing_policy() const
storing policy refers to storing functions or pointers to functions
Definition cloud.h:474
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:1058
std::atomic< long > batch_deserialize_time
deserializing the bytes, microseconds
Definition cloud.h:947
void replicate_according_to_policy(const std::size_t chunk_size=INT_MAX)
Definition cloud.h:842
T load_from_cache(madness::World &world, const keyT &record) const
load an object from the cache, record is unchanged
Definition cloud.h:990
madness::meta::is_detected< member_cloud_serialize_t, T > has_cloud_serialize
Definition cloud.h:403
std::vector< unsigned char > valueT
Definition cloud.h:351
void set_replication_policy(const DistributionType value)
is the cloud container replicated: per rank, per node, or distributed
Definition cloud.h:446
void distribute_targets(const DistributionType dt=Distributed)
distribute/node/rank replicate the targets of all world objects stored in the cloud
Definition cloud.h:722
bool dofence
fences after load/store
Definition cloud.h:343
void print_timings(World &universe) const
backwards compatibility
Definition cloud.h:612
bool validate_replication_policy() const
Definition cloud.h:457
T allocator(World &world) const
Definition cloud.h:1107
std::atomic< long > writing_time
Definition cloud.h:952
void set_storing_policy(const StoragePolicy value)
storing policy refers to storing functions or pointers to functions
Definition cloud.h:469
madness::WorldContainer< keyT, valueT > container
Definition cloud.h:386
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:761
StoragePolicy
Definition cloud.h:355
@ StoreFunctionPointer
Definition cloud.h:358
@ StoreFunction
Definition cloud.h:356
std::map< keyT, cached_objT > cacheT
Definition cloud.h:352
T consuming_load(madness::World &world, recordlistT &recordlist) const
similar to load, but will consume the recordlist
Definition cloud.h:752
std::atomic< long > batch_store_time
store_batch wall time, microseconds
Definition cloud.h:945
std::atomic< long > cache_stores
Definition cloud.h:956
FunctionImpl holds all Function state to facilitate shallow copy semantics.
Definition funcimpl.h:982
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:1299
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:1466
std::size_t size() const
Returns the number of local entries (no communication)
Definition worlddc.h:1614
implT::const_accessor const_accessor
Definition worlddc.h:1309
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:177
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:2757
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 DFConvergence.h:9
void hash_range(hashT &seed, It first, It last)
Definition worldhash.h:281
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:261
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:2668
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:698
DistributionType dt
Definition cloud.h:699
int operator()(WorldObjectBase *wo) const
Definition cloud.h:701
DistributeFunctor(const DistributionType dt)
Definition cloud.h:700
std::atomic< long > & rtime
Definition cloud.h:972
World & world
Definition cloud.h:970
double wall0
Definition cloud.h:971
~cloudtimer()
Definition cloud.h:976
cloudtimer(World &world, std::atomic< long > &readtime)
Definition cloud.h:974
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