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

BP5internal - Switch to name based record lookup #3981

Merged
merged 2 commits into from
Jan 3, 2024
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
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
Loading