Skip to content

Commit

Permalink
Improve progress reporting to cover limit calculation.
Browse files Browse the repository at this point in the history
Refs #11056
  • Loading branch information
martyngigg committed Mar 11, 2016
1 parent 374cb1a commit 77e497d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 0 additions & 2 deletions Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadSQW2.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ namespace Mantid {
// Forward declarations
namespace API {
class ExperimentInfo;
class Progress;
}

namespace MDAlgorithms {
Expand Down Expand Up @@ -93,7 +92,6 @@ class DLLExport LoadSQW2 : public API::IFileLoader<Kernel::FileDescriptor> {
uint16_t m_nspe;
Kernel::DblMatrix m_uToRLU;
Kernel::DblMatrix m_rluToU;
std::unique_ptr<API::Progress> m_progress;
std::string m_outputFrame;
};

Expand Down
15 changes: 9 additions & 6 deletions Framework/MDAlgorithms/src/LoadSQW2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ DECLARE_FILELOADER_ALGORITHM(LoadSQW2)
/// Default constructor
LoadSQW2::LoadSQW2()
: API::IFileLoader<Kernel::FileDescriptor>(), m_file(), m_reader(),
m_outputWS(), m_nspe(0), m_uToRLU(), m_rluToU(), m_progress(),
m_outputWS(), m_nspe(0), m_uToRLU(), m_rluToU(),
m_outputFrame() {}

/// Default destructor
Expand Down Expand Up @@ -162,8 +162,6 @@ void LoadSQW2::initFileReader() {
m_file = Kernel::make_unique<std::ifstream>(getPropertyValue("Filename"),
std::ios_base::binary);
m_reader = Kernel::make_unique<BinaryStreamReader>(*m_file);
// steps are reset once we know what we are reading
m_progress = Kernel::make_unique<Progress>(this, 0.0, 1.0, 100);
}

/**
Expand Down Expand Up @@ -473,6 +471,9 @@ std::vector<float> LoadSQW2::calculateDimLimitsFromData() {

int64_t npixtot(0);
*m_reader >> npixtot;
API::Progress status(this, 0.0, 0.5, npixtot);
status.setNotifyStep(0.01);

constexpr int64_t bufferSize(FIELDS_PER_PIXEL * NPIX_CHUNK);
std::vector<float> pixBuffer(bufferSize);
int64_t pixelsLeftToRead(npixtot);
Expand All @@ -495,6 +496,7 @@ std::vector<float> LoadSQW2::calculateDimLimitsFromData() {
else if (uj > dimLimits[2 * j + 1])
dimLimits[2 * j + 1] = uj;
}
status.report("Calculating data extents");
}
pixelsLeftToRead -= chunkSize;
}
Expand Down Expand Up @@ -645,8 +647,9 @@ void LoadSQW2::readPixelDataIntoWorkspace() {
*m_reader >> npixtot;
g_log.debug() << " npixtot: " << npixtot << "\n";
warnIfMemoryInsufficient(npixtot);
m_progress->setNumSteps(npixtot);

API::Progress status(this, 0.5, 1.0, npixtot);
status.setNotifyStep(0.01);

// Each pixel has 9 float fields. Do a chunked read to avoid
// using too much memory for the buffer and also split the
// boxes regularly to ensure that larger workspaces can be loaded
Expand All @@ -663,7 +666,7 @@ void LoadSQW2::readPixelDataIntoWorkspace() {
m_reader->read(pixBuffer, FIELDS_PER_PIXEL * chunkSize);
for (int64_t i = 0; i < chunkSize; ++i) {
pixelsAdded += addEventFromBuffer(pixBuffer.data() + i * 9);
m_progress->report();
status.report("Reading pixel data to workspace");
}
pixelsLeftToRead -= chunkSize;
++chunksRead;
Expand Down

0 comments on commit 77e497d

Please sign in to comment.