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

Update for OPENPMD_VERBOSE logging #1574

Merged
merged 2 commits into from
Dec 18, 2023
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
13 changes: 11 additions & 2 deletions include/openPMD/IO/IOTask.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "openPMD/backend/Attribute.hpp"
#include "openPMD/backend/ParsePreference.hpp"

#include <cstddef>
#include <map>
#include <memory>
#include <string>
Expand Down Expand Up @@ -680,15 +681,23 @@ template <>
struct OPENPMDAPI_EXPORT Parameter<Operation::DEREGISTER>
: public AbstractParameter
{
Parameter() = default;
Parameter(Parameter const &) : AbstractParameter()
Parameter(void const *ptr_in) : former_parent(ptr_in)
{}

Parameter(Parameter const &) = default;
Parameter(Parameter &&) = default;

Parameter &operator=(Parameter const &) = default;
Parameter &operator=(Parameter &&) = default;

std::unique_ptr<AbstractParameter> to_heap() && override
{
return std::make_unique<Parameter<Operation::DEREGISTER>>(
std::move(*this));
}

// Just for verbose logging.
void const *former_parent = nullptr;
};

/** @brief Self-contained description of a single IO operation.
Expand Down
50 changes: 41 additions & 9 deletions src/IO/AbstractIOHandlerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,24 +358,56 @@ std::future<void> AbstractIOHandlerImpl::flush()
auto &parameter = deref_dynamic_cast<Parameter<O::DEREGISTER>>(
i.parameter.get());
writeToStderr(
"[", i.writable->parent, "->", i.writable, "] DEREGISTER");
"[",
parameter.former_parent,
"->",
i.writable,
"] DEREGISTER");
deregister(i.writable, parameter);
break;
}
}
}
catch (...)
{
std::cerr << "[AbstractIOHandlerImpl] IO Task "
<< internal::operationAsString(i.operation)
<< " failed with exception. Clearing IO queue and "
"passing on the exception."
<< std::endl;
while (!m_handler->m_work.empty())
auto base_handler = [&i, this]() {
std::cerr << "[AbstractIOHandlerImpl] IO Task "
<< internal::operationAsString(i.operation)
<< " failed with exception. Clearing IO queue and "
"passing on the exception."
<< std::endl;
while (!m_handler->m_work.empty())
{
m_handler->m_work.pop();
}
};

if (m_verboseIOTasks)
{
try
{
// Throw again so we can distinguish between std::exception
// and other exception types.
throw;
}
catch (std::exception const &e)
{
base_handler();
std::cerr << "Original exception: " << e.what()
<< std::endl;
throw;
}
catch (...)
{
base_handler();
throw;
}
}
else
{
m_handler->m_work.pop();
base_handler();
throw;
}
throw;
}
(*m_handler).m_work.pop();
}
Expand Down
2 changes: 1 addition & 1 deletion src/backend/Writable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Writable::~Writable()
* remove references to this object from internal data structures.
*/
IOHandler->value()->enqueue(
IOTask(this, Parameter<Operation::DEREGISTER>()));
IOTask(this, Parameter<Operation::DEREGISTER>(parent)));
}

void Writable::seriesFlush(std::string backendConfig)
Expand Down