Skip to content

Commit

Permalink
Re #7228. Small tidy-ups (formatting, spelling).
Browse files Browse the repository at this point in the history
  • Loading branch information
RussellTaylor committed Sep 25, 2013
1 parent f3ee0f0 commit d4b8f20
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 45 deletions.
25 changes: 13 additions & 12 deletions Code/Mantid/Framework/API/inc/MantidAPI/BoxController.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,15 @@ namespace API
// TODO: Smarter ways to determine all of these values
m_maxDepth = 5;
m_addingEvents_eventsPerTask = 1000;
m_SignifEventsNumber = 10000000;
m_significantEventsNumber = 10000000;
m_addingEvents_numTasksPerBlock = Kernel::ThreadPool::getNumPhysicalCores() * 5;
m_splitInto.resize(this->nd, 1);
resetNumBoxes();
}

virtual ~BoxController();
/** get number of events used as significatn in box splitting (the box splitting begins after that)*/
size_t getSignifEventsNumber()const
{return m_SignifEventsNumber;}
// create new box controller from the existing one
virtual BoxController *clone()const;
virtual BoxController *clone() const;
/// Serialize
std::string toXMLString() const;

Expand Down Expand Up @@ -241,6 +238,12 @@ namespace API
resetNumBoxes();
}

/// The number of events that triggers box splitting
size_t getSignificantEventsNumber() const
{
return m_significantEventsNumber;
}

