Skip to content

Commit

Permalink
Merge pull request #2341 from pnorbert/gatherv_throw_exception
Browse files Browse the repository at this point in the history
Throw an exception in GathervArrays() and GathervVectors() if we try …
  • Loading branch information
pnorbert authored Jun 18, 2020
2 parents 062e395 + cd79949 commit c8ca6a5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion source/adios2/helper/adiosComm.inl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ void Comm::GathervArrays(const T *source, size_t sourceCount,
if (rankDestination == this->Rank())
{
displs = GetGathervDisplacements(counts, countsSize);
const size_t totalElements =
displs[countsSize - 1] + counts[countsSize - 1];
if (totalElements > 2147483648)
{
std::runtime_error(
"ERROR: GathervArrays does not support gathering more than "
"2^31 elements. Here it was tasked with " +
std::to_string(totalElements) + " elements\n");
}
}
this->Gatherv(source, sourceCount, destination, counts, displs.data(),
rankDestination);
Expand Down Expand Up @@ -93,7 +102,7 @@ void Comm::GathervVectors(const std::vector<T> &in, std::vector<T> &out,
}

this->GathervArrays(in.data(), in.size(), counts.data(), counts.size(),
out.data() + position);
out.data() + position, rankDestination);
position += gatheredSize;
}

Expand Down

0 comments on commit c8ca6a5

Please sign in to comment.