Skip to content

Commit

Permalink
Checks and changes in Get(variable, datum) (#4352)
Browse files Browse the repository at this point in the history
* For Get(variable, datum), check that variable shape is Global or Local Value, pass launch mode
* Fix inline reader to retrieve global/local values with default launch mode
* Fix skeleton reader to retrieve global/local values with default launch mode
* Fix ssc reader to retrieve global/local values with default launch mode
  • Loading branch information
eisenhauer authored Sep 27, 2024
1 parent cae0a45 commit 9cf916b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 9 deletions.
9 changes: 7 additions & 2 deletions source/adios2/core/Engine.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,14 @@ void Engine::Get(const std::string &variableName, T *data, const Mode launch)
}

template <class T>
void Engine::Get(Variable<T> &variable, T &datum, const Mode /*launch*/)
void Engine::Get(Variable<T> &variable, T &datum, const Mode launch)
{
Get(variable, &datum, Mode::Sync);
if ((variable.m_ShapeID != ShapeID::GlobalValue) && (variable.m_ShapeID != ShapeID::LocalValue))
{
helper::Throw<std::invalid_argument>("Core", "Engine", "Get",
"Single-valued Get() used on array variable.");
}
Get(variable, &datum, launch);
}

template <class T>
Expand Down
13 changes: 10 additions & 3 deletions source/adios2/engine/inline/InlineReader.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,16 @@ void InlineReader::Get(core::Variable<T> &variable, T **data) const
template <class T>
void InlineReader::GetDeferredCommon(Variable<T> &variable, T *data)
{
helper::Throw<std::runtime_error>(
"Engine", "InlineReader", "GetDeferredCommon",
"GetBlockDeferredCommon should be used instead of GetDeferredCommon.");
if ((variable.m_ShapeID == ShapeID::GlobalValue) || (variable.m_ShapeID == ShapeID::LocalValue))
{
GetSyncCommon(variable, data);
}
else
{
helper::Throw<std::runtime_error>(
"Engine", "InlineReader", "GetDeferredCommon",
"GetBlockDeferredCommon should be used instead of GetDeferredCommon.");
}
}

template <class T>
Expand Down
15 changes: 11 additions & 4 deletions source/adios2/engine/skeleton/SkeletonReader.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,19 @@ template <class T>
void SkeletonReader::GetDeferredCommon(Variable<T> &variable, T *data)
{
// returns immediately
if (m_Verbosity == 5)
if ((variable.m_ShapeID == ShapeID::GlobalValue) || (variable.m_ShapeID == ShapeID::LocalValue))
{
std::cout << "Skeleton Reader " << m_ReaderRank << " GetDeferred(" << variable.m_Name
<< ")\n";
GetSyncCommon(variable, data);
}
else
{
if (m_Verbosity == 5)
{
std::cout << "Skeleton Reader " << m_ReaderRank << " GetDeferred("
<< variable.m_Name << ")\n";
}
m_NeedPerformGets = true;
}
m_NeedPerformGets = true;
}

} // end namespace engine
Expand Down
5 changes: 5 additions & 0 deletions source/adios2/engine/ssc/SscReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ void SscReader::DoClose(const int transportIndex)
m_Verbosity >= 10 ? m_Comm.Rank() : 0, m_Comm.Rank(), 5, m_Verbosity, \
helper::LogMode::INFO); \
m_EngineInstance->GetDeferred(variable, data); \
if ((variable.m_ShapeID == ShapeID::GlobalValue) || \
(variable.m_ShapeID == ShapeID::LocalValue)) \
{ \
m_EngineInstance->PerformGets(); \
} \
} \
std::vector<typename Variable<T>::BPInfo> SscReader::DoBlocksInfo(const Variable<T> &variable, \
const size_t step) const \
Expand Down
4 changes: 4 additions & 0 deletions testing/adios2/engine/bp/TestBPWriteReadADIOS2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,10 @@ TEST_F(BPWriteReadTestADIOS2, ADIOS2BPWriteRead1D8)
bpReader.Get(var_u32, U32.data());
bpReader.Get(var_u64, U64.data());

{
float float_datum;
EXPECT_THROW(bpReader.Get(var_r32, float_datum), std::invalid_argument);
}
bpReader.Get(var_r32, R32.data());
bpReader.Get(var_r64, R64.data());

Expand Down

0 comments on commit 9cf916b

Please sign in to comment.