Skip to content

Commit

Permalink
comment out multi-threaded parsing of variable index in BP4 as it is …
Browse files Browse the repository at this point in the history
…not safe as described in ornladios#1615.
  • Loading branch information
pnorbert committed Jul 29, 2019
1 parent a196a04 commit 00ec474
Showing 1 changed file with 38 additions and 34 deletions.
72 changes: 38 additions & 34 deletions source/adios2/toolkit/format/bp4/BP4Deserializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,10 @@ void BP4Deserializer::ParseVariablesIndexPerStep(const BufferSTL &bufferSTL,
const size_t startPosition = position;
size_t localPosition = 0;

if (m_Threads == 1)
/* FIXME: multi-threaded processing does not work here
* because DefineVariable may be called from several threads
*/
/*if (m_Threads == 1)*/
{
while (localPosition < length)
{
Expand All @@ -339,48 +342,49 @@ void BP4Deserializer::ParseVariablesIndexPerStep(const BufferSTL &bufferSTL,
}
return;
}
/*
// threads for reading Variables
std::vector<std::future<void>> asyncs(m_Threads);
std::vector<size_t> asyncPositions(m_Threads);
// threads for reading Variables
std::vector<std::future<void>> asyncs(m_Threads);
std::vector<size_t> asyncPositions(m_Threads);
bool launched = false;
bool launched = false;

while (localPosition < length)
{
// extract async positions
for (unsigned int t = 0; t < m_Threads; ++t)
while (localPosition < length)
{
asyncPositions[t] = position;
const size_t elementIndexSize =
static_cast<size_t>(helper::ReadValue<uint32_t>(
buffer, position, m_Minifooter.IsLittleEndian));
position += elementIndexSize;
localPosition = position - startPosition;

if (launched)
{
asyncs[t].get();
}

if (localPosition <= length)
// extract async positions
for (unsigned int t = 0; t < m_Threads; ++t)
{
asyncs[t] =
std::async(std::launch::async, lf_ReadElementIndexPerStep,
std::ref(engine), std::ref(buffer),
asyncPositions[t], step);
asyncPositions[t] = position;
const size_t elementIndexSize =
static_cast<size_t>(helper::ReadValue<uint32_t>(
buffer, position, m_Minifooter.IsLittleEndian));
position += elementIndexSize;
localPosition = position - startPosition;
if (launched)
{
asyncs[t].get();
}
if (localPosition <= length)
{
asyncs[t] =
std::async(std::launch::async,
lf_ReadElementIndexPerStep, std::ref(engine), std::ref(buffer),
asyncPositions[t], step);
}
}
launched = true;
}
launched = true;
}
for (auto &async : asyncs)
{
if (async.valid())
for (auto &async : asyncs)
{
async.wait();
if (async.valid())
{
async.wait();
}
}
}
*/
}

/* void BP4Deserializer::ParseVariablesIndex(const BufferSTL &bufferSTL,
Expand Down

0 comments on commit 00ec474

Please sign in to comment.