//-----------------------------------------------------------------------------------
/** Determine when would be a good time to split MDBoxes into MDGridBoxes.
* This is to be called while adding events. Splitting boxes too frequently
Expand All @@ -257,15 +260,13 @@ namespace API
// Avoid divide by zero
if(numMDBoxes == 0)
return false;
// Performance depends pretty strongly on WHEN you split the boxes.
// Performance depends pretty strongly on WHEN you split the boxes.
// This is an empirically-determined way to optimize the splitting calls.
// Split when adding 1/16^th as many events as are already in the output,
// (because when the workspace gets very large you should split less often)
// But no more often than every 10 million events.
size_t comparisonPoint = nEventsInOutput/16;
if (comparisonPoint < m_SignifEventsNumber)
comparisonPoint = m_SignifEventsNumber;
if (eventsAdded > (comparisonPoint))return true;
const size_t comparisonPoint = std::max(nEventsInOutput/16, m_significantEventsNumber);
if (eventsAdded > comparisonPoint) return true;

// Return true if the average # of events per box is big enough to split.
return ((eventsAdded / numMDBoxes) > m_SplitThreshold);
Expand Down Expand Up @@ -416,8 +417,8 @@ namespace API
/// Splitting threshold
size_t m_SplitThreshold;

/// this number of events takes noticeple time to process. Identified experimentally and used in box splitting limings
size_t m_SignifEventsNumber;
/// This empirically-determined number of events takes a noticeable time to process and triggers box splitting.
size_t m_significantEventsNumber;

/** Maximum splitting depth: don't go further than this many levels of recursion.
* This avoids infinite recursion and should be set to a value that gives a smallest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,14 @@ namespace MDAlgorithms

// Disabled for this version
declareProperty(new PropertyWithValue<bool>("ClearInputWorkspace", false, Direction::Input),
"Clearing the events from the input workspace during conversion, to save memory is not supported by algorithm v2");
"Clearing the events from the input workspace during conversion (to save memory) is not supported by algorithm v2");
// disable property on interface
this->setPropertySettings("ClearInputWorkspace", new DisabledProperty());
this->setPropertySettings("ClearInputWorkspace", new DisabledProperty());

declareProperty(new PropertyWithValue<bool>("OneEventPerBin", true, Direction::Input),
"Use the histogram representation (event for event workspaces).\n"
"One MDEvent will be created for each histogram bin (even empty ones).\n"
"Warning! This can use signficantly more memory!");
// disable property on interface
//this->setPropertySettings("OneEventPerBin", new DisabledProperty());



frameOptions.push_back("Q (sample frame)");
frameOptions.push_back("Q (lab frame)");
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/MDAlgorithms/src/ConvertToMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ ConvertToMD::init()
"and is ignored in any other case."
);
declareProperty(new PropertyWithValue<bool>("IgnoreZeroSignals", false, Direction::Input),
"Enabling this property forces algorithm to ignore bins with zero signal for input matxix workspace. Input events workspaces are not affected. "
"This violates the data normalization but may substantially accelerate calculations in situations when the normalization is not important. (e.g. peak finding)."
"Enabling this property forces the algorithm to ignore bins with zero signal for an input matrix workspace. Input event workspaces are not affected. "
"This violates the data normalization but may substantially accelerate calculations in situations when the normalization is not important (e.g. peak finding)."
);
declareProperty(new ArrayProperty<double>("MinValues"),
"It has to be N comma separated values, where N is the number of dimensions of the target workspace. Values "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ namespace MDEvents
// On multiprocessor machine the algorithm should run and utilizes all cores (see Kernel::Threadpool),
// but this can be chenged setting this parameter to 0 (no multithreading) or positive number specifying the requested nymber of threads
int m_NumThreads;
// propery which indicates that data with 0 signal should be ignored
bool m_IgnoreZeros;
// Flag which indicates that data with 0 signal should be ignored
bool m_ignoreZeros;
/// Any special coordinate system used.
Mantid::API::SpecialCoordinateSystem m_coordinateSystem;
private:
Expand All @@ -112,4 +112,4 @@ namespace MDEvents

} // end namespace MDAlgorithms
} // end namespace Mantid
#endif
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
#include "MantidMDEvents/ConvToMDBase.h"
// coordinate transformation
#include "MantidMDEvents/MDTransfInterface.h"
//#include "MantidKernel/Multithreaded.h"
#include "MantidKernel/Task.h"
#include "Poco/ScopedLock.h"

namespace Mantid
{
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/MDEvents/src/ConvToMDBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Mantid
size_t ConvToMDBase::initialize(const MDEvents::MDWSDescription &WSD, boost::shared_ptr<MDEvents::MDEventWSWrapper> inWSWrapper, bool ignoreZeros)
{

m_IgnoreZeros = ignoreZeros;
m_ignoreZeros = ignoreZeros;
m_InWS2D = WSD.getInWS();
// preprocessed detectors information:
// check if detector information has been precalculated:
Expand Down
26 changes: 8 additions & 18 deletions Code/Mantid/Framework/MDEvents/src/ConvToMDHistoWS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ namespace Mantid
size_t ConvToMDHistoWS::conversionChunk(size_t startSpectra)
{
size_t nAddedEvents(0),nBufEvents(0);
// cach global variable locally
bool ignoreZeros(m_IgnoreZeros);
// cache global variable locally
bool ignoreZeros(m_ignoreZeros);

const size_t specSize = this->m_InWS2D->blocksize();
// preprocessed detectors associate each spectra with a detector (position)
Expand Down Expand Up @@ -170,15 +170,15 @@ namespace Mantid

// estimate the size of data conversion a single thread should perform
//TO DO: this piece of code should be carefully rethinked
size_t eventsChunkNum = bc->getSignifEventsNumber();
size_t eventsChunkNum = bc->getSignificantEventsNumber();
this->estimateThreadWork(nThreads,specSize,eventsChunkNum);

//External loop over the spectra:
for (size_t i = 0; i < nValidSpectra; i+=m_spectraChunk)
{
size_t nThreadEv = this->conversionChunk(i);
nAddedEvents+=nThreadEv;
nEventsInWS +=nThreadEv;
size_t nThreadEv = this->conversionChunk(i);
nAddedEvents+=nThreadEv;
nEventsInWS +=nThreadEv;


if (bc->shouldSplitBoxes(nEventsInWS,nAddedEvents,lastNumBoxes))
Expand Down Expand Up @@ -234,7 +234,7 @@ namespace Mantid
*/
void ConvToMDHistoWS::estimateThreadWork(size_t nThreads,size_t specSize,size_t nPointsToProcess)
{
if (nThreads==0)nThreads=1;
if (nThreads==0) nThreads=1;

// buffer size is at least a spectra size or more
m_bufferSize = ((specSize>DATA_BUFFER_SIZE)?specSize:DATA_BUFFER_SIZE);
Expand All @@ -243,18 +243,8 @@ namespace Mantid
m_bufferSize = ((m_bufferSize/specSize)+1)*specSize;
}

//
size_t nSpectras = nPointsToProcess/specSize+1;

m_spectraChunk = nSpectras/nThreads;
if(m_spectraChunk<1)m_spectraChunk =1;

//if(m_spectraChunk<1)m_spectraChunk=1;
// TMP
//m_spectraChunk = 10;

//m_spectraChunk = 1;
//m_bufferSize = specSize;
m_spectraChunk = std::max(nSpectras/nThreads, static_cast<size_t>(1));
}

} // endNamespace MDEvents
Expand Down

0 comments on commit d4b8f20

Please sign in to comment.