From cb64b5cc7d4e9e2e2c7f4fe9e634ed2931d0fc92 Mon Sep 17 00:00:00 2001 From: Jason Wang Date: Tue, 23 Mar 2021 17:58:23 -0400 Subject: [PATCH] use ssc::Buffer for ssc reader data buffer as well --- source/adios2/engine/ssc/SscReader.cpp | 11 ++++++----- source/adios2/engine/ssc/SscReader.h | 2 +- source/adios2/engine/ssc/SscReader.tcc | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/source/adios2/engine/ssc/SscReader.cpp b/source/adios2/engine/ssc/SscReader.cpp index b28fb01768..71206571d2 100644 --- a/source/adios2/engine/ssc/SscReader.cpp +++ b/source/adios2/engine/ssc/SscReader.cpp @@ -67,7 +67,8 @@ void SscReader::BeginStepConsequentFixed() void SscReader::BeginStepFlexible(StepStatus &status) { m_AllReceivingWriterRanks.clear(); - m_Buffer.resize(1, 0); + m_Buffer.reserve(1); + m_Buffer[0] = 0; m_GlobalWritePattern.clear(); m_GlobalWritePattern.resize(m_StreamSize); m_LocalReadPattern.clear(); @@ -199,7 +200,7 @@ void SscReader::PerformGets() { totalDataSize += i.second.second; } - m_Buffer.resize(totalDataSize); + m_Buffer.reserve(totalDataSize); for (const auto &i : m_AllReceivingWriterRanks) { MPI_Win_lock(MPI_LOCK_SHARED, i.first, 0, m_MpiWin); @@ -246,7 +247,7 @@ void SscReader::PerformGets() { \ continue; \ } \ - helper::NdCopy(m_Buffer.data() + b.bufferStart, b.start, \ + helper::NdCopy(m_Buffer.data() + b.bufferStart, b.start, \ b.count, true, true, \ reinterpret_cast(br.data), br.start, \ br.count, true, true); \ @@ -277,7 +278,7 @@ void SscReader::EndStepFixed() { MPI_Win_free(&m_MpiWin); SyncReadPattern(); - MPI_Win_create(m_Buffer.data(), m_Buffer.size(), 1, MPI_INFO_NULL, + MPI_Win_create(m_Buffer.data(), m_Buffer.capacity(), 1, MPI_INFO_NULL, m_StreamComm, &m_MpiWin); } if (m_MpiMode == "twosided") @@ -484,7 +485,7 @@ void SscReader::SyncReadPattern() { totalDataSize += i.second.second; } - m_Buffer.resize(totalDataSize); + m_Buffer.reserve(totalDataSize); if (m_Verbosity >= 20) { diff --git a/source/adios2/engine/ssc/SscReader.h b/source/adios2/engine/ssc/SscReader.h index 1c0e2df9de..4bd50b3109 100644 --- a/source/adios2/engine/ssc/SscReader.h +++ b/source/adios2/engine/ssc/SscReader.h @@ -48,7 +48,7 @@ class SscReader : public Engine ssc::Buffer m_GlobalWritePatternBuffer; ssc::RankPosMap m_AllReceivingWriterRanks; - std::vector m_Buffer; + ssc::Buffer m_Buffer; MPI_Win m_MpiWin; MPI_Group m_WriterGroup; MPI_Comm m_StreamComm; diff --git a/source/adios2/engine/ssc/SscReader.tcc b/source/adios2/engine/ssc/SscReader.tcc index 8404229e06..8c17d72bc3 100644 --- a/source/adios2/engine/ssc/SscReader.tcc +++ b/source/adios2/engine/ssc/SscReader.tcc @@ -138,7 +138,7 @@ void SscReader::GetDeferredCommon(Variable &variable, T *data) if (b.shapeId == ShapeID::GlobalArray || b.shapeId == ShapeID::LocalArray) { - helper::NdCopy(m_Buffer.data() + b.bufferStart, + helper::NdCopy(m_Buffer.data() + b.bufferStart, b.start, b.count, true, true, reinterpret_cast(data), vStart, vCount, true, true);