33 #ifndef MADNESS_WORLD_WORLDRMI_H__INCLUDED 
   34 #define MADNESS_WORLD_WORLDRMI_H__INCLUDED 
  106             : len(len), func(func), i(i), src(src), attr(attr), count(count) {}
 
  109             return count < other.
count;
 
  124                 : nmsg_sent(0), nbyte_sent(0), nmsg_recv(0), nbyte_recv(0) {}
 
  128         typedef uint16_t counterT;
 
  129         typedef uint32_t attrT;
 
  149 #endif // HAVE_INTEL_TBB 
  158             std::list< std::pair<int,size_t> > hugeq; 
 
  163             volatile bool finished;     
 
  167             std::size_t max_msg_len_;
 
  178             static inline bool is_ordered(attrT attr) { 
return attr & 
ATTR_ORDERED; }
 
  186             tbb::task* execute() {
 
  190                    tbb::task::increment_ref_count();
 
  191                    tbb::task::recycle_as_safe_continuation();
 
  198                     while (! finished) process_some();
 
  205 #endif // HAVE_INTEL_TBB 
  209                     std::cerr << rank << 
":RMI: sending exit request to server thread" << std::endl;
 
  216             static void huge_msg_handler(
void *buf, 
size_t nbytein);
 
  220             void post_pending_huge_msg();
 
  222             void post_recv_buf(
int i);
 
  227         static tbb::task* tbb_rmi_parent_task;
 
  228 #endif // HAVE_INTEL_TBB 
  230         static RmiTask* task_ptr;    
 
  231         static RMIStats stats;
 
  232         static volatile bool debugging;    
 
  234         static const size_t DEFAULT_MAX_MSG_LEN = 3*512*1024;
 
  236         static const int DEFAULT_NRECV=128;
 
  238         static const int DEFAULT_NRECV=32;
 
  243         RMI& operator=(
const RMI&);
 
  248             return (task_ptr ? task_ptr->max_msg_len_ : DEFAULT_MAX_MSG_LEN);
 
  251             MADNESS_ASSERT(task_ptr);
 
  252             return task_ptr->maxq_;
 
  255             MADNESS_ASSERT(task_ptr);
 
  256             return task_ptr->nrecv_;
 
  263                   "!! MADNESS RMI error: Attempting to send a message when the RMI thread is not running\n" 
  264                   "!! MADNESS RMI error: This typically occurs when an active message is sent or a remote task is spawned after calling madness::finalize()\n";
 
  265               MADNESS_EXCEPTION(
"!! MADNESS error: The RMI thread is not running", (task_ptr != NULL));
 
  267             return task_ptr->isend(buf, nbyte, dest, func, attr);
 
  271             MADNESS_ASSERT(task_ptr == NULL);
 
  273             tbb_rmi_parent_task = 
new( tbb::task::allocate_root() ) tbb::empty_task;
 
  274             tbb_rmi_parent_task->set_ref_count(2);
 
  276             task_ptr = 
new( tbb_rmi_parent_task->allocate_child() ) RmiTask();
 
  277             tbb::task::enqueue(*task_ptr, tbb::priority_high);
 
  279             task_ptr = 
new RmiTask();
 
  281 #endif // HAVE_INTEL_TBB 
  288                 tbb_rmi_parent_task->wait_for_all();
 
  289                 tbb::task::destroy(*tbb_rmi_parent_task);
 
  290 #endif // HAVE_INTEL_TBB 
  295         static void set_debug(
bool status) { debugging = status; }
 
  304 #endif // MADNESS_WORLD_WORLDRMI_H__INCLUDED 
ProcessID src
Definition: worldrmi.h:101
Serializes calls to MPI in case it does not support THREAD_MULTIPLE. 
Mutex using pthread mutex operations. 
Definition: worldmutex.h:94
static void begin()
Definition: worldrmi.h:270
int i
Definition: worldrmi.h:100
uint64_t nmsg_sent
Definition: worldrmi.h:118
std::complex< double > func(int n, int t1, int t2, int t3, double xx, double yy, double zz)
Definition: wannier.cc:98
static const attrT ATTR_UNORDERED
Definition: worldrmi.h:138
RMIStats()
Definition: worldrmi.h:123
SafeMPI::Request Request
Definition: worldrmi.h:132
Wrapper around MPI_Comm. Has a shallow copy constructor; use Create(Get_group()) for deep copy...
Definition: safempi.h:437
static bool get_debug()
Definition: worldrmi.h:297
uint64_t nbyte_sent
Definition: worldrmi.h:119
uint64_t nbyte_recv
Definition: worldrmi.h:121
static Request isend(const void *buf, size_t nbyte, ProcessID dest, rmi_handlerT func, unsigned int attr=ATTR_UNORDERED)
Definition: worldrmi.h:260
static std::size_t nrecv()
Definition: worldrmi.h:254
Definition: worldrmi.h:117
size_t len
Definition: worldrmi.h:98
uint64_t nmsg_recv
Definition: worldrmi.h:120
qmsg()
Definition: worldrmi.h:112
static const attrT ATTR_ORDERED
Definition: worldrmi.h:139
Implements Dqueue, Thread, ThreadBase and ThreadPool. 
static std::size_t maxq()
Definition: worldrmi.h:250
Definition: worldrmi.h:95
uint32_t attrT
Definition: worldrmi.h:97
static const RMIStats & get_stats()
Definition: worldrmi.h:299
void(* rmi_handlerT)(void *buf, size_t nbyte)
Definition: worldrmi.h:93
static std::size_t max_msg_len()
Definition: worldrmi.h:247
static const size_t HEADER_LEN
Definition: worldrmi.h:137
uint16_t counterT
Definition: worldrmi.h:96
int ProcessID
Used to clearly identify process number/rank. 
Definition: worldtypes.h:37
static void set_debug(bool status)
Definition: worldrmi.h:295
Definition: safempi.h:243
counterT count
Definition: worldrmi.h:103
qmsg(size_t len, rmi_handlerT func, int i, int src, attrT attr, counterT count)
Definition: worldrmi.h:105
#define HAVE_INTEL_TBB
Definition: config.h:65
static const size_t ALIGNMENT
Definition: worldrmi.h:136
Simplified thread wrapper to hide pthread complexity. 
Definition: worldthread.h:91
#define MADNESS_EXCEPTION(msg, value)
Definition: worldexc.h:88
Definition: worldrmi.h:127
static void end()
Definition: worldrmi.h:284
attrT attr
Definition: worldrmi.h:102
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces. 
Definition: chem/atomutil.cc:45
bool operator<(const qmsg &other) const 
Definition: worldrmi.h:108
rmi_handlerT func
Definition: worldrmi.h:99