Skip to content

Commit

Permalink
BP5: fixes memory error with IBM XL
Browse files Browse the repository at this point in the history
  • Loading branch information
vicentebolea committed May 10, 2023
1 parent 8ce4ff9 commit 5012782
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
8 changes: 5 additions & 3 deletions source/adios2/engine/bp5/BP5Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,12 +547,14 @@ void BP5Writer::EndStep()
m_Profiler.Start("AWD");
// TSInfo destructor would delete the DataBuffer so we need to save it
// for async IO and let the writer free it up when not needed anymore
adios2::format::BufferV *databuf = TSInfo.DataBuffer;
TSInfo.DataBuffer = NULL;
m_AsyncWriteLock.lock();
m_flagRush = false;
m_AsyncWriteLock.unlock();
WriteData(databuf);

// WriteData will free TSInfo.DataBuffer
WriteData(TSInfo.DataBuffer);
TSInfo.DataBuffer = NULL;

m_Profiler.Stop("AWD");

/*
Expand Down
20 changes: 14 additions & 6 deletions source/adios2/toolkit/format/bp5/BP5Serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1333,19 +1333,27 @@ BP5Serializer::TimestepInfo BP5Serializer::CloseTimestep(int timestep,
MBase->BitField = tmp;
NewAttribute = false;

struct TimestepInfo Ret
{
Formats, Metadata, AttrData, CurDataBuffer
};
struct TimestepInfo Ret;
Ret.NewMetaMetaBlocks = Formats;
Ret.MetaEncodeBuffer.reset(Metadata);
Ret.AttributeEncodeBuffer.reset(AttrData);
Ret.DataBuffer = CurDataBuffer;
CurDataBuffer = NULL;

if (Info.AttributeFields)
{
free_FMfield_list(Info.AttributeFields);
Info.AttributeFields = NULL;
Info.AttributeFields = NULL;
}
Info.AttributeFieldCount = 0;

if (Info.AttributeData)
{
free(Info.AttributeData);
Info.AttributeData = NULL;
Info.AttributeData = NULL;
}
Info.AttributeSize = 0;

return Ret;
}

Expand Down
14 changes: 3 additions & 11 deletions source/adios2/toolkit/format/bp5/BP5Serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,9 @@ class BP5Serializer : virtual public BP5Base
struct TimestepInfo
{
std::vector<MetaMetaInfoBlock> NewMetaMetaBlocks;
Buffer *MetaEncodeBuffer;
Buffer *AttributeEncodeBuffer;
BufferV *DataBuffer;

~TimestepInfo()
{
delete MetaEncodeBuffer;
if (AttributeEncodeBuffer)
delete AttributeEncodeBuffer;
delete DataBuffer;
}
std::shared_ptr<Buffer> MetaEncodeBuffer;
std::shared_ptr<Buffer> AttributeEncodeBuffer;
BufferV* DataBuffer;
};

typedef struct _MetadataInfo
Expand Down

0 comments on commit 5012782

Please sign in to comment.