Mantid
Loading...
Searching...
No Matches
ParallelAlgorithm.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
14ParallelAlgorithm::getParallelExecutionMode(const std::map<std::string, Parallel::StorageMode> &storageModes) const {
15 using namespace Parallel;
16 // Match all cloned or empty.
17 if (std::all_of(
18 storageModes.begin(), storageModes.end(),
19 [](const std::pair<std::string, Parallel::StorageMode> &item) { return item.second == StorageMode::Cloned; }))
20 return getCorrespondingExecutionMode(StorageMode::Cloned);
21 // Match all master-only (empty handled earlier).
22 if (std::all_of(storageModes.begin(), storageModes.end(),
23 [](const std::pair<std::string, Parallel::StorageMode> &item) {
24 return item.second == StorageMode::MasterOnly;
25 }))
26 return getCorrespondingExecutionMode(StorageMode::MasterOnly);
27 return ExecutionMode::Invalid;
28}
29
30} // 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.