32 #ifndef _util_group_message_h
33 #define _util_group_message_h
38 #include <util/class/class.h>
39 #include <util/state/state.h>
40 #include <util/keyval/keyval.h>
41 #include <util/group/topology.h>
49 virtual void reduce(T*target, T*data,
int n) = 0;
56 void reduce(T*target, T*data,
int nelement);
63 void reduce(T*target, T*data,
int nelement);
70 void reduce(T*target, T*data,
int nelement);
76 void reduce(T*target, T*data,
int nelement);
82 void reduce(T*target, T*data,
int nelement);
88 void reduce(T*target, T*data,
int nelement);
94 void reduce(T*target, T*data,
int nelement);
100 void (*func_)(T*target,T*data,
int nelement);
103 void reduce(T*target, T*data,
int nelement);
116 std::map<ClassDescP,int> classdesc_to_index_;
136 int n() {
return n_; }
138 int me() {
return me_; }
160 virtual void send(
int target,
const double* data,
int ndata);
161 virtual void send(
int target,
const unsigned int* data,
int ndata);
162 virtual void send(
int target,
const int* data,
int ndata);
163 virtual void send(
int target,
const char* data,
int nbyte);
164 virtual void send(
int target,
const unsigned char* data,
int nbyte);
165 virtual void send(
int target,
const signed char* data,
int nbyte);
166 virtual void send(
int target,
const short* data,
int ndata);
167 virtual void send(
int target,
const long* data,
int ndata);
168 virtual void send(
int target,
const float* data,
int ndata);
169 void send(
int target,
double data) {
send(target,&data,1); }
170 void send(
int target,
int data) {
send(target,&data,1); }
171 virtual void raw_send(
int target,
const void* data,
int nbyte) = 0;
175 virtual void sendt(
int target,
int type,
const double* data,
int ndata);
176 virtual void sendt(
int target,
int type,
const unsigned int* data,
int ndata);
177 virtual void sendt(
int target,
int type,
const int* data,
int ndata);
178 virtual void sendt(
int target,
int type,
const char* data,
int nbyte);
179 virtual void sendt(
int target,
int type,
const unsigned char* data,
int nbyte);
180 virtual void sendt(
int target,
int type,
const signed char* data,
int nbyte);
181 virtual void sendt(
int target,
int type,
const short* data,
int ndata);
182 virtual void sendt(
int target,
int type,
const long* data,
int ndata);
183 virtual void sendt(
int target,
int type,
const float* data,
int ndata);
184 void sendt(
int target,
int type,
double data) {
sendt(target,type,&data,1);}
185 void sendt(
int target,
int type,
int data) {
sendt(target,type,&data,1);}
186 virtual void raw_sendt(
int target,
int type,
const void* data,
int nbyte) = 0;
190 virtual void recv(
int sender,
double* data,
int ndata);
191 virtual void recv(
int sender,
unsigned int* data,
int ndata);
192 virtual void recv(
int sender,
int* data,
int ndata);
193 virtual void recv(
int sender,
char* data,
int nbyte);
194 virtual void recv(
int sender,
unsigned char* data,
int nbyte);
195 virtual void recv(
int sender,
signed char* data,
int nbyte);
196 virtual void recv(
int sender,
short* data,
int ndata);
197 virtual void recv(
int sender,
long* data,
int ndata);
198 virtual void recv(
int sender,
float* data,
int ndata);
199 void recv(
int sender,
double& data) {
recv(sender,&data,1); }
200 void recv(
int sender,
int& data) {
recv(sender,&data,1); }
201 virtual void raw_recv(
int sender,
void* data,
int nbyte) = 0;
205 virtual void recvt(
int type,
double* data,
int ndata);
206 virtual void recvt(
int type,
unsigned int* data,
int ndata);
207 virtual void recvt(
int type,
int* data,
int ndata);
208 virtual void recvt(
int type,
char* data,
int nbyte);
209 virtual void recvt(
int type,
unsigned char* data,
int nbyte);
210 virtual void recvt(
int type,
signed char* data,
int nbyte);
211 virtual void recvt(
int type,
short* data,
int ndata);
212 virtual void recvt(
int type,
long* data,
int ndata);
213 virtual void recvt(
int type,
float* data,
int ndata);
214 void recvt(
int type,
double& data) {
recvt(type,&data,1); }
215 void recvt(
int type,
int& data) {
recvt(type,&data,1); }
216 virtual void raw_recvt(
int type,
void* data,
int nbyte) = 0;
219 virtual int probet(
int type) = 0;
223 virtual void bcast(
double* data,
int ndata,
int from = 0);
224 virtual void bcast(
unsigned int* data,
int ndata,
int from = 0);
225 virtual void bcast(
int* data,
int ndata,
int from = 0);
226 virtual void bcast(
char* data,
int nbyte,
int from = 0);
227 virtual void bcast(
unsigned char* data,
int nbyte,
int from = 0);
228 virtual void bcast(
signed char* data,
int nbyte,
int from = 0);
229 virtual void bcast(
short* data,
int ndata,
int from = 0);
230 virtual void bcast(
long* data,
int ndata,
int from = 0);
231 virtual void bcast(
float* data,
int ndata,
int from = 0);
232 virtual void raw_bcast(
void* data,
int nbyte,
int from = 0);
233 void bcast(
double& data,
int from = 0) {
bcast(&data, 1, from); }
234 void bcast(
int& data,
int from = 0) {
bcast(&data, 1, from); }
238 virtual void raw_collect(
const void *part,
const int *lengths,
239 void *whole,
int bytes_per_datum=1);
240 void collect(
const double *part,
const int *lengths,
double *whole);
244 virtual void sum(
double* data,
int n,
double* = 0,
int target = -1);
245 virtual void sum(
unsigned int* data,
int n,
unsigned int* = 0,
int target = -1);
246 virtual void sum(
int* data,
int n,
int* = 0,
int target = -1);
247 virtual void sum(
char* data,
int n,
char* = 0,
int target = -1);
248 virtual void sum(
unsigned char* data,
int n,
249 unsigned char* = 0,
int target = -1);
250 virtual void sum(
signed char* data,
int n,
251 signed char* = 0,
int target = -1);
252 void sum(
double& data) {
sum(&data, 1); }
253 void sum(
int& data) {
sum(&data, 1); }
256 virtual void max(
double* data,
int n,
double* = 0,
int target = -1);
257 virtual void max(
int* data,
int n,
int* = 0,
int target = -1);
258 virtual void max(
unsigned int* data,
int n,
unsigned int* = 0,
int target = -1);
259 virtual void max(
char* data,
int n,
char* = 0,
int target = -1);
260 virtual void max(
unsigned char* data,
int n,
261 unsigned char* = 0,
int target = -1);
262 virtual void max(
signed char* data,
int n,
263 signed char* = 0,
int target = -1);
264 void max(
double& data) {
max(&data, 1); }
265 void max(
int& data) {
max(&data, 1); }
268 virtual void min(
double* data,
int n,
double* = 0,
int target = -1);
269 virtual void min(
int* data,
int n,
int* = 0,
int target = -1);
270 virtual void min(
unsigned int* data,
int n,
unsigned int* = 0,
int target = -1);
271 virtual void min(
char* data,
int n,
char* = 0,
int target = -1);
272 virtual void min(
unsigned char* data,
int n,
273 unsigned char* = 0,
int target = -1);
274 virtual void min(
signed char* data,
int n,
275 signed char* = 0,
int target = -1);
276 void min(
double& data) {
min(&data, 1); }
277 void min(
int& data) {
min(&data, 1); }
280 virtual void reduce(
double*,
int n, GrpReduce<double>&,
281 double*scratch = 0,
int target = -1);
282 virtual void reduce(
int*,
int n, GrpReduce<int>&,
283 int*scratch = 0,
int target = -1);
284 virtual void reduce(
unsigned int*,
int n, GrpReduce<unsigned int>&,
285 unsigned int*scratch = 0,
int target = -1);
286 virtual void reduce(
char*,
int n, GrpReduce<char>&,
287 char*scratch = 0,
int target = -1);
288 virtual void reduce(
unsigned char*,
int n, GrpReduce<unsigned char>&,
289 unsigned char*scratch = 0,
int target = -1);
290 virtual void reduce(
signed char*,
int n, GrpReduce<signed char>&,
291 signed char*scratch = 0,
int target = -1);
292 virtual void reduce(
short*,
int n, GrpReduce<short>&,
293 short*scratch = 0,
int target = -1);
294 virtual void reduce(
float*,
int n, GrpReduce<float>&,
295 float*scratch = 0,
int target = -1);
296 virtual void reduce(
long*,
int n, GrpReduce<long>&,
297 long*scratch = 0,
int target = -1);
298 void reduce(
double& data, GrpReduce<double>& r) {
reduce(&data, 1, r); }
299 void reduce(
int& data, GrpReduce<int>& r) {
reduce(&data, 1, r); }
313 const ClassDesc* index_to_classdesc(
int);
314 int nclass()
const {
return nclass_; }
334 void sendit(
message_t *& messages,
int dest,
int msgtype,
const void* buf,
int bytes);
335 void recvit(
message_t *& messages,
int source,
int type,
void* buf,
int bytes,
336 int& last_size,
int& last_type);
345 void raw_send(
int target,
const void* data,
int nbyte);
346 void raw_sendt(
int target,
int type,
const void* data,
int nbyte);
347 void raw_recv(
int sender,
void* data,
int nbyte);
348 void raw_recvt(
int type,
void* data,
int nbyte);
349 void raw_bcast(
void* data,
int nbyte,
int from);
378 int msgtype_typ(
int msgtype);
379 int typ_msgtype(
int usrtype);
380 int seq_msgtype(
int source,
int seq);
387 virtual void basic_send(
int target,
int type,
const void* data,
int nbyte) = 0;
389 virtual void basic_recv(
int type,
void* data,
int nbyte) = 0;
396 void initialize(
int me,
int n,
int nbits);
400 void raw_send(
int target,
const void* data,
int nbyte);
401 void raw_recv(
int sender,
void* data,
int nbyte);
402 void raw_sendt(
int target,
int type,
const void* data,
int nbyte);
403 void raw_recvt(
int type,
void* data,
int nbyte);
407 int leftover_ctl_bits();
412 #include <util/group/messaget.h>
static MessageGrp * get_default_messagegrp()
Returns the default message group.
int probet(int)
Ask if a given typed message has been received.
virtual Ref< MessageGrp > clone(void)=0
Returns a copy of this MessageGrp specialization that provides an independent communication context.
virtual void min(double *data, int n, double *=0, int target=-1)
Global minimization.
A template class that maintains references counts.
Definition: ref.h:332
int probet(int type)
Ask if a given typed message has been received.
Uses integer message types to send and receive messages.
Definition: message.h:358
virtual int basic_probe(int type)=0
Must be implemented by specializations.
virtual void sum(double *data, int n, double *=0, int target=-1)
Global sum reduction.
This class is used to contain information about classes.
Definition: class.h:158
int me()
Returns my processor number. In the range [0,n()).
Definition: message.h:138
virtual int probet(int type)=0
Ask if a given typed message has been received.
int n()
Returns the number of processors.
Definition: message.h:136
virtual void recv(int sender, double *data, int ndata)
Receive messages sent sequentually from the sender.
static void set_default_messagegrp(const Ref< MessageGrp > &)
The default message group contains the primary message group to be used by an application.
Ref< MachineTopology > topology()
Return the MachineTopology object.
Definition: message.h:305
Ref< MessageGrp > clone(void)
Returns a copy of this MessageGrp specialization that provides an independent communication context.
Definition: message.h:317
virtual void raw_collect(const void *part, const int *lengths, void *whole, int bytes_per_datum=1)
Collect data distributed on the nodes to a big array replicated on each node.
virtual void reduce(double *, int n, GrpReduce< double > &, double *scratch=0, int target=-1)
Global generic reduction.
static MessageGrp * initial_messagegrp(int &argc, char **&argv)
Create a message group.
virtual void basic_send(int target, int type, const void *data, int nbyte)=0
Must be implemented by specializations.
virtual void max(double *data, int n, double *=0, int target=-1)
Global maximization.
int classdesc_to_index(const ClassDesc *)
Each message group maintains an association of ClassDesc with a global index so SavableState informat...
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:244
virtual void bcast(double *data, int ndata, int from=0)
Do broadcasts of various types of data.
virtual void sendt(int target, int type, const double *data, int ndata)
Send typed messages to the target processor.
ProcMessageGrp provides a concrete specialization of MessageGrp that supports only one node.
Definition: message.h:328
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.
The MessageGrp abstract class provides a mechanism for moving data and objects between nodes in a par...
Definition: message.h:109
virtual void basic_recv(int type, void *data, int nbyte)=0
Must be implemented by specializations.
virtual void recvt(int type, double *data, int ndata)
Receive messages sent by type.
virtual void send(int target, const double *data, int ndata)
Send messages sequentially to the target processor.
Generated at Sun Jan 26 2020 23:33:04 for MPQC
2.3.1 using the documentation package Doxygen
1.8.16.