Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix a bug where reader could hang when there is no attributes #1406

Merged
merged 6 commits into from
May 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions source/adios2/toolkit/format/dataman/DataManSerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ void DataManSerializer::PutAttributes(core::IO &io)
{
TAU_SCOPED_TIMER_FUNC();
const auto &attributesDataMap = io.GetAttributesDataMap();
bool attributePut = false;
for (const auto &attributePair : attributesDataMap)
{
const std::string name(attributePair.first);
Expand All @@ -360,6 +361,23 @@ void DataManSerializer::PutAttributes(core::IO &io)
}
ADIOS2_FOREACH_ATTRIBUTE_STDTYPE_1ARG(declare_type)
#undef declare_type
attributePut = true;
}

if (not m_StaticDataFinished)
{
if (not attributePut)
{
nlohmann::json staticVar;
staticVar["N"] = "NoAttributes";
staticVar["Y"] = "bool";
staticVar["V"] = true;
staticVar["G"] = true;
m_StaticDataJsonMutex.lock();
m_StaticDataJson["S"].emplace_back(std::move(staticVar));
m_StaticDataJsonMutex.unlock();
}
m_StaticDataFinished = true;
}
}

Expand Down
1 change: 1 addition & 0 deletions source/adios2/toolkit/format/dataman/DataManSerializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ class DataManSerializer
// for global variables and attributes, needs mutex
nlohmann::json m_StaticDataJson;
std::mutex m_StaticDataJsonMutex;
bool m_StaticDataFinished = false;

// for generating deferred requests, only accessed from reader app thread,
// does not need mutex
Expand Down
5 changes: 5 additions & 0 deletions testing/adios2/engine/wdm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@ if(ADIOS2_HAVE_MPI AND ADIOS2_HAVE_ZeroMQ)
add_test(NAME WdmTest COMMAND "mpirun" "-n" "8" $<TARGET_FILE:WdmTest>)
endif()

if(ADIOS2_HAVE_MPI AND ADIOS2_HAVE_ZeroMQ)
add_executable(WdmTestNoAttributes WdmTestNoAttributes.cpp)
target_link_libraries(WdmTestNoAttributes adios2 gtest MPI::MPI_C)
add_test(NAME WdmTestNoAttributes COMMAND "mpirun" "-n" "8" $<TARGET_FILE:WdmTestNoAttributes>)
endif()


20 changes: 12 additions & 8 deletions testing/adios2/engine/wdm/WdmTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ void VerifyData(const T *data, size_t step, const Dims &start,
}

void Writer(const Dims &shape, const Dims &start, const Dims &count,
const size_t steps, const adios2::Params &engineParams)
const size_t steps, const adios2::Params &engineParams,
const std::string &name)
{
size_t datasize = std::accumulate(count.begin(), count.end(), 1,
std::multiplies<size_t>());
Expand Down Expand Up @@ -152,8 +153,7 @@ void Writer(const Dims &shape, const Dims &start, const Dims &count,
auto bpDComplexes = dataManIO.DefineVariable<std::complex<double>>(
"bpDComplexes", shape, start, count);
dataManIO.DefineAttribute<int>("AttInt", 110);
adios2::Engine dataManWriter =
dataManIO.Open("stream", adios2::Mode::Write);
adios2::Engine dataManWriter = dataManIO.Open(name, adios2::Mode::Write);
for (int i = 0; i < steps; ++i)
{
dataManWriter.BeginStep();
Expand Down Expand Up @@ -184,13 +184,14 @@ void Writer(const Dims &shape, const Dims &start, const Dims &count,
}

void Reader(const Dims &shape, const Dims &start, const Dims &count,
const size_t steps, const adios2::Params &engineParams)
const size_t steps, const adios2::Params &engineParams,
const std::string &name)
{
adios2::ADIOS adios(mpiComm, adios2::DebugON);
adios2::IO dataManIO = adios.DeclareIO("Test");
dataManIO.SetEngine("wdm");
dataManIO.SetParameters(engineParams);
adios2::Engine dataManReader = dataManIO.Open("stream", adios2::Mode::Read);
adios2::Engine dataManReader = dataManIO.Open(name, adios2::Mode::Read);

size_t datasize = std::accumulate(count.begin(), count.end(), 1,
std::multiplies<size_t>());
Expand Down Expand Up @@ -332,16 +333,19 @@ TEST_F(WdmEngineTest, BaseTest)
Dims start = {2, (size_t)mpiRank * 2};
Dims count = {5, 2};

adios2::Params engineParams = {{"Port", "12306"}, {"Verbose", "0"}};
std::string filename = "BaseTest";

if (mpiGroup == 0)
{
Writer(shape, start, count, 1000, adios2::Params());
Writer(shape, start, count, 1000, engineParams, filename);
}

std::this_thread::sleep_for(std::chrono::milliseconds(1));
std::this_thread::sleep_for(std::chrono::milliseconds(100));

if (mpiGroup == 1)
{
Reader(shape, start, count, 10, adios2::Params());
Reader(shape, start, count, 10, engineParams, filename);
}

MPI_Barrier(MPI_COMM_WORLD);
Expand Down
Loading