Newer
Older
// ----------------- LHS detectors are subset of RHS, which are Grouped
// --------------------------------------
if (!done) {
// Didn't find it? Now we need to iterate through the output workspace to
// match the detector ID.
// NOTE: This can be SUPER SLOW!
for (rhsWI = 0; rhsWI < static_cast<int64_t>(rhs_nhist); rhsWI++) {
const auto &rhsDets = rhs->getSpectrum(rhsWI).getDetectorIDs();
// Checks that lhsDets is a subset of rhsDets
if (std::includes(rhsDets.begin(), rhsDets.end(), lhsDets.begin(),
lhsDets.end())) {
// This one is right. Now we can stop looking.
Janik Zikovsky
committed
(*table)[lhsWI] = rhsWI;
Janik Zikovsky
committed
}
}
Janik Zikovsky
committed
// ------- Still nothing ! -----------
if (!done) {
(*table)[lhsWI] = -1;
// std::ostringstream mess;
// mess << "BinaryOperation: cannot find a RHS spectrum that
// contains the detectors in LHS workspace index " << lhsWI <<
// "\n";
// throw std::runtime_error(mess.str());
Janik Zikovsky
committed
}
}
return table;
}
Janik Zikovsky
committed
Parallel::ExecutionMode BinaryOperation::getParallelExecutionMode(
const std::map<std::string, Parallel::StorageMode> &storageModes) const {
if (static_cast<bool>(getProperty("AllowDifferentNumberSpectra")))
return Parallel::ExecutionMode::Invalid;
auto lhs = storageModes.find(inputPropName1())->second;
auto rhs = storageModes.find(inputPropName2())->second;
// Two identical modes is ok
if (lhs == rhs)
return getCorrespondingExecutionMode(storageModes.begin()->second);
// Mode <X> times Cloned is ok if the cloned workspace is WorkspaceSingleValue
if (rhs == Parallel::StorageMode::Cloned) {
API::MatrixWorkspace_const_sptr ws = getProperty(inputPropName2());
if (boost::dynamic_pointer_cast<const WorkspaceSingleValue>(ws))
return getCorrespondingExecutionMode(lhs);
}
// Other options are not ok (e.g., MasterOnly times Distributed)
return Parallel::ExecutionMode::Invalid;
}
Peterson, Peter
committed
} // namespace Mantid