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

Fix MultiBlockChangingShape test #2863

Merged
merged 5 commits into from
Sep 14, 2021
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
4 changes: 4 additions & 0 deletions source/adios2/core/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,10 @@ class Engine
*/
bool m_ReaderSelectionsLocked = false;

/** true: Currently executing after BeginStep and before EndStep
*/
bool m_BetweenStepPairs = false;

private:
/** Throw exception by Engine virtual functions not implemented/supported by
* a derived class */
Expand Down
13 changes: 13 additions & 0 deletions source/adios2/engine/bp3/BP3Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ StepStatus BP3Reader::BeginStep(StepMode mode, const float timeoutSeconds)
"PerformGets() or EndStep()?, in call to BeginStep\n");
}

if (m_BetweenStepPairs)
{
throw std::logic_error("ERROR: BeginStep() is called a second time "
"without an intervening EndStep()");
}

m_BetweenStepPairs = true;
if (m_FirstStep)
{
m_FirstStep = false;
Expand Down Expand Up @@ -78,6 +85,12 @@ size_t BP3Reader::CurrentStep() const { return m_CurrentStep; }

void BP3Reader::EndStep()
{
if (!m_BetweenStepPairs)
{
throw std::logic_error(
"ERROR: EndStep() is called without a successful BeginStep()");
}
m_BetweenStepPairs = false;
PERFSTUBS_SCOPED_TIMER("BP3Reader::EndStep");
PerformGets();
}
Expand Down
13 changes: 13 additions & 0 deletions source/adios2/engine/bp4/BP4Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ StepStatus BP4Reader::BeginStep(StepMode mode, const float timeoutSeconds)
"BeginStep\n");
}

if (m_BetweenStepPairs)
{
throw std::logic_error("ERROR: BeginStep() is called a second time "
"without an intervening EndStep()");
}

if (!m_BP4Deserializer.m_DeferredVariables.empty())
{
throw std::invalid_argument(
Expand Down Expand Up @@ -75,6 +81,7 @@ StepStatus BP4Reader::BeginStep(StepMode mode, const float timeoutSeconds)

if (status == StepStatus::OK)
{
m_BetweenStepPairs = true;
if (m_FirstStep)
{
m_FirstStep = false;
Expand All @@ -101,6 +108,12 @@ size_t BP4Reader::CurrentStep() const { return m_CurrentStep; }

void BP4Reader::EndStep()
{
if (!m_BetweenStepPairs)
{
throw std::logic_error(
"ERROR: EndStep() is called without a successful BeginStep()");
}
m_BetweenStepPairs = false;
PERFSTUBS_SCOPED_TIMER("BP4Reader::EndStep");
PerformGets();
}
Expand Down
17 changes: 17 additions & 0 deletions source/adios2/engine/bp5/BP5Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ StepStatus BP5Reader::BeginStep(StepMode mode, const float timeoutSeconds)
throw std::logic_error(
"ERROR: BeginStep called in random access mode\n");
}
if (m_BetweenStepPairs)
{
throw std::logic_error("ERROR: BeginStep() is called a second time "
"without an intervening EndStep()");
}

if (mode != StepMode::Read)
{
throw std::invalid_argument("ERROR: mode is not supported yet, "
Expand All @@ -105,6 +111,7 @@ StepStatus BP5Reader::BeginStep(StepMode mode, const float timeoutSeconds)
}
if (status == StepStatus::OK)
{
m_BetweenStepPairs = true;
if (m_FirstStep)
{
m_FirstStep = false;
Expand Down Expand Up @@ -146,6 +153,16 @@ size_t BP5Reader::CurrentStep() const { return m_CurrentStep; }

void BP5Reader::EndStep()
{
if (m_OpenMode == Mode::ReadRandomAccess)
{
throw std::logic_error("ERROR: EndStep called in random access mode\n");
}
if (!m_BetweenStepPairs)
{
throw std::logic_error(
"ERROR: EndStep() is called without a successful BeginStep()");
}
m_BetweenStepPairs = false;
PERFSTUBS_SCOPED_TIMER("BP5Reader::EndStep");
PerformGets();
}
Expand Down
1 change: 0 additions & 1 deletion source/adios2/engine/sst/SstReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class SstReader : public Engine
SstMarshalMethod m_WriterMarshalMethod;
int m_WriterIsRowMajor;
bool m_DefinitionsNotified = false;
bool m_BetweenStepPairs = false;

/* --- Used only with BP marshaling --- */
SstFullMetadata m_CurrentStepMetaData = NULL;
Expand Down
1 change: 0 additions & 1 deletion source/adios2/engine/sst/SstWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class SstWriter : public Engine

SstStream m_Output;
long m_WriterStep = -1;
bool m_BetweenStepPairs = false;
bool m_DefinitionsNotified = false;
size_t m_MarshaledAttributesCount = 0;
struct _SstParams Params;
Expand Down
1 change: 0 additions & 1 deletion source/adios2/toolkit/sst/cp/ffs_marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,6 @@ void NO_SANITIZE_THREAD SstReaderInitFFSCallback(
{
Stream->VarSetupUpcall = VarCallback;
Stream->ArraySetupUpcall = ArrayCallback;
printf("Minarraycallback is %p\n", MinArrayCallback);
Stream->MinArraySetupUpcall = MinArrayCallback;
Stream->AttrSetupUpcall = AttrCallback;
Stream->ArrayBlocksInfoUpcall = BlocksInfoCallback;
Expand Down
2 changes: 2 additions & 0 deletions testing/adios2/bindings/fortran/TestF2C_BPReadFBlocks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ TEST_F(BPReadFBlocks, FHeatMap2D)
EXPECT_TRUE(r32Blocks[i].IsReverseDims);
}
}
bpReader.EndStep();
}
}
}
Expand Down Expand Up @@ -117,6 +118,7 @@ TEST_F(BPReadFBlocks, FHeatMap3D)
EXPECT_EQ(r32Blocks[i].IsReverseDims, true);
}
}
bpReader.EndStep();
}
}
}
Expand Down
23 changes: 3 additions & 20 deletions testing/adios2/engine/bp/TestBPChangingShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,28 +353,11 @@ TEST_F(BPChangingShape, MultiBlock)
var.SetSelection(
{{0, 0}, {static_cast<size_t>(nproc), expected_shape}});

