MPQC  2.3.1
messmpi.h
1 //
2 // messmpi.h
3 //
4 // Copyright (C) 1996 Limit Point Systems, Inc.
5 //
6 // Author: Curtis Janssen <cljanss@limitpt.com>
7 // Maintainer: LPS
8 //
9 // This file is part of the SC Toolkit.
10 //
11 // The SC Toolkit is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU Library General Public License as published by
13 // the Free Software Foundation; either version 2, or (at your option)
14 // any later version.
15 //
16 // The SC Toolkit is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU Library General Public License for more details.
20 //
21 // You should have received a copy of the GNU Library General Public License
22 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
23 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24 //
25 // The U.S. Government is granted a limited license as per AL 91-7.
26 //
27 
28 #ifndef _util_group_messmpi_h
29 #define _util_group_messmpi_h
30 
31 #include <util/group/message.h>
32 #include <util/group/thread.h>
33 
34 #define MPICH_SKIP_MPICXX
35 #include <mpi.h>
36 
37 namespace sc {
38 
41 class MPIMessageGrp: public MessageGrp {
42  protected:
43  void* buf;
44  int bufsize;
45 
46  int rnode;
47  int rtag;
48  int rlen;
49 
52 
54  static int nmpi_grps;
57 
58  Ref<ThreadGrp> threadgrp;
60  MPI_Comm commgrp;
61 
63  void init(MPI_Comm comm, int *argc=0, char ***argv=0);
64  public:
65  MPIMessageGrp();
68  MPIMessageGrp(MPI_Comm comm);
72  MPIMessageGrp(int *argc, char ***argv);
74  MPIMessageGrp(const Ref<KeyVal>&);
75  ~MPIMessageGrp();
76 
78  Ref<MessageGrp> clone(void);
79 
80  void raw_send(int target, const void* data, int nbyte);
81  void raw_recv(int sender, void* data, int nbyte);
82  void raw_sendt(int target, int type, const void* data, int nbyte);
83  void raw_recvt(int type, void* data, int nbyte);
84 
85  int probet(int type);
86 
87  void sync();
88 
89  void sum(double*, int n, double*scratch = 0, int target = -1);
90  void sum(int*, int n, int*scratch = 0, int target = -1);
91 
92  void reduce(double*, int n, GrpReduce<double>&,
93  double*scratch = 0, int target = -1);
94  void reduce(unsigned int*, int n, GrpReduce<unsigned int>&,
95  unsigned int*scratch = 0, int target = -1);
96  void reduce(int*, int n, GrpReduce<int>&,
97  int*scratch = 0, int target = -1);
98  void reduce(char*, int n, GrpReduce<char>&,
99  char*scratch = 0, int target = -1);
100  void reduce(unsigned char*, int n, GrpReduce<unsigned char>&,
101  unsigned char*scratch = 0, int target = -1);
102  void reduce(signed char*, int n, GrpReduce<signed char>&,
103  signed char*scratch = 0, int target = -1);
104  void reduce(short*, int n, GrpReduce<short>&,
105  short*scratch = 0, int target = -1);
106  void reduce(float*, int n, GrpReduce<float>&,
107  float*scratch = 0, int target = -1);
108  void reduce(long*, int n, GrpReduce<long>&,
109  long*scratch = 0, int target = -1);
110 
111  void raw_bcast(void* data, int nbyte, int from);
112 };
113 
114 }
115 
116 #endif
117 
118 // Local Variables:
119 // mode: c++
120 // c-file-style: "CLJ"
121 // End:
sc::MPIMessageGrp::use_messagegrp_collectives_
bool use_messagegrp_collectives_
If true use the generic collective routines in the base class.
Definition: messmpi.h:51
sc::Ref
A template class that maintains references counts.
Definition: ref.h:332
sc::MPIMessageGrp::clone
Ref< MessageGrp > clone(void)
Clones (dups) an MPIMessageGrp from MPI_COMM_WORLD.
sc::MPIMessageGrp::nmpi_grps
static int nmpi_grps
Number of MPIMessageGrp's currently in use.
Definition: messmpi.h:54
sc::GrpReduce
Definition: message.h:46
sc::MPIMessageGrp::sync
void sync()
Synchronize all of the processors.
sc::MessageGrp::n
int n()
Returns the number of processors.
Definition: message.h:136
sc::MPIMessageGrp::init
void init(MPI_Comm comm, int *argc=0, char ***argv=0)
Not thread-safe due to race condition on nmpi_grps variable.
sc::MPIMessageGrp::sum
void sum(double *, int n, double *scratch=0, int target=-1)
Global sum reduction.
sc::MPIMessageGrp
The MPIMessageGrp class is an concrete implementation of MessageGrp that uses the MPI 1 library.
Definition: messmpi.h:41
sc::MPIMessageGrp::grplock
static Ref< ThreadLock > grplock
lock to access nmpi_grps variable
Definition: messmpi.h:56
sc::MPIMessageGrp::probet
int probet(int type)
Ask if a given typed message has been received.
sc::MPIMessageGrp::reduce
void reduce(double *, int n, GrpReduce< double > &, double *scratch=0, int target=-1)
Global generic reduction.
sc::MessageGrp
The MessageGrp abstract class provides a mechanism for moving data and objects between nodes in a par...
Definition: message.h:109
sc::MPIMessageGrp::commgrp
MPI_Comm commgrp
Currently each commgrp is a dup of MPI_COMM_WORLD.
Definition: messmpi.h:60

Generated at Sun Jan 26 2020 23:33:04 for MPQC 2.3.1 using the documentation package Doxygen 1.8.16.