Status.h 1.36 KB
Newer Older
1
2
3
4
5
6
// 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
// SPDX - License - Identifier: GPL - 3.0 +
7
#pragma once
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

#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
31
32
  Status(const boost::mpi::status &status)
      : m_status(status), m_threadingBackend{false} {}
33
34
35
36
37
38
39
40
41
42
43
#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:
44
  Status(const size_t size) : m_size(size) {}
45
46
47
48
#ifdef MPI_EXPERIMENTAL
  boost::mpi::status m_status;
#endif
  const size_t m_size{0};
49
50
51
#ifdef MPI_EXPERIMENTAL
  bool m_threadingBackend{true};
#endif
52
53
54
55
56
57
  // For accessing constructor based on size.
  friend class detail::ThreadingBackend;
};

} // namespace Parallel
} // namespace Mantid