forked from AmbaPant/mantid
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Status.h
56 lines (48 loc) · 1.39 KB
/
Status.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2017 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#pragma once
#include "MantidParallel/DllConfig.h"
#include <boost/optional/optional.hpp>
#ifdef MPI_EXPERIMENTAL
#include <boost/mpi/status.hpp>
#endif
namespace Mantid {
namespace Parallel {
namespace detail {
class ThreadingBackend;
}
/** Wrapper for boost::mpi::status. For non-MPI builds an equivalent
implementation is provided.
@author Simon Heybrock
@date 2017
*/
class MANTID_PARALLEL_DLL Status {
public:
#ifdef MPI_EXPERIMENTAL
Status(const boost::mpi::status &status) : m_status(status), m_threadingBackend{false} {}
#endif
template <typename T> boost::optional<int> count() const {
#ifdef MPI_EXPERIMENTAL
if (!m_threadingBackend)
return m_status.count<T>();
#endif
return static_cast<int>(m_size / sizeof(T));
}
private:
Status(const size_t size) : m_size(size) {}
#ifdef MPI_EXPERIMENTAL
boost::mpi::status m_status;
#endif
const size_t m_size{0};
#ifdef MPI_EXPERIMENTAL
bool m_threadingBackend{true};
#endif
// For accessing constructor based on size.
friend class detail::ThreadingBackend;
};
} // namespace Parallel
} // namespace Mantid