Skip to content

Commit

Permalink
BP5internal - Switch to name based record lookup (#3981)
Browse files Browse the repository at this point in the history
* BP5internal - Switch to name based record lookup

* Fix Var reference
  • Loading branch information
eisenhauer committed Jan 3, 2024
1 parent 9f9248a commit c093fb1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
1 change: 0 additions & 1 deletion CTestConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ set(MEMORYCHECK_SUPPRESSIONS_FILE ${CMAKE_SOURCE_DIR}/scripts/dashboard/nightly/

# Ignore tests that are currently failing, remove tests here as they are fixed
list(APPEND CTEST_CUSTOM_MEMCHECK_IGNORE
Engine.BP.BPWriteReadAsStreamTestADIOS2.ReaderWriterDefineVariable.BP5.Serial
Remote.BPWriteReadADIOS2stdio.GetRemote
Remote.BPWriteMemorySelectionRead.GetRemote
Remote.BPWriteMemorySelectionRead.FileRemote
Expand Down
21 changes: 12 additions & 9 deletions source/adios2/toolkit/format/bp5/BP5Serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ namespace format
BP5Serializer::BP5Serializer() { Init(); }
BP5Serializer::~BP5Serializer()
{
if (!Info.RecMap.empty())
if (!Info.RecNameMap.empty())
{
for (auto &rec : Info.RecMap)
for (auto &rec : Info.RecNameMap)
{
if (rec.second.OperatorType)
free(rec.second.OperatorType);
}
Info.RecMap.clear();
Info.RecNameMap.clear();
}
if (Info.MetaFieldCount)
free_FMfield_list(Info.MetaFields);
Expand Down Expand Up @@ -82,12 +82,13 @@ void BP5Serializer::Init()
((BP5MetadataInfoStruct *)MetadataBuf)->BitField = (std::size_t *)malloc(sizeof(size_t));
((BP5MetadataInfoStruct *)MetadataBuf)->DataBlockSize = 0;
}
BP5Serializer::BP5WriterRec BP5Serializer::LookupWriterRec(void *Key) const
BP5Serializer::BP5WriterRec BP5Serializer::LookupWriterRec(void *Variable) const
{
auto it = Info.RecMap.find(Key);
if (it != Info.RecMap.end())
core::VariableBase *VB = static_cast<core::VariableBase *>(Variable);
auto it2 = Info.RecNameMap.find(VB->m_Name);
if (it2 != Info.RecNameMap.end())
{
return const_cast<BP5WriterRec>(&(it->second));
return const_cast<BP5WriterRec>(&(it2->second));
}
return NULL;
}
Expand Down Expand Up @@ -467,6 +468,8 @@ void BP5Serializer::AddDoubleArrayField(FMFieldList *FieldP, int *CountP, const
void BP5Serializer::ValidateWriterRec(BP5Serializer::BP5WriterRec Rec, void *Variable)
{
core::VariableBase *VB = static_cast<core::VariableBase *>(Variable);

Rec->Key = Variable; // reset this, because Variable might have been destroyed and recreated
if ((VB->m_Operations.size() == 0) && Rec->OperatorType)
{
// removed operator case
Expand Down Expand Up @@ -505,7 +508,7 @@ BP5Serializer::BP5WriterRec BP5Serializer::CreateWriterRec(void *Variable, const
#ifdef ADIOS2_HAVE_DERIVED_VARIABLE
core::VariableDerived *VD = dynamic_cast<core::VariableDerived *>(VB);
#endif
auto obj = Info.RecMap.insert(std::make_pair(Variable, _BP5WriterRec()));
auto obj = Info.RecNameMap.insert(std::make_pair(VB->m_Name, _BP5WriterRec()));
BP5WriterRec Rec = &obj.first->second;
if (Type == DataType::String)
ElemSize = sizeof(char *);
Expand Down Expand Up @@ -1250,7 +1253,7 @@ BufferV *BP5Serializer::ReinitStepData(BufferV *DataBuffer, bool forceCopyDeferr

void BP5Serializer::CollectFinalShapeValues()
{
for (auto it : Info.RecMap)
for (auto it : Info.RecNameMap)
{
BP5WriterRec Rec = &it.second;
if (Rec->Shape == ShapeID::GlobalArray)
Expand Down
2 changes: 1 addition & 1 deletion source/adios2/toolkit/format/bp5/BP5Serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class BP5Serializer : virtual public BP5Base
FMFormat AttributeFormat = NULL;
void *AttributeData = NULL;
int AttributeSize = 0;
std::unordered_map<void *, _BP5WriterRec> RecMap;
std::unordered_map<std::string, _BP5WriterRec> RecNameMap;
};

FMFormat GenericAttributeFormat = NULL;
Expand Down

0 comments on commit c093fb1

Please sign in to comment.