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
37namespace sc {
38
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:
68 MPIMessageGrp(MPI_Comm comm);
72 MPIMessageGrp(int *argc, char ***argv);
76
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:
Definition message.h:46
The MPIMessageGrp class is an concrete implementation of MessageGrp that uses the MPI 1 library.
Definition messmpi.h:41
MPI_Comm commgrp
Currently each commgrp is a dup of MPI_COMM_WORLD.
Definition messmpi.h:60
MPIMessageGrp(const Ref< KeyVal > &)
Construction MPIMessageGrp given a KeyVal input object.
static int nmpi_grps
Number of MPIMessageGrp's currently in use.
Definition messmpi.h:54
bool use_messagegrp_collectives_
If true use the generic collective routines in the base class.
Definition messmpi.h:51
void init(MPI_Comm comm, int *argc=0, char ***argv=0)
Not thread-safe due to race condition on nmpi_grps variable.
int probet(int type)
Ask if a given typed message has been received.
Ref< MessageGrp > clone(void)
Clones (dups) an MPIMessageGrp from MPI_COMM_WORLD.
void sum(double *, int n, double *scratch=0, int target=-1)
Global sum reduction.
MPIMessageGrp(MPI_Comm comm)
Use an MPI communicator to create a MessageGrp.
static Ref< ThreadLock > grplock
lock to access nmpi_grps variable
Definition messmpi.h:56
void sync()
Synchronize all of the processors.
void reduce(double *, int n, GrpReduce< double > &, double *scratch=0, int target=-1)
Global generic reduction.
MPIMessageGrp(int *argc, char ***argv)
Use argc and argv to create a MPIMessageGrp.
The MessageGrp abstract class provides a mechanism for moving data and objects between nodes in a par...
Definition message.h:109
int n()
Returns the number of processors.
Definition message.h:136
A template class that maintains references counts.
Definition ref.h:332

Generated at Thu Jul 20 2023 00:00:00 for MPQC 2.3.1 using the documentation package Doxygen 1.9.8.