Skip to content

Commit

Permalink
First cut at reader-side derived variables
Browse files Browse the repository at this point in the history
  • Loading branch information
eisenhauer committed Jul 16, 2024
1 parent ab1518d commit 1b5d544
Show file tree
Hide file tree
Showing 11 changed files with 334 additions and 14 deletions.
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);
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

0 comments on commit 1b5d544

Please sign in to comment.