Skip to content

Damaris plugin - #693

Open
Yushan-Wang wants to merge 68 commits into
pdidev:mainfrom
jmorice91:damaris_plugin
Open

Yushan-Wang wants to merge 68 commits into
pdidev:mainfrom
jmorice91:damaris_plugin

Conversation

@Yushan-Wang

Copy link
Copy Markdown
Member

List of things to check before making a PR

Before merging your code, please check the following:

  • you have added a line describing your changes to the Changelog;
  • you have added unit tests for any new or improved feature;
  • in case you updated dependencies, you have checked pdi/docs/CheckList.md;
  • in case of a change in pdi.h, this same change must be reflected in no-pdi/include/pdi.h;
  • you have checked your code format:
    • you have checked that you respect all conventions specified in CONTRIBUTING.md;
    • you have checked that the indentation and formatting conforms to the .clang-format;
    • you have documented with doxygen any new or changed function / class;
  • you have correctly updated the copyright headers:
    • your institution is in the copyright header of every file you (substantially) modified;
    • you have checked that the end-year of the copyright there is the current one;
  • you have updated the AUTHORS file:
    • you have added yourself to the AUTHORS file;
    • if this is a new contribution, you have added it to the AUTHORS file;
  • you have added everything to the user documentation:
    • any new CMake configuration option;
    • any change in the yaml config;
    • any change to the public or plugin API;
    • any other new or changed user-facing feature;
    • any change to the dependencies;
  • you have correctly linked your MR to one or more issues:
    • your MR solves an identified issue;
    • your commit contain the Fix #issue keyword to autoclose the issue when merged.

endamlabin and others added 30 commits January 16, 2025 12:40
…ide other plugins (trace, mpi, Decl'HDF5, etc.)
…ch element requiring any metadata value uses depends_on YAML attribute to ensure an update of its attributes value to Damaris lib once the metadata are exposed (using Damaris Parameters in the background)!
…ding auto initialize without on_init event, and adding some cmake instruction in enforce finding of Damaris when Damaris_ROOT is provided.
The condition to do that is to always have this sequence at the end of the simulation:
PDI_finalize();
MPI_Finalize();
Or provide in the yml conf the code following PDI_finalize();
Code like the following could not be handled:
PDI_finalize();
PC_tree_destroy(&conf);
free(cur);
free(next);
MPI_Finalize();
* Hide is_client from user, and ending damaris server in background:
- The  condition to do that is to always have this sequence at the end of the simulation:

PDI_finalize();
MPI_Finalize();

- Or provide in the yml conf the code following PDI_finalize();

- Code like the following could not be handled for the moment. But in the future by providing the instructions to execute...:

PDI_finalize();
PC_tree_destroy(&conf);
free(cur);
free(next);
MPI_Finalize();

* update copyright

* Removing on_init and on_finalize
* Example with only Damaris API (resolves #10)
@Yushan-Wang
Yushan-Wang requested a review from a team August 5, 2026 16:51
@jmorice91

jmorice91 commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Some known issues of this implementation are defined in https://github.com/jmorice91/pdi/issues.
(The issue name become with [Damaris plugin])
These developments will be done in other steps.

@jmorice91 jmorice91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A first review.

Comment thread plugins/damaris/damaris_async_gather.h Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This file is never used. Perhaps, we should remove for a first version?

@endamlabin : What is the objective of this file?

Comment thread plugins/damaris/damaris.cxx Outdated
ctx.logger().info("Plugin loaded successfully");
}

void data(const std::string& name, PDI::Ref ref)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

missing description.
As the name of function is to general, we should change the name.

Comment thread plugins/damaris/damaris.cxx Outdated
}
}

void event(const std::string& event_name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

missing description.
As the name of function is to general, we should change the name.

}
}

void ensure_damaris_is_initialized(const std::string& event_name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

missing description

}
}

void damaris_init()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

missing description