// Check data on rank 0
if (!rank)
{
std::vector<double> data(nproc * expected_shape);
reader.Get(var, data.data());
std::vector<double> data(nproc * expected_shape);
reader.Get(var, data.data());

reader.EndStep();

for (int i = 0; i < nproc; i++)
{
double value = static_cast<double>(i) +
static_cast<double>(step + 1) / 10.0;

for (int j = 0; j < nblocks[step]; j++)
{
EXPECT_EQ(data[i * nblocks[step] + j], value);
value += 0.01;
}
}
}
EXPECT_THROW(reader.EndStep(), std::logic_error);
}
reader.Close();
}
}

Expand Down
2 changes: 1 addition & 1 deletion testing/adios2/hierarchy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
#accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#

gtest_add_tests_helper(HierarchicalReading MPI_NONE "" "" . "")
bp_gtest_add_tests_helper(HierarchicalReading MPI_NONE)
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,8 @@ TEST_F(ADIOSHierarchicalReadVariableTest, Read)
EXPECT_EQ(res.size(), 5);
res = g.AvailableAttributes();
EXPECT_EQ(res.size(), 0);
engine.EndStep();
}
for (size_t step = 0; step < NSteps; step++)
{
engine.BeginStep();
auto g = io.InquireGroup('/');
auto res = g.AvailableGroups();
EXPECT_EQ(res[0], "group1");
res = g.AvailableVariables();
EXPECT_EQ(res[0], "variable6");
engine.EndStep();
}
for (size_t step = 0; step < NSteps; step++)
{
auto g = io.InquireGroup('/');

g = io.InquireGroup('/');
auto var = g.InquireVariable<int32_t>("variable6");
EXPECT_TRUE(var);
if (var)
Expand All @@ -128,12 +115,8 @@ TEST_F(ADIOSHierarchicalReadVariableTest, Read)
engine.Get<int32_t>(var, myInts, adios2::Mode::Sync);
EXPECT_EQ(Ints, myInts);
}
}
for (size_t step = 0; step < NSteps; step++)
{
auto g = io.InquireGroup('/');
g.setPath("group1/group2/group3/group4");
auto var = g.InquireVariable<int32_t>("variable1");
var = g.InquireVariable<int32_t>("variable1");
EXPECT_TRUE(var);
if (var)
{
Expand All @@ -143,6 +126,7 @@ TEST_F(ADIOSHierarchicalReadVariableTest, Read)

EXPECT_EQ(Ints, myInts);
}
engine.EndStep();
}
engine.Close();
}
Expand Down