Commit db6fb95a authored by Ruonan Wang's avatar Ruonan Wang Committed by Wang, Ruonan
Browse files

simplified the copy logic

parent df9e12e7
......@@ -41,20 +41,22 @@ void SscWriter::PutDeferredCommon(Variable<T> &variable, const T *data)
variable.m_Shape.push_back(1);
}
if (m_CurrentStep == 0)
bool found = false;
for (const auto &b : m_GlobalWritePattern[m_StreamRank])
{
bool found = false;
for (const auto &b : m_GlobalWritePattern[m_StreamRank])
if (b.name == variable.m_Name and
ssc::AreSameDims(variable.m_Start, b.start) and
ssc::AreSameDims(variable.m_Count, b.count) and
ssc::AreSameDims(variable.m_Shape, b.shape))
{
if (b.name == variable.m_Name and
ssc::AreSameDims(variable.m_Start, b.start) and
ssc::AreSameDims(variable.m_Count, b.count) and
ssc::AreSameDims(variable.m_Shape, b.shape))
{
found = true;
}
std::memcpy(m_Buffer.data() + b.bufferStart, data, b.bufferCount);
found = true;
}
if (not found)
}
if (not found)
{
if (m_CurrentStep == 0)
{
m_GlobalWritePattern[m_StreamRank].emplace_back();
auto &b = m_GlobalWritePattern[m_StreamRank].back();
......@@ -66,25 +68,13 @@ void SscWriter::PutDeferredCommon(Variable<T> &variable, const T *data)
b.bufferStart = m_Buffer.size();
b.bufferCount = ssc::TotalDataSize(b.count, b.type);
m_Buffer.resize(b.bufferStart + b.bufferCount);
std::memcpy(m_Buffer.data() + b.bufferStart, data, b.bufferCount);
}
}
bool found = false;
for (const auto &b : m_GlobalWritePattern[m_StreamRank])
{
if (b.name == variable.m_Name and
ssc::AreSameDims(variable.m_Start, b.start) and
ssc::AreSameDims(variable.m_Count, b.count) and
ssc::AreSameDims(variable.m_Shape, b.shape))
else
{
std::memcpy(m_Buffer.data() + b.bufferStart, data, b.bufferCount);
found = true;
throw std::runtime_error("ssc only accepts fixed IO pattern");
}
}
if (not found)
{
throw std::runtime_error("ssc only accepts fixed IO pattern");
}
}
} // end namespace engine
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment