communicatorstatus.hh 3.25 KB
Newer Older
1
2
3
4
5
6
7
8
/*
 * @file:   communicatorstatus.hh
 * @author: Jordan P. Lefebvre, lefebvrejp@ornl.gov
 *
 * Created on July 2, 2013, 4:12 PM
 */

#ifndef RADIX_RADIXPARA_COMMUNICATORSTATUS_HH_
9
#define RADIX_RADIXPARA_COMMUNICATORSTATUS_HH_
10
11
#include <memory>

12
#include "radixcore/visibility.hh"
13

14
15
16
#ifdef USE_MPI
#include <mpi.h>
#endif
17
18
19
20
namespace radix
{
namespace Private
{
21
#ifdef USE_MPI
22
23
24
25
/**
 * @class MPICommStatus
 * @brief MPI implementation of {@code CommunicatorStatus}
 */
26
27
class RADIX_PUBLIC MPICommStatus
{
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
 public:
  /**
   * Default constructor
   */
  MPICommStatus();
  /**
   * Initialized constructor
   * @param status <b>MPI_Status</b>
   * @param nsource <b>int</b>
   * @param ntag <b>int</b>
   * @param nerror <b>int</b>
   * @param ntype <b>MPI_Datatype</b>
   */
  MPICommStatus(MPI_Status status, int nsource, int ntag, int nerror,
                MPI_Datatype ntype);
  virtual ~MPICommStatus();

  /**
   * @brief source rank
   * @return <b>int</b>
   */
  virtual int source() const;

  /**
   * @brief associated tag
   * @return <b>int</b>
   */
  virtual int tag() const;

  /**
   * @brief Get error if occurred
   * @return <b>int</b>
   */
  virtual int error() const;

  /**
   * @brief Was the communicator method cancelled
   * @return <b>bool</b>
   */
  virtual bool cancelled() const;

  /**
   * @brief Get number of objects associated with communicator method
   * @return <b>int</b>
   */
  virtual int count() const;

 private:
  MPI_Status d_status;
  int d_source;
  int d_error;
  int d_tag;
  MPI_Datatype d_type;

};     // class MPICommStatus
83
84
#endif /** ifdef USE_MPI **/

85
86
87
88
/**
 * @class SerialCommStatus
 * @brief Serial implementation
 */
89
90
class RADIX_PUBLIC SerialCommStatus
{
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
 public:
  /**
   * Default constructor
   */
  SerialCommStatus();
  virtual ~SerialCommStatus();

  /**
   * @brief source rank
   * @return <b>int</b>
   */
  virtual int source() const;

  /**
   * @brief associated tag
   * @return <b>int</b>
   */
  virtual int tag() const;

  /**
   * @brief Get error if occurred
   * @return <b>int</b>
   */
  virtual int error() const;

  /**
   * @brief Was the communicator method cancelled
   * @return <b>bool</b>
   */
  virtual bool cancelled() const;

  /**
   * @brief Get number of objects associated with communicator method
   * @return <b>int</b>
   */
  virtual int count() const;

 private:
};  // class MPICommStatus
}  // namespace Privatee
131
132
133
134
135

/**
 * @class CommunicatorStatus
 * @brief Interface for Communicator Status implementation
 */
136
#ifdef USE_MPI
137
template <class StatusImpl = Private::MPICommStatus>
138
139
#else

140
template <class StatusImpl = Private::SerialCommStatus>
141
#endif
142
143
class RADIX_PUBLIC CommunicatorStatusImpl : public StatusImpl
{
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
 public:
  /**
   * Default constructor
   */
  CommunicatorStatusImpl();
  /**
   * Copy constructor
   */
  CommunicatorStatusImpl(const StatusImpl &orig);

  /**
   * Default destructor
   */
  virtual ~CommunicatorStatusImpl();

 private:
160
161
162
163
164
165
166
167
168
};
/**
 * Default CommunicatorStatus implementations
 */
typedef CommunicatorStatusImpl<> CommunicatorStatus;
/**
 * typedef std::shared_ptr<CommunicatorStatus>
 */
typedef std::shared_ptr<CommunicatorStatus> SP;
169

170
}  // namespace radix
171
172
173
174
175

//
// Include template implementations
//
#include "radixpara/communicatorstatus.i.hh"
176
#endif /* RADIX_RADIXPARA_COMMUNICATORSTATUS_HH_ */