Skip to content

Commit

Permalink
added test for ssc struct BlocksInfo
Browse files Browse the repository at this point in the history
JasonRuonanWang committed May 3, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 0520d14 commit 7e3a855
Showing 5 changed files with 28 additions and 13 deletions.
9 changes: 6 additions & 3 deletions source/adios2/engine/ssc/SscReaderGeneric.cpp
Original file line number Diff line number Diff line change
@@ -575,10 +575,10 @@ SscReaderGeneric::BlocksInfo(const VariableStruct &variable,
const size_t step) const
{
std::vector<VariableStruct::BPInfo> ret;

for (const auto &r : m_GlobalWritePattern)
size_t blockID = 0;
for (size_t i = 0; i < m_GlobalWritePattern.size(); ++i)
{
for (auto &v : r)
for (auto &v : m_GlobalWritePattern[i])
{
if (v.name == variable.m_Name)
{
@@ -590,10 +590,13 @@ SscReaderGeneric::BlocksInfo(const VariableStruct &variable,
b.Step = m_CurrentStep;
b.StepsStart = m_CurrentStep;
b.StepsCount = 1;
b.WriterID = i;
b.BlockID = blockID;
if (m_IO.m_ArrayOrder != ArrayOrdering::RowMajor)
{
b.IsReverseDims = true;
}
++blockID;
}
}
}
9 changes: 6 additions & 3 deletions source/adios2/engine/ssc/SscReaderGeneric.tcc
Original file line number Diff line number Diff line change
@@ -29,10 +29,10 @@ SscReaderGeneric::BlocksInfoCommon(const Variable<T> &variable,
const size_t step) const
{
std::vector<typename Variable<T>::BPInfo> ret;

for (const auto &r : m_GlobalWritePattern)
size_t blockID = 0;
for (size_t i = 0; i < m_GlobalWritePattern.size(); ++i)
{
for (auto &v : r)
for (auto &v : m_GlobalWritePattern[i])
{
if (v.name == variable.m_Name)
{
@@ -44,6 +44,8 @@ SscReaderGeneric::BlocksInfoCommon(const Variable<T> &variable,
b.Step = m_CurrentStep;
b.StepsStart = m_CurrentStep;
b.StepsCount = 1;
b.WriterID = i;
b.BlockID = blockID;
if (m_IO.m_ArrayOrder != ArrayOrdering::RowMajor)
{
b.IsReverseDims = true;
@@ -66,6 +68,7 @@ SscReaderGeneric::BlocksInfoCommon(const Variable<T> &variable,
v.bufferCount);
}
}
++blockID;
}
}
}
3 changes: 3 additions & 0 deletions source/adios2/engine/ssc/SscReaderNaive.cpp
Original file line number Diff line number Diff line change
@@ -210,6 +210,7 @@ SscReaderNaive::BlocksInfo(const VariableStruct &variable,
const size_t step) const
{
std::vector<VariableStruct::BPInfo> ret;
size_t blockID = 0;
auto it = m_BlockMap.find(variable.m_Name);
if (it != m_BlockMap.end())
{
@@ -223,10 +224,12 @@ SscReaderNaive::BlocksInfo(const VariableStruct &variable,
b.Step = m_CurrentStep;
b.StepsStart = m_CurrentStep;
b.StepsCount = 1;
b.BlockID = blockID;
if (m_IO.m_ArrayOrder != ArrayOrdering::RowMajor)
{
b.IsReverseDims = true;
}
++blockID;
}
}
return ret;
3 changes: 3 additions & 0 deletions source/adios2/engine/ssc/SscReaderNaive.tcc
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@ SscReaderNaive::BlocksInfoCommon(const Variable<T> &variable,
const size_t step) const
{
std::vector<typename Variable<T>::BPInfo> ret;
size_t blockID = 0;
auto it = m_BlockMap.find(variable.m_Name);
if (it != m_BlockMap.end())
{
@@ -42,6 +43,7 @@ SscReaderNaive::BlocksInfoCommon(const Variable<T> &variable,
b.Step = m_CurrentStep;
b.StepsStart = m_CurrentStep;
b.StepsCount = 1;
b.BlockID = blockID;
if (m_IO.m_ArrayOrder != ArrayOrdering::RowMajor)
{
b.IsReverseDims = true;
@@ -53,6 +55,7 @@ SscReaderNaive::BlocksInfoCommon(const Variable<T> &variable,
std::memcpy(reinterpret_cast<char *>(&b.Value), v.value.data(),
v.value.size());
}
++blockID;
}
}
return ret;
17 changes: 10 additions & 7 deletions testing/adios2/engine/ssc/TestSscStruct.cpp
Original file line number Diff line number Diff line change
@@ -13,6 +13,8 @@
using namespace adios2;
int mpiRank = 0;
int mpiSize = 1;
int worldRank = 0;
int worldSize = 2;
MPI_Comm mpiComm;

class SscEngineTest : public ::testing::Test
@@ -262,6 +264,14 @@ void Reader(const Dims &shape, const Dims &start, const Dims &count,
ASSERT_EQ(myParticles[i].b[2], 20);
ASSERT_EQ(myParticles[i].b[3], 30);
}
auto structBlocks = engine.BlocksInfo(varStruct, currentStep);
ASSERT_EQ(structBlocks.size(), worldSize - mpiSize);
for (size_t i = 0; i < structBlocks.size(); ++i)
{
ASSERT_FALSE(structBlocks[i].IsValue);
ASSERT_FALSE(structBlocks[i].IsReverseDims);
ASSERT_EQ(structBlocks[i].Step, currentStep);
}

ASSERT_EQ(i, currentStep);
engine.EndStep();
@@ -284,9 +294,6 @@ TEST_F(SscEngineTest, TestSscStruct)
{
std::string filename = "TestSscStruct";
adios2::Params engineParams = {{"Verbose", "0"}};
int worldRank, worldSize;
MPI_Comm_rank(MPI_COMM_WORLD, &worldRank);
MPI_Comm_size(MPI_COMM_WORLD, &worldSize);
int mpiGroup = worldRank / (worldSize / 2);
MPI_Comm_split(MPI_COMM_WORLD, mpiGroup, worldRank, &mpiComm);
MPI_Comm_rank(mpiComm, &mpiRank);
@@ -310,9 +317,6 @@ TEST_F(SscEngineTest, TestSscStruct)
std::string filename = "TestSscStructNaive";
adios2::Params engineParams = {{"Verbose", "0"},
{"EngineMode", "naive"}};
int worldRank, worldSize;
MPI_Comm_rank(MPI_COMM_WORLD, &worldRank);
MPI_Comm_size(MPI_COMM_WORLD, &worldSize);
int mpiGroup = worldRank / (worldSize / 2);
MPI_Comm_split(MPI_COMM_WORLD, mpiGroup, worldRank, &mpiComm);
MPI_Comm_rank(mpiComm, &mpiRank);
@@ -337,7 +341,6 @@ TEST_F(SscEngineTest, TestSscStruct)
int main(int argc, char **argv)
{
MPI_Init(&argc, &argv);
int worldRank, worldSize;
MPI_Comm_rank(MPI_COMM_WORLD, &worldRank);
MPI_Comm_size(MPI_COMM_WORLD, &worldSize);
::testing::InitGoogleTest(&argc, argv);

0 comments on commit 7e3a855

Please sign in to comment.