diff --git a/Framework/Algorithms/src/AbsorptionCorrection.cpp b/Framework/Algorithms/src/AbsorptionCorrection.cpp index 9af5ead1ce262dd342fa70a5cc471b1d9206bd67..6a8e5686d80173e2fca5ad3a4d01e464e98434e1 100644 --- a/Framework/Algorithms/src/AbsorptionCorrection.cpp +++ b/Framework/Algorithms/src/AbsorptionCorrection.cpp @@ -138,7 +138,7 @@ void AbsorptionCorrection::exec() { Progress prog(this, 0.0, 1.0, numHists); // Loop over the spectra - PARALLEL_FOR2(m_inputWS, correctionFactors) + PARALLEL_FOR_IF(Kernel::threadSafe(*m_inputWS, *correctionFactors)) for (int64_t i = 0; i < int64_t(numHists); ++i) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Algorithms/src/ApplyTransmissionCorrection.cpp b/Framework/Algorithms/src/ApplyTransmissionCorrection.cpp index 1dbaf00f3df6a498ad9765bfd1f32ad37962bbbf..469c8d3e8facc26b39593aca19863eb8c08b8a9a 100644 --- a/Framework/Algorithms/src/ApplyTransmissionCorrection.cpp +++ b/Framework/Algorithms/src/ApplyTransmissionCorrection.cpp @@ -89,7 +89,7 @@ void ApplyTransmissionCorrection::exec() { const auto &spectrumInfo = inputWS->spectrumInfo(); // Loop through the spectra and apply correction - PARALLEL_FOR2(inputWS, corrWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *corrWS)) for (int i = 0; i < numHists; i++) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Algorithms/src/CalculateFlatBackground.cpp b/Framework/Algorithms/src/CalculateFlatBackground.cpp index 8e7d06c8edb29f49d50ebbeac2820663fbdfd371..5de0b7ac98b02f3a54af220db72bd67655709175 100644 --- a/Framework/Algorithms/src/CalculateFlatBackground.cpp +++ b/Framework/Algorithms/src/CalculateFlatBackground.cpp @@ -161,7 +161,7 @@ void CalculateFlatBackground::exec() { // the output if (outputWS != inputWS) { outputWS = WorkspaceFactory::Instance().create(inputWS); - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int i = 0; i < numHists; ++i) { PARALLEL_START_INTERUPT_REGION outputWS->setHistogram(i, inputWS->histogram(i)); diff --git a/Framework/Algorithms/src/ChopData.cpp b/Framework/Algorithms/src/ChopData.cpp index a0e9556d92e9f2d8482f3028ec2242412b97502e..3867c52997728d2e30379965465cbccc5e942216 100644 --- a/Framework/Algorithms/src/ChopData.cpp +++ b/Framework/Algorithms/src/ChopData.cpp @@ -129,7 +129,7 @@ void ChopData::exec() { nbins + 1, nbins); // Copy over X, Y and E data - PARALLEL_FOR2(inputWS, workspace) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *workspace)) for (int j = 0; j < nHist; j++) { auto edges = inputWS->binEdges(j); diff --git a/Framework/Algorithms/src/ConvertAxesToRealSpace.cpp b/Framework/Algorithms/src/ConvertAxesToRealSpace.cpp index a04e46808a82c0a1261985acedd7d95352e332ef..b3245bdb626e5836d2beb1d748504348c3b0cf80 100644 --- a/Framework/Algorithms/src/ConvertAxesToRealSpace.cpp +++ b/Framework/Algorithms/src/ConvertAxesToRealSpace.cpp @@ -114,7 +114,7 @@ void ConvertAxesToRealSpace::exec() { const auto &spectrumInfo = summedWs->spectrumInfo(); // for each spectra - PARALLEL_FOR2(summedWs, outputWs) + PARALLEL_FOR_IF(Kernel::threadSafe(*summedWs, *outputWs)) for (int i = 0; i < nHist; ++i) { try { V3D pos = spectrumInfo.position(i); diff --git a/Framework/Algorithms/src/ConvertToMatrixWorkspace.cpp b/Framework/Algorithms/src/ConvertToMatrixWorkspace.cpp index 0b861ef3f2b5bc09be429924d802f1080b731460..41f179a671d1b75ae08e52209b147841d9c50ce1 100644 --- a/Framework/Algorithms/src/ConvertToMatrixWorkspace.cpp +++ b/Framework/Algorithms/src/ConvertToMatrixWorkspace.cpp @@ -48,7 +48,7 @@ void ConvertToMatrixWorkspace::exec() { outputWorkspace = WorkspaceFactory::Instance().create(inputWorkspace); // ...but not the data, so do that here. - PARALLEL_FOR2(inputWorkspace, outputWorkspace) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWorkspace, *outputWorkspace)) for (int64_t i = 0; i < static_cast<int64_t>(numHists); ++i) { PARALLEL_START_INTERUPT_REGION const auto &inSpec = inputWorkspace->getSpectrum(i); diff --git a/Framework/Algorithms/src/CorrectFlightPaths.cpp b/Framework/Algorithms/src/CorrectFlightPaths.cpp index de7c68a877be7138ba47609e74600b76f54faf41..10d156888ce8515aa2e4511053e96bdf5174cee5 100644 --- a/Framework/Algorithms/src/CorrectFlightPaths.cpp +++ b/Framework/Algorithms/src/CorrectFlightPaths.cpp @@ -88,7 +88,7 @@ void CorrectFlightPaths::exec() { // Loop over the histograms (detector spectra) - PARALLEL_FOR2(m_inputWS, m_outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*m_inputWS, *m_outputWS)) for (int64_t i = 0; i < numberOfSpectra_i; ++i) { PARALLEL_START_INTERUPT_REGION m_outputWS->setHistogram(i, m_outputWS->histogram(i)); diff --git a/Framework/Algorithms/src/CorrectKiKf.cpp b/Framework/Algorithms/src/CorrectKiKf.cpp index 96b920a13483768b884f52ee4358c34b4aabbb01..ff2631863c6c486d26ac980df871912395ac77f5 100644 --- a/Framework/Algorithms/src/CorrectKiKf.cpp +++ b/Framework/Algorithms/src/CorrectKiKf.cpp @@ -96,7 +96,7 @@ void CorrectKiKf::exec() { // Get the parameter map const ParameterMap &pmap = outputWS->constInstrumentParameters(); - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int64_t i = 0; i < int64_t(numberOfSpectra); ++i) { PARALLEL_START_INTERUPT_REGION double Efi = 0; diff --git a/Framework/Algorithms/src/CreatePSDBleedMask.cpp b/Framework/Algorithms/src/CreatePSDBleedMask.cpp index 6de7570375a7d6ebf22ce769975839b51a4add86..3c096be5f472d65eaacaf2f4717970b1749f2556 100644 --- a/Framework/Algorithms/src/CreatePSDBleedMask.cpp +++ b/Framework/Algorithms/src/CreatePSDBleedMask.cpp @@ -149,11 +149,10 @@ void CreatePSDBleedMask::exec() { progress.resetNumSteps(numTubes, 0, 1); - PARALLEL_FOR2(inputWorkspace, outputWorkspace) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWorkspace, *outputWorkspace)) for (int i = 0; i < numTubes; ++i) { PARALLEL_START_INTERUPT_REGION - auto current = tubeMap.begin(); - std::advance(current, i); + auto current = std::next(tubeMap.begin(), i); const TubeIndex::mapped_type tubeIndices = current->second; bool mask = performBleedTest(tubeIndices, inputWorkspace, maxRate, numIgnoredPixels); diff --git a/Framework/Algorithms/src/CrossCorrelate.cpp b/Framework/Algorithms/src/CrossCorrelate.cpp index 1edbca628905ae2edab0c522b9787f056ecb1371..27a527d38c44776744bb2bd913dc589e443f7115 100644 --- a/Framework/Algorithms/src/CrossCorrelate.cpp +++ b/Framework/Algorithms/src/CrossCorrelate.cpp @@ -169,7 +169,7 @@ void CrossCorrelate::exec() { // Initialise the progress reporting object out->mutableX(0) = XX; m_progress = new Progress(this, 0.0, 1.0, nspecs); - PARALLEL_FOR2(inputWS, out) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *out)) for (int i = 0; i < nspecs; ++i) // Now loop on all spectra { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Algorithms/src/DetectorEfficiencyCor.cpp b/Framework/Algorithms/src/DetectorEfficiencyCor.cpp index e396a47405e4d66de2705c082ac47205f02445ae..f76796d8070a2a7f5c51ade83d80b9d9f863fcd3 100644 --- a/Framework/Algorithms/src/DetectorEfficiencyCor.cpp +++ b/Framework/Algorithms/src/DetectorEfficiencyCor.cpp @@ -121,7 +121,7 @@ void DetectorEfficiencyCor::exec() { double numHists_d = static_cast<double>(numHists); const int64_t progStep = static_cast<int64_t>(ceil(numHists_d / 100.0)); - PARALLEL_FOR2(m_inputWS, m_outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*m_inputWS, *m_outputWS)) for (int64_t i = 0; i < numHists; ++i) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Algorithms/src/DetectorEfficiencyCorUser.cpp b/Framework/Algorithms/src/DetectorEfficiencyCorUser.cpp index 6e63ff725907a90dee7db76ab03d66233c37abfb..0268ca3fdd3d4780822097e0c2b547db6e9db673 100644 --- a/Framework/Algorithms/src/DetectorEfficiencyCorUser.cpp +++ b/Framework/Algorithms/src/DetectorEfficiencyCorUser.cpp @@ -76,7 +76,7 @@ void DetectorEfficiencyCorUser::exec() { static_cast<int64_t>(numberOfSpectra); // cast to make openmp happy // Loop over the histograms (detector spectra) - PARALLEL_FOR2(m_outputWS, m_inputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*m_outputWS, *m_inputWS)) for (int64_t i = 0; i < numberOfSpectra_i; ++i) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Algorithms/src/DiffractionFocussing2.cpp b/Framework/Algorithms/src/DiffractionFocussing2.cpp index b0f6575b90663f62a7d194c09f98be6df3449e85..f35dfe6ff89762178a5025d925f5ada41afde0ae 100644 --- a/Framework/Algorithms/src/DiffractionFocussing2.cpp +++ b/Framework/Algorithms/src/DiffractionFocussing2.cpp @@ -170,9 +170,8 @@ void DiffractionFocussing2::exec() { Progress *prog; prog = new API::Progress(this, 0.2, 1.00, static_cast<int>(totalHistProcess) + nGroups); -#ifndef __APPLE__ - PARALLEL_FOR2(m_matrixInputW, out) -#endif + + PARALLEL_FOR_IF(Kernel::threadSafe(*m_matrixInputW, *out)) for (int outWorkspaceIndex = 0; outWorkspaceIndex < static_cast<int>(m_validGroups.size()); outWorkspaceIndex++) { @@ -181,9 +180,8 @@ void DiffractionFocussing2::exec() { // Get the group auto it = group2xvector.find(group); - group2vectormap::difference_type dif = - std::distance(group2xvector.begin(), it); - auto &Xout = (*it).second; + auto dif = std::distance(group2xvector.begin(), it); + auto &Xout = it->second; // Assign the new X axis only once (i.e when this group is encountered the // first time) diff --git a/Framework/Algorithms/src/ExtractMask.cpp b/Framework/Algorithms/src/ExtractMask.cpp index 31ba189d20e74c34edfa3601752929005814e938..e07e47e7a4aa435e50dcd4986a0d604c64911ef2 100644 --- a/Framework/Algorithms/src/ExtractMask.cpp +++ b/Framework/Algorithms/src/ExtractMask.cpp @@ -74,7 +74,7 @@ void ExtractMask::exec() { MantidVecPtr xValues; xValues.access() = MantidVec(1, 0.0); - PARALLEL_FOR2(inputWS, maskWS) + PARALLEL_FOR_IF(Kernel::threadSafe((*inputWS, *maskWS)) for (int i = 0; i < nHist; ++i) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Algorithms/src/ExtractSpectra.cpp b/Framework/Algorithms/src/ExtractSpectra.cpp index 9581e735c9e85696290aaecc7ecaa8fa43e39800..c2871a39620fa2179458f8cc6313d17cd8aeabd7 100644 --- a/Framework/Algorithms/src/ExtractSpectra.cpp +++ b/Framework/Algorithms/src/ExtractSpectra.cpp @@ -293,7 +293,7 @@ void ExtractSpectra::execEvent() { Progress prog(this, 0.0, 1.0, 2 * m_workspaceIndexList.size()); eventW->sortAll(Mantid::DataObjects::TOF_SORT, &prog); // Loop over the required workspace indices, copying in the desired bins - PARALLEL_FOR2(m_inputWorkspace, outputWorkspace) + PARALLEL_FOR_IF(Kernel::threadSafe(*m_inputWorkspace, *outputWorkspace)) for (int j = 0; j < static_cast<int>(m_workspaceIndexList.size()); ++j) { PARALLEL_START_INTERUPT_REGION auto i = m_workspaceIndexList[j]; diff --git a/Framework/Algorithms/src/He3TubeEfficiency.cpp b/Framework/Algorithms/src/He3TubeEfficiency.cpp index aa3cbf5d2bd85a71de9da557b90c3b9f9f44c1a1..72052a9840aa6095a6aecb00e3dbcf4f004b74b1 100644 --- a/Framework/Algorithms/src/He3TubeEfficiency.cpp +++ b/Framework/Algorithms/src/He3TubeEfficiency.cpp @@ -117,7 +117,7 @@ void He3TubeEfficiency::exec() { std::size_t numHists = this->inputWS->getNumberHistograms(); this->progress = new API::Progress(this, 0.0, 1.0, numHists); - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int i = 0; i < static_cast<int>(numHists); ++i) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Algorithms/src/Integration.cpp b/Framework/Algorithms/src/Integration.cpp index b035bf502efc69fac6a2b829c8584aa3e158b5d1..0e06abbe111e8abc9de45f75ff46614390176744 100644 --- a/Framework/Algorithms/src/Integration.cpp +++ b/Framework/Algorithms/src/Integration.cpp @@ -141,7 +141,7 @@ void Integration::exec() { const bool axisIsNumeric = localworkspace->getAxis(1)->isNumeric(); // Loop over spectra - PARALLEL_FOR2(localworkspace, outputWorkspace) + PARALLEL_FOR_IF(Kernel::threadSafe(*localworkspace, *outputWorkspace)) for (int i = minSpec; i <= maxSpec; ++i) { PARALLEL_START_INTERUPT_REGION // Workspace index on the output diff --git a/Framework/Algorithms/src/MaxMin.cpp b/Framework/Algorithms/src/MaxMin.cpp index 0e8bb126562dcd53cdda890a48a5036491ca9d18..4b8142b6b81858879ee9551b52ff219182355fe6 100644 --- a/Framework/Algorithms/src/MaxMin.cpp +++ b/Framework/Algorithms/src/MaxMin.cpp @@ -88,7 +88,7 @@ void MaxMin::exec() { MaxSpec - MinSpec + 1, 2, 1); Progress progress(this, 0, 1, (MaxSpec - MinSpec + 1)); - PARALLEL_FOR2(localworkspace, outputWorkspace) + PARALLEL_FOR_IF(Kernel::threadSafe(*localworkspace, *outputWorkspace)) // Loop over spectra for (int i = MinSpec; i <= MaxSpec; ++i) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Algorithms/src/MedianDetectorTest.cpp b/Framework/Algorithms/src/MedianDetectorTest.cpp index 98c72be2d0334abec7f1be8b3b136bf130793a8a..ec1dd565999a8f67ebdf5a09de8287e53b247560 100644 --- a/Framework/Algorithms/src/MedianDetectorTest.cpp +++ b/Framework/Algorithms/src/MedianDetectorTest.cpp @@ -314,7 +314,7 @@ int MedianDetectorTest::doDetectorTests( (instrument->getSample() != nullptr)); } - PARALLEL_FOR2(countsWS, maskWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*countsWS, *maskWS)) for (int j = 0; j < static_cast<int>(indexmap.size()); ++j) { std::vector<size_t> hists = indexmap.at(j); double median = medianvec.at(j); diff --git a/Framework/Algorithms/src/ModeratorTzero.cpp b/Framework/Algorithms/src/ModeratorTzero.cpp index 97767babcff63f3da5fb963b2aecb9d08e177fb0..ec95fa9103727b9560d2189bd261952f599f2157 100644 --- a/Framework/Algorithms/src/ModeratorTzero.cpp +++ b/Framework/Algorithms/src/ModeratorTzero.cpp @@ -127,7 +127,7 @@ void ModeratorTzero::exec() { const size_t numHists = static_cast<size_t>(inputWS->getNumberHistograms()); Progress prog(this, 0.0, 1.0, numHists); // report progress of algorithm - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) // iterate over the spectra for (int i = 0; i < static_cast<int>(numHists); ++i) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Algorithms/src/ModeratorTzeroLinear.cpp b/Framework/Algorithms/src/ModeratorTzeroLinear.cpp index 6172b04da5cc1fbbd8dfaec9832f409e28bdcfb9..4790a0452537d2db4837142aaf43d5040c6fc944 100644 --- a/Framework/Algorithms/src/ModeratorTzeroLinear.cpp +++ b/Framework/Algorithms/src/ModeratorTzeroLinear.cpp @@ -131,7 +131,7 @@ void ModeratorTzeroLinear::exec() { // do the shift in X const size_t numHists = inputWS->getNumberHistograms(); Progress prog(this, 0.0, 1.0, numHists); // report progress of algorithm - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int i = 0; i < static_cast<int>(numHists); ++i) { PARALLEL_START_INTERUPT_REGION double t_f, L_i; diff --git a/Framework/Algorithms/src/MonitorEfficiencyCorUser.cpp b/Framework/Algorithms/src/MonitorEfficiencyCorUser.cpp index ee44bc929d7d0ca6d2ed0781b875a609b960bfd0..bb91bd7c334fb828df65f1eb2db31b6694ec0ffc 100644 --- a/Framework/Algorithms/src/MonitorEfficiencyCorUser.cpp +++ b/Framework/Algorithms/src/MonitorEfficiencyCorUser.cpp @@ -72,7 +72,7 @@ void MonitorEfficiencyCorUser::exec() { // Loop over the histograms (detector spectra) double factor = 1 / eff0; - PARALLEL_FOR2(m_outputWS, m_inputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*m_outputWS, *m_inputWS)) for (int64_t i = 0; i < numberOfSpectra_i; ++i) { PARALLEL_START_INTERUPT_REGION m_outputWS->setHistogram(i, m_inputWS->histogram(i) * factor); diff --git a/Framework/Algorithms/src/MultiplyRange.cpp b/Framework/Algorithms/src/MultiplyRange.cpp index 817fd188d40bcd21709f148bdba2081934edc6fa..877e9bb95cbb1194566007a9f8c3424045d9fe2f 100644 --- a/Framework/Algorithms/src/MultiplyRange.cpp +++ b/Framework/Algorithms/src/MultiplyRange.cpp @@ -71,7 +71,7 @@ void MultiplyRange::exec() { const int histogramCount = static_cast<int>(inputWS->getNumberHistograms()); Progress progress(this, 0.0, 1.0, histogramCount); // Loop over spectra - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int i = 0; i < histogramCount; ++i) { PARALLEL_START_INTERUPT_REGION outputWS->setHistogram(i, inputWS->histogram(i)); diff --git a/Framework/Algorithms/src/NormaliseByDetector.cpp b/Framework/Algorithms/src/NormaliseByDetector.cpp index 3b2ff40bd6a2096540dfec48d0f051e1fec91916..91430566a623f1901b009e58ad6f1d990e597cb1 100644 --- a/Framework/Algorithms/src/NormaliseByDetector.cpp +++ b/Framework/Algorithms/src/NormaliseByDetector.cpp @@ -178,7 +178,7 @@ NormaliseByDetector::processHistograms(MatrixWorkspace_sptr inWS) { // Choose between parallel execution and sequential execution then, process // histograms accordingly. if (m_parallelExecution) { - PARALLEL_FOR2(inWS, denominatorWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inWS, *denominatorWS)) for (int wsIndex = 0; wsIndex < static_cast<int>(nHistograms); ++wsIndex) { PARALLEL_START_INTERUPT_REGION this->processHistogram(wsIndex, denominatorWS, inWS, prog); diff --git a/Framework/Algorithms/src/Q1DWeighted.cpp b/Framework/Algorithms/src/Q1DWeighted.cpp index 5f717b8dd3ff8a9210435008eee2eb1543763fd6..e150a7199882a65e8441bfee9aa9f91c33f6737f 100644 --- a/Framework/Algorithms/src/Q1DWeighted.cpp +++ b/Framework/Algorithms/src/Q1DWeighted.cpp @@ -160,7 +160,7 @@ void Q1DWeighted::exec() { const auto &spectrumInfo = inputWS->spectrumInfo(); - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) // Loop over all xLength-1 detector channels // Note: xLength -1, because X is a histogram and has a number of boundaries // equal to the number of detector channels + 1. diff --git a/Framework/Algorithms/src/Qxy.cpp b/Framework/Algorithms/src/Qxy.cpp index 8f5389434b3d5e13f2e3270f4762f3adaabebf7d..8e373a1f6370324eaf651c8ea1b6dcaeb05bf5f9 100644 --- a/Framework/Algorithms/src/Qxy.cpp +++ b/Framework/Algorithms/src/Qxy.cpp @@ -123,9 +123,7 @@ void Qxy::exec() { const auto &spectrumInfo = inputWorkspace->spectrumInfo(); - // PARALLEL_FOR2(inputWorkspace,outputWorkspace) for (int64_t i = 0; i < int64_t(numSpec); ++i) { - // PARALLEL_START_INTERUPT_REGION // Get the pixel relating to this spectrum IDetector_const_sptr det; try { @@ -290,9 +288,7 @@ void Qxy::exec() { prog.report("Calculating Q"); - // PARALLEL_END_INTERUPT_REGION } // loop over all spectra - // PARALLEL_CHECK_INTERUPT_REGION // take sqrt of error weight values // left to be executed here for computational efficiency diff --git a/Framework/Algorithms/src/Rebin.cpp b/Framework/Algorithms/src/Rebin.cpp index 64388219cf672609ce49b1fa75e91050dc9d1845..b7729e557e175382029736f6cf3648e65c2e97db 100644 --- a/Framework/Algorithms/src/Rebin.cpp +++ b/Framework/Algorithms/src/Rebin.cpp @@ -247,7 +247,7 @@ void Rebin::exec() { outputWS->replaceAxis(1, inputWS->getAxis(1)->clone(outputWS.get())); Progress prog(this, 0.0, 1.0, histnumber); - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int hist = 0; hist < histnumber; ++hist) { PARALLEL_START_INTERUPT_REGION // get const references to input Workspace arrays (no copying) diff --git a/Framework/Algorithms/src/Rebin2D.cpp b/Framework/Algorithms/src/Rebin2D.cpp index f1a38bd712b34dd0db9fb87f34706c422c88e7db..dbfe546044780c8b8a512b43091cdfe5947fcc5b 100644 --- a/Framework/Algorithms/src/Rebin2D.cpp +++ b/Framework/Algorithms/src/Rebin2D.cpp @@ -118,7 +118,7 @@ void Rebin2D::exec() { m_progress = boost::shared_ptr<API::Progress>( new API::Progress(this, 0.0, 1.0, nreports)); - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int64_t i = 0; i < static_cast<int64_t>(numYBins); ++i) // signed for openmp { diff --git a/Framework/Algorithms/src/RebinByPulseTimes.cpp b/Framework/Algorithms/src/RebinByPulseTimes.cpp index c52af972f76e499fc824d228c811eb954eeb1ec2..6067ef19a528fb77dabb56e6f105d6caa690d780 100644 --- a/Framework/Algorithms/src/RebinByPulseTimes.cpp +++ b/Framework/Algorithms/src/RebinByPulseTimes.cpp @@ -50,7 +50,7 @@ void RebinByPulseTimes::doHistogramming(IEventWorkspace_sptr inWS, auto x = Kernel::make_cow<HistogramData::HistogramX>(OutXValues_scaled); - PARALLEL_FOR2(inWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inWS, *outputWS)) for (int i = 0; i < histnumber; ++i) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Algorithms/src/RebinByTimeAtSample.cpp b/Framework/Algorithms/src/RebinByTimeAtSample.cpp index e6e0446fb71423397eaf4e00d9ab24dde13efb1e..cb0445ff59620e2e657256eccbde3956477c3e50 100644 --- a/Framework/Algorithms/src/RebinByTimeAtSample.cpp +++ b/Framework/Algorithms/src/RebinByTimeAtSample.cpp @@ -61,7 +61,7 @@ void RebinByTimeAtSample::doHistogramming(IEventWorkspace_sptr inWS, auto x = Kernel::make_cow<HistogramData::HistogramX>(OutXValues_scaled); // Go through all the histograms and set the data - PARALLEL_FOR2(inWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inWS, *outputWS)) for (int i = 0; i < histnumber; ++i) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Algorithms/src/Rebunch.cpp b/Framework/Algorithms/src/Rebunch.cpp index 8dfa51318a3a622a9b4b600db4e88fd76644ca66..a7fb024357b83ea2fd0caa1d28b7c8aff511a834 100644 --- a/Framework/Algorithms/src/Rebunch.cpp +++ b/Framework/Algorithms/src/Rebunch.cpp @@ -79,7 +79,7 @@ void Rebunch::exec() { int progress_step = histnumber / 100; if (progress_step == 0) progress_step = 1; - PARALLEL_FOR2(inputW, outputW) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputW, *outputW)) for (int hist = 0; hist < histnumber; hist++) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Algorithms/src/RemoveBackground.cpp b/Framework/Algorithms/src/RemoveBackground.cpp index b63c667ae70fb79c03c891c067b3e7b6b739d8df..ffc385ad655973ebfbd0d832acd1b1a07b1fbb0b 100644 --- a/Framework/Algorithms/src/RemoveBackground.cpp +++ b/Framework/Algorithms/src/RemoveBackground.cpp @@ -116,7 +116,7 @@ void RemoveBackground::exec() { inPlace, nullifyNegative); Progress prog(this, 0.0, 1.0, histnumber); - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int hist = 0; hist < histnumber; ++hist) { PARALLEL_START_INTERUPT_REGION // get references to output Workspace X-arrays. diff --git a/Framework/Algorithms/src/RemoveExpDecay.cpp b/Framework/Algorithms/src/RemoveExpDecay.cpp index f8b53edef4b398246da4f1d31d4f763fd4408d17..c8e7dc7edffda76138828b1b7d2f6d65ca2f7c58 100644 --- a/Framework/Algorithms/src/RemoveExpDecay.cpp +++ b/Framework/Algorithms/src/RemoveExpDecay.cpp @@ -77,7 +77,7 @@ void MuonRemoveExpDecay::exec() { if (inputWS != outputWS) { // Copy all the Y and E data - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int64_t i = 0; i < int64_t(numSpectra); ++i) { PARALLEL_START_INTERUPT_REGION const auto index = static_cast<size_t>(i); @@ -91,7 +91,7 @@ void MuonRemoveExpDecay::exec() { // Do the specified spectra only int specLength = static_cast<int>(spectra.size()); - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int i = 0; i < specLength; ++i) { PARALLEL_START_INTERUPT_REGION const auto specNum = static_cast<size_t>(spectra[i]); diff --git a/Framework/Algorithms/src/ResampleX.cpp b/Framework/Algorithms/src/ResampleX.cpp index b40eaafee21e290e38ce66b0f60c7772aa4477b6..9e13cdf4d6e483f9aa187ee89ab03b8a6540e016 100644 --- a/Framework/Algorithms/src/ResampleX.cpp +++ b/Framework/Algorithms/src/ResampleX.cpp @@ -340,7 +340,7 @@ void ResampleX::exec() { Progress prog(this, 0.0, 1.0, numSpectra); // do the rebinning - PARALLEL_FOR2(inputEventWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputEventWS, *outputWS)) for (int wkspIndex = 0; wkspIndex < numSpectra; ++wkspIndex) { PARALLEL_START_INTERUPT_REGION BinEdges xValues(0); @@ -375,7 +375,7 @@ void ResampleX::exec() { Progress prog(this, 0.0, 1.0, numSpectra); // Go through all the histograms and set the data - PARALLEL_FOR2(inputEventWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputEventWS, *outputWS)) for (int wkspIndex = 0; wkspIndex < numSpectra; ++wkspIndex) { PARALLEL_START_INTERUPT_REGION @@ -445,7 +445,7 @@ void ResampleX::exec() { outputWS->replaceAxis(1, inputWS->getAxis(1)->clone(outputWS.get())); Progress prog(this, 0.0, 1.0, numSpectra); - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int wkspIndex = 0; wkspIndex < numSpectra; ++wkspIndex) { PARALLEL_START_INTERUPT_REGION // get const references to input Workspace arrays (no copying) diff --git a/Framework/Algorithms/src/ResetNegatives.cpp b/Framework/Algorithms/src/ResetNegatives.cpp index c1e0ce16578e9f3c04cd3a87c725c51bbb25f2ae..5cb840c07c26989c10f8a930c35c0d44e5636639 100644 --- a/Framework/Algorithms/src/ResetNegatives.cpp +++ b/Framework/Algorithms/src/ResetNegatives.cpp @@ -93,7 +93,7 @@ void ResetNegatives::exec() { // generate output workspace - copy X and dY outputWS = API::WorkspaceFactory::Instance().create(inputWS); - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int64_t i = 0; i < nHist; i++) { PARALLEL_START_INTERUPT_REGION const auto index = static_cast<size_t>(i); @@ -138,7 +138,7 @@ inline double fixZero(const double value) { void ResetNegatives::pushMinimum(MatrixWorkspace_const_sptr minWS, MatrixWorkspace_sptr wksp, Progress &prog) { int64_t nHist = minWS->getNumberHistograms(); - PARALLEL_FOR2(wksp, minWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*wksp, *minWS)) for (int64_t i = 0; i < nHist; i++) { PARALLEL_START_INTERUPT_REGION double minValue = minWS->y(i)[0]; @@ -170,7 +170,7 @@ void ResetNegatives::changeNegatives(MatrixWorkspace_const_sptr minWS, MatrixWorkspace_sptr wksp, Progress &prog) { int64_t nHist = wksp->getNumberHistograms(); - PARALLEL_FOR2(minWS, wksp) + PARALLEL_FOR_IF(Kernel::threadSafe(*minWS, *wksp)) for (int64_t i = 0; i < nHist; i++) { PARALLEL_START_INTERUPT_REGION if (minWS->y(i)[0] <= diff --git a/Framework/Algorithms/src/SampleCorrections/MayersSampleCorrection.cpp b/Framework/Algorithms/src/SampleCorrections/MayersSampleCorrection.cpp index 3792bcd460a606fc91a7bb2ce03bc7629ee64e87..8fbb84a2d88f091299dec2f5814c55f6620d355a 100644 --- a/Framework/Algorithms/src/SampleCorrections/MayersSampleCorrection.cpp +++ b/Framework/Algorithms/src/SampleCorrections/MayersSampleCorrection.cpp @@ -101,7 +101,7 @@ void MayersSampleCorrection::exec() { Progress prog(this, 0., 1., nhist); prog.setNotifyStep(0.01); - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int64_t i = 0; i < static_cast<int64_t>(nhist); ++i) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Algorithms/src/ScaleX.cpp b/Framework/Algorithms/src/ScaleX.cpp index f80e8b9b6b18b7fe2e854ec0661add9efcd0e6b4..3f6b646782ef2a14f2365a259fae3db045aca787 100644 --- a/Framework/Algorithms/src/ScaleX.cpp +++ b/Framework/Algorithms/src/ScaleX.cpp @@ -123,7 +123,7 @@ void ScaleX::exec() { } // do the shift in X - PARALLEL_FOR2(inputW, outputW) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputW, *outputW)) for (int i = 0; i < histnumber; ++i) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Algorithms/src/SetUncertainties.cpp b/Framework/Algorithms/src/SetUncertainties.cpp index c50c15891b02cee9508a39646767ded87f85f969..c9c597c01bbd1dafecf30641ca7c8268de08f9a6 100644 --- a/Framework/Algorithms/src/SetUncertainties.cpp +++ b/Framework/Algorithms/src/SetUncertainties.cpp @@ -111,7 +111,7 @@ void SetUncertainties::exec() { const size_t numHists = inputWorkspace->getNumberHistograms(); Progress prog(this, 0.0, 1.0, numHists); - PARALLEL_FOR2(inputWorkspace, outputWorkspace) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWorkspace, *outputWorkspace)) for (int64_t i = 0; i < int64_t(numHists); ++i) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Algorithms/src/SmoothData.cpp b/Framework/Algorithms/src/SmoothData.cpp index 9d29d867e13152106b54091926e0a56565677705..4a70205ccf0a16bb66c4d5f4cb6070022d655e07 100644 --- a/Framework/Algorithms/src/SmoothData.cpp +++ b/Framework/Algorithms/src/SmoothData.cpp @@ -62,7 +62,7 @@ void SmoothData::exec() { WorkspaceFactory::Instance().create(inputWorkspace); Progress progress(this, 0.0, 1.0, inputWorkspace->getNumberHistograms()); - PARALLEL_FOR2(inputWorkspace, outputWorkspace) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWorkspace, *outputWorkspace) // Loop over all the spectra in the workspace for (int i = 0; i < static_cast<int>(inputWorkspace->getNumberHistograms()); ++i) { diff --git a/Framework/Algorithms/src/SmoothNeighbours.cpp b/Framework/Algorithms/src/SmoothNeighbours.cpp index 66ebfbc23b568e7b3ebb6728348d6d1917bdeede..51b23fd3a280764717d1135b602502b2c5a79311 100644 --- a/Framework/Algorithms/src/SmoothNeighbours.cpp +++ b/Framework/Algorithms/src/SmoothNeighbours.cpp @@ -620,7 +620,7 @@ void SmoothNeighbours::execWorkspace2D() { // API::WorkspaceFactory::Instance().initializeFromParent(inWS, outWS, false); // Go through all the output workspace - PARALLEL_FOR2(inWS, outWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inWS, *outWS)) for (int outWIi = 0; outWIi < int(numberOfSpectra); outWIi++) { PARALLEL_START_INTERUPT_REGION @@ -772,7 +772,7 @@ void SmoothNeighbours::execEvent(Mantid::DataObjects::EventWorkspace_sptr ws) { boost::dynamic_pointer_cast<MatrixWorkspace>(outWS)); // Go through all the output workspace - PARALLEL_FOR2(ws, outWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*ws, *outWS)) for (int outWIi = 0; outWIi < int(numberOfSpectra); outWIi++) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Algorithms/src/SofQWNormalisedPolygon.cpp b/Framework/Algorithms/src/SofQWNormalisedPolygon.cpp index 4042592782552a15d5b041f73a1b17e572b8367a..aa3c21d4153c135ca4146956e5820c485d9c9e6d 100644 --- a/Framework/Algorithms/src/SofQWNormalisedPolygon.cpp +++ b/Framework/Algorithms/src/SofQWNormalisedPolygon.cpp @@ -103,7 +103,7 @@ void SofQWNormalisedPolygon::exec() { const auto &X = inputWS->x(0); int emode = m_EmodeProperties.m_emode; - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int64_t i = 0; i < static_cast<int64_t>(nHistos); ++i) // signed for openmp { diff --git a/Framework/Algorithms/src/SofQWPolygon.cpp b/Framework/Algorithms/src/SofQWPolygon.cpp index 1e55da72e902f8f5191a2f815f24a9dec3fdfdba..cceb6adc60c0551f484b3fe66705e59d2dd0ed47 100644 --- a/Framework/Algorithms/src/SofQWPolygon.cpp +++ b/Framework/Algorithms/src/SofQWPolygon.cpp @@ -75,7 +75,7 @@ void SofQWPolygon::exec() { qCalculator = &SofQWPolygon::calculateIndirectQ; } - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int64_t i = 0; i < static_cast<int64_t>(nTheta); ++i) // signed for openmp { diff --git a/Framework/Algorithms/src/SolidAngle.cpp b/Framework/Algorithms/src/SolidAngle.cpp index d9a5464c2230b7620b14154af8839dfe1213446f..06c60b3f0beec950d0d5933363c68bbbe870d71a 100644 --- a/Framework/Algorithms/src/SolidAngle.cpp +++ b/Framework/Algorithms/src/SolidAngle.cpp @@ -101,7 +101,7 @@ void SolidAngle::exec() { Progress prog(this, 0.0, 1.0, numberOfSpectra); // Loop over the histograms (detector spectra) - PARALLEL_FOR2(outputWS, inputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*outputWS, *inputWS)) for (int j = 0; j <= loopIterations; ++j) { PARALLEL_START_INTERUPT_REGION int i = j + m_MinSpec; diff --git a/Framework/Algorithms/src/Stitch1D.cpp b/Framework/Algorithms/src/Stitch1D.cpp index 247c7dc2166e81c8a14e8439537fc3ff4d465c26..eafb16cae72ad334a0feb981e0543e3dc4de337d 100644 --- a/Framework/Algorithms/src/Stitch1D.cpp +++ b/Framework/Algorithms/src/Stitch1D.cpp @@ -60,7 +60,7 @@ MatrixWorkspace_sptr Stitch1D::maskAllBut(int a1, int a2, MatrixWorkspace_sptr &source) { MatrixWorkspace_sptr product = WorkspaceFactory::Instance().create(source); const int histogramCount = static_cast<int>(source->getNumberHistograms()); - PARALLEL_FOR2(source, product) + PARALLEL_FOR_IF(Kernel::threadSafe(*source, *product)) for (int i = 0; i < histogramCount; ++i) { PARALLEL_START_INTERUPT_REGION // Copy over the bin boundaries diff --git a/Framework/Algorithms/src/TOFSANSResolution.cpp b/Framework/Algorithms/src/TOFSANSResolution.cpp index 6ec683c5a0cb5bd4eab2b54f9c968c17b3faaa7d..d5e283b604d5b45e383944bd40dc8fea34f35d4a 100644 --- a/Framework/Algorithms/src/TOFSANSResolution.cpp +++ b/Framework/Algorithms/src/TOFSANSResolution.cpp @@ -131,7 +131,7 @@ void TOFSANSResolution::exec() { const auto &spectrumInfo = reducedWS->spectrumInfo(); const double L1 = spectrumInfo.l1(); - PARALLEL_FOR2(reducedWS, iqWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*reducedWS, *iqWS)) for (int i = 0; i < numberOfSpectra; i++) { PARALLEL_START_INTERUPT_REGION if (!spectrumInfo.hasDetectors(i)) { diff --git a/Framework/Algorithms/src/Transpose.cpp b/Framework/Algorithms/src/Transpose.cpp index 79e77ea269c5e76534fc2aecadfe33ecc59e6c50..2d834bc6c271ca1d4949d77f70e339b8d7eab2ad 100644 --- a/Framework/Algorithms/src/Transpose.cpp +++ b/Framework/Algorithms/src/Transpose.cpp @@ -52,7 +52,7 @@ void Transpose::exec() { Kernel::make_cow<HistogramData::HistogramX>(std::move(newXValues)); Progress progress(this, 0.0, 1.0, newNhist * newYsize); - PARALLEL_FOR2(inputWorkspace, outputWorkspace) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWorkspace, *outputWorkspace)) for (int64_t i = 0; i < static_cast<int64_t>(newNhist); ++i) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Algorithms/src/UnaryOperation.cpp b/Framework/Algorithms/src/UnaryOperation.cpp index ebeb073f94f2a960b36af9c4a95177b9fca049dd..9f62f1e0901bdf3efa007402b261490467a71a71 100644 --- a/Framework/Algorithms/src/UnaryOperation.cpp +++ b/Framework/Algorithms/src/UnaryOperation.cpp @@ -76,7 +76,7 @@ void UnaryOperation::exec() { // Loop over every cell in the workspace, calling the abstract correction // function - PARALLEL_FOR2(in_work, out_work) + PARALLEL_FOR_IF(Kernel::threadSafe(*in_work, *out_work)) for (int64_t i = 0; i < int64_t(numSpec); ++i) { PARALLEL_START_INTERUPT_REGION // Copy the X values over diff --git a/Framework/Algorithms/src/UnwrapSNS.cpp b/Framework/Algorithms/src/UnwrapSNS.cpp index b58faed5ae2051c113b39192cc69c57306370c00..52cb486887e25dbf0f32290855620a7b77fe2df1 100644 --- a/Framework/Algorithms/src/UnwrapSNS.cpp +++ b/Framework/Algorithms/src/UnwrapSNS.cpp @@ -136,7 +136,7 @@ void UnwrapSNS::exec() { const auto &spectrumInfo = m_inputWS->spectrumInfo(); const double L1 = spectrumInfo.l1(); - PARALLEL_FOR2(m_inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*m_inputWS, *outputWS)) for (int workspaceIndex = 0; workspaceIndex < m_numberOfSpectra; workspaceIndex++) { PARALLEL_START_INTERUPT_REGION @@ -199,10 +199,8 @@ void UnwrapSNS::execEvent() { const double L1 = spectrumInfo.l1(); // do the actual work - // PARALLEL_FOR2(m_inputWS, outW) for (int workspaceIndex = 0; workspaceIndex < m_numberOfSpectra; workspaceIndex++) { - // PARALLEL_START_INTERUPT_REGION std::size_t numEvents = outW->getSpectrum(workspaceIndex).getNumberEvents(); double Ld = -1.0; if (spectrumInfo.hasDetectors(workspaceIndex)) @@ -228,9 +226,7 @@ void UnwrapSNS::execEvent() { outW->getSpectrum(workspaceIndex).setTofs(times); } m_progress->report(); - // PARALLEL_END_INTERUPT_REGION } - // PARALLEL_CHECK_INTERUPT_REGION outW->clearMRU(); this->runMaskDetectors(); diff --git a/Framework/Algorithms/src/WorkspaceJoiners.cpp b/Framework/Algorithms/src/WorkspaceJoiners.cpp index c767982fc2b0cd401c90e2f3cd242514c1841b8b..28bb6d13ce98bd6a2af080442b1a454dc57869f8 100644 --- a/Framework/Algorithms/src/WorkspaceJoiners.cpp +++ b/Framework/Algorithms/src/WorkspaceJoiners.cpp @@ -50,7 +50,7 @@ WorkspaceJoiners::execWS2D(API::MatrixWorkspace_const_sptr ws1, // Loop over the input workspaces in turn copying the data into the output one const int64_t &nhist1 = ws1->getNumberHistograms(); - PARALLEL_FOR2(ws1, output) + PARALLEL_FOR_IF(Kernel::threadSafe(*ws1, *output)) for (int64_t i = 0; i < nhist1; ++i) { PARALLEL_START_INTERUPT_REGION auto &outSpec = output->getSpectrum(i); @@ -80,7 +80,7 @@ WorkspaceJoiners::execWS2D(API::MatrixWorkspace_const_sptr ws1, // For second loop we use the offset from the first const int64_t &nhist2 = ws2->getNumberHistograms(); const auto &spectrumInfo = ws2->spectrumInfo(); - PARALLEL_FOR2(ws2, output) + PARALLEL_FOR_IF(Kernel::threadSafe(*ws2, *output)) for (int64_t j = 0; j < nhist2; ++j) { PARALLEL_START_INTERUPT_REGION // The spectrum in the output workspace diff --git a/Framework/Algorithms/src/XDataConverter.cpp b/Framework/Algorithms/src/XDataConverter.cpp index 0e893f24b4234b71befd3205ee5c90fc9778284f..290cc76352d54e4296c88947d73205f3727f8309 100644 --- a/Framework/Algorithms/src/XDataConverter.cpp +++ b/Framework/Algorithms/src/XDataConverter.cpp @@ -61,7 +61,7 @@ void XDataConverter::exec() { outputWS->replaceAxis(1, inputWS->getAxis(1)->clone(outputWS.get())); Progress prog(this, 0.0, 1.0, numSpectra); - PARALLEL_FOR2(inputWS, outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) for (int i = 0; i < int(numSpectra); ++i) { PARALLEL_START_INTERUPT_REGION @@ -102,4 +102,4 @@ void XDataConverter::setXData(API::MatrixWorkspace_sptr outputWS, } } } -} \ No newline at end of file +} diff --git a/Framework/Crystal/src/AnvredCorrection.cpp b/Framework/Crystal/src/AnvredCorrection.cpp index 93b633615f0b5a692de97685291080c0b6c210c6..b475e3df6006340ece9e96b05edb24f070605f74 100644 --- a/Framework/Crystal/src/AnvredCorrection.cpp +++ b/Framework/Crystal/src/AnvredCorrection.cpp @@ -169,7 +169,7 @@ void AnvredCorrection::exec() { Progress prog(this, 0.0, 1.0, numHists); // Loop over the spectra - PARALLEL_FOR2(m_inputWS, correctionFactors) + PARALLEL_FOR_IF(Kernel::threadSafe(*m_inputWS, *correctionFactors)) for (int64_t i = 0; i < int64_t(numHists); ++i) { PARALLEL_START_INTERUPT_REGION @@ -282,7 +282,7 @@ void AnvredCorrection::execEvent() { Progress prog(this, 0.0, 1.0, numHists); // Loop over the spectra - PARALLEL_FOR2(eventW, correctionFactors) + PARALLEL_FOR_IF(Kernel::threadSafe(*eventW, *correctionFactors)) for (int64_t i = 0; i < int64_t(numHists); ++i) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Crystal/src/CentroidPeaks.cpp b/Framework/Crystal/src/CentroidPeaks.cpp index 73ea7b933056ccad9a03baad383bee7d3861d6b5..8f59c8e22a021523f2dc9d87834914d1b4af3bf5 100644 --- a/Framework/Crystal/src/CentroidPeaks.cpp +++ b/Framework/Crystal/src/CentroidPeaks.cpp @@ -87,7 +87,7 @@ void CentroidPeaks::integrate() { int Edge = getProperty("EdgePixels"); Progress prog(this, MinPeaks, 1.0, MaxPeaks); - PARALLEL_FOR2(inWS, peakWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inWS, *peakWS)) for (int i = MinPeaks; i <= MaxPeaks; i++) { PARALLEL_START_INTERUPT_REGION // Get a direct ref to that peak. @@ -223,7 +223,7 @@ void CentroidPeaks::integrateEvent() { int Edge = getProperty("EdgePixels"); Progress prog(this, MinPeaks, 1.0, MaxPeaks); - PARALLEL_FOR2(inWS, peakWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inWS, *peakWS)) for (int i = MinPeaks; i <= MaxPeaks; i++) { PARALLEL_START_INTERUPT_REGION // Get a direct ref to that peak. diff --git a/Framework/Crystal/src/NormaliseVanadium.cpp b/Framework/Crystal/src/NormaliseVanadium.cpp index 08cbfb59c94a774aa0e65298f563e68980e1844d..26423a185c5ccc6cfb9af46a6da47282cb50f6a3 100644 --- a/Framework/Crystal/src/NormaliseVanadium.cpp +++ b/Framework/Crystal/src/NormaliseVanadium.cpp @@ -67,7 +67,7 @@ void NormaliseVanadium::exec() { Progress prog(this, 0.0, 1.0, numHists); // Loop over the spectra - PARALLEL_FOR2(m_inputWS, correctionFactors) + PARALLEL_FOR_IF(Kernel::threadSafe(*m_inputWS, *correctionFactors)) for (int64_t i = 0; i < int64_t(numHists); ++i) { // PARALLEL_START_INTERUPT_REGION //FIXME: Restore diff --git a/Framework/Crystal/src/PeaksIntersection.cpp b/Framework/Crystal/src/PeaksIntersection.cpp index 833a6d292a9b35b48db4d4edf4778d0dd4d2cf87..6051f4e2f2eb80051e983c5c6b8efed4fcb66414 100644 --- a/Framework/Crystal/src/PeaksIntersection.cpp +++ b/Framework/Crystal/src/PeaksIntersection.cpp @@ -104,7 +104,7 @@ void PeaksIntersection::executePeaksIntersection(const bool checkPeakExtents) { } Progress prog(this, 0, 1, 100); - PARALLEL_FOR2(ws, outputWorkspace) + PARALLEL_FOR_IF(Kernel::threadSafe(*ws, *outputWorkspace)) for (int i = 0; i < nPeaks; ++i) { PARALLEL_START_INTERUPT_REGION IPeak *peak = ws->getPeakPtr(i); diff --git a/Framework/CurveFitting/src/Algorithms/ConvertToYSpace.cpp b/Framework/CurveFitting/src/Algorithms/ConvertToYSpace.cpp index 51f88a0f47b3cbf797ed44243c000659f93a46e4..fe99f86d374f3b2d78dec702556751f331c83415 100644 --- a/Framework/CurveFitting/src/Algorithms/ConvertToYSpace.cpp +++ b/Framework/CurveFitting/src/Algorithms/ConvertToYSpace.cpp @@ -196,7 +196,7 @@ void ConvertToYSpace::exec() { const int64_t nreports = nhist; auto progress = boost::make_shared<Progress>(this, 0.0, 1.0, nreports); - PARALLEL_FOR2(m_inputWS, m_outputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*m_inputWS, *m_outputWS)) for (int64_t i = 0; i < nhist; ++i) { PARALLEL_START_INTERUPT_REGION diff --git a/Framework/Kernel/inc/MantidKernel/MultiThreaded.h b/Framework/Kernel/inc/MantidKernel/MultiThreaded.h index 07014cbba03a54ca45dede942876485463bc8b8b..f85c13d73deb5a5fe28f923e839d5d1843651bf2 100644 --- a/Framework/Kernel/inc/MantidKernel/MultiThreaded.h +++ b/Framework/Kernel/inc/MantidKernel/MultiThreaded.h @@ -153,15 +153,6 @@ threadSafe(const Arg &workspace, Args &&... others) { #define PARALLEL_FOR1(workspace1) \ PRAGMA(omp parallel for if ( !workspace1 || workspace1->threadSafe() ) ) -/** Includes code to add OpenMP commands to run the next for loop in parallel. -* Both workspaces are checked to ensure they suitable for multithreaded -*access -* or equal to NULL which is also safe -*/ -#define PARALLEL_FOR2(workspace1, workspace2) \ - PRAGMA(omp parallel for if ( ( !workspace1 || workspace1->threadSafe() ) && \ - ( !workspace2 || workspace2->threadSafe() ) )) - /** Ensures that the next execution line or block is only executed if * there are multple threads execting in this region */ @@ -217,7 +208,6 @@ threadSafe(const Arg &workspace, Args &&... others) { #define PARALLEL_FOR_NOWS_CHECK_FIRSTPRIVATE(variable) #define PARALLEL_FOR_NO_WSP_CHECK_FIRSTPRIVATE2(variable1, variable2) #define PARALLEL_FOR1(workspace1) -#define PARALLEL_FOR2(workspace1, workspace2) #define IF_PARALLEL if (false) #define IF_NOT_PARALLEL #define PARALLEL_CRITICAL(name) diff --git a/Framework/MDAlgorithms/src/ThresholdMD.cpp b/Framework/MDAlgorithms/src/ThresholdMD.cpp index 392fdf687502c0718f634695abee6449546201e3..d760285d3e022ac0f7d60fd6afff886cf2c7b181 100644 --- a/Framework/MDAlgorithms/src/ThresholdMD.cpp +++ b/Framework/MDAlgorithms/src/ThresholdMD.cpp @@ -109,7 +109,7 @@ void ThresholdMD::exec() { frequency = nPoints / 100; } - PARALLEL_FOR2(inputWS, outWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outWS)) for (int64_t i = 0; i < nPoints; ++i) { PARALLEL_START_INTERUPT_REGION const double signalAt = inputWS->getSignalAt(i); diff --git a/Framework/WorkflowAlgorithms/src/SANSSolidAngleCorrection.cpp b/Framework/WorkflowAlgorithms/src/SANSSolidAngleCorrection.cpp index 41accef33b20b2692474fdffb1e745e07bcf7f9f..4de89057f6fc5ffecda8e7fb113dce3bd2341492 100644 --- a/Framework/WorkflowAlgorithms/src/SANSSolidAngleCorrection.cpp +++ b/Framework/WorkflowAlgorithms/src/SANSSolidAngleCorrection.cpp @@ -110,7 +110,7 @@ void SANSSolidAngleCorrection::exec() { // Number of X bins const int xLength = static_cast<int>(inputWS->readY(0).size()); - PARALLEL_FOR2(outputWS, inputWS) + PARALLEL_FOR_IF(Kernel::threadSafe(*outputWS, *inputWS)) for (int i = 0; i < numHists; ++i) { PARALLEL_START_INTERUPT_REGION outputWS->dataX(i) = inputWS->readX(i);