Commit a42ce70f authored by Podhorszki, Norbert's avatar Podhorszki, Norbert
Browse files

Bug fix for broadcasting metadata >2GB: Limit MPI_Bcast to 1GB blocks to avoid integer overflow.

parent 2d86df27
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -128,8 +128,18 @@ void BroadcastVector(std::vector<char> &vector, MPI_Comm mpiComm,
        vector.resize(inputSize);
    }

    MPI_Bcast(vector.data(), static_cast<int>(inputSize), MPI_CHAR, rankSource,
              mpiComm);
    const int MAXBCASTSIZE = 1073741824;
    int blockSize = (inputSize > MAXBCASTSIZE ? MAXBCASTSIZE : inputSize);
    size_t sent = 0;
    size_t pos = 0;
    char *buffer = vector.data();
    while (inputSize > 0)
    {
        MPI_Bcast(buffer, blockSize, MPI_CHAR, rankSource, mpiComm);
        buffer += blockSize;
        inputSize -= blockSize;
        blockSize = (inputSize > MAXBCASTSIZE ? MAXBCASTSIZE : inputSize);
    }
}

// GatherArrays specializations