32#ifndef MADNESS_WORLD_WORLDAM_H__INCLUDED
33#define MADNESS_WORLD_WORLDAM_H__INCLUDED
73 template <
class Derived>
class WorldObject;
132 unsigned char*
buf()
const {
return (
unsigned char*)(
this) +
sizeof(
AmArg); }
138 template <
typename T>
144 template <
typename T>
163 std::size_t narg = 1 + (nbyte+
sizeof(
AmArg)-1)/
sizeof(
AmArg);
172 memcpy(
reinterpret_cast<void*
>(r), &
arg,
arg.size()+
sizeof(
AmArg));
183 template <
typename Archive>
187 template <
typename Archive,
typename T,
typename... argT>
193 template <
typename... argT>
255 static void handler(
void *buf, std::size_t nbyte) {
338 while (!
send_req[i].TestAndFree()) {
356 for (
int i=0; i<
nsend; i++) {
358 if (
send_req[i].TestAndFree()) nfree++;
double w(double t, double eps)
Definition DKops.h:22
Implements an archive wrapping a memory buffer.
bool Test(MPI_Status &status)
Definition safempi.h:409
World active message that extends an RMI message.
Definition worldam.h:80
std::uint64_t worldid
Definition worldam.h:89
unsigned char header[RMI::HEADER_LEN]
Definition worldam.h:87
std::size_t nbyte
Definition worldam.h:88
archive::BufferOutputArchive make_output_arch() const
Definition worldam.h:124
archive::BufferOutputArchive operator&(const T &t) const
Used to serialize arguments into outgoing message.
Definition worldam.h:145
std::size_t size() const
Returns the size of the user's payload.
Definition worldam.h:135
void set_src(ProcessID source)
Definition worldam.h:101
bool is_pending() const
Definition worldam.h:114
AmArg & operator=(const AmArg &)
ProcessID src
Definition worldam.h:91
friend AmArg * alloc_am_arg(std::size_t nbyte)
Allocates a new AmArg with nbytes of user data ... delete with free_am_arg.
Definition worldam.h:162
std::ptrdiff_t func
Definition worldam.h:90
AmArg()
Definition worldam.h:129
archive::BufferInputArchive operator&(T &t) const
Used to deserialize arguments from incoming message.
Definition worldam.h:139
unsigned char * buf() const
Returns a pointer to the user's payload (aligned in same way as AmArg)
Definition worldam.h:132
void set_worldid(unsigned long id)
Definition worldam.h:103
archive::BufferInputArchive make_input_arch() const
Definition worldam.h:120
am_handlerT get_func() const
Definition worldam.h:118
ProcessID get_src() const
For incoming AM gives the source process.
Definition worldam.h:150
unsigned int flags
Definition worldam.h:92
void set_size(std::size_t numbyte)
Definition worldam.h:110
void set_func(am_handlerT handler)
Definition worldam.h:105
void clear_flags()
Definition worldam.h:116
void set_pending()
Definition worldam.h:112
World * get_world() const
For incoming AM gives the associated world.
Definition worldam.h:154
std::uint64_t get_worldid() const
Return the world id.
Definition worldam.h:157
Mutex using pthread mutex operations.
Definition worldmutex.h:131
void unlock() const
Free a mutex owned by this thread.
Definition worldmutex.h:165
bool try_lock() const
Try to acquire the mutex ... return true on success, false on failure.
Definition worldmutex.h:150
void lock() const
Acquire the mutex waiting if necessary.
Definition worldmutex.h:155
static bool get_this_thread_is_server()
Definition worldrmi.h:186
static const size_t HEADER_LEN
Definition worldrmi.h:179
static const attrT ATTR_ORDERED
Definition worldrmi.h:181
static std::list< std::unique_ptr< RMISendReq > > send_req
Definition worldrmi.h:188
static Request isend(const void *buf, size_t nbyte, ProcessID dest, rmi_handlerT func, unsigned int attr=ATTR_UNORDERED)
Send a remote method invocation (again you should probably be looking at worldam.h instead)
Definition worldrmi.h:355
void free()
Definition worldam.h:221
SendReq(AmArg *b, const RMI::Request &r)
Definition worldam.h:224
RMI::Request req
Definition worldam.h:220
SendReq()
Definition worldam.h:223
bool TestAndFree()
Definition worldam.h:226
void set(AmArg *b, const RMI::Request &r)
Definition worldam.h:225
~SendReq()
Definition worldam.h:236
AmArg * buf
Definition worldam.h:219
Implements AM interface.
Definition worldam.h:207
const int nproc
Definition worldam.h:246
unsigned long worldid
The world which contains this instance of WorldAmInterface.
Definition worldam.h:244
int cur_msg
Index of next buffer to attempt to use.
Definition worldam.h:248
std::vector< int > map_to_comm_world
Maps rank in current MPI communicator to SafeMPI::COMM_WORLD.
Definition worldam.h:252
const ProcessID rank
Definition worldam.h:245
virtual ~WorldAmInterface()
Definition worldam.cc:85
unsigned long nsent
Counts no. of AM sent for purpose of termination detection.
Definition worldam.h:249
static const int DEFAULT_NSEND
Definition worldam.h:215
void fence()
Currently a noop.
Definition worldam.h:275
std::unique_ptr< SendReq[]> send_req
Send requests and managed buffers.
Definition worldam.h:243
int free_managed_buffers()
Frees as many send buffers as possible, returning the number that are free.
Definition worldam.h:354
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
int nsend
Max no. of pending sends.
Definition worldam.h:242
unsigned long nrecv
Counts no. of AM received for purpose of termination detection.
Definition worldam.h:250
static void handler(void *buf, std::size_t nbyte)
This handles all incoming RMI messages for all instances.
Definition worldam.h:255
Provides collectives that interoperate with the AM and task interfaces.
Definition worldgop.h:145
Implements most parts of a globally addressable object (via unique ID).
Definition world_object.h:364
A parallel world class.
Definition world.h:132
static World * world_from_id(std::uint64_t id)
Convert a World ID to a World pointer.
Definition world.h:474
Wraps an archive around a memory buffer for output.
Definition buffer_archive.h:59
std::size_t size() const
Return the amount of data stored (counted) in the buffer.
Definition buffer_archive.h:123
auto T(World &world, response_space &f) -> response_space
Definition global_functions.cc:34
std::ptrdiff_t to_rel_fn_ptr(const T &fn)
converts function or (free or static member) function pointer to the relative function pointer
Definition archive.h:237
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:2502
Tensor< double > op(const Tensor< double > &x)
Definition kain.cc:508
#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
Namespace for all elements and tools of MADNESS.
Definition DFParameters.h:10
AmArg * copy_am_arg(const AmArg &arg)
Definition worldam.h:170
static void myusleep(unsigned int us)
Sleep or spin for specified number of microseconds.
Definition timers.h:164
std::shared_ptr< FunctionFunctorInterface< double, 3 > > func(new opT(g))
AmArg * new_am_arg(const argT &... args)
Convenience template for serializing arguments into a new AmArg.
Definition worldam.h:194
void free_am_arg(AmArg *arg)
Frees an AmArg allocated with alloc_am_arg.
Definition worldam.h:177
void(* am_handlerT)(const AmArg &)
Type of AM handler functions.
Definition worldam.h:77
void serialize_am_args(Archive &&)
Terminate argument serialization.
Definition worldam.h:184
AmArg * alloc_am_arg(std::size_t nbyte)
Allocates a new AmArg with nbytes of user data ... delete with free_am_arg.
Definition worldam.h:162
static const double b
Definition nonlinschro.cc:119
This for RMI server thread to manage lifetime of WorldAM messages that it is sending.
Definition worldrmi.h:159
std::string ok(const bool b)
Definition test6.cc:43
double source(const coordT &r)
Definition testperiodic.cc:48
Declares the World class for the parallel runtime environment.
Lowest level API for sending active messages — you should probably be looking at worldam....
int ProcessID
Used to clearly identify process number/rank.
Definition worldtypes.h:43