314 #ifndef MADNESS_WORLD_WORLDFWD_H__INCLUDED 
  315 #define MADNESS_WORLD_WORLDFWD_H__INCLUDED 
  350     class WorldTaskQueue;
 
  351     class WorldAmInterface;
 
  352     class WorldGopInterface;
 
  402     extern void xterm_debug(
const char* path, 
const char* display);
 
  404     void error(
const char *msg);
 
  406     template <
typename T>
 
  407     static void error(
const char *msg, 
const T& data) {
 
  408         std::cerr << 
"MADNESS: fatal error: " << msg << 
" " << data << std::endl;
 
  424         static unsigned long idbase;        
 
  425         static World* default_world;        
 
  426         static std::list<World*> worlds;    
 
  429             inline std::size_t operator()(
const void* p)
 const {
 
  430                 return std::size_t(p);    
 
  437         map_id_to_ptrT map_id_to_ptr;
 
  438         map_ptr_to_idT map_ptr_to_id;
 
  442         unsigned long obj_id;               
 
  465         unsigned int myrand_next;
 
  478             typedef std::list<World*>::const_iterator citer;
 
  479             for(citer it = worlds.begin(); it != worlds.end(); ++it) {
 
  480                 if ((*it)->mpi.comm() == comm)
 
  493             MADNESS_ASSERT(default_world);
 
  494             return *default_world;
 
  520         void args(
int argc, 
char**argv);
 
  523         unsigned long id()
 const { 
return _id; }
 
  563         template <
typename T>
 
  565             MADNESS_ASSERT(
sizeof(
T*) == 
sizeof(
void *));
 
  567             map_id_to_ptr.insert(std::pair<uniqueidT,void*>(
id,static_cast<void*>(ptr)));
 
  568             map_ptr_to_id.insert(std::pair<void*,uniqueidT>(static_cast<void*>(ptr),
id));
 
  574         template <
typename T>
 
  577             map_id_to_ptr.erase(
id);
 
  578             map_ptr_to_id.erase((
void *) ptr);
 
  585         template <
typename T>
 
  587             T* 
const ptr = ptr_from_id<T>(
id);
 
  588             map_id_to_ptr.erase(
id);
 
  589             map_ptr_to_id.erase((
void *) ptr);
 
  596         template <
typename T>
 
  599             if (it == map_id_to_ptr.end())
 
  602                 return (
T*)(it->second);
 
  609         template <
typename T>
 
  613             if (it == map_ptr_to_id.end())
 
  630             for (std::list<World *>::iterator it=worlds.begin(); it != worlds.end(); ++it) {
 
  631                 if ((*it) && (*it)->_id == 
id) 
return *it;
 
  639         struct MpiRequestTester {
 
  642             bool operator()()
 const {
 
  657         template <
typename Probe>
 
  658         static void inline await(
const Probe& probe, 
bool dowork = 
true) {
 
  662         void srand(
unsigned long seed = 0ul) {
 
  663             if (seed == 0) seed = 
rank();
 
  668             for (
int i=0; i<1000; ++i) 
rand(); 
 
  669 #endif // HAVE_RANDOM 
  678             return int(random() & 0xfffffful);
 
  680             myrand_next = myrand_next * 1103515245UL + 12345UL;
 
  681             return int((myrand_next>>8) & 0xfffffful);
 
  682 #endif // HAVE_RANDOM 
  697             if (
size() == 1) 
return -1;
 
  701             } 
while (p == 
rank());
 
  710         template <
typename, 
typename>
 
  711         struct ArchiveLoadImpl;
 
  712         template <
typename, 
typename>
 
  713         struct ArchiveStoreImpl;
 
  715         template <
class Archive>
 
  717             static inline void load(
const Archive& ar, 
World*& wptr) {
 
  718                 unsigned long id = 0ul;
 
  721                 MADNESS_ASSERT(wptr);
 
  725         template <
class Archive>
 
  727             static inline void store(
const Archive& ar, 
World* 
const & wptr) {
 
  736 #endif // MADNESS_WORLD_WORLDFWD_H__INCLUDED 
friend void finalize()
Call this once at the very end of your main program instead of calling MPI_Finalize. 
Definition: world.cc:212
static void await(const Probe &probe, bool dowork=true)
Gracefully wait for a condition to become true ... executes tasks if any in queue. 
Definition: worldfwd.h:658
void error(const char *msg)
Definition: world.cc:128
WorldGopInterface & gop
Global operations. 
Definition: worldfwd.h:462
static void await(SafeMPI::Request &request, bool dowork=true)
Wait for MPI request to complete. 
Definition: worldfwd.h:650
static World * find_instance(const SafeMPI::Intracomm &comm)
Find the World corresponding to the given communicator. 
Definition: worldfwd.h:477
static World & get_default()
Default World object accessor. 
Definition: worldfwd.h:492
static void load(const Archive &ar, World *&wptr)
Definition: worldfwd.h:717
iterator for hash 
Definition: worldhashmap.h:190
double drand()
Returns a CRUDE, LOW-QUALITY, random number uniformly distributed in [0,1). 
Definition: worldfwd.h:687
WorldMpiInterface & mpi
MPI interface. 
Definition: worldfwd.h:459
Wrapper around MPI_Comm. Has a shallow copy constructor; use Create(Get_group()) for deep copy...
Definition: safempi.h:437
void clear_user_state()
Clears user-defined state ... same as set_user_state(0) 
Definition: worldfwd.h:514
uniqueidT unique_obj_id()
Returns new universe-wide unique ID for objects created in this world. No comms. 
Definition: worldfwd.h:545
ProcessID nproc() const 
Returns the number of processes in this world (same as MPI_Comm_size()) 
Definition: worldfwd.h:530
unsigned long id() const 
Returns the system-wide unique integer ID of this world. 
Definition: worldfwd.h:523
Definition: uniqueid.h:46
void unregister_ptr(const uniqueidT id)
Unregister a unique id for a local pointer based on id. 
Definition: worldfwd.h:586
void print_stats(World &world)
Call this to print misc. stats ... collective. 
Definition: world.cc:305
ProcessID size() const 
Returns the number of processes in this world (same as MPI_Comm_size()) 
Definition: worldfwd.h:533
This class wraps/extends the MPI interface for World. 
Definition: worldmpi.h:245
World & initialize(int &argc, char **&argv)
Initialize the MADNESS runtime. 
Definition: world.cc:134
static void await(const Probe &probe, bool dowork=true)
Gracefully wait for a condition to become true ... executes tasks if any in queue. 
Definition: worldthread.h:1056
void Abort(int code=1) const 
Definition: safempi.h:648
ProcessID random_proc_not_me()
Returns a random process number [0,world.size()) != current process. 
Definition: worldfwd.h:696
Default store of a thingy via serialize(ar,t) 
Definition: archive.h:708
bool Test(MPI_Status &status)
Definition: safempi.h:356
Implements WorldMpiInterface. 
Multi-threaded queue to manage and run tasks. 
Definition: worldtask.h:393
int size() const 
Definition: worldmpi.h:354
static World * world_from_id(unsigned long id)
Convert world id to world pointer. 
Definition: worldfwd.h:628
WorldAmInterface & am
AM interface. 
Definition: worldfwd.h:460
Provides collectives that interoperate with the AM and task interfaces. 
Definition: worldgop.h:147
int MPI_Comm
Definition: stubmpi.h:22
int rand()
Returns a CRUDE, LOW-QUALITY, random number uniformly distributed in [0,2**24). 
Definition: worldfwd.h:676
const T1 &f1 return GTEST_2_TUPLE_() T(f0, f1)
World(const SafeMPI::Intracomm &comm)
Definition: world.cc:76
~World()
Definition: world.cc:120
void finalize()
Call this once at the very end of your main program instead of calling MPI_Finalize. 
Definition: world.cc:212
Implements Dqueue, Thread, ThreadBase and ThreadPool. 
Default load of a thingy via serialize(ar,t) 
Definition: archive.h:718
ProcessID random_proc()
Returns a random process number [0,world.size()) 
Definition: worldfwd.h:690
uniqueidT register_ptr(T *ptr)
Associate a local pointer with a universe-wide unique id. 
Definition: worldfwd.h:564
void unregister_ptr(T *ptr)
Unregister a unique id for a local pointer. 
Definition: worldfwd.h:575
bool initialized()
Definition: world.cc:70
A parallel world with full functionality wrapping an MPI communicator. 
Definition: worldfwd.h:416
void args(int argc, char **argv)
Processes command line arguments. 
Definition: world.cc:111
int ProcessID
Used to clearly identify process number/rank. 
Definition: worldtypes.h:37
static void store(const Archive &ar, World *const &wptr)
Definition: worldfwd.h:727
ProcessID rank() const 
Returns the process rank in this world (same as MPI_Comm_rank())) 
Definition: worldfwd.h:526
Implements AM interface. 
Definition: worldam.h:266
void redirectio(World &world)
Definition: redirectio.cc:45
Definition: safempi.h:243
int rank() const 
Definition: worldmpi.h:350
WorldTaskQueue & taskq
Task queue. 
Definition: worldfwd.h:461
void xterm_debug(const char *path, const char *display)
Definition: debug.cc:106
void set_user_state(void *state)
Sets a pointer to user-managed local state. 
Definition: worldfwd.h:506
T * ptr_from_id(uniqueidT id) const 
Look up local pointer from world-wide unique id. 
Definition: worldfwd.h:597
Intracomm COMM_WORLD
Definition: safempi.cc:70
friend World & initialize(int &, char **&, const SafeMPI::Intracomm &)
Initialize the MADNESS runtime. 
Definition: world.cc:142
void * get_user_state()
Returns pointer to user-managed state set by set_user_state() 
Definition: worldfwd.h:511
const uniqueidT & id_from_ptr(T *ptr) const 
Look up id from local pointer. 
Definition: worldfwd.h:610
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces. 
Definition: chem/atomutil.cc:45
void srand(unsigned long seed=0ul)
Definition: worldfwd.h:662
int nproc() const 
Definition: worldmpi.h:352
Disables default copy constructor and assignment operators. 
Definition: nodefaults.h:49
Defines and implements a concurrent hashmap.