diff --git a/source/adios2/toolkit/format/bp5/BP5Serializer.cpp b/source/adios2/toolkit/format/bp5/BP5Serializer.cpp index b88535c099..2cd0ba0ed5 100644 --- a/source/adios2/toolkit/format/bp5/BP5Serializer.cpp +++ b/source/adios2/toolkit/format/bp5/BP5Serializer.cpp @@ -28,18 +28,37 @@ namespace adios2 namespace format { +namespace +{ +// To keep ABI compatibility with ADIOS 2.9.0 +static std::map GlobalRecMap; +} + +BP5Serializer::RecMap &BP5Serializer::GetRecMap(BP5Serializer *ptr) +{ + auto it = GlobalRecMap.find(ptr); + if (it == GlobalRecMap.end()) + { + it = GlobalRecMap.insert({ptr, {}}).first; + } + return it->second; +} + BP5Serializer::BP5Serializer() { Init(); } BP5Serializer::~BP5Serializer() { - if (!Info.RecMap.empty()) + auto &rec_map = BP5Serializer::GetRecMap(this); + if (!rec_map.empty()) { - for (auto &rec : Info.RecMap) + for (auto &rec : rec_map) { if (rec.second.OperatorType) free(rec.second.OperatorType); } - Info.RecMap.clear(); + rec_map.clear(); } + GlobalRecMap.erase(this); + if (Info.MetaFieldCount) free_FMfield_list(Info.MetaFields); if (Info.LocalFMContext) @@ -79,8 +98,9 @@ void BP5Serializer::Init() } BP5Serializer::BP5WriterRec BP5Serializer::LookupWriterRec(void *Key) { - auto it = Info.RecMap.find(Key); - if (it != Info.RecMap.end()) + auto &rec_map = BP5Serializer::GetRecMap(this); + auto it = rec_map.find(Key); + if (it != rec_map.end()) { return const_cast(&(it->second)); } @@ -438,7 +458,8 @@ BP5Serializer::CreateWriterRec(void *Variable, const char *Name, DataType Type, size_t ElemSize, size_t DimCount) { core::VariableBase *VB = static_cast(Variable); - auto obj = Info.RecMap.insert(std::make_pair(Variable, _BP5WriterRec())); + auto obj = BP5Serializer::GetRecMap(this).insert( + std::make_pair(Variable, _BP5WriterRec())); BP5WriterRec Rec = &obj.first->second; if (Type == DataType::String) ElemSize = sizeof(char *); @@ -1129,7 +1150,7 @@ BufferV *BP5Serializer::ReinitStepData(BufferV *DataBuffer, void BP5Serializer::CollectFinalShapeValues() { - for (auto it : Info.RecMap) + for (auto it : BP5Serializer::GetRecMap(this)) { BP5WriterRec Rec = &it.second; if (Rec->Shape == ShapeID::GlobalArray) diff --git a/source/adios2/toolkit/format/bp5/BP5Serializer.h b/source/adios2/toolkit/format/bp5/BP5Serializer.h index fc4f43c2ed..2cf72d3c1a 100644 --- a/source/adios2/toolkit/format/bp5/BP5Serializer.h +++ b/source/adios2/toolkit/format/bp5/BP5Serializer.h @@ -21,8 +21,6 @@ #pragma warning(disable : 4250) #endif -#include - namespace adios2 { namespace format @@ -42,9 +40,7 @@ class BP5Serializer : virtual public BP5Base Buffer *AttributeEncodeBuffer; BufferV *DataBuffer; - ~TimestepInfo() - { - } + ~TimestepInfo() {} }; typedef struct _MetadataInfo @@ -162,6 +158,7 @@ class BP5Serializer : virtual public BP5Base struct FFSWriterMarshalBase { int RecCount = 0; + BP5WriterRec RecList = NULL; FMContext LocalFMContext = {0}; int MetaFieldCount = 0; FMFieldList MetaFields = NULL; @@ -171,7 +168,6 @@ class BP5Serializer : virtual public BP5Base FMFormat AttributeFormat = NULL; void *AttributeData = NULL; int AttributeSize = 0; - std::unordered_map RecMap; }; FMFormat GenericAttributeFormat = NULL; @@ -255,6 +251,10 @@ class BP5Serializer : virtual public BP5Base size_t ElemCount; void *Array; } ArrayRec; + +public: + using RecMap = std::unordered_map; + static RecMap &GetRecMap(BP5Serializer *ptr); }; } // end namespace format