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

openPMD: Add ADIOS2 Engine Parameter Control #2872

Merged
merged 6 commits into from
Feb 18, 2022
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
15 changes: 15 additions & 0 deletions Docs/source/usage/parameters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1892,6 +1892,21 @@ In-situ capabilities can be used by turning on Sensei or Ascent (provided they a
<diag_name>.adios2_operator.type = zfp
<diag_name>.adios2_operator.parameters.precision = 3

* ``<diag_name>.adios2_engine.type`` (``bp4``, ``sst``, ``ssc``, ``dataman``) optional,
`ADIOS2 Engine type <https://openpmd-api.readthedocs.io/en/0.14.0/details/backendconfig.html#adios2>`__ for `openPMD <https://www.openPMD.org>`_ data dumps.
See full list of engines at `ADIOS2 readthedocs <https://adios2.readthedocs.io/en/latest/engines/engines.html>`__

* ``<diag_name>.adios2_engine.parameters.*`` optional,
`ADIOS2 Engine parameters <https://openpmd-api.readthedocs.io/en/0.14.0/details/backendconfig.html#adios2>`__ for `openPMD <https://www.openPMD.org>`_ data dumps.

An example for parameters for the BP engine are setting the number of writers (``NumAggregators``), transparently redirecting data to burst buffers etc.
A detailed list of engine-specific parameters are available at the official `ADIOS2 documentation <https://adios2.readthedocs.io/en/latest/engines/engines.html>`__

.. code-block:: text

<diag_name>.adios2_engine.parameter.NumAggregators = 2048
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Little typo fixed in #3002

<diag_name>.adios2_engine.parameters.BurstBufferPath="/mnt/bb/username"

* ``<diag_name>.fields_to_plot`` (list of `strings`, optional)
Fields written to output.
Possible values: ``Ex`` ``Ey`` ``Ez`` ``Bx`` ``By`` ``Bz`` ``jx`` ``jy`` ``jz`` ``part_per_cell`` ``rho`` ``phi`` ``F`` ``part_per_grid`` ``divE`` ``divB`` and ``rho_<species_name>``, where ``<species_name>`` must match the name of one of the available particle species. Note that ``phi`` will only be written out when do_electrostatic==labframe.
Expand Down
17 changes: 17 additions & 0 deletions Source/Diagnostics/FlushFormats/FlushFormatOpenPMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,27 @@ FlushFormatOpenPMD::FlushFormatOpenPMD (const std::string& diag_name)
operator_parameters.insert({k, v});
}

// ADIOS2 engine type & parameters
std::string engine_type;
pp_diag_name.query("adios2_engine.type", engine_type);
std::string const engine_prefix = diag_name + ".adios2_engine.parameters";
ParmParse ppe;
auto eng_entr = ppe.getEntries(engine_prefix);

std::map< std::string, std::string > engine_parameters;
ax3l marked this conversation as resolved.
Show resolved Hide resolved
auto const prefixlen = engine_prefix.size() + 1;
for (std::string k : eng_entr) {
std::string v;
ppe.get(k.c_str(), v);
k.erase(0, prefixlen);
engine_parameters.insert({k, v});
}

auto & warpx = WarpX::GetInstance();
m_OpenPMDPlotWriter = std::make_unique<WarpXOpenPMDPlot>(
encoding, openpmd_backend,
operator_type, operator_parameters,
engine_type, engine_parameters,
warpx.getPMLdirections()
);

Expand Down
2 changes: 2 additions & 0 deletions Source/Diagnostics/WarpXOpenPMD.H
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ public:
std::string filetype,
std::string operator_type,
std::map< std::string, std::string > operator_parameters,
std::string engine_type,
std::map< std::string, std::string > engine_parameters,
std::vector<bool> fieldPMLdirections);

~WarpXOpenPMDPlot ();
Expand Down
83 changes: 66 additions & 17 deletions Source/Diagnostics/WarpXOpenPMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,18 @@ namespace detail
*/
inline std::string
getSeriesOptions (std::string const & operator_type,
std::map< std::string, std::string > const & operator_parameters)
std::map< std::string, std::string > const & operator_parameters,
std::string const & engine_type,
std::map< std::string, std::string > const & engine_parameters)
{
if (operator_type.empty() && engine_type.empty())
return "{}";

std::string options;
std::string top_block;
std::string end_block;
std::string op_block;
std::string en_block;

std::string op_parameters;
for (const auto& kv : operator_parameters) {
Expand All @@ -133,31 +142,68 @@ namespace detail
.append("\"").append(kv.first).append("\": ") /* key */
.append("\"").append(kv.second).append("\""); /* value (as string) */
}
if (!operator_type.empty()) {
options = R"END(

std::string en_parameters;
for (const auto& kv : engine_parameters) {
if (!en_parameters.empty()) en_parameters.append(",\n");
en_parameters.append(std::string(12, ' ')) /* just pretty alignment */
.append("\"").append(kv.first).append("\": ") /* key */
.append("\"").append(kv.second).append("\""); /* value (as string) */
}

// create the outer-level blocks
top_block = R"END(
{
"adios2": {
"adios2": {)END";

end_block = R"END(
}
})END";

// add the operator string block
if (!operator_type.empty()) {
op_block = R"END(
"dataset": {
"operators": [
{
"type": ")END";
options += operator_type + "\"";
}
if (!operator_type.empty() && !op_parameters.empty()) {
options += R"END(
,"parameters": {
op_block += operator_type + "\"";

if (!op_parameters.empty()) {
op_block += R"END(,
"parameters": {
)END";
options += op_parameters + "}";
op_block += op_parameters + "}";
}
if (!operator_type.empty())
options += R"END(
op_block += R"END(
}
]
}
}
}
})END";
if (!engine_type.empty())
op_block += ",";

} // end operator string block

// add the engine string block
if (!engine_type.empty()) {
Comment on lines +182 to +188
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, these blocks are only added if a user explicitly specifies an engine. Maybe we should add a default here?

en_block = R"END(
"engine": {
"type": ")END";
en_block += engine_type + "\"";

if (!en_parameters.empty()) {
en_block += R"END(,
"parameters": {
)END";
if (options.empty()) options = "{}";
en_block += en_parameters + "}";
}

en_block += R"END(
})END";

} // end engine string block

options = top_block + op_block + en_block + end_block;
return options;
}

Expand Down Expand Up @@ -337,6 +383,8 @@ WarpXOpenPMDPlot::WarpXOpenPMDPlot (
std::string openPMDFileType,
std::string operator_type,
std::map< std::string, std::string > operator_parameters,
std::string engine_type,
std::map< std::string, std::string > engine_parameters,
std::vector<bool> fieldPMLdirections)
:m_Series(nullptr),
m_Encoding(ie),
Expand All @@ -355,7 +403,8 @@ WarpXOpenPMDPlot::WarpXOpenPMDPlot (
m_OpenPMDFileType = "json";
#endif

m_OpenPMDoptions = detail::getSeriesOptions(operator_type, operator_parameters);
m_OpenPMDoptions = detail::getSeriesOptions(operator_type, operator_parameters,
engine_type, engine_parameters);
}

WarpXOpenPMDPlot::~WarpXOpenPMDPlot ()
Expand Down