MPQC 3.0.0-alpha
Loading...
Searching...
No Matches
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 OMPI_SKIP_MPICXX
35#define MPICH_SKIP_MPICXX
36#include <mpi.h>
37
38namespace sc {
39
43 protected:
44 void* buf;
45 int bufsize;
46
49
51 static int nmpi_grps;
56 static bool mpi_init_called;
57
58 Ref<ThreadGrp> threadgrp;
60 MPI_Comm commgrp;
61
63 void init(MPI_Comm comm, int *argc=0, char ***argv=0);
64
66 public:
67 MPI_Request req;
68 size_t nbyte;
69 MessageHandleData(size_t n): nbyte(n) {}
70 };
71 public:
75 MPIMessageGrp(MPI_Comm comm);
79 MPIMessageGrp(int *argc, char ***argv);
83
86 Ref<MessageGrp> split(int grpkey=0, int rankkey=0);
87 Ref<MessageGrp> subset(const std::set<int> &);
88
89 void raw_send(int target, const void* data, int nbyte);
90 void raw_recv(int sender, void* data, int nbyte,
91 MessageInfo *info=0);
92 void raw_sendt(int target, int type, const void* data, int nbyte,
93 bool rcvrdy=false);
94 void raw_recvt(int sender, int type, void* data, int nbyte,
95 MessageInfo *info=0);
96
97 int probet(int sender, int type, MessageInfo *info=0);
98
99 void sync();
100
101 void sum(double*, int n, double*scratch = 0, int target = -1);
102 void sum(int*, int n, int*scratch = 0, int target = -1);
103
104 void reduce(double*, int n, GrpReduce<double>&,
105 double*scratch = 0, int target = -1);
106 void reduce(unsigned int*, int n, GrpReduce<unsigned int>&,
107 unsigned int*scratch = 0, int target = -1);
108 void reduce(int*, int n, GrpReduce<int>&,
109 int*scratch = 0, int target = -1);
110 void reduce(char*, int n, GrpReduce<char>&,
111 char*scratch = 0, int target = -1);
112 void reduce(unsigned char*, int n, GrpReduce<unsigned char>&,
113 unsigned char*scratch = 0, int target = -1);
114 void reduce(signed char*, int n, GrpReduce<signed char>&,
115 signed char*scratch = 0, int target = -1);
116 void reduce(short*, int n, GrpReduce<short>&,
117 short*scratch = 0, int target = -1);
118 void reduce(float*, int n, GrpReduce<float>&,
119 float*scratch = 0, int target = -1);
120 void reduce(long*, int n, GrpReduce<long>&,
121 long*scratch = 0, int target = -1);
122
123 void raw_nb_sendt(int sender, int type,
124 const void* data, int nbyte,
126 bool rcvrdy=false);
127 void raw_nb_recvt(int sender, int type,
128 void* data, int nbyte,
130 void wait(const MessageHandle&,
131 MessageInfo *info=0);
132
133 void raw_bcast(void* data, int nbyte, int from);
134};
135
136}
137
138#endif
139
140// Local Variables:
141// mode: c++
142// c-file-style: "CLJ"
143// End:
Definition message.h:43
The MPIMessageGrp class is an concrete implementation of MessageGrp that uses the MPI 1 library.
Definition messmpi.h:42
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:51
bool use_messagegrp_collectives_
If true use the generic collective routines in the base class.
Definition messmpi.h:48
void init(MPI_Comm comm, int *argc=0, char ***argv=0)
Not thread-safe due to race condition on nmpi_grps variable.
Ref< MessageGrp > split(int grpkey=0, int rankkey=0)
Returns MessageGrp objects that are a subset of this MessageGrp.
Ref< MessageGrp > clone(void)
Clones (dups) an MPIMessageGrp from MPI_COMM_WORLD.
static ThreadLock * grplock
lock to access nmpi_grps variable
Definition messmpi.h:54
void wait(const MessageHandle &, MessageInfo *info=0)
Wait for an operation to complete.
Ref< MessageGrp > subset(const std::set< int > &)
Returns MessageGrp objects that are a subset of this MessageGrp.
MPIMessageGrp(MPI_Comm comm)
Use an MPI communicator to create a MessageGrp.
static bool mpi_init_called
Was MPI_Init called by one of MPIMessagrGrp? Will also call MPI_Finalize, if so.
Definition messmpi.h:56
int probet(int sender, int type, MessageInfo *info=0)
Ask if a given typed message has been received.
void sync()
Synchronize all of the processors.
MPIMessageGrp(int *argc, char ***argv)
Use argc and argv to create a MPIMessageGrp.
Definition message.h:135
Definition message.h:122
The MessageGrp abstract class provides a mechanism for moving data and objects between nodes in a par...
Definition message.h:120
int n()
Returns the number of processors.
Definition message.h:192
A template class that maintains references counts.
Definition ref.h:361
The ThreadLock abstract class provides mutex locks to be used in conjunction with ThreadGrp's.
Definition thread.h:40
Contains all MPQC code up to version 3.
Definition mpqcin.h:14

Generated at Wed Sep 25 2024 02:45:30 for MPQC 3.0.0-alpha using the documentation package Doxygen 1.12.0.