Mantid
|
This class is used by MDBox and MDGridBox in order to intelligently determine optimal behavior. More...
#include <BoxController.h>
Public Member Functions | |
BoxController (size_t nd) | |
Constructor. More... | |
size_t | claimIDRange (size_t range) |
get range of id-s and increment box ID by this range; More... | |
void | clearBoxesCounter (size_t depth) |
void | clearFileBacked () |
function clears the file-backed status of the box controller More... | |
void | clearGridBoxesCounter (size_t depth) |
virtual BoxController * | clone () const |
create new box controller from the existing one. More... | |
void | fromXMLString (const std::string &xml) |
De-serializing XML. More... | |
size_t | getAddingEvents_eventsPerTask () const |
size_t | getAddingEvents_numTasksPerBlock () const |
void | getAddingEventsParameters (size_t &eventsPerTask, size_t &numTasksPerBlock) const |
Get parameters for adding events to a MDGridBox, trying to optimize parallel CPU use. More... | |
double | getAverageDepth () const |
Return the average recursion depth of gridding. More... | |
IBoxControllerIO * | getFileIO () |
returns the pointer to the class, responsible for fileIO operations; More... | |
std::string | getFilename () const |
the function left for compartibility with the previous bc python interface. More... | |
std::mutex & | getIdMutex () |
size_t | getMaxDepth () const |
size_t | getMaxId () const |
const std::vector< double > & | getMaxNumMDBoxes () const |
Return the vector giving the MAXIMUM number of MD Boxes as a function of depth. More... | |
size_t | getNDims () const |
Get # of dimensions. More... | |
size_t | getNextId () |
size_t | getNumEventAtMax () const |
return the numner of events, which are sitting at max depth and would be split if not due to the max depth of the box they are occupying More... | |
const std::vector< size_t > & | getNumMDBoxes () const |
Return the vector giving the number of MD Boxes as a function of depth. More... | |
const std::vector< size_t > & | getNumMDGridBoxes () const |
Return the vector giving the number of MD Grid Boxes as a function of depth. More... | |
size_t | getNumSplit () const |
Return how many boxes (total) a MDGridBox will contain. More... | |
size_t | getSignificantEventsNumber () const |
The number of events that triggers box splitting. More... | |
size_t | getSplitInto (size_t dim) const |
Return into how many to split along a dimension. More... | |
const std::vector< size_t > & | getSplitIntoAll () const |
Return into how many to split along a every dimension. More... | |
size_t | getSplitThreshold () const |
Return the splitting threshold, in # of events. More... | |
boost::optional< std::vector< size_t > > | getSplitTopInto () const |
Return into how many to split along a dimension for the top level. More... | |
size_t | getTotalNumMDBoxes () const |
Return the total number of MD Boxes, irrespective of depth. More... | |
size_t | getTotalNumMDGridBoxes () const |
Return the total number of MDGridBox'es, irrespective of depth. More... | |
void | incBoxesCounter (size_t depth, size_t inc=1) |
void | incGridBoxesCounter (size_t depth, size_t inc=1) |
bool | isFileBacked () const |
Returns if current box controller is file backed. More... | |
bool | operator== (const BoxController &other) const |
Equality operator. More... | |
void | resetNumBoxes () |
Reset the number of boxes tracked in m_numMDBoxes. More... | |
void | rizeEventAtMax () |
void | setAddingEvents_eventsPerTask (size_t m_addingEvents_eventsPerTask) |
When adding events, how many events per task should be done? More... | |
void | setAddingEvents_numTasksPerBlock (size_t m_addingEvents_numTasksPerBlock) |
When adding events, how many events tasks per block should be done? More... | |
void | setFileBacked (const std::shared_ptr< IBoxControllerIO > &newFileIO, const std::string &fileName="") |
makes box controller file based by providing class, responsible for fileIO. More... | |
void | setMaxDepth (size_t value) |
Sets the max recursion depth allowed for grid box splitting. More... | |
void | setMaxId (size_t newMaxId) |
Set the new maximum ID number anywhere in the workspace. More... | |
void | setSplitInto (size_t dim, size_t num) |
Set the way splitting will be done. More... | |
void | setSplitInto (size_t num) |
Set the way splitting will be done. More... | |
void | setSplitThreshold (size_t threshold) |
Set the splitting threshold. More... | |
void | setSplitTopInto (size_t dim, size_t num) |
Set the way splitting will be done for the top level. More... | |
bool | shouldSplitBoxes (size_t nEventsInOutput, size_t eventsAdded, size_t numMDBoxes) const |
Determine when would be a good time to split MDBoxes into MDGridBoxes. More... | |
std::string | toXMLString () const |
Serialize. More... | |
void | trackNumBoxes (size_t depth) |
Call to track the number of MDBoxes are contained in the MDEventWorkspace This should be called when a MDBox gets split into a MDGridBox. More... | |
bool | useWriteBuffer () const |
the compartibility function – the write buffer is always used for file based workspaces More... | |
bool | willSplit (size_t numPoints, size_t depth) const |
Return true if the MDBox should split, given : More... | |
virtual | ~BoxController () |
Destructor. More... | |
Protected Member Functions | |
BoxController (const BoxController &other) | |
box controller is an ws-based singleton so it should not be possible to copy it, left protected for inheritance; More... | |
BoxController & | operator= (const BoxController &)=delete |
Private Member Functions | |
void | calcNumSplit () |
When you split a MDBox, it becomes this many sub-boxes. More... | |
void | calcNumTopSplit () |
When you split an MDBox by force, it becomes this many sub boxes. More... | |
void | resetMaxNumBoxes () |
Calculate the vector of the max # of MDBoxes per level. More... | |
Private Attributes | |
size_t | m_addingEvents_eventsPerTask |
For adding events tasks. More... | |
size_t | m_addingEvents_numTasksPerBlock |
For adding events tasks. More... | |
std::shared_ptr< IBoxControllerIO > | m_fileIO |
std::mutex | m_idMutex |
Mutex for getting IDs. More... | |
size_t | m_maxDepth |
Maximum splitting depth: don't go further than this many levels of recursion. More... | |
size_t | m_maxId |
The maximum ID number of any boxes in the workspace (not inclusive, i.e. More... | |
std::vector< double > | m_maxNumMDBoxes |
This is the maximum number of MD boxes there could be at each recursion level (e.g. More... | |
std::mutex | m_mutexNumMDBoxes |
Mutex for changing the number of MD Boxes. More... | |
volatile size_t | m_numEventsAtMax |
number of events sitting in the boxes which should be split but are already split up to the max depth More... | |
std::vector< size_t > | m_numMDBoxes |
For tracking how many MDBoxes (not MDGridBoxes) are at each recursion level. More... | |
std::vector< size_t > | m_numMDGridBoxes |
For tracking how many MDGridBoxes (not MDBoxes) are at each recursion level. More... | |
size_t | m_numSplit |
When you split a MDBox, it becomes this many sub-boxes. More... | |
size_t | m_numTopSplit |
When you split a top level MDBox by force, it becomes this many sub boxes. More... | |
size_t | m_significantEventsNumber |
This empirically-determined number of events takes a noticeable time to process and triggers box splitting. More... | |
std::vector< size_t > | m_splitInto |
Splitting # for all dimensions. More... | |
size_t | m_SplitThreshold |
Splitting threshold. More... | |
boost::optional< std::vector< size_t > > | m_splitTopInto |
Splittin # for all dimensions in the top level. More... | |
size_t | nd |
Number of dimensions. More... | |
This class is used by MDBox and MDGridBox in order to intelligently determine optimal behavior.
It informs:
Definition at line 33 of file BoxController.h.
|
inline |
Constructor.
nd | :: number of dimensions |
Definition at line 41 of file BoxController.h.
|
virtual |
|
protected |
box controller is an ws-based singleton so it should not be possible to copy it, left protected for inheritance;
Definition at line 42 of file BoxController.cpp.
|
inlineprivate |
When you split a MDBox, it becomes this many sub-boxes.
And this changes the max # of boxes too
Definition at line 404 of file BoxController.h.
References Mantid::Geometry::d.
Referenced by fromXMLString().
|
inlineprivate |
When you split an MDBox by force, it becomes this many sub boxes.
And this changes the max # of boxes too
Definition at line 414 of file BoxController.h.
References Mantid::Geometry::d.
Referenced by fromXMLString().
size_t Mantid::API::BoxController::claimIDRange | ( | size_t | range | ) |
get range of id-s and increment box ID by this range;
reserve range of id-s for use on set of adjacent boxes.
Needed to be thread safe as adjacent boxes have to have subsequent ID-s
range | –range number of box-id-s to lock |
Definition at line 116 of file BoxController.cpp.
|
inline |
Definition at line 279 of file BoxController.h.
void Mantid::API::BoxController::clearFileBacked | ( | ) |
function clears the file-backed status of the box controller
Definition at line 262 of file BoxController.cpp.
References m_fileIO.
|
inline |
Definition at line 284 of file BoxController.h.
|
virtual |
create new box controller from the existing one.
Drops file-based state if the box-controller was file-based
Definition at line 35 of file BoxController.cpp.
void Mantid::API::BoxController::fromXMLString | ( | const std::string & | xml | ) |
De-serializing XML.
Static method that sets the data inside this BoxController from an XML string.
xml | :: string generated by BoxController::toXMLString() |
Definition at line 211 of file BoxController.cpp.
References calcNumSplit(), calcNumTopSplit(), Mantid::Kernel::Strings::convert(), m_numMDBoxes, m_numMDGridBoxes, m_splitInto, m_splitTopInto, nd, setMaxDepth(), setMaxId(), and setSplitThreshold().
|
inline |
Definition at line 199 of file BoxController.h.
|
inline |
Definition at line 210 of file BoxController.h.
|
inline |
Get parameters for adding events to a MDGridBox, trying to optimize parallel CPU use.
[out] | eventsPerTask | :: the number of events that should be added by a single task object. This should be large enough to avoid overhead without being too large, making event lists too long before splitting |
[out] | numTasksPerBlock | :: the number of tasks (of size eventsPerTask) to be allocated before the grid boxes should be re-split. Having enough parallel tasks will help the CPU be used fully. |
Definition at line 226 of file BoxController.h.
|
inline |
Return the average recursion depth of gridding.
Definition at line 350 of file BoxController.h.
Referenced by export_BoxController().
|
inline |
returns the pointer to the class, responsible for fileIO operations;
Definition at line 378 of file BoxController.h.
Referenced by Mantid::DataObjects::MDBoxSaveable::flushData(), Mantid::DataObjects::MDBoxSaveable::load(), and Mantid::DataObjects::MDBoxSaveable::save().
std::string Mantid::API::BoxController::getFilename | ( | ) | const |
the function left for compartibility with the previous bc python interface.
Definition at line 195 of file BoxController.cpp.
References m_fileIO.
Referenced by export_BoxController().
|
inline |
Definition at line 91 of file BoxController.h.
|
inline |
Definition at line 234 of file BoxController.h.
Referenced by export_BoxController(), and toXMLString().
|
inline |
Definition at line 80 of file BoxController.h.
Referenced by toXMLString().
|
inline |
Return the vector giving the MAXIMUM number of MD Boxes as a function of depth.
Definition at line 336 of file BoxController.h.
|
inline |
Get # of dimensions.
Definition at line 70 of file BoxController.h.
Referenced by MantidTestHelpers::BoxControllerDummyIO::BoxControllerDummyIO(), Mantid::DataObjects::BoxControllerNeXusIO::BoxControllerNeXusIO(), export_BoxController(), Mantid::DataObjects::BoxControllerNeXusIO::openFile(), Mantid::DataObjects::BoxControllerNeXusIO::prepareNxSdata_CurVersion(), Mantid::DataObjects::BoxControllerNeXusIO::setDataType(), MantidTestHelpers::BoxControllerDummyIO::setDataType(), and toXMLString().
|
inline |
Definition at line 75 of file BoxController.h.
|
inline |
return the numner of events, which are sitting at max depth and would be split if not due to the max depth of the box they are occupying
Definition at line 391 of file BoxController.h.
|
inline |
Return the vector giving the number of MD Boxes as a function of depth.
Definition at line 328 of file BoxController.h.
|
inline |
Return the vector giving the number of MD Grid Boxes as a function of depth.
Definition at line 332 of file BoxController.h.
|
inline |
Return how many boxes (total) a MDGridBox will contain.
Definition at line 146 of file BoxController.h.
|
inline |
The number of events that triggers box splitting.
Definition at line 246 of file BoxController.h.
|
inline |
Return into how many to split along a dimension.
dim | :: index of the dimension to split |
Definition at line 119 of file BoxController.h.
Referenced by export_BoxController().
|
inline |
Return into how many to split along a every dimension.
Definition at line 132 of file BoxController.h.
|
inline |
Return the splitting threshold, in # of events.
Definition at line 106 of file BoxController.h.
Referenced by export_BoxController(), and toXMLString().
|
inline |
Return into how many to split along a dimension for the top level.
Definition at line 138 of file BoxController.h.
|
inline |
Return the total number of MD Boxes, irrespective of depth.
Definition at line 339 of file BoxController.h.
Referenced by Mantid::MDAlgorithms::MinusMD::doMinus(), Mantid::MDAlgorithms::PlusMD::doPlus(), and export_BoxController().
|
inline |
Return the total number of MDGridBox'es, irrespective of depth.
Definition at line 344 of file BoxController.h.
Referenced by export_BoxController().
|
inline |
Definition at line 293 of file BoxController.h.
|
inline |
Definition at line 288 of file BoxController.h.
|
inline |
Returns if current box controller is file backed.
Assumes that BC(workspace) is fileBackd if fileIO is defined;
Definition at line 376 of file BoxController.h.
Referenced by export_BoxController().
|
protecteddelete |
bool Mantid::API::BoxController::operator== | ( | const BoxController & | other | ) | const |
Equality operator.
Definition at line 52 of file BoxController.cpp.
References m_maxDepth, m_maxId, m_maxNumMDBoxes, m_numMDBoxes, m_numMDGridBoxes, m_numSplit, m_splitInto, m_SplitThreshold, m_splitTopInto, and nd.
|
inlineprivate |
Calculate the vector of the max # of MDBoxes per level.
Definition at line 424 of file BoxController.h.
|
inline |
Reset the number of boxes tracked in m_numMDBoxes.
Definition at line 364 of file BoxController.h.
|
inline |
Definition at line 388 of file BoxController.h.
|
inline |
When adding events, how many events per task should be done?
m_addingEvents_eventsPerTask | :: events per task |
Definition at line 195 of file BoxController.h.
|
inline |
When adding events, how many events tasks per block should be done?
m_addingEvents_numTasksPerBlock | :: tasks/block |
Definition at line 205 of file BoxController.h.
void Mantid::API::BoxController::setFileBacked | ( | const std::shared_ptr< IBoxControllerIO > & | newFileIO, |
const std::string & | fileName = "" |
||
) |
makes box controller file based by providing class, responsible for fileIO.
The box controller become responsible for the FileIO pointer
newFileIO | – instance of the box controller responsible for the IO; |
fileName | – if newFileIO comes without opened file, this is the file name to open for the file based IO operations |
Definition at line 278 of file BoxController.cpp.
References m_fileIO.
|
inline |
Sets the max recursion depth allowed for grid box splitting.
NOTE! This resets numMDBoxes stats!
value | :: the max depth for splitting |
Definition at line 240 of file BoxController.h.
References value.
Referenced by fromXMLString().
|
inline |
Set the new maximum ID number anywhere in the workspace.
Should only be called when loading a file.
newMaxId | value to set the newMaxId to |
Definition at line 87 of file BoxController.h.
Referenced by fromXMLString().
|
inline |
Set the way splitting will be done.
dim | :: dimension to set |
num | :: amount in which to split |
Definition at line 164 of file BoxController.h.
|
inline |
Set the way splitting will be done.
num | :: amount in which to split |
Definition at line 152 of file BoxController.h.
Referenced by Mantid::DataObjects::MDEventsTestHelper::makeMDBox1().
|
inline |
Set the splitting threshold.
threshold | :: # of points at which the MDBox splits |
Definition at line 111 of file BoxController.h.
Referenced by fromXMLString(), and Mantid::DataObjects::MDEventsTestHelper::makeMDBox1().
|
inline |
Set the way splitting will be done for the top level.
dim | :: dimension to set |
num | :: amount in which to split |
Definition at line 178 of file BoxController.h.
|
inline |
Determine when would be a good time to split MDBoxes into MDGridBoxes.
This is to be called while adding events. Splitting boxes too frequently would be a slow-down, but keeping the boxes split at an earlier stage should help scalability for later adding, so there is a balance to get.
nEventsInOutput | :: How many events are currently in workspace in memory; |
eventsAdded | :: How many events were added since the last split? |
numMDBoxes | :: How many un-split MDBoxes are there (total) in the workspace |
Definition at line 261 of file BoxController.h.
std::string Mantid::API::BoxController::toXMLString | ( | ) | const |
Serialize.
Serialize to an XML string.
Definition at line 125 of file BoxController.cpp.
References getMaxDepth(), getMaxId(), getNDims(), getSplitThreshold(), Mantid::Kernel::Strings::join(), m_numMDBoxes, m_numMDGridBoxes, m_splitInto, and m_splitTopInto.
|
inline |
Call to track the number of MDBoxes are contained in the MDEventWorkspace This should be called when a MDBox gets split into a MDGridBox.
The number of MDBoxes at [depth] is reduced by one The number of MDBoxes at [depth+1] is increased by however many the splitting gives. Also tracks the number of MDGridBoxes.
depth | :: the depth of the MDBox that is being split into MDGrid boxes. |
Definition at line 308 of file BoxController.h.
bool Mantid::API::BoxController::useWriteBuffer | ( | ) | const |
the compartibility function – the write buffer is always used for file based workspaces
the function left for compartibility with the previous bc python interface.
Definition at line 203 of file BoxController.cpp.
References m_fileIO.
Referenced by export_BoxController().
|
inline |
Return true if the MDBox should split, given :
numPoints | :: # of points in the box |
depth | :: recursion depth of the box |
Definition at line 100 of file BoxController.h.
|
private |
For adding events tasks.
Definition at line 486 of file BoxController.h.
|
private |
For adding events tasks.
Definition at line 489 of file BoxController.h.
|
private |
Definition at line 510 of file BoxController.h.
Referenced by clearFileBacked(), getFilename(), setFileBacked(), useWriteBuffer(), and ~BoxController().
|
private |
Mutex for getting IDs.
Definition at line 507 of file BoxController.h.
Referenced by claimIDRange().
|
private |
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 box size that is a little smaller than the finest desired binning upon viewing.
RE: In fact, max depth should not be higher then EPSILON(coord_t/(BIGGEST_BOX_SIZE))=max_split_size^m_maxDepth;
Definition at line 468 of file BoxController.h.
Referenced by operator==().
|
private |
The maximum ID number of any boxes in the workspace (not inclusive, i.e.
maxId = 100 means there the highest ID number is 99.
Definition at line 449 of file BoxController.h.
Referenced by claimIDRange(), and operator==().
|
private |
This is the maximum number of MD boxes there could be at each recursion level (e.g.
(splitInto ^ ndims) ^ depth )
Definition at line 504 of file BoxController.h.
Referenced by operator==().
|
private |
Mutex for changing the number of MD Boxes.
Definition at line 500 of file BoxController.h.
|
private |
number of events sitting in the boxes which should be split but are already split up to the max depth
Definition at line 471 of file BoxController.h.
|
private |
For tracking how many MDBoxes (not MDGridBoxes) are at each recursion level.
Definition at line 493 of file BoxController.h.
Referenced by fromXMLString(), operator==(), and toXMLString().
|
private |
For tracking how many MDGridBoxes (not MDBoxes) are at each recursion level.
Definition at line 497 of file BoxController.h.
Referenced by fromXMLString(), operator==(), and toXMLString().
|
private |
When you split a MDBox, it becomes this many sub-boxes.
Definition at line 480 of file BoxController.h.
Referenced by operator==().
|
private |
When you split a top level MDBox by force, it becomes this many sub boxes.
Definition at line 483 of file BoxController.h.
|
private |
This empirically-determined number of events takes a noticeable time to process and triggers box splitting.
Definition at line 456 of file BoxController.h.
|
private |
Splitting # for all dimensions.
Definition at line 474 of file BoxController.h.
Referenced by fromXMLString(), operator==(), and toXMLString().
|
private |
|
private |
Splittin # for all dimensions in the top level.
Definition at line 477 of file BoxController.h.
Referenced by fromXMLString(), operator==(), and toXMLString().
|
private |
Number of dimensions.
Definition at line 445 of file BoxController.h.
Referenced by fromXMLString(), and operator==().