Skip to content

Commit

Permalink
fixed some bugs for ssc writer multiblock
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonRuonanWang committed Jan 8, 2020
1 parent 0422759 commit c6ce6fd
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 49 deletions.
16 changes: 8 additions & 8 deletions source/adios2/engine/ssc/SscHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,17 +138,17 @@ void JsonToBlockVecVec(const nlohmann::json &input, BlockVecVec &output)
{
auto &rankj = input[i];
output[i].clear();
for (auto it = rankj.begin(); it != rankj.end(); ++it)
for (const auto &j : rankj)
{
output[i].emplace_back();
auto &b = output[i].back();
b.name = it.key();
b.type = it.value()["T"].get<std::string>();
b.start = it.value()["O"].get<Dims>();
b.count = it.value()["C"].get<Dims>();
b.shape = it.value()["S"].get<Dims>();
b.bufferStart = it.value()["X"].get<size_t>();
b.bufferCount = it.value()["Y"].get<size_t>();
b.name = j["N"].get<std::string>();
b.type = j["T"].get<std::string>();
b.start = j["O"].get<Dims>();
b.count = j["C"].get<Dims>();
b.shape = j["S"].get<Dims>();
b.bufferStart = j["X"].get<size_t>();
b.bufferCount = j["Y"].get<size_t>();
}
}
}
Expand Down
62 changes: 28 additions & 34 deletions source/adios2/engine/ssc/SscReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,51 +143,43 @@ void SscReader::SyncWritePattern()
MPI_Win_free(&win);

// deserialize
nlohmann::json j;
try
{
j = nlohmann::json::parse(globalVec);
}
catch (...)
{
throw(std::runtime_error("reader received corrupted metadata"));
}

m_GlobalWritePattern.resize(m_WriterSize);
for (int rank = 0; rank < m_WriterSize; ++rank)
ssc::JsonToBlockVecVec(globalVec, m_GlobalWritePattern);

for (const auto &blockVec : m_GlobalWritePattern)
{
for (auto itVar = j[rank].begin(); itVar != j[rank].end(); ++itVar)
for (const auto &b : blockVec)
{
std::string type = itVar.value()["T"].get<std::string>();
Dims shape = itVar.value()["S"].get<Dims>();
Dims start = itVar.value()["O"].get<Dims>();
auto &blockVecRef = m_GlobalWritePattern[rank];
blockVecRef.emplace_back();
blockVecRef.back().name = itVar.key();
blockVecRef.back().shape = shape;
blockVecRef.back().start = start;
blockVecRef.back().count = itVar.value()["C"].get<Dims>();
blockVecRef.back().type = type;
blockVecRef.back().bufferStart = itVar.value()["X"].get<size_t>();
blockVecRef.back().bufferCount = itVar.value()["Y"].get<size_t>();
if (rank == 0)
if (b.type.empty())
{
if (type.empty())
{
throw(std::runtime_error("unknown data type"));
}
throw(std::runtime_error("unknown data type"));
}
#define declare_type(T) \
else if (type == helper::GetType<T>()) \
else if (b.type == helper::GetType<T>()) \
{ \
m_IO.DefineVariable<T>(itVar.key(), shape, start, shape); \
auto v = m_IO.InquireVariable<T>(b.name); \
if (not v) \
{ \
m_IO.DefineVariable<T>(b.name, b.shape, b.start, b.shape); \
} \
}
ADIOS2_FOREACH_STDTYPE_1ARG(declare_type)
ADIOS2_FOREACH_STDTYPE_1ARG(declare_type)
#undef declare_type
else { throw(std::runtime_error("unknown data type")); }
}
else { throw(std::runtime_error("unknown data type")); }
}
}

nlohmann::json j;
try
{
j = nlohmann::json::parse(globalVec);
}
catch (...)
{
throw(std::runtime_error("corrupted json string"));
}

for (const auto &attributeJson : j[m_WriterSize])
{
const std::string type(attributeJson["T"].get<std::string>());
Expand Down Expand Up @@ -256,7 +248,9 @@ void SscReader::SyncReadPattern()
#undef declare_type
else { throw(std::runtime_error("unknown data type")); }

auto &jref = j[var.first];
j.emplace_back();
auto &jref = j.back();
jref["N"] = var.first;
jref["T"] = type;
jref["O"] = b.start;
jref["C"] = b.count;
Expand Down
10 changes: 3 additions & 7 deletions source/adios2/engine/ssc/SscWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ void SscWriter::SyncWritePattern()

for (const auto &b : m_GlobalWritePattern[m_WriterRank])
{
auto &jref = j[b.name];
j.emplace_back();
auto &jref = j.back();
jref["N"] = b.name;
jref["T"] = b.type;
jref["S"] = b.shape;
jref["O"] = b.start;
Expand Down Expand Up @@ -277,12 +279,6 @@ void SscWriter::SyncReadPattern()
ssc::PrintBlockVec(m_GlobalWritePattern[m_WriterRank],
"Local Write Pattern");
}

if (m_WriterRank == 0)
{
ssc::PrintBlockVec(m_GlobalWritePattern[m_WriterRank],
"Local Write Pattern");
}
}

void SscWriter::CalculatePosition(ssc::BlockVecVec &writerVecVec,
Expand Down

0 comments on commit c6ce6fd

Please sign in to comment.