Comment thread plugins/damaris/damaris.cxx Outdated
// context().logger().error("The Damaris need write access on the data (`{}')", name);
throw PDI::System_error{"The Damaris need write access on the data `{}' ", name};
}
} else if (m_config.is_parameter_to_update(name)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps, add a comment on this condition?

Comment on lines +300 to +301
//MayBe a PDI_multi_expose is under traitement
multi_expose_transaction_dataname.emplace_back(name);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you give us a use case of these lines with an example?

multi_expose_transaction_dataname.emplace_back(name);
}
} else { //Handle other situations...
multi_expose_transaction_dataname.emplace_back(name);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you give us a use case of these lines with an example?

Comment thread plugins/damaris/damaris.cxx Outdated
}
} else { //Handle other situations...
multi_expose_transaction_dataname.emplace_back(name);
//multi_expose_transaction_dataref.emplace_back(ref);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please, remove this line.

if (ds_write_info.when.to_long(context())) {
context().logger().debug("data `{}' will be written when = '{}'", name, ds_write_info.when.to_long(context()));

int32_t block = ds_write_info.block.to_long(context());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the block? What is the interest for a user?

@jmorice91 jmorice91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

General comment:
There is not test and no example with custom event name defined in specification tree.

Comment thread plugins/damaris/damaris.cxx Outdated
std::string finalize_event_name = m_event_handler.get_event_name(Event_type::DAMARIS_FINALIZE);
m_event_handler.damaris_api_call_event(context(), m_damaris, finalize_event_name, multi_expose_transaction_dataname);
}
} else if (m_event_handler.is_damaris_api_call_event(event_name)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add a comment like the if before.

Suggested change
} else if (m_event_handler.is_damaris_api_call_event(event_name)) {
}
// use of defined names in damaris plugin to call damaris api
else if (m_event_handler.is_damaris_api_call_event(event_name)) {

Comment thread plugins/damaris/damaris_cfg.h Outdated
};

/** These default event names are for internal use. If a configured name is given, these ones will be surcharged */
const std::unordered_map<Event_type, std::string> event_names

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This variables depends on the naming of the event in the core of damaris plugin as he used in other files.
suggestion: damaris_event_names

if (!m_damaris) {
if (m_config.events().find(event_name) != m_config.events().end()) {
//Means the first action received by the plugin wasn't fir initialization...
if (!m_config.init_on_event().empty() && event_name != m_config.init_on_event()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if the event name for init_on_event="", what is arrived?
(need to be checked)

Do you mean that in your code
m_config.init_on_event().empty() is equivalent to no init_on_event defined in the specification tree of damaris ?

Perhaps, we can add a boolean in the code to know if no init_on_event defined in the specification tree of damaris ?

Comment on lines +363 to +367
if (m_config.finalize_on_event().empty() && m_damaris) {
context().logger().debug("Calling DAMARIS_FINALIZE in ~damaris_plugin()");
std::string finalize_event_name = m_event_handler.get_event_name(Event_type::DAMARIS_FINALIZE);
m_event_handler.damaris_api_call_event(context(), m_damaris, finalize_event_name, multi_expose_transaction_dataname);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps, we should add the "m_config.finalize_on_event() is not empty and m_damaris" in the case of the user doesn't call event to finalize in its code?

Question:
If the user doesn't call "DAMARIS_STOP" before "DAMARIS_FINALIZE", what damaris do when we call "damaris_finalize"?

Comment thread plugins/damaris/damaris_cfg.h Outdated

struct Architecture_type {
int domain;
placement arch_placement;

@jmorice91 jmorice91 Sep 2, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

placement is never used? Perhaps, we can remove for a first version.

Question: What is the placement for damaris?

@jmorice91 jmorice91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

some other comments:

Comment thread plugins/damaris/damaris_cfg.h Outdated

/** These default event names are for internal use. If a configured name is given, these ones will be surcharged */
const std::unordered_map<Event_type, std::string> event_names
= {{Event_type::DAMARIS_INITIALIZE, "initialize"},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The event name doesn't depend on damaris.

Suggested change
= {{Event_type::DAMARIS_INITIALIZE, "initialize"},
= {{Event_type::DAMARIS_INITIALIZE, "damaris_initialize"},

Comment thread plugins/damaris/damaris_cfg.h Outdated
{Event_type::DAMARIS_SIGNAL, "damaris_signal"},
{Event_type::DAMARIS_BIND, "damaris_bind"},
{Event_type::DAMARIS_STOP, "damaris_stop"},
{Event_type::DAMARIS_FINALIZE, "finalize"}};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The event name doesn't depend on damaris.

Suggested change
{Event_type::DAMARIS_FINALIZE, "finalize"}};
{Event_type::DAMARIS_FINALIZE, "damaris_finalize"}};

…ous code in Damaris plugin

- Fix uninitialized pointer dereferences in DAMARIS_PARAMETER_GET/SET and
  DAMARIS_SET_BLOCK_POSITION/WRITE_BLOCK
- Fix damaris_pdi_write_block returning bool instead of int, which collapsed
  distinct Damaris error codes down to 0/1
- Remove dead code: shadowed Damaris_cfg architecture members, unused
  reset_parameter_depends_on(vector)/reset_all_parameters_depends_on(),
  unnecessary static local
- Use const auto& instead of by-value copies in get_updatable_parameters
- Resolve and clean up all remaining "// Jacques:" review comments in
  damaris_cfg.cxx, merging them into proper doxygen where applicable
- Add doxygen/explanatory comments across damaris_cfg.h/.cxx,
  damaris_api_call_handler.h/.cxx and damaris_wrapper.cxx for non-obvious
  variables and code paths
Revert the erroneous copyright changes to the other 5 files, and correctly
extend damaris_api_call_handler.h's end years to 2026 without altering its
start years (2015 for CEA, 2024 for Inria).
Comment on lines +2 to +4
* Copyright (C) 2015-2019 Commissariat a l'energie atomique et aux energies alternatives (CEA)
* Copyright (C) 2021 Institute of Bioorganic Chemistry Polish Academy of Science (PSNC)
* All rights reserved.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Copyright (C) 2015-2019 Commissariat a l'energie atomique et aux energies alternatives (CEA)
* Copyright (C) 2021 Institute of Bioorganic Chemistry Polish Academy of Science (PSNC)
* All rights reserved.
* Copyright (C) 2026 Commissariat a l'energie atomique et aux energies alternatives (CEA)
* All rights reserved.

Comment on lines +2 to +3
* Copyright (C) 2015-2019 Commissariat a l'energie atomique et aux energies alternatives (CEA)
* Copyright (C) 2021 Institute of Bioorganic Chemistry Polish Academy of Science (PSNC)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The copyright need to be change.

@jmorice91 jmorice91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The copyright is needed to be checked in all the files.

Comment on lines +2 to +3
# Copyright (C) 2015-2024 Commissariat a l'energie atomique et aux energies alternatives (CEA)
# Copyright (C) 2024-2026 Institut national de recherche en informatique et en automatique (Inria)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The copyright need to be updated.

Suggested change
# Copyright (C) 2015-2024 Commissariat a l'energie atomique et aux energies alternatives (CEA)
# Copyright (C) 2024-2026 Institut national de recherche en informatique et en automatique (Inria)
# Copyright (C) 2026 Commissariat a l'energie atomique et aux energies alternatives (CEA)
# Copyright (C) 2024-2026 Institut national de recherche en informatique et en automatique (Inria)

jmorice91 and others added 4 commits September 6, 2026 18:26
* Adding tests for multidimensional array with ghosts layer
* Adding a test with when condition
* Apply suggestion from @Yushan-Wang
- #9: document what `block` means (local sub-domain index, relevant when
  architecture/domains > 1) in the README, Dataset_Write_Info, and at its
  read site in damaris.cxx
- #12: confirm init_on_event().empty() is the intended "not configured"
  check, per direct confirmation
- #13: fix DAMARIS_FINALIZE's auto-stop fallback to key off whether
  DAMARIS_STOP has actually run (new m_stopped flag) rather than whether
  stop_on_event was configured, closing the gap where an explicitly
  configured stop_on_event that never fires would let finalize run without
  ever stopping dedicated server ranks (traced via ~/damaris source: no
  server-side check ties finalize to a prior stop)
Comment thread plugins/damaris/README.md
* `write`: list of data that will be write on the disk by damaris. Each data is composed with
* `dataset`: The dataset in which the data will be written.
* `position`: The starting position of the data (for each client process) with repect to the dataset.
* `block`(integer, default: 0): Which local sub-domain of this client process the data belongs to, when `architecture/domains` is greater than 1 (i.e. a single client manages several sub-domains/patches itself). Must be between `0` and `domains - 1`. Can be left at its default when `domains = 1`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where is the test for this option?
It would be nice to have a discuss about this point.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

remove domains and block for the 1st release

include(FindPackageHandleStandardArgs)
include(DamarisPluginUtils)

set(Damaris_BASE_DIR /usr/local/lib/damaris /usr/lib/damaris /opt/damaris)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

is this still needed?

include(DamarisPluginUtils)

set(Damaris_BASE_DIR /usr/local/lib/damaris /usr/lib/damaris /opt/damaris)
set(Damaris_VERSIONS 1.12.0)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

shouldn't this version number be retrieved from Damaris lib?

Comment on lines +40 to +42
global: ['$psize[0]*($dsize[0]-2)', '$psize[1]*($dsize[1]-2)']
dimensions: [ '$dsize[0]', '$dsize[1]' ] # process dim, with ghosts/boundaries
ghosts: '1:1,1:1'

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Suggested change
global: ['$psize[0]*($dsize[0]-2)', '$psize[1]*($dsize[1]-2)']
dimensions: [ '$dsize[0]', '$dsize[1]' ] # process dim, with ghosts/boundaries
ghosts: '1:1,1:1'
# some where in the config yaml we have NG = 2
global: ['$psize[0]*($dsize[0]-$NG*2)', '$psize[1]*($dsize[1]-$NG*2)']
dimensions: [ '$dsize[0]', '$dsize[1]' ] # process dim, with ghosts/boundaries
ghosts: '$NG:$NG,$NG:$NG'

Comment on lines +206 to +211
} else if (key == "init_on_event" || key == "on_init") {
m_init_on_event = PDI::to_string(value);
load_event(m_events, ctx, m_init_on_event, Event_type::DAMARIS_INITIALIZE);
} else if (key == "finalize_on_event" || key == "on_finalize") {
m_finalize_on_event = PDI::to_string(value);
load_event(m_events, ctx, m_finalize_on_event, Event_type::DAMARIS_FINALIZE);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It is would be better to use only one key to define this event.

@jmorice91 jmorice91 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

some comment

store.store_opt_FileMode_ = PDI::to_string(value);
} else if (key == "files_path") {
store.store_opt_FilesPath_ = PDI::to_string(value);
// bool create_dir = creation_directory_c_only(ctx, store.store_opt_FilesPath_);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can remove these lines

/// @return true if the directory is created or exists
/// NOTE: currently unused (kept as a pre-C++17 <filesystem> fallback) - creation_directory_cpp()
/// below is the one actually called from parse_storages_tree().
bool creation_directory_c_only(PDI::Context& ctx, const std::string& dir_name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Never used. we can remove.

void retrive_nested_groups(std::string& dataset_elt_full_name, char delimiter, std::string nested_groups_names[], unsigned& index);
template <typename DS_TYPE>
void insert_dataset_elts_to_group(DS_TYPE varxml, std::string nested_groups_names[], unsigned index);
//void insert_dataset_elts_to_group(damaris::model::DamarisVarXML varxml, std::string nested_groups_names[], unsigned index);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we can remove.

}
}

else if (key == "start" || key == "get_is_client" || key == "is_client_get")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

keep only one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants