Mantid
Loading...
Searching...
No Matches
DistributedAlgorithm.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
8
9#include <algorithm>
10
11namespace Mantid::API {
12
13Parallel::ExecutionMode
14DistributedAlgorithm::getParallelExecutionMode(const std::map<std::string, Parallel::StorageMode> &storageModes) const {
15 using namespace Parallel;
16 if (std::any_of(storageModes.begin(), storageModes.end(),
17 [](const std::pair<std::string, Parallel::StorageMode> &item) {
18 return item.second == StorageMode::Distributed;
19 })) {
20 if (std::any_of(storageModes.begin(), storageModes.end(),
21 [](const std::pair<std::string, Parallel::StorageMode> &item) {
22 return item.second == StorageMode::MasterOnly;
23 }))
24 return ExecutionMode::Invalid;
25 return ExecutionMode::Distributed;
26 }
27 if (std::any_of(storageModes.begin(), storageModes.end(),
28 [](const std::pair<std::string, Parallel::StorageMode> &item) {
29 return item.second == StorageMode::MasterOnly;
30 }))
31 return ExecutionMode::MasterOnly;
32 return ExecutionMode::Identical;
33}
34
35} // namespace Mantid::API
Parallel::ExecutionMode getParallelExecutionMode(const std::map< std::string, Parallel::StorageMode > &storageModes) const override
Get correct execution mode based on input storage modes for an MPI run.