38#ifndef MADNESS_WORLD_WORLD_OBJECT_H__INCLUDED
39#define MADNESS_WORLD_WORLD_OBJECT_H__INCLUDED
54 template <
typename>
class WorldObject;
93 template <
typename memfunT>
129 template <
typename Archive>
139 template <
typename memfunT>
177 template <
typename Archive>
211 template <
typename objT,
typename memfnT,
typename Enabler =
void>
214 typedef typename std::conditional<memfunc_traits<memfnT>::constness,
250 return make_task_fn(
static_cast<const objT*
>(obj), memfn);
265#ifndef MADNESS_DISABLE_SHARED_FROM_THIS
275 template <
typename objT,
typename memfnT>
277 typename
std::enable_if< std::is_base_of<std::enable_shared_from_this<objT>, objT>::value >
::type>
280 typedef typename std::conditional<memfunc_traits<memfnT>::constness,
284 typedef typename std::conditional<memfunc_traits<memfnT>::constness,
298 return wrapperT(
const_cast<ptrT>(obj)->shared_from_this(), memfn);
309 return wrapperT(
const_cast<ptrT>(obj)->shared_from_this(), memfn);
320 return make_task_fn(
static_cast<const objT*
>(obj), memfn);
385 template <
typename DerivedT>
408 "WorldObjectBase::~WorldObjectBase() the world of this object has already been destroyed");
417 "WorldObjectBase::~WorldObjectBase() cached world differs from world in object ID");
490 template <
class Derived>
540 std::optional<Derived *> opt_obj =
541 arg.get_world()->template ptr_from_id<Derived>(
id);
545 obj =
static_cast<objT *
>(*opt_obj);
550 if (obj->ready ||
arg.is_pending())
560 std::optional<Derived *> opt_obj =
561 arg.get_world()->template ptr_from_id<Derived>(
id);
565 obj =
static_cast<objT *
>(*opt_obj);
571 if (obj->ready ||
arg.is_pending())
574 const_cast<AmArg &
>(
arg).set_pending();
597 template <
typename memfnT,
typename arg1T,
typename arg2T,
typename arg3T,
typename arg4T,
598 typename arg5T,
typename arg6T,
typename arg7T,
typename arg8T,
typename arg9T>
603 am_handlerT ptr = handler<memfnT,arg1T,arg2T,arg3T,arg4T,arg5T,arg6T,arg7T,arg8T,arg9T>;
618 arg & info & arg1 & arg2 & arg3 & arg4 & arg5 & arg6 & arg7 & arg8 & arg9;
622 arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
632 template <
typename taskT>
635 typename taskT::functionT::memfn_type> task_helper;
640 am_handlerT ptr = & objT::template spawn_remote_task_handler<taskT>;
648 taskT*
task =
new taskT(
typename taskT::futureT(info.
ref),
649 task_helper::make_task_fn(obj, info.
memfun()), info.
attr, input_arch);
652 arg.get_world()->taskq.add(
task);
663 template <
typename T>
676 template <
typename T>
677 static inline const T&
am_arg(
const T& t) {
707 template <
typename memfnT,
typename a1T,
typename a2T,
typename a3T,
708 typename a4T,
typename a5T,
typename a6T,
typename a7T,
709 typename a8T,
typename a9T>
712 const a3T& a3,
const a4T& a4,
const a5T& a5,
const a6T& a6,
713 const a7T& a7,
const a8T& a8,
const a9T& a9)
const
719 a1,
a2, a3, a4, a5, a6, a7, a8, a9);
723 world.
am.
send(dest, & objT::template handler<memfnT, a1T, a2T, a3T, a4T, a5T, a6T, a7T, a8T, a9T>,
758 template <
typename taskT,
typename memfnT,
typename a1T,
typename a2T,
typename a3T,
759 typename a4T,
typename a5T,
typename a6T,
typename a7T,
760 typename a8T,
typename a9T>
761 typename taskT::futureT
763 const a2T&
a2,
const a3T& a3,
const a4T& a4,
const a5T& a5,
764 const a6T& a6,
const a7T& a7,
const a8T& a8,
const a9T& a9,
767 typename taskT::futureT result;
771 world.
am.
send(dest, & objT::template spawn_remote_task_handler<taskT>,
772 new_am_arg(info,
a1,
a2, a3, a4, a5, a6, a7, a8, a9),
RMI::ATTR_UNORDERED);
800 for (pendingT::iterator it=nv.begin(); it!=nv.end();) {
802 if (
p.id == this->id()) {
810 if (tmp.size() == 0)
ready=
true;
816 tmp.front().invokehandler();
856 template <
typename memfnT>
874 template <
typename memfnT,
typename a1T>
894 template <
typename memfnT,
typename a1T,
typename a2T>
916 template <
typename memfnT,
typename a1T,
typename a2T,
typename a3T>
942 template <
typename memfnT,
typename a1T,
typename a2T,
typename a3T,
946 const a3T& a3,
const a4T& a4)
const
971 template <
typename memfnT,
typename a1T,
typename a2T,
typename a3T,
972 typename a4T,
typename a5T>
975 const a3T& a3,
const a4T& a4,
const a5T& a5)
const
1002 template <
typename memfnT,
typename a1T,
typename a2T,
typename a3T,
1003 typename a4T,
typename a5T,
typename a6T>
1006 const a3T& a3,
const a4T& a4,
const a5T& a5,
const a6T& a6)
const
1035 template <
typename memfnT,
typename a1T,
typename a2T,
typename a3T,
1036 typename a4T,
typename a5T,
typename a6T,
typename a7T>
1039 const a3T& a3,
const a4T& a4,
const a5T& a5,
const a6T& a6,
1040 const a7T& a7)
const
1071 template <
typename memfnT,
typename a1T,
typename a2T,
typename a3T,
1072 typename a4T,
typename a5T,
typename a6T,
typename a7T,
typename a8T>
1075 const a3T& a3,
const a4T& a4,
const a5T& a5,
const a6T& a6,
1076 const a7T& a7,
const a8T& a8)
const
1109 template <
typename memfnT,
typename a1T,
typename a2T,
typename a3T,
1110 typename a4T,
typename a5T,
typename a6T,
typename a7T,
typename a8T,
1114 const a3T& a3,
const a4T& a4,
const a5T& a5,
const a6T& a6,
1115 const a7T& a7,
const a8T& a8,
const a9T& a9)
const
1130 template <
typename memfnT>
1136 return this->
get_world().
taskq.
add(task_helper::make_task_fn(
this, memfn), attr);
1153 template <
typename memfnT,
typename a1T>
1159 typedef TaskFn<
typename task_helper::wrapperT,
1182 template <
typename memfnT,
typename a1T,
typename a2T>
1188 typedef TaskFn<
typename task_helper::wrapperT,
1214 template <
typename memfnT,
typename a1T,
typename a2T,
typename a3T>
1220 typedef TaskFn<
typename task_helper::wrapperT,
1249 template <
typename memfnT,
typename a1T,
typename a2T,
typename a3T,
1256 typedef TaskFn<
typename task_helper::wrapperT,
1263 a1,
a2, a3, a4, attr);
1288 template <
typename memfnT,
typename a1T,
typename a2T,
typename a3T,
1289 typename a4T,
typename a5T>
1292 const a3T& a3,
const a4T& a4,
const a5T& a5,
1296 typedef TaskFn<
typename task_helper::wrapperT,
1304 a1,
a2, a3, a4, a5, attr);
1331 template <
typename memfnT,
typename a1T,
typename a2T,
typename a3T,
1332 typename a4T,
typename a5T,
typename a6T>
1335 const a3T& a3,
const a4T& a4,
const a5T& a5,
const a6T& a6,
1339 typedef TaskFn<
typename task_helper::wrapperT,
1348 a1,
a2, a3, a4, a5, a6, attr);
1378 template <
typename memfnT,
typename a1T,
typename a2T,
typename a3T,
1379 typename a4T,
typename a5T,
typename a6T,
typename a7T>
1382 const a3T& a3,
const a4T& a4,
const a5T& a5,
const a6T& a6,
1386 typedef TaskFn<
typename task_helper::wrapperT,
1396 a1,
a2, a3, a4, a5, a6, a7, attr);
1427 template <
typename memfnT,
typename a1T,
typename a2T,
typename a3T,
1428 typename a4T,
typename a5T,
typename a6T,
typename a7T,
typename a8T>
1431 const a3T& a3,
const a4T& a4,
const a5T& a5,
const a6T& a6,
1432 const a7T& a7,
const a8T& a8,
1436 typedef TaskFn<
typename task_helper::wrapperT,
1447 a1,
a2, a3, a4, a5, a6, a7, a8, attr);
1483 template <
typename memfnT,
typename a1T,
typename a2T,
typename a3T,
1484 typename a4T,
typename a5T,
typename a6T,
typename a7T,
typename a8T,
1488 const a3T& a3,
const a4T& a4,
const a5T& a5,
const a6T& a6,
1489 const a7T& a7,
const a8T& a8,
const a9T& a9,
1493 typedef TaskFn<
typename task_helper::wrapperT,
1505 a1,
a2, a3, a4, a5, a6, a7, a8, a9, attr);
1526#ifdef MADNESS_WORLDOBJECT_FUTURE_TRACE
1538 template <
typename T>
1539 std::enable_if_t<!std::is_same_v<T,void>,
void> trace(
Future<T>&
f)
const;
1543 static bool trace_futures(
const uniqueidT &
id);
1546 bool trace_futures()
const {
1547 return trace_futures(this->
id());
1552 static std::size_t trace_status_nfuture_registered(
const uniqueidT&
id);
1555 std::size_t trace_status_nfuture_registered()
const {
1556 return trace_status_nfuture_registered(this->
id());
1561 static std::size_t trace_status_nfuture_assigned(
const uniqueidT&
id);
1564 std::size_t trace_status_nfuture_assigned()
const {
1565 return trace_status_nfuture_assigned(this->
id());
1570#ifdef MADNESS_WORLDOBJECT_FUTURE_TRACE
1572 template <
typename Derived>
struct WorldObjectFutureTracer {
1574 constexpr static std::size_t world_id =
1575#ifndef MADNESS_WORLDOBJECT_FUTURE_TRACE_WORLD_ID
1578 MADNESS_WORLDOBJECT_FUTURE_TRACE_WORLD_ID
1582 constexpr static std::size_t max_object_id =
1583#ifndef MADNESS_WORLDOBJECT_FUTURE_TRACE_MAX_NOBJECTS
1586 MADNESS_WORLDOBJECT_FUTURE_TRACE_MAX_NOBJECTS
1590 static constexpr bool do_trace(
const uniqueidT&
id) {
1591 return id.get_world_id() == world_id &&
1592 id.get_obj_id() < max_object_id;
1595 static std::array<std::atomic<std::size_t>, max_object_id>
1597 static std::array<std::atomic<std::size_t>, max_object_id>
1600 struct Initializer {
1602 for (
auto &&
v : nfuture_registered) {
1605 for (
auto &&
v : nfuture_assigned) {
1610 static Initializer initializer;
1612 struct FutureTracer :
public CallbackInterface {
1613 FutureTracer(
const uniqueidT &
id) : id_(id) {
1614 if (do_trace(id_)) {
1615 nfuture_registered[id_.get_obj_id()]++;
1620 FutureTracer(
const FutureTracer &) =
delete;
1621 FutureTracer &operator=(
const FutureTracer &) =
delete;
1623 virtual ~FutureTracer() {}
1629 void notify()
override {
1630 if (do_trace(id_)) {
1631 nfuture_assigned[id_.get_obj_id()]++;
1641 template <
typename Derived>
1642 typename WorldObjectFutureTracer<Derived>::Initializer
1643 WorldObjectFutureTracer<Derived>::initializer;
1644 template <
typename Derived>
1645 std::array<std::atomic<std::size_t>, WorldObjectFutureTracer<Derived>::max_object_id>
1646 WorldObjectFutureTracer<Derived>::nfuture_registered;
1647 template <
typename Derived>
1648 std::array<std::atomic<std::size_t>, WorldObjectFutureTracer<Derived>::max_object_id>
1649 WorldObjectFutureTracer<Derived>::nfuture_assigned;
1652 template <
typename Derived>
1653 template <
typename T>
1654 std::enable_if_t<!std::is_same_v<T,void>,
void> WorldObject<Derived>::trace(Future<T>&
f)
const {
1655 f.register_callback(
1656 new typename detail::WorldObjectFutureTracer<Derived>::FutureTracer(
1660 template <
typename Derived>
1661 bool WorldObject<Derived>::trace_futures(
const uniqueidT&
id) {
1662 return detail::WorldObjectFutureTracer<Derived>::do_trace(
id);
1665 template <
typename Derived>
1666 std::size_t WorldObject<Derived>::trace_status_nfuture_registered(
const uniqueidT&
id) {
1667 if (detail::WorldObjectFutureTracer<
1668 Derived>::do_trace(
id)) {
1669 return detail::WorldObjectFutureTracer<
1670 Derived>::nfuture_registered[
id.get_obj_id()];
1675 template <
typename Derived>
1676 std::size_t WorldObject<Derived>::trace_status_nfuture_assigned(
const uniqueidT&
id) {
1677 if (detail::WorldObjectFutureTracer<
1678 Derived>::do_trace(
id)) {
1679 return detail::WorldObjectFutureTracer<
1680 Derived>::nfuture_assigned[
id.get_obj_id()];
1693 template <
class Derived>
1706 if (!ptr_opt)
MADNESS_EXCEPTION(
"WorldObj: remote operation attempting to use a locally uninitialized object",0);
1708 if (!ptr)
MADNESS_EXCEPTION(
"WorldObj: remote operation attempting to use a locally deregistered object",0);
1716 template <
class Derived>
1732 template <
class Derived>
1745 if (!ptr_opt)
MADNESS_EXCEPTION(
"WorldObj: remote operation attempting to use a locally uninitialized object",0);
1747 if (!ptr)
MADNESS_EXCEPTION(
"WorldObj: remote operation attempting to use a locally deregistered object",0);
1755 template <
class Derived>
double w(double t, double eps)
Definition DKops.h:22
World active message that extends an RMI message.
Definition worldam.h:80
Implements the functionality of futures.
Definition future.h:75
Specialization of Future<void> for internal convenience. This does nothing useful!
Definition future.h:733
static const Future< void > value
Definition future.h:739
A future is a possibly yet unevaluated value.
Definition future.h:370
static const attrT ATTR_UNORDERED
Definition worldrmi.h:180
Simple structure used to manage references/pointers to remote instances.
Definition worldref.h:395
Mutex that is applied/released at start/end of a scope.
Definition worldmutex.h:239
Spinlock using pthread spinlock operations.
Definition worldmutex.h:253
void lock() const
Acquire the spinlock waiting if necessary.
Definition worldmutex.h:277
void unlock() const
Free a spinlock owned by this thread.
Definition worldmutex.h:287
Contains attributes of a task.
Definition thread.h:329
void send(ProcessID dest, am_handlerT op, const AmArg *arg, const int attr=RMI::ATTR_ORDERED)
Sends a managed non-blocking active message.
Definition worldam.h:278
Implements most parts of a globally addressable object (via unique ID).
Definition world_object.h:491
detail::task_result_type< memfnT >::futureT task(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const TaskAttributes &attr=TaskAttributes()) const
Sends task to derived class method returnT (this->*memfn)(a1,a2,a3,a4,a5,a6).
Definition world_object.h:1334
WorldObject(World &world)
Constructor that associates an object (via the derived class) with a globally unique ID.
Definition world_object.h:834
detail::task_result_type< memfnT >::futureT send(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8) const
Definition world_object.h:1074
static const T & am_arg(const T &t)
Definition world_object.h:677
static bool is_ready(const uniqueidT &id, objT *&obj, const AmArg &arg, am_handlerT ptr)
Definition world_object.h:539
static Spinlock pending_mutex
Definition world_object.h:517
detail::task_result_type< memfnT >::futureT send(ProcessID dest, memfnT memfn, const a1T &a1) const
Definition world_object.h:876
detail::task_result_type< memfnT >::futureT send(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8, const a9T &a9) const
Definition world_object.h:1113
WorldObject< Derived > objT
Definition world_object.h:494
WorldObject(const WorldObject &other)
Definition world_object.h:500
detail::task_result_type< memfnT >::futureT task(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const TaskAttributes &attr=TaskAttributes()) const
Sends task to derived class method returnT (this->*memfn)(a1,a2,a3,a4,a5).
Definition world_object.h:1291
detail::task_result_type< memfnT >::futureT task(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const TaskAttributes &attr=TaskAttributes()) const
Sends task to derived class method returnT (this->*memfn)(a1,a2).
Definition world_object.h:1184
std::list< detail::PendingMsg > pendingT
Definition world_object.h:507
detail::task_result_type< memfnT >::futureT task(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const TaskAttributes &attr=TaskAttributes()) const
Sends task to derived class method returnT (this->*memfn)(a1,a2,a3,a4).
Definition world_object.h:1252
detail::task_result_type< memfnT >::futureT send(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2) const
Definition world_object.h:896
void process_pending()
To be called from derived constructor to process pending messages.
Definition world_object.h:787
WorldObject & operator=(const WorldObject &)=delete
static void spawn_remote_task_handler(const AmArg &arg)
Handler for remote arguments.
Definition world_object.h:633
detail::task_result_type< memfnT >::futureT send(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3) const
Definition world_object.h:918
detail::task_result_type< memfnT >::futureT send(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7) const
Definition world_object.h:1038
ProcessID me
Rank of self.
Definition world_object.h:514
detail::task_result_type< memfnT >::futureT task(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8, const TaskAttributes &attr=TaskAttributes()) const
Sends task to derived class method returnT (this->*memfn)(a1,a2,a3,a4,a5,a6,a7,a8).
Definition world_object.h:1430
detail::task_result_type< memfnT >::futureT task(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const TaskAttributes &attr=TaskAttributes()) const
Sends task to derived class method returnT (this->*memfn)(a1,a2,a3,a4,a5,a6,a7).
Definition world_object.h:1381
detail::task_result_type< memfnT >::futureT send(ProcessID dest, memfnT memfn) const
Definition world_object.h:858
volatile bool ready
True if ready to rock 'n roll.
Definition world_object.h:513
virtual ~WorldObject()
Definition world_object.h:1512
detail::voidT voidT
Definition world_object.h:510
taskT::futureT send_task(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8, const a9T &a9, const TaskAttributes &attr) const
Definition world_object.h:762
detail::task_result_type< memfnT >::futureT task(ProcessID dest, memfnT memfn, const a1T &a1, const TaskAttributes &attr=TaskAttributes()) const
Sends task to derived class method returnT (this->*memfn)(a1).
Definition world_object.h:1155
detail::task_result_type< memfnT >::futureT task(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const TaskAttributes &attr=TaskAttributes()) const
Sends task to derived class method returnT (this->*memfn)(a1,a2,a3).
Definition world_object.h:1216
detail::task_result_type< memfnT >::futureT send(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4) const
Definition world_object.h:945
detail::task_result_type< memfnT >::futureT send_am(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8, const a9T &a9) const
Definition world_object.h:711
static const T & am_arg(const Future< T > &f)
Definition world_object.h:664
detail::task_result_type< memfnT >::futureT send(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6) const
Definition world_object.h:1005
detail::task_result_type< memfnT >::futureT send(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5) const
Definition world_object.h:974
detail::task_result_type< memfnT >::futureT task(ProcessID dest, memfnT memfn, const a1T &a1, const a2T &a2, const a3T &a3, const a4T &a4, const a5T &a5, const a6T &a6, const a7T &a7, const a8T &a8, const a9T &a9, const TaskAttributes &attr=TaskAttributes()) const
Sends task to derived class method returnT (this->*memfn)(a1,a2,a3,a4,a5,a6,a7,a8,...
Definition world_object.h:1487
static volatile pendingT pending
Buffer for pending messages.
Definition world_object.h:518
detail::task_result_type< memfnT >::futureT task(ProcessID dest, memfnT memfn, const TaskAttributes &attr=TaskAttributes()) const
Sends task to derived class method returnT (this->*memfn)().
Definition world_object.h:1132
static void handler(const AmArg &arg)
Handler for an incoming AM.
Definition world_object.h:599
void add(TaskInterface *t)
Add a new local task, taking ownership of the pointer.
Definition world_task_queue.h:466
A parallel world class.
Definition world.h:134
static World * world_from_id(std::uint64_t id)
Convert a World ID to a World pointer.
Definition world.h:516
WorldTaskQueue & taskq
Task queue.
Definition world.h:215
ProcessID rank() const
Returns the process rank in this World (same as MPI_Comm_rank()).
Definition world.h:344
std::shared_ptr< const std::atomic< bool > > liveness_handleT
The type of the handle returned by liveness().
Definition world.h:327
void unregister_ptr(const uniqueidT id)
Unregister a global object via its the unique ID.
Definition world.h:413
uniqueidT register_ptr(T *ptr)
Associate a local pointer with a universe-wide unique ID.
Definition world.h:400
std::optional< T * > ptr_from_id(uniqueidT id) const
Look up a local pointer from a world-wide unique ID.
Definition world.h:440
WorldAmInterface & am
AM interface.
Definition world.h:214
Wraps an archive around a memory buffer for output.
Definition buffer_archive.h:59
Functor wrapper for object and member function pointers.
Definition mem_func_wrapper.h:89
Class for unique global IDs.
Definition uniqueid.h:53
unsigned long get_world_id() const
Access the World ID.
Definition uniqueid.h:90
char * p(char *buf, const char *name, int k, int initial_level, double thresh, int order)
Definition derivatives.cc:72
archive_array< unsigned char > wrap_opaque(const T *, unsigned int)
Factory function to wrap a pointer to contiguous data as an opaque (uchar) archive_array.
Definition archive.h:926
auto to_rel_memfn_ptr(const T &fn)
converts nonstatic member function pointer to the relative equivalent
Definition archive.h:260
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
#define MADNESS_PRAGMA_CLANG(x)
Definition madness_config.h:200
#define MADNESS_EXCEPTION(msg, value)
Macro for throwing a MADNESS exception.
Definition madness_exception.h:119
#define MADNESS_ASSERT(condition)
Assert a condition that should be free of side-effects since in release builds this might be a no-op.
Definition madness_exception.h:134
#define MADNESS_ASSERT_NOEXCEPT(condition)
Same as MADNESS_ASSERT , but never throws.
Definition madness_exception.h:141
Definition potentialmanager.cc:41
static const uniqueidT & peek(const AmArg &arg)
Extract the unique object ID from an incoming active message header.
Definition world_object.h:200
std::enable_if< std::is_void< typenamedetail::result_of< fnT >::type >::value >::type run_function(Future< void > &result, fnT fn, const voidT &, const voidT &, const voidT &, const voidT &, const voidT &, const voidT &, const voidT &, const voidT &, const voidT &)
Definition taskfn.h:317
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
AmArg * copy_am_arg(const AmArg &arg)
Definition worldam.h:170
AmArg * new_am_arg(const argT &... args)
Convenience template for serializing arguments into a new AmArg.
Definition worldam.h:194
bool initialized()
Check if the MADNESS runtime has been initialized (and not subsequently finalized).
Definition world.cc:75
static double pop(std::vector< double > &v)
Definition SCF.cc:116
void free_am_arg(AmArg *arg)
Frees an AmArg allocated with alloc_am_arg.
Definition worldam.h:177
NDIM & f
Definition mra.h:2622
void(* am_handlerT)(const AmArg &)
Type of AM handler functions.
Definition worldam.h:77
std::string type(const PairType &n)
Definition PNOParameters.h:18
Wrap a callable object and its arguments into a task function.
Definition taskfn.h:473
Base class for WorldObject.
Definition world_object.h:345
World & world
Memoized reference to the world to which this object belongs.
Definition world_object.h:348
World & get_world() const
Definition world_object.h:446
World & get_world_unchecked() const noexcept
Unchecked access to the memoized world reference.
Definition world_object.h:397
virtual ~WorldObjectBase()
Definition world_object.h:403
const uniqueidT & id() const
Returns the globally unique object ID.
Definition world_object.h:424
World & get_world_noexcept() const noexcept
Get the world to which this object belongs, without risking a throw.
Definition world_object.h:459
WorldObjectBase(World &w)
Construct a new WorldObjectBase.
Definition world_object.h:360
WorldObjectBase(const WorldObjectBase &other)
Copy constructor; produces an unregistered object.
Definition world_object.h:373
void register_self(DerivedT *this_ptr)
Registers this object with its world, making it globally addressable.
Definition world_object.h:386
uniqueidT objid
Unique object ID; null until register_self() has been called.
Definition world_object.h:347
World::liveness_handleT world_liveness
Reports whether world is still alive.
Definition world_object.h:349
bool world_is_alive() const noexcept
Reports whether the world to which this object belongs still exists.
Definition world_object.h:433
Default load of an object via serialize(ar, t).
Definition archive.h:667
static void store(const BufferOutputArchive &ar, WorldObject< Derived > *const &ptr)
Write a globally-addressable object to a BufferOutputArchive.
Definition world_object.h:1723
static void store(const BufferOutputArchive &ar, const WorldObject< Derived > *const &ptr)
Write a globally-addressable object to a BufferOutputArchive.
Definition world_object.h:1762
Default store of an object via serialize(ar, t).
Definition archive.h:612
Common base class for pending messages to ensure in-order processing.
Definition world_object.h:63
void invokehandler()
Definition world_object.h:71
uniqueidT id
Definition world_object.h:64
AmArg * arg
Definition world_object.h:66
am_handlerT handler
Definition world_object.h:65
PendingMsg(uniqueidT id, am_handlerT handler, const AmArg &arg)
Definition world_object.h:68
static wrapperT make_task_fn(WorldObject< objT > *obj, memfnT memfn)
Definition world_object.h:330
MemFuncWrapper< shared_ptrT, memfnT, typename result_of< memfnT >::type > wrapperT
Definition world_object.h:288
std::conditional< memfunc_traits< memfnT >::constness, std::shared_ptr< constobjT >, std::shared_ptr< objT > >::type shared_ptrT
Definition world_object.h:285
std::conditional< memfunc_traits< memfnT >::constness, constobjT *, objT * >::type ptrT
Definition world_object.h:281
static wrapperT make_task_fn(const objT *obj, memfnT memfn)
Definition world_object.h:297
static wrapperT make_task_fn(objT *obj, memfnT memfn)
Definition world_object.h:308
static wrapperT make_task_fn(const WorldObject< objT > *obj, memfnT memfn)
Definition world_object.h:319
Definition world_object.h:212
static wrapperT make_task_fn(const objT *obj, memfnT memfn)
Definition world_object.h:227
static wrapperT make_task_fn(WorldObject< objT > *obj, memfnT memfn)
Definition world_object.h:259
std::conditional< memfunc_traits< memfnT >::constness, constobjT *, objT * >::type ptrT
Definition world_object.h:215
static wrapperT make_task_fn(const WorldObject< objT > *obj, memfnT memfn)
Definition world_object.h:249
static wrapperT make_task_fn(objT *obj, memfnT memfn)
Definition world_object.h:238
MemFuncWrapper< ptrT, memfnT, typename result_of< memfnT >::type > wrapperT
Definition world_object.h:218
Definition world_object.h:94
TaskAttributes attr
Definition world_object.h:100
void serialize(const Archive &ar)
Serializes a info_base for I/O.
Definition world_object.h:130
ProcessID requestor
Definition world_object.h:98
memfunT_rel_ptr memfun_rel_ptr
Definition world_object.h:99
memfunT memfun() const
Definition world_object.h:103
uniqueidT id
Definition world_object.h:97
info_base()
Definition world_object.h:109
info_base(const uniqueidT &id, ProcessID requestor, memfunT memfun, const TaskAttributes &attr=TaskAttributes())
Definition world_object.h:118
decltype(archive::to_rel_memfn_ptr(std::declval< memfunT >())) memfunT_rel_ptr
Definition world_object.h:95
Definition world_object.h:140
Future< REMFUTURE(MEMFUN_RETURNT(memfunT)) > futureT
Future for a return value of the memory function.
Definition world_object.h:142
info()
Definition world_object.h:148
void serialize(const Archive &ar)
Serializes a info for I/O.
Definition world_object.h:178
info(const AmArg &arg)
Definition world_object.h:154
refT ref
Definition world_object.h:146
info(const uniqueidT &id, ProcessID requestor, memfunT memfun, const refT &ref, const TaskAttributes &attr=TaskAttributes())
Definition world_object.h:168
RemoteReference< FutureImpl< REMFUTURE(MEMFUN_RETURNT(memfunT)) > > refT
Definition world_object.h:144
T type
Definition taskfn.h:213
Future< resultT > futureT
Definition taskfn.h:244
Implements Dqueue, Thread, ThreadBase and ThreadPool.
#define REMFUTURE(T)
Macro to determine type of future (by removing wrapping Future template).
Definition type_traits.h:163
#define MEMFUN_RETURNT(MEMFUN)
Macro to make member function type traits easier to use.
Definition type_traits.h:773
const double a2
Definition vnucso.cc:86
const double a1
Definition vnucso.cc:85
Defines TaskInterface and implements WorldTaskQueue and associated stuff.
int ProcessID
Used to clearly identify process number/rank.
Definition worldtypes.h:43