Skip to content

Commit

Permalink
Merge pull request #8 from williamfgc/bpindataman
Browse files Browse the repository at this point in the history
Implemented new function to reset metadata in BP3Deserializer
  • Loading branch information
JasonRuonanWang authored Jan 29, 2018
2 parents cf0d2fd + f78c520 commit 4a0da85
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 24 deletions.
43 changes: 22 additions & 21 deletions examples/hello/datamanReader/helloDataManReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,30 @@ int main(int argc, char *argv[])

for (unsigned int i = 0; i < 3; ++i)
{
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
std::this_thread::sleep_for(std::chrono::milliseconds(10000));
}

adios2::Variable<float> *bpFloats;

std::vector<float> myFloats(10);

bpFloats = dataManIO.InquireVariable<float>("bpFloats");
if (bpFloats == nullptr)
{
std::cout << "Variable bpFloats not read...yet\n";
}

else
{
for (int i = 0; i < 1000; ++i)
{
dataManReader.BeginStep();
dataManReader.GetSync<float>(*bpFloats, myFloats.data());
Dump(myFloats);
dataManReader.EndStep();
}
}
// adios2::Variable<float> *bpFloats;
//
// std::vector<float> myFloats(10);
//
// bpFloats = dataManIO.InquireVariable<float>("bpFloats");
// if (bpFloats == nullptr)
// {
// std::cout << "Variable bpFloats not read...yet\n";
// }
//
// else
// {
// for (int i = 0; i < 1000; ++i)
// {
// dataManReader.BeginStep();
// dataManReader.GetSync<float>(*bpFloats,
// myFloats.data());
// Dump(myFloats);
// dataManReader.EndStep();
// }
// }

dataManReader.Close();
}
Expand Down
2 changes: 1 addition & 1 deletion examples/hello/datamanWriter/helloDataManWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ int main(int argc, char *argv[])
{"Library", "ZMQ"}, {"IPAddress", "127.0.0.1"},
});

// Define variable and local size
auto bpFloats =
dataManIO.DefineVariable<float>("bpFloats", {}, {}, {Nx});

Expand All @@ -60,6 +59,7 @@ int main(int argc, char *argv[])

for (int i = 0; i < 1000; ++i)
{
// Define variable and local size
dataManWriter.BeginStep();
for (auto &j : myFloats)
{
Expand Down
4 changes: 3 additions & 1 deletion source/adios2/engine/dataman/DataManReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void DataManReader::ReadThread(std::shared_ptr<transportman::DataMan> man)
// implementation needs multiple threads then this has to be
// rewriten by manually removing variables one by one and it
// has to be protected by mutex.
// m_IO.RemoveAllVariables();

std::shared_ptr<std::vector<char>> buffer = man->ReadWAN();
if (buffer != nullptr)
{
Expand All @@ -80,6 +80,8 @@ void DataManReader::ReadThread(std::shared_ptr<transportman::DataMan> man)
buffer->data(), buffer->size());

m_MutexIO.lock();
m_IO.RemoveAllVariables();
m_IO.RemoveAllAttributes();
std::cout << "ParseMetadata ===\n";
deserializer.ParseMetadata(deserializer.m_Data, m_IO);
m_MutexIO.unlock();
Expand Down
3 changes: 2 additions & 1 deletion source/adios2/engine/dataman/DataManWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ void DataManWriter::EndStep()
m_BP3Serializer.CloseStream(m_IO);
m_Man.WriteWAN(m_BP3Serializer.m_Data.m_Buffer,
m_BP3Serializer.m_Data.m_Position);
m_BP3Serializer.ResetBuffer(m_BP3Serializer.m_Data);
m_BP3Serializer.ResetBuffer(m_BP3Serializer.m_Data, true);
m_BP3Serializer.ResetIndices();
}
}

Expand Down
6 changes: 6 additions & 0 deletions source/adios2/toolkit/format/bp3/BP3Serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,12 @@ void BP3Serializer::CloseStream(IO &io)
ProfilerStop("buffering");
}

void BP3Serializer::ResetIndices()
{
m_MetadataSet.AttributesIndices.clear();
m_MetadataSet.VarsIndices.clear();
}

std::string BP3Serializer::GetRankProfilingJSON(
const std::vector<std::string> &transportsTypes,
const std::vector<profiling::IOChrono *> &transportsProfilers) noexcept
Expand Down
2 changes: 2 additions & 0 deletions source/adios2/toolkit/format/bp3/BP3Serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class BP3Serializer : public BP3Base
*/
void CloseStream(IO &io);

void ResetIndices();

/**
* Get a string with profiling information for this rank
* @param name stream name
Expand Down

0 comments on commit 4a0da85

Please sign in to comment.