Skip to content

Commit

Permalink
Add back the parallelisation for SofQW polygon algorithms
Browse files Browse the repository at this point in the history
Refs #12584
  • Loading branch information
martyngigg committed Jun 25, 2015
1 parent 137727e commit 6b5a5b0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
18 changes: 14 additions & 4 deletions Code/Mantid/Framework/Algorithms/src/SofQWNormalisedPolygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "MantidKernel/UnitFactory.h"
#include "MantidKernel/VectorHelper.h"

#include <valgrind/callgrind.h>

namespace Mantid {
namespace Algorithms {
// Setup typedef for later use
Expand Down Expand Up @@ -95,11 +97,15 @@ void SofQWNormalisedPolygon::exec() {
const MantidVec &X = inputWS->readX(0);

int emode = m_EmodeProperties.m_emode;
/* PARALLEL_FOR2(inputWS, outputWS) */

// CALLGRIND_START_INSTRUMENTATION;
// CALLGRIND_TOGGLE_COLLECT;

PARALLEL_FOR2(inputWS, outputWS)
for (int64_t i = 0; i < static_cast<int64_t>(nHistos);
++i) // signed for openmp
{
/* PARALLEL_START_INTERUPT_REGION */
PARALLEL_START_INTERUPT_REGION

DetConstPtr detector = inputWS->getDetector(i);
if (detector->isMasked() || detector->isMonitor()) {
Expand Down Expand Up @@ -157,18 +163,22 @@ void SofQWNormalisedPolygon::exec() {
std::upper_bound(m_Qout.begin(), m_Qout.end(), lrQ) - m_Qout.begin();
if (qIndex != 0 && qIndex < static_cast<int>(m_Qout.size())) {
// Add this spectra-detector pair to the mapping
PARALLEL_CRITICAL(SofQWNormalisedPolygon_spectramap) {
specNumberMapping.push_back(
outputWS->getSpectrum(qIndex - 1)->getSpectrumNo());
detIDMapping.push_back(detector->getID());
}
}
}
if (g_log.is(Logger::Priority::PRIO_DEBUG)) {
g_log.debug(logStream.str());
}

/* PARALLEL_END_INTERUPT_REGION */
PARALLEL_END_INTERUPT_REGION
}
/* PARALLEL_CHECK_INTERUPT_REGION */
PARALLEL_CHECK_INTERUPT_REGION

//CALLGRIND_STOP_INSTRUMENTATION;

outputWS->finalize();
this->normaliseOutput(outputWS, inputWS);
Expand Down
16 changes: 9 additions & 7 deletions Code/Mantid/Framework/Algorithms/src/SofQWPolygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ void SofQWPolygon::exec() {
qCalculator = &SofQWPolygon::calculateIndirectQ;
}

/* PARALLEL_FOR2(inputWS, outputWS) */
PARALLEL_FOR2(inputWS, outputWS)
for (int64_t i = 0; i < static_cast<int64_t>(nTheta);
++i) // signed for openmp
{
/* PARALLEL_START_INTERUPT_REGION */
PARALLEL_START_INTERUPT_REGION

const double theta = m_thetaPts[i];
if (theta < 0.0) // One to skip
Expand Down Expand Up @@ -112,15 +112,17 @@ void SofQWPolygon::exec() {
std::upper_bound(m_Qout.begin(), m_Qout.end(), lrQ) - m_Qout.begin();
if (qIndex != 0 && qIndex < static_cast<int>(m_Qout.size())) {
// Add this spectra-detector pair to the mapping
specNumberMapping.push_back(
outputWS->getSpectrum(qIndex - 1)->getSpectrumNo());
detIDMapping.push_back(det->getID());
PARALLEL_CRITICAL(SofQWPolygon_spectramap) {
specNumberMapping.push_back(
outputWS->getSpectrum(qIndex - 1)->getSpectrumNo());
detIDMapping.push_back(det->getID());
}
}
}

/* PARALLEL_END_INTERUPT_REGION */
PARALLEL_END_INTERUPT_REGION
}
/* PARALLEL_CHECK_INTERUPT_REGION */
PARALLEL_CHECK_INTERUPT_REGION

normaliseOutput(outputWS, inputWS);

Expand Down

0 comments on commit 6b5a5b0

Please sign in to comment.