Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero out first and last KB of data buffer in BP4, instead of the enti… #2534

Merged
merged 1 commit into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions source/adios2/engine/bp4/BP4Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void BP4Writer::Flush(const int transportIndex)
{
TAU_SCOPED_TIMER("BP4Writer::Flush");
DoFlush(false, transportIndex);
m_BP4Serializer.ResetBuffer(m_BP4Serializer.m_Data);
m_BP4Serializer.ResetBuffer(m_BP4Serializer.m_Data, false, false);

if (m_BP4Serializer.m_Parameters.CollectiveMetadata)
{
Expand Down Expand Up @@ -683,10 +683,10 @@ void BP4Writer::WriteCollectiveMetadataFile(const bool isFinal)
}
}
/*Clear the local indices buffer at the end of each step*/
m_BP4Serializer.ResetBuffer(m_BP4Serializer.m_Metadata, true);
m_BP4Serializer.ResetBuffer(m_BP4Serializer.m_Metadata, true, true);

/* clear the metadata index buffer*/
m_BP4Serializer.ResetBuffer(m_BP4Serializer.m_MetadataIndex, true);
m_BP4Serializer.ResetBuffer(m_BP4Serializer.m_MetadataIndex, true, true);

/* reset the metadata index table*/
m_BP4Serializer.ResetMetadataIndexTable();
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/engine/bp4/BP4Writer.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void BP4Writer::PutSyncCommon(Variable<T> &variable,
if (resizeResult == format::BP4Base::ResizeResult::Flush)
{
DoFlush(false);
m_BP4Serializer.ResetBuffer(m_BP4Serializer.m_Data);
m_BP4Serializer.ResetBuffer(m_BP4Serializer.m_Data, false, false);

// new group index for incoming variable
m_BP4Serializer.PutProcessGroupIndex(
Expand Down
21 changes: 20 additions & 1 deletion source/adios2/toolkit/format/buffer/heap/BufferSTL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#include "BufferSTL.h"
#include "BufferSTL.tcc"
#include <cstdlib>
#include <cstring>

namespace adios2
{
Expand Down Expand Up @@ -51,7 +53,24 @@ void BufferSTL::Reset(const bool resetAbsolutePosition,
}
if (zeroInitialize)
{
m_Buffer.assign(m_Buffer.size(), '\0');
std::fill(m_Buffer.begin(), m_Buffer.end(), 0);
}
else
{
// just zero out the first and last 1kb
const size_t bufsize = m_Buffer.size();
size_t s = (bufsize < 1024 ? bufsize : 1024);
std::fill_n(m_Buffer.begin(), s, 0);
if (bufsize > 1024)
{
size_t pos = bufsize - 1024;
if (pos < 1024)
{
pos = 1024;
}
s = bufsize - pos;
std::fill_n(next(m_Buffer.begin(), pos), s, 0);
}
}
}

Expand Down