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

First cut at reader-side derived variables #4228

Merged
merged 1 commit into from
Jul 16, 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
17 changes: 17 additions & 0 deletions source/adios2/common/ADIOSTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ std::string ToString(MemorySpace value)
}
}

#ifdef ADIOS2_HAVE_DERIVED_VARIABLE
std::string ToString(DerivedVarType value)
{
switch (value)
{
case DerivedVarType::MetadataOnly:
return "DerivedVarType::MetadataOnly";
case DerivedVarType::ExpressionString:
return "DerivedVarType::ExpressionString";
case DerivedVarType::StoreData:
return "DerivedVarType::StoreData";
default:
return "ToString: Unknown DerivedVarType";
}
};
#endif

std::string ToString(ShapeID value)
{
switch (value)
Expand Down
3 changes: 3 additions & 0 deletions source/adios2/common/ADIOSTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ bool TypeHasMinMax(DataType adiosvartype);
*/

std::string ToString(ShapeID value);
#ifdef ADIOS2_HAVE_DERIVED_VARIABLE
std::string ToString(DerivedVarType value);
#endif
std::string ToString(IOMode value);
std::string ToString(Mode value);
std::string ToString(ReadMultiplexPattern value);
Expand Down
7 changes: 7 additions & 0 deletions source/adios2/core/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,13 @@ class Engine
return nullptr;
}

// in this call, Step is RELATIVE, not absolute
virtual MinVarInfo *MinBlocksInfo(const VariableBase &, const size_t Step,
const size_t WriterID, const size_t BlockID) const
{
return nullptr;
}

// in this call, Step is RELATIVE, not absolute
virtual bool VarShape(const VariableBase &, const size_t Step, Dims &Shape) const
{
Expand Down
16 changes: 16 additions & 0 deletions source/adios2/core/IO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,22 @@ bool IO::RemoveVariable(const std::string &name) noexcept
return isRemoved;
}

#ifdef ADIOS2_HAVE_DERIVED_VARIABLE
bool IO::RemoveDerivedVariable(const std::string &name) noexcept
{
PERFSTUBS_SCOPED_TIMER("IO::RemoveVariable");
bool isRemoved = false;
auto itVariable = m_VariablesDerived.find(name);
// variable exists
if (itVariable != m_VariablesDerived.end())
{
m_VariablesDerived.erase(itVariable);
isRemoved = true;
}
return isRemoved;
}
#endif

void IO::RemoveAllVariables() noexcept
{
PERFSTUBS_SCOPED_TIMER("IO::RemoveAllVariables");
Expand Down
12 changes: 12 additions & 0 deletions source/adios2/core/IO.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,18 @@ class IO
*/
bool RemoveVariable(const std::string &name) noexcept;

#ifdef ADIOS2_HAVE_DERIVED_VARIABLE
/**
* @brief Removes an existing DerivedVariable in current IO object.
* Dangerous function since references and
* pointers can be dangling after this call.
* @param name unique identifier input
* @return true: found and removed variable, false: not found, nothing to
* remove
*/
bool RemoveDerivedVariable(const std::string &name) noexcept;
#endif

/**
* @brief Removes all existing variables in current IO object.
* Dangerous function since references and
Expand Down
13 changes: 9 additions & 4 deletions source/adios2/engine/bp5/BP5Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,7 @@ void BP5Reader::PerformGets()
}

// clear pending requests inside deserializer
{
std::vector<adios2::format::BP5Deserializer::ReadRequest> empty;
m_BP5Deserializer->FinalizeGets(empty);
}
m_BP5Deserializer->ClearGetState();
}

void BP5Reader::PerformRemoteGetsWithKVCache()
Expand Down Expand Up @@ -661,6 +658,8 @@ void BP5Reader::PerformLocalGets()
m_BP5Deserializer->FinalizeGet(Req, false);
}
}
m_BP5Deserializer->FinalizeDerivedGets(ReadRequests);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be included between macros #ifdef ADIOS2_HAVE_DERIVED_VARIABLE

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FinalizeDerivedGets is defined without or without derived vars, it just has a null body without them. Could go either way here, but having a null body keeps the number of #ifdef's down at least a little bit.

m_BP5Deserializer->ClearGetState();
m_JSONProfiler.Stop("DataRead");
/*TP end = NOW();
double t1 = DURATION(start, end);
Expand Down Expand Up @@ -914,6 +913,12 @@ MinVarInfo *BP5Reader::MinBlocksInfo(const VariableBase &Var, const size_t Step)
return m_BP5Deserializer->MinBlocksInfo(Var, Step);
}

MinVarInfo *BP5Reader::MinBlocksInfo(const VariableBase &Var, const size_t Step,
const size_t WriterID, const size_t BlockID) const
{
return m_BP5Deserializer->MinBlocksInfo(Var, Step, WriterID, BlockID);
}

bool BP5Reader::VarShape(const VariableBase &Var, const size_t Step, Dims &Shape) const
{
return m_BP5Deserializer->VarShape(Var, Step, Shape);
Expand Down
2 changes: 2 additions & 0 deletions source/adios2/engine/bp5/BP5Reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class BP5Reader : public BP5Engine, public Engine
void PerformGets() final;

MinVarInfo *MinBlocksInfo(const VariableBase &, const size_t Step) const;
MinVarInfo *MinBlocksInfo(const VariableBase &, const size_t Step, const size_t WriterID,
const size_t BlockID) const;
bool VarShape(const VariableBase &Var, const size_t Step, Dims &Shape) const;
bool VariableMinMax(const VariableBase &, const size_t Step, MinMaxStruct &MinMax);
std::string VariableExprStr(const VariableBase &Var);
Expand Down
1 change: 1 addition & 0 deletions source/adios2/engine/sst/SstReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,7 @@ void SstReader::BP5PerformGets()
}

m_BP5Deserializer->FinalizeGets(ReadRequests);
m_BP5Deserializer->ClearGetState();
}

void SstReader::PerformGets()
Expand Down
Loading
Loading