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 bug: BP4 with time aggregation (FlushStepCount > 1) broke if ther… #2429

Merged
merged 2 commits into from
Aug 14, 2020
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
15 changes: 6 additions & 9 deletions source/adios2/toolkit/format/bp/bp4/BP4Serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,12 +958,10 @@ void BP4Serializer::AggregateCollectiveMetadataIndices(helper::Comm const &comm,

const uint64_t variablesIndexStart = position;
ptrs.push_back(variablesIndexStart);
if (!varIndicesInfo.empty())
const auto itvars = varIndicesInfo.find(t);
if (itvars != varIndicesInfo.end())
{

std::unordered_map<std::string,
std::vector<std::tuple<size_t, size_t>>>
perStepVarIndicesInfo = varIndicesInfo.at(t);
const auto perStepVarIndicesInfo = itvars->second;
size_t perStepVarCountPosition = position;
const uint32_t perStepVarCountU32 =
static_cast<uint32_t>(perStepVarIndicesInfo.size());
Expand Down Expand Up @@ -1026,11 +1024,10 @@ void BP4Serializer::AggregateCollectiveMetadataIndices(helper::Comm const &comm,
const uint64_t attributesIndexStart = position;
ptrs.push_back(attributesIndexStart);

if (!attrIndicesInfo.empty())
const auto itattrs = attrIndicesInfo.find(t);
if (itattrs != attrIndicesInfo.end())
{
std::unordered_map<std::string,
std::vector<std::tuple<size_t, size_t>>>
perStepAttrIndicesInfo = attrIndicesInfo.at(t);
const auto perStepAttrIndicesInfo = itattrs->second;
size_t perStepAttrCountPosition = position;
const uint32_t perStepAttrCountU32 =
static_cast<uint32_t>(perStepAttrIndicesInfo.size());
Expand Down
21 changes: 21 additions & 0 deletions testing/adios2/engine/bp/TestBPTimeAggregation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ void TimeAggregation1D8(const std::string flushstepscount)
#else
adios2::ADIOS adios;
#endif
const std::string TestName =
"TimeAggregation1D8 flush every " + flushstepscount + " steps";
{
adios2::IO io = adios.DeclareIO("TestIO");

Expand Down Expand Up @@ -73,6 +75,8 @@ void TimeAggregation1D8(const std::string flushstepscount)
auto var_r32 = io.DefineVariable<float>("r32", shape, start, count);
auto var_r64 =
io.DefineVariable<double>("r64", shape, start, count);

io.DefineAttribute<std::string>("TestName", TestName);
}

if (!engineName.empty())
Expand Down Expand Up @@ -230,6 +234,12 @@ void TimeAggregation1D8(const std::string flushstepscount)
ASSERT_EQ(var_r64.Steps(), NSteps);
ASSERT_EQ(var_r64.Shape()[0], mpiSize * Nx);

auto attr = io.InquireAttribute<std::string>("TestName");
EXPECT_TRUE(attr);
ASSERT_EQ(attr.Data().size() == 1, true);
ASSERT_EQ(attr.Type(), adios2::GetType<std::string>());
ASSERT_EQ(attr.Data().front(), TestName);

// TODO: other types

SmallTestData testData;
Expand Down Expand Up @@ -355,6 +365,9 @@ void TimeAggregation2D4x2(const std::string flushstepscount)
#else
adios2::ADIOS adios;
#endif
const std::string TestName =
"TimeAggregation2D4x2 flush every " + flushstepscount + " steps";

{
adios2::IO io = adios.DeclareIO("TestIO");

Expand Down Expand Up @@ -387,6 +400,8 @@ void TimeAggregation2D4x2(const std::string flushstepscount)
auto var_r32 = io.DefineVariable<float>("r32", shape, start, count);
auto var_r64 =
io.DefineVariable<double>("r64", shape, start, count);

io.DefineAttribute<std::string>("TestName", TestName);
}

if (!engineName.empty())
Expand Down Expand Up @@ -552,6 +567,12 @@ void TimeAggregation2D4x2(const std::string flushstepscount)
ASSERT_EQ(var_r64.Shape()[0], Ny);
ASSERT_EQ(var_r64.Shape()[1], static_cast<size_t>(mpiSize * Nx));

auto attr = io.InquireAttribute<std::string>("TestName");
EXPECT_TRUE(attr);
ASSERT_EQ(attr.Data().size() == 1, true);
ASSERT_EQ(attr.Type(), adios2::GetType<std::string>());
ASSERT_EQ(attr.Data().front(), TestName);

std::string IString;
std::array<int8_t, Nx * Ny> I8;
std::array<int16_t, Nx * Ny> I16;
Expand Down