28 #ifndef _util_group_message_h
29 #define _util_group_message_h
35 #include <util/class/class.h>
36 #include <util/state/state.h>
37 #include <util/keyval/keyval.h>
38 #include <util/group/topology.h>
47 virtual void reduce(T*target, T*data,
int n) = 0;
55 void reduce(T*target, T*data,
int nelement);
63 void reduce(T*target, T*data,
int nelement);
71 void reduce(T*target, T*data,
int nelement);
74 template <
class T,
class BinaryPredicate = std::less<T> >
79 void reduce(T*target, T*data,
int nelement);
87 void reduce(T*target, T*data,
int nelement);
93 void reduce(T*target, T*data,
int nelement);
99 void reduce(T*target, T*data,
int nelement);
105 void reduce(T*target, T*data,
int nelement);
111 void (*func_)(T*target,T*data,
int nelement);
114 void reduce(T*target, T*data,
int nelement);
129 int sender()
const {
return sender_; }
130 int type()
const {
return type_; }
131 int nbyte()
const {
return nbyte_; }
133 enum { AnyType = -1 };
134 enum { AnySender = -1 };
149 std::map<ClassDescP,int> classdesc_to_index_;
165 if (info) info->sender_ = sender;
167 void set_type(MessageInfo *info,
int type) {
168 if (info) info->type_ = type;
170 void set_nbyte(MessageInfo *info,
int nbyte) {
171 if (info) info->nbyte_ = nbyte;
174 void set_id(MessageHandle *handle,
void *
id) {
177 void *get_id(
const MessageHandle *handle) {
183 MessageGrp(
const Ref<KeyVal>&);
192 int n() {
return n_; }
194 int me() {
return me_; }
239 virtual void send(
int target,
const double* data,
int ndata);
240 virtual void send(
int target,
const unsigned int* data,
int ndata);
241 virtual void send(
int target,
const int* data,
int ndata);
242 virtual void send(
int target,
const char* data,
int nbyte);
243 virtual void send(
int target,
const unsigned char* data,
int nbyte);
244 virtual void send(
int target,
const signed char* data,
int nbyte);
245 virtual void send(
int target,
const short* data,
int ndata);
246 virtual void send(
int target,
const long* data,
int ndata);
247 virtual void send(
int target,
const float* data,
int ndata);
249 void send(
int target,
double data) {
send(target,&data,1); }
251 void send(
int target,
int data) {
send(target,&data,1); }
252 virtual void raw_send(
int target,
const void* data,
int nbyte) = 0;
263 virtual void sendt(
int target,
int type,
const double* data,
int ndata,
265 virtual void sendt(
int target,
int type,
const unsigned int* data,
int ndata,
267 virtual void sendt(
int target,
int type,
const int* data,
int ndata,
269 virtual void sendt(
int target,
int type,
const char* data,
int nbyte,
271 virtual void sendt(
int target,
int type,
const unsigned char* data,
int nbyte,
273 virtual void sendt(
int target,
int type,
const signed char* data,
int nbyte,
275 virtual void sendt(
int target,
int type,
const short* data,
int ndata,
277 virtual void sendt(
int target,
int type,
const long* data,
int ndata,
279 virtual void sendt(
int target,
int type,
const float* data,
int ndata,
282 void sendt(
int target,
int type,
double data,
283 bool rcvrdy=
false) {sendt(target,type,&data,1,rcvrdy);}
285 void sendt(
int target,
int type,
int data,
286 bool rcvrdy=
false) {sendt(target,type,&data,1,rcvrdy);}
287 virtual void raw_sendt(
int target,
int type,
const void* data,
int nbyte,
288 bool rcvrdy=
false) = 0;
297 virtual void recv(
int sender,
double* data,
int ndata);
298 virtual void recv(
int sender,
unsigned int* data,
int ndata);
299 virtual void recv(
int sender,
int* data,
int ndata);
300 virtual void recv(
int sender,
char* data,
int nbyte);
301 virtual void recv(
int sender,
unsigned char* data,
int nbyte);
302 virtual void recv(
int sender,
signed char* data,
int nbyte);
303 virtual void recv(
int sender,
short* data,
int ndata);
304 virtual void recv(
int sender,
long* data,
int ndata);
305 virtual void recv(
int sender,
float* data,
int ndata);
307 void recv(
int sender,
double& data) {
recv(sender,&data,1); }
309 void recv(
int sender,
int& data) {
recv(sender,&data,1); }
310 virtual void raw_recv(
int sender,
void* data,
int nbyte,
311 MessageInfo *info=0) = 0;
321 virtual void recvt(
int sender,
int type,
double* data,
int ndata);
322 virtual void recvt(
int sender,
int type,
unsigned int* data,
int ndata);
323 virtual void recvt(
int sender,
int type,
int* data,
int ndata);
324 virtual void recvt(
int sender,
int type,
char* data,
int nbyte);
325 virtual void recvt(
int sender,
int type,
unsigned char* data,
int nbyte);
326 virtual void recvt(
int sender,
int type,
signed char* data,
int nbyte);
327 virtual void recvt(
int sender,
int type,
short* data,
int ndata);
328 virtual void recvt(
int sender,
int type,
long* data,
int ndata);
329 virtual void recvt(
int sender,
int type,
float* data,
int ndata);
331 void recvt(
int sender,
int type,
double& data) {
332 recvt(sender,type,&data,1);
335 void recvt(
int sender,
int type,
int& data) {
336 recvt(sender,type,&data,1);
338 virtual void raw_recvt(
int sender,
int type,
void* data,
int nbyte,
339 MessageInfo *info=0) = 0;
359 virtual void nb_sendt(
int target,
int type,
360 const double* data,
int ndata,
361 MessageHandle&handle,
363 virtual void nb_sendt(
int target,
int type,
364 const unsigned int* data,
int ndata,
365 MessageHandle&handle,
367 virtual void nb_sendt(
int target,
int type,
368 const int* data,
int ndata,
369 MessageHandle&handle,
371 virtual void nb_sendt(
int target,
int type,
372 const char* data,
int nbyte,
373 MessageHandle&handle,
375 virtual void nb_sendt(
int target,
int type,
376 const unsigned char* data,
int nbyte,
377 MessageHandle&handle,
379 virtual void nb_sendt(
int target,
int type,
380 const signed char* data,
int nbyte,
381 MessageHandle&handle,
383 virtual void nb_sendt(
int target,
int type,
384 const short* data,
int ndata,
385 MessageHandle&handle,
387 virtual void nb_sendt(
int target,
int type,
388 const long* data,
int ndata,
389 MessageHandle&handle,
391 virtual void nb_sendt(
int target,
int type,
392 const float* data,
int ndata,
393 MessageHandle&handle,
395 void nb_sendt(
int target,
int type,
double data,
396 MessageHandle&handle,
398 nb_sendt(target,type,&data,1,handle,rcvrdy);
400 void nb_sendt(
int target,
int type,
int data,
401 MessageHandle&handle,
403 nb_sendt(target,type,&data,1,handle,rcvrdy);
405 virtual void raw_nb_sendt(
int target,
int type,
406 const void* data,
int nbyte,
408 bool rcvrdy=
false) = 0;
426 virtual void nb_recvt(
int sender,
int type,
double* data,
int ndata,
427 MessageHandle&handle);
428 virtual void nb_recvt(
int sender,
int type,
unsigned int* data,
int ndata,
429 MessageHandle&handle);
430 virtual void nb_recvt(
int sender,
int type,
int* data,
int ndata,
431 MessageHandle&handle);
432 virtual void nb_recvt(
int sender,
int type,
char* data,
int nbyte,
433 MessageHandle&handle);
434 virtual void nb_recvt(
int sender,
int type,
unsigned char* data,
int nbyte,
435 MessageHandle&handle);
436 virtual void nb_recvt(
int sender,
int type,
signed char* data,
int nbyte,
437 MessageHandle&handle);
438 virtual void nb_recvt(
int sender,
int type,
short* data,
int ndata,
439 MessageHandle&handle);
440 virtual void nb_recvt(
int sender,
int type,
long* data,
int ndata,
441 MessageHandle&handle);
442 virtual void nb_recvt(
int sender,
int type,
float* data,
int ndata,
443 MessageHandle&handle);
447 nb_recvt(sender,type,&data,1,handle);
452 nb_recvt(sender,type,&data,1,handle);
454 virtual void raw_nb_recvt(
int sender,
int type,
455 void* data,
int nbyte,
464 virtual void wait(
const MessageHandle&handle,
465 MessageInfo *info=0) = 0;
468 virtual int probet(
int sender,
int type, MessageInfo*info=0) = 0;
473 virtual void bcast(
double* data,
int ndata,
int from = 0);
474 virtual void bcast(
unsigned int* data,
int ndata,
int from = 0);
475 virtual void bcast(
int* data,
int ndata,
int from = 0);
476 virtual void bcast(
char* data,
int nbyte,
int from = 0);
477 virtual void bcast(
unsigned char* data,
int nbyte,
int from = 0);
478 virtual void bcast(
signed char* data,
int nbyte,
int from = 0);
479 virtual void bcast(
short* data,
int ndata,
int from = 0);
480 virtual void bcast(
long* data,
int ndata,
int from = 0);
481 virtual void bcast(
float* data,
int ndata,
int from = 0);
482 virtual void raw_bcast(
void* data,
int nbyte,
int from = 0);
483 void bcast(
double& data,
int from = 0) { bcast(&data, 1, from); }
484 void bcast(
int& data,
int from = 0) { bcast(&data, 1, from); }
491 virtual void raw_collect(
const void *part,
const int *lengths,
492 void *whole,
int bytes_per_datum=1);
493 void collect(
const double *part,
const int *lengths,
double *whole);
498 virtual void sum(
double* data,
int n,
double* = 0,
int target = -1);
499 virtual void sum(
unsigned int* data,
int n,
unsigned int* = 0,
int target = -1);
500 virtual void sum(
int* data,
int n,
int* = 0,
int target = -1);
501 virtual void sum(
long* data,
int n,
long* = 0,
int target = -1);
502 virtual void sum(
unsigned long* data,
int n,
unsigned long* = 0,
int target = -1);
503 virtual void sum(
char* data,
int n,
char* = 0,
int target = -1);
504 virtual void sum(
unsigned char* data,
int n,
505 unsigned char* = 0,
int target = -1);
506 virtual void sum(
signed char* data,
int n,
507 signed char* = 0,
int target = -1);
508 void sum(
double& data) { sum(&data, 1); }
509 void sum(
int& data) { sum(&data, 1); }
514 virtual void max(
double* data,
int n,
double* = 0,
int target = -1);
515 virtual void max(
int* data,
int n,
int* = 0,
int target = -1);
516 virtual void max(
unsigned int* data,
int n,
unsigned int* = 0,
int target = -1);
517 virtual void max(
char* data,
int n,
char* = 0,
int target = -1);
518 virtual void max(
unsigned char* data,
int n,
519 unsigned char* = 0,
int target = -1);
520 virtual void max(
signed char* data,
int n,
521 signed char* = 0,
int target = -1);
522 void max(
double& data) { max(&data, 1); }
523 void max(
int& data) { max(&data, 1); }
528 virtual void min(
double* data,
int n,
double* = 0,
int target = -1);
529 virtual void min(
int* data,
int n,
int* = 0,
int target = -1);
530 virtual void min(
unsigned int* data,
int n,
unsigned int* = 0,
int target = -1);
531 virtual void min(
char* data,
int n,
char* = 0,
int target = -1);
532 virtual void min(
unsigned char* data,
int n,
533 unsigned char* = 0,
int target = -1);
534 virtual void min(
signed char* data,
int n,
535 signed char* = 0,
int target = -1);
536 void min(
double& data) { min(&data, 1); }
537 void min(
int& data) { min(&data, 1); }
542 template <
typename T>
544 void reduce(T*,
int n, GrpReduce<T>&,
545 T*scratch = 0,
int target = -1);
546 virtual void reduce(
double*,
int n, GrpReduce<double>&,
547 double*scratch = 0,
int target = -1);
548 virtual void reduce(
int*,
int n, GrpReduce<int>&,
549 int*scratch = 0,
int target = -1);
550 virtual void reduce(
unsigned int*,
int n, GrpReduce<unsigned int>&,
551 unsigned int*scratch = 0,
int target = -1);
552 virtual void reduce(
char*,
int n, GrpReduce<char>&,
553 char*scratch = 0,
int target = -1);
554 virtual void reduce(
unsigned char*,
int n, GrpReduce<unsigned char>&,
555 unsigned char*scratch = 0,
int target = -1);
556 virtual void reduce(
signed char*,
int n, GrpReduce<signed char>&,
557 signed char*scratch = 0,
int target = -1);
558 virtual void reduce(
short*,
int n, GrpReduce<short>&,
559 short*scratch = 0,
int target = -1);
560 virtual void reduce(
float*,
int n, GrpReduce<float>&,
561 float*scratch = 0,
int target = -1);
562 virtual void reduce(
long*,
int n, GrpReduce<long>&,
563 long*scratch = 0,
int target = -1);
564 void reduce(
double& data, GrpReduce<double>& r) {
reduce(&data, 1, r); }
565 void reduce(
int& data, GrpReduce<int>& r) {
reduce(&data, 1, r); }
581 int classdesc_to_index(
const ClassDesc*);
582 const ClassDesc* index_to_classdesc(
int);
583 int nclass()
const {
return nclass_; }
604 void sendit(
message_t *& messages,
int dest,
int msgtype,
const void* buf,
int bytes);
605 void recvit(
message_t *& messages,
int source,
int type,
void* buf,
int bytes,
606 int& last_size,
int& last_type);
617 void raw_send(
int target,
const void* data,
int nbyte);
618 void raw_sendt(
int target,
int type,
const void* data,
int nbyte,
620 void raw_recv(
int sender,
void* data,
int nbyte,
622 void raw_recvt(
int sender,
int type,
void* data,
int nbyte,
624 void raw_bcast(
void* data,
int nbyte,
int from);
626 void raw_nb_sendt(
int sender,
int type,
627 const void* data,
int nbyte,
630 void raw_nb_recvt(
int sender,
int type,
631 void* data,
int nbyte,
642 #include <util/group/messaget.h>
static MessageGrp * get_default_messagegrp()
Returns the default message group.
void send(int target, double data)
This sends a single double datum.
Definition: message.h:249
virtual Ref< MessageGrp > clone(void)=0
Returns a copy of this MessageGrp specialization that provides an independent communication context.
void send(int target, int data)
This sends a single integer datum.
Definition: message.h:251
virtual ~MessageGrp()
Destroy this MessageGrp.
Definition: message.h:135
A template class that maintains references counts.
Definition: ref.h:361
void nb_recvt(int sender, int type, double &data, MessageHandle &handle)
This receives a single double datum.
Definition: message.h:445
Definition: message.h:109
void sendt(int target, int type, double data, bool rcvrdy=false)
This sends a single double datum.
Definition: message.h:282
Ref< MessageGrp > subset(const std::set< int > &)
Returns MessageGrp objects that are a subset of this MessageGrp.
This class is used to contain information about classes.
Definition: class.h:147
int me()
Returns my processor number. In the range [0,n()).
Definition: message.h:194
int probet(int sender, int type, MessageInfo *info=0)
Ask if a given typed message has been received.
void wait(const MessageHandle &, MessageInfo *info=0)
Wait for an operation to complete.
int n()
Returns the number of processors.
Definition: message.h:192
static void set_default_messagegrp(const Ref< MessageGrp > &)
The default message group contains the primary message group to be used by an application.
void recv(int sender, int &data)
This receives a single integer datum.
Definition: message.h:309
Ref< MachineTopology > topology()
Return the MachineTopology object.
Definition: message.h:572
Ref< MessageGrp > clone(void)
Returns a copy of this MessageGrp specialization that provides an independent communication context.
Definition: message.h:587
void nb_recvt(int sender, int type, int &data, MessageHandle &handle)
This receives a single integer datum.
Definition: message.h:450
virtual Ref< MessageGrp > subset(const std::set< int > &)=0
Returns MessageGrp objects that are a subset of this MessageGrp.
virtual Ref< MessageGrp > split(int grpkey=0, int rankkey=0)=0
Returns MessageGrp objects that are a subset of this MessageGrp.
Ref< MessageGrp > split(int grpkey=0, int rankkey=0)
Returns MessageGrp objects that are a subset of this MessageGrp.
static MessageGrp * initial_messagegrp(int &argc, char **&argv)
Create a message group.
virtual void sync()
Synchronize all of the processors.
Classes which need runtime information about themselves and their relationship to other classes can v...
Definition: class.h:233
Definition: message.h:122
void recv(int sender, double &data)
This receives a single double datum.
Definition: message.h:307
void sendt(int target, int type, int data, bool rcvrdy=false)
This sends a single integer datum.
Definition: message.h:285
virtual int probet(int sender, int type, MessageInfo *info=0)=0
Ask if a given typed message has been received.
Definition: message.h:103
ProcMessageGrp provides a concrete specialization of MessageGrp that supports only one node.
Definition: message.h:598
void recvt(int sender, int type, int &data)
This receives a single integer datum.
Definition: message.h:335
void initialize(int me, int n)
The classdesc_to_index_ and index_to_classdesc_ arrays cannot be initialized by the MessageGrp CTOR,...
void sync()
Synchronize all of the processors.
void recvt(int sender, int type, double &data)
This receives a single double datum.
Definition: message.h:331
The MessageGrp abstract class provides a mechanism for moving data and objects between nodes in a par...
Definition: message.h:120
Contains all MPQC code up to version 3.
Definition: mpqcin.h:14
void reduce(T *, int n, GrpReduce< T > &, T *scratch=0, int target=-1)
T must be a POD (plain old data) type so that it can be copied bytewise.
Definition: messaget.h:116
virtual void wait(const MessageHandle &handle, MessageInfo *info=0)=0
Wait for an operation to complete.
Generated at Sun Jan 26 2020 23:24:01 for MPQC
3.0.0-alpha using the documentation package Doxygen
1.8.16.