Skip to content
Snippets Groups Projects
Commit 17e94485 authored by Jan David Mol's avatar Jan David Mol
Browse files

Task #5844: Fix use of MPIReceiveStations no-op case (beamlets.empty())

parent dd239e25
No related branches found
No related tags found
No related merge requests found
...@@ -37,9 +37,18 @@ using namespace LOFAR::Cobalt::MPIProtocol; ...@@ -37,9 +37,18 @@ using namespace LOFAR::Cobalt::MPIProtocol;
namespace LOFAR { namespace LOFAR {
namespace Cobalt { namespace Cobalt {
namespace {
ssize_t first(const std::vector<size_t> &v) {
return v.empty() ? -1 : v.at(0);
}
ssize_t last(const std::vector<size_t> &v) {
return v.empty() ? -1 : v.at(v.size()-1);
}
};
MPIReceiveStations::MPIReceiveStations( size_t nrStations, const std::vector<size_t> &beamlets, size_t blockSize ) MPIReceiveStations::MPIReceiveStations( size_t nrStations, const std::vector<size_t> &beamlets, size_t blockSize )
: :
logPrefix(str(boost::format("[beamlets %u..%u (%u)] [MPIReceiveStations] ") % beamlets[0] % beamlets[beamlets.size()-1] % beamlets.size())), logPrefix(str(boost::format("[beamlets %d..%d (%u)] [MPIReceiveStations] ") % first(beamlets) % last(beamlets) % beamlets.size())),
nrStations(nrStations), nrStations(nrStations),
beamlets(beamlets), beamlets(beamlets),
blockSize(blockSize), blockSize(blockSize),
...@@ -74,6 +83,9 @@ namespace LOFAR { ...@@ -74,6 +83,9 @@ namespace LOFAR {
template<typename T> template<typename T>
void MPIReceiveStations::receiveBlock( MultiDimArray<T, 3> &data, MultiDimArray<struct MPIProtocol::MetaData, 2> &metaData ) void MPIReceiveStations::receiveBlock( MultiDimArray<T, 3> &data, MultiDimArray<struct MPIProtocol::MetaData, 2> &metaData )
{ {
if (beamlets.empty())
return;
ASSERT(data.num_elements() == nrStations * beamlets.size() * blockSize); ASSERT(data.num_elements() == nrStations * beamlets.size() * blockSize);
ASSERT(metaData.num_elements() == nrStations * beamlets.size()); ASSERT(metaData.num_elements() == nrStations * beamlets.size());
......
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