Skip to content
Snippets Groups Projects
Commit 1225e565 authored by Simon Heybrock's avatar Simon Heybrock
Browse files

Re #20887. Use communicator from workspace in parallel loader.

Do not default to WORLD anymore. This is needed for unit testing on the
algorithm level.
parent 855e89eb
No related branches found
No related tags found
No related merge requests found
#include "MantidDataHandling/ParallelEventLoader.h" #include "MantidDataHandling/ParallelEventLoader.h"
#include "MantidDataObjects/EventWorkspace.h" #include "MantidDataObjects/EventWorkspace.h"
#include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidGeometry/Instrument/DetectorInfo.h"
#include "MantidIndexing/IndexInfo.h"
#include "MantidParallel/IO/EventLoader.h" #include "MantidParallel/IO/EventLoader.h"
#include "MantidTypes/SpectrumDefinition.h" #include "MantidTypes/SpectrumDefinition.h"
#include "MantidTypes/Event/TofEvent.h" #include "MantidTypes/Event/TofEvent.h"
...@@ -54,7 +55,7 @@ void ParallelEventLoader::load(DataObjects::EventWorkspace &ws, ...@@ -54,7 +55,7 @@ void ParallelEventLoader::load(DataObjects::EventWorkspace &ws,
DataObjects::getEventsFrom(ws.getSpectrum(i), eventLists[i]); DataObjects::getEventsFrom(ws.getSpectrum(i), eventLists[i]);
Parallel::IO::EventLoader::load( Parallel::IO::EventLoader::load(
filename, groupName, bankNames, ws.indexInfo().communicator(), filename, groupName, bankNames,
bankOffsets(ws, filename, groupName, bankNames), std::move(eventLists)); bankOffsets(ws, filename, groupName, bankNames), std::move(eventLists));
} }
......
...@@ -117,7 +117,7 @@ public: ...@@ -117,7 +117,7 @@ public:
bool isOnThisPartition(GlobalSpectrumIndex globalIndex) const; bool isOnThisPartition(GlobalSpectrumIndex globalIndex) const;
Parallel::StorageMode storageMode() const; Parallel::StorageMode storageMode() const;
Parallel::Communicator communicator() const; const Parallel::Communicator &communicator() const;
private: private:
void makeSpectrumNumberTranslator( void makeSpectrumNumberTranslator(
......
...@@ -205,7 +205,7 @@ bool IndexInfo::isOnThisPartition(GlobalSpectrumIndex globalIndex) const { ...@@ -205,7 +205,7 @@ bool IndexInfo::isOnThisPartition(GlobalSpectrumIndex globalIndex) const {
Parallel::StorageMode IndexInfo::storageMode() const { return m_storageMode; } Parallel::StorageMode IndexInfo::storageMode() const { return m_storageMode; }
/// Returns the communicator used in MPI runs. /// Returns the communicator used in MPI runs.
Parallel::Communicator IndexInfo::communicator() const { const Parallel::Communicator &IndexInfo::communicator() const {
return *m_communicator; return *m_communicator;
} }
......
...@@ -16,6 +16,7 @@ class TofEvent; ...@@ -16,6 +16,7 @@ class TofEvent;
} }
} }
namespace Parallel { namespace Parallel {
class Communicator;
namespace IO { namespace IO {
/** Loader for event data from Nexus files with parallelism based on multiple /** Loader for event data from Nexus files with parallelism based on multiple
...@@ -50,8 +51,8 @@ MANTID_PARALLEL_DLL std::vector<boost::optional<int32_t>> ...@@ -50,8 +51,8 @@ MANTID_PARALLEL_DLL std::vector<boost::optional<int32_t>>
anyEventIdFromBanks(const std::string &filename, const std::string &groupName, anyEventIdFromBanks(const std::string &filename, const std::string &groupName,
const std::vector<std::string> &bankNames); const std::vector<std::string> &bankNames);
MANTID_PARALLEL_DLL void MANTID_PARALLEL_DLL void
load(const std::string &filename, const std::string &groupName, load(const Communicator &communicator, const std::string &filename,
const std::vector<std::string> &bankNames, const std::string &groupName, const std::vector<std::string> &bankNames,
const std::vector<int32_t> &bankOffsets, const std::vector<int32_t> &bankOffsets,
std::vector<std::vector<Types::Event::TofEvent> *> eventLists); std::vector<std::vector<Types::Event::TofEvent> *> eventLists);
} }
......
...@@ -91,13 +91,13 @@ void load(const Chunker &chunker, NXEventDataSource<TimeOffsetType> &dataSource, ...@@ -91,13 +91,13 @@ void load(const Chunker &chunker, NXEventDataSource<TimeOffsetType> &dataSource,
} }
template <class TimeOffsetType> template <class TimeOffsetType>
void load(const H5::Group &group, const std::vector<std::string> &bankNames, void load(const Communicator &comm, const H5::Group &group,
const std::vector<std::string> &bankNames,
const std::vector<int32_t> &bankOffsets, const std::vector<int32_t> &bankOffsets,
std::vector<std::vector<Types::Event::TofEvent> *> eventLists) { std::vector<std::vector<Types::Event::TofEvent> *> eventLists) {
// TODO automatically(?) determine good chunk size // TODO automatically(?) determine good chunk size
// TODO automatically(?) determine good number of ranks to use for load // TODO automatically(?) determine good number of ranks to use for load
const size_t chunkSize = 1024 * 1024; const size_t chunkSize = 1024 * 1024;
Communicator comm;
const Chunker chunker(comm.size(), comm.rank(), const Chunker chunker(comm.size(), comm.rank(),
readBankSizes(group, bankNames), chunkSize); readBankSizes(group, bankNames), chunkSize);
NXEventDataLoader<TimeOffsetType> loader(comm.size(), group, bankNames); NXEventDataLoader<TimeOffsetType> loader(comm.size(), group, bankNames);
......
...@@ -29,14 +29,15 @@ anyEventIdFromBanks(const std::string &filename, const std::string &groupName, ...@@ -29,14 +29,15 @@ anyEventIdFromBanks(const std::string &filename, const std::string &groupName,
} }
/// Load events from given banks into event lists. /// Load events from given banks into event lists.
void load(const std::string &filename, const std::string &groupName, void load(const Communicator &comm, const std::string &filename,
const std::string &groupName,
const std::vector<std::string> &bankNames, const std::vector<std::string> &bankNames,
const std::vector<int32_t> &bankOffsets, const std::vector<int32_t> &bankOffsets,
std::vector<std::vector<Types::Event::TofEvent> *> eventLists) { std::vector<std::vector<Types::Event::TofEvent> *> eventLists) {
H5::H5File file(filename, H5F_ACC_RDONLY); H5::H5File file(filename, H5F_ACC_RDONLY);
H5::Group group = file.openGroup(groupName); H5::Group group = file.openGroup(groupName);
load(readDataType(group, bankNames, "event_time_offset"), group, bankNames, load(readDataType(group, bankNames, "event_time_offset"), comm, group,
bankOffsets, std::move(eventLists)); bankNames, bankOffsets, std::move(eventLists));
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment