DistributedAlgorithm.cpp 1.44 KB
Newer Older
1
2
3
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4
5
//   NScD Oak Ridge National Laboratory, European Spallation Source,
//   Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6
// SPDX - License - Identifier: GPL - 3.0 +
7
#include "MantidAPI/DistributedAlgorithm.h"
8

9
10
#include <algorithm>

11
namespace Mantid::API {
12

Samuel Jones's avatar
Samuel Jones committed
13
14
Parallel::ExecutionMode
DistributedAlgorithm::getParallelExecutionMode(const std::map<std::string, Parallel::StorageMode> &storageModes) const {
15
  using namespace Parallel;
Samuel Jones's avatar
Samuel Jones committed
16
17
18
19
20
21
22
23
  if (std::any_of(storageModes.begin(), storageModes.end(),
                  [](const std::pair<std::string, Parallel::StorageMode> &item) {
                    return item.second == StorageMode::Distributed;
                  })) {
    if (std::any_of(storageModes.begin(), storageModes.end(),
                    [](const std::pair<std::string, Parallel::StorageMode> &item) {
                      return item.second == StorageMode::MasterOnly;
                    }))
24
25
26
      return ExecutionMode::Invalid;
    return ExecutionMode::Distributed;
  }
Samuel Jones's avatar
Samuel Jones committed
27
28
29
30
  if (std::any_of(storageModes.begin(), storageModes.end(),
                  [](const std::pair<std::string, Parallel::StorageMode> &item) {
                    return item.second == StorageMode::MasterOnly;
                  }))
31
32
    return ExecutionMode::MasterOnly;
  return ExecutionMode::Identical;
33
34
}

35
} // namespace Mantid::API