forked from AmbaPant/mantid
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Nonblocking.h
43 lines (37 loc) · 1.33 KB
/
Nonblocking.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
// 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 "MantidParallel/Request.h"
#ifdef MPI_EXPERIMENTAL
#include <boost/mpi/nonblocking.hpp>
#endif
namespace Mantid {
namespace Parallel {
/** Wrapper for boost::mpi::nonblocking. For non-MPI builds an equivalent
implementation with reduced functionality is provided.
@author Simon Heybrock
@date 2017
*/
template <typename ForwardIterator> void wait_all(ForwardIterator begin, ForwardIterator end) {
#ifdef MPI_EXPERIMENTAL
class RequestIteratorWrapper : public ForwardIterator {
public:
RequestIteratorWrapper(const ForwardIterator &it) : ForwardIterator(it) {}
boost::mpi::request &operator*() { return ForwardIterator::operator*(); }
boost::mpi::request *operator->() { return &operator*(); }
};
if (begin == end || !begin->hasBackend())
return boost::mpi::wait_all(RequestIteratorWrapper(begin), RequestIteratorWrapper(end));
#endif
while (begin != end) {
(*begin).wait();
++begin;
}
}
} // namespace Parallel
} // namespace Mantid