Skip to content

[Scheduler][PIC] create pdl as list #1513

Open
aserhani wants to merge 15 commits intoShamrock-code:mainfrom
aserhani:pic/pdl-as-list
Open

[Scheduler][PIC] create pdl as list #1513
aserhani wants to merge 15 commits intoShamrock-code:mainfrom
aserhani:pic/pdl-as-list

Conversation

@aserhani
Copy link
Collaborator

@aserhani aserhani commented Jan 2, 2026

  • Created a list (as std::vector) of PatchDataLayerLayout
  • Set the default PatchDataLayerLayout to be the first element of the list

@gemini-code-assist
Copy link

Summary of Changes

Hello @aserhani, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant architectural change by transforming the single PatchDataLayerLayout into a std::deque of PatchDataLayerLayout objects. This modification lays the groundwork for supporting multiple, distinct data layers within the Shamrock framework, enhancing its flexibility and scalability for complex simulations. While many operations currently default to interacting with the first layer in the deque, the underlying structure is now capable of managing and accessing multiple layers, paving the way for future multi-layer functionalities.

Highlights

  • Data Layer Management Refactor: The core PatchDataLayerLayout object, previously managed as a single std::shared_ptr, has been refactored to be stored within a std::deque<std::shared_ptr<PatchDataLayerLayout>>. This change enables the system to handle multiple data layers.
  • API Updates for Multi-Layer Support: Key classes like ShamrockCtx and PatchScheduler have been updated to store and operate on this std::deque of data layers. Methods interacting with PatchDataLayerLayout now accept an optional layer_idx parameter, defaulting to the first layer (index 0) for backward compatibility.
  • Python Bindings Adaptation: The Python bindings (pyShamrockCtx.cpp) have been modified to iterate through all available PatchDataLayerLayout objects in the new deque structure when retrieving field names, ensuring all layers are considered.
  • Test and I/O Adjustments: Existing test cases (benchmark_selfgrav.cpp, shamrock_article_1Tests.cpp) and I/O operations (ShamrockDump.cpp) have been adapted to instantiate and utilize the std::deque for PatchDataLayerLayout, typically accessing the first element as the default layer.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

Thanks @aserhani for opening this PR!

You can do multiple things directly here:
1 - Comment pre-commit.ci run to run pre-commit checks.
2 - Comment pre-commit.ci autofix to apply fixes.
3 - Add label autofix.ci to fix authorship & pre-commit for every commit made.
4 - Add label light-ci to only trigger a reduced & faster version of the CI (need the full one before merge).
5 - Add label trigger-ci to create an empty commit to trigger the CI.

Once the workflow completes a message will appear displaying informations related to the run.

Also the PR gets automatically reviewed by gemini, you can:
1 - Comment /gemini review to trigger a review
2 - Comment /gemini summary for a summary
3 - Tag it using @gemini-code-assist either in the PR or in review comments on files

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the PatchDataLayerLayout from a single object to a std::deque, allowing for multiple layouts. The changes are propagated through ShamrockCtx, PatchScheduler, and related test files. The default layout is consistently set to the first element of the list, which aligns with the PR's goal of an incremental update.
My review has identified two main issues:

  1. A critical bug in PatchScheduler.hpp where a validation check constructs an exception but fails to throw it, rendering the check ineffective.
  2. A high-severity bug in pyShamrockCtx.cpp that could lead to data loss when collecting data for Python bindings due to overwriting dictionary keys for field names that appear in multiple layers.
    I have provided code suggestions to fix both issues. The rest of the changes look good and are consistent with the stated objective.

Comment on lines 135 to 144
for (u32 layer_idx = 0; layer_idx < pdl_ptr_list.size(); layer_idx++) {
if (!pdl(layer_idx).check_main_field_type<vectype>()) {
std::invalid_argument(
std::string("the main field is not of the correct type to call this function\n")
+ "fct called : " + __PRETTY_FUNCTION__
+ shambase::format("current patch data layout of index {} : ", layer_idx)
+ pdl(layer_idx).get_description_str()
);
}
}

Choose a reason for hiding this comment

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

critical

This loop has a critical issue: std::invalid_argument is constructed but not thrown, which means the type check is ineffective. The program will continue even with a type mismatch, potentially leading to undefined behavior. You must throw the exception.

Additionally, for improved readability and to follow modern C++ practices, consider using a range-based for loop. To include the index in the error message, you can maintain a counter variable.

        u32 layer_idx = 0;
        for (const auto& pdl_ptr : pdl_ptr_list) {
            if (!pdl_ptr->check_main_field_type<vectype>()) {
                throw std::invalid_argument(
                    std::string("the main field is not of the correct type to call this function\n")
                    + "fct called : " + __PRETTY_FUNCTION__
                    + shambase::format("current patch data layout of index {} : ", layer_idx)
                    + pdl_ptr->get_description_str()
                );
            }
            layer_idx++;
        }

Comment on lines 289 to 309
for (u32 layer_idx = 0; layer_idx < ctx.pdl_list.size(); layer_idx++) {
for (auto fname : ctx.pdl_list.at(layer_idx)->get_field_names()) {
append_to_map<f32>(fname, data, dic_out);
append_to_map<f32_2>(fname, data, dic_out);
append_to_map<f32_3>(fname, data, dic_out);
append_to_map<f32_4>(fname, data, dic_out);
append_to_map<f32_8>(fname, data, dic_out);
append_to_map<f32_16>(fname, data, dic_out);
append_to_map<f64>(fname, data, dic_out);
append_to_map<f64_2>(fname, data, dic_out);
append_to_map<f64_3>(fname, data, dic_out);
append_to_map<f64_4>(fname, data, dic_out);
append_to_map<f64_8>(fname, data, dic_out);
append_to_map<f64_16>(fname, data, dic_out);
append_to_map<u32>(fname, data, dic_out);
append_to_map<u64>(fname, data, dic_out);
append_to_map<u32_3>(fname, data, dic_out);
append_to_map<u64_3>(fname, data, dic_out);
append_to_map<i64_3>(fname, data, dic_out);
}
}

Choose a reason for hiding this comment

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

high

The current implementation iterates through each layer and then through each field name, calling append_to_map for each. If the same field name exists in multiple layers, the data for that field in the output dictionary (dic_out) will be overwritten by subsequent calls to append_to_map. This can lead to data loss.

To fix this, you should first collect all unique field names from all layers and then iterate over this unique set to populate the dictionary. This ensures that each field is processed only once, aggregating data correctly across all patches as append_to_map does.

Additionally, using range-based for loops would make the code more modern and readable. Note that you may need to include the <set> header for std::set.

                std::set<std::string> all_field_names;
                for (const auto& pdl_ptr : ctx.pdl_list) {
                    for (const auto& fname : pdl_ptr->get_field_names()) {
                        all_field_names.insert(fname);
                    }
                }

                for (const auto& fname : all_field_names) {
                    append_to_map<f32>(fname, data, dic_out);
                    append_to_map<f32_2>(fname, data, dic_out);
                    append_to_map<f32_3>(fname, data, dic_out);
                    append_to_map<f32_4>(fname, data, dic_out);
                    append_to_map<f32_8>(fname, data, dic_out);
                    append_to_map<f32_16>(fname, data, dic_out);
                    append_to_map<f64>(fname, data, dic_out);
                    append_to_map<f64_2>(fname, data, dic_out);
                    append_to_map<f64_3>(fname, data, dic_out);
                    append_to_map<f64_4>(fname, data, dic_out);
                    append_to_map<f64_8>(fname, data, dic_out);
                    append_to_map<f64_16>(fname, data, dic_out);
                    append_to_map<u32>(fname, data, dic_out);
                    append_to_map<u64>(fname, data, dic_out);
                    append_to_map<u32_3>(fname, data, dic_out);
                    append_to_map<u64_3>(fname, data, dic_out);
                    append_to_map<i64_3>(fname, data, dic_out);
                }

Copy link
Member

@tdavidcl tdavidcl left a comment

Choose a reason for hiding this comment

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

I will try to review in greater datil ASAP. But in the meantime i see two aspects that should be addressed.

1 - Use std::vector instead of std::deque for direct lookup
2 - Wrap the Layout list in a class, something like:

class PatchDataLayout {
    <...>
    std::vector<std::shared_ptr<PatchDataLayerLayout>> layer_layouts;
    
    std::shared_ptr<PatchDataLayerLayout> & get_layer_layout(size_t id){
        return shambase::get_check_ref(layer_layouts.at(id));
    }
    
    /// const overload of get_layer_layaout_ptr
    const std::shared_ptr<PatchDataLayerLayout> & get_layer_layout_ptr(size_t id) const {
        return layer_layouts.at(id);
    }
    
    PatchDataLayerLayout & get_layer_layout_ptr(size_t id){
        return layer_layouts.at(id);
    }
    <...>
}

Which would make the logic of layers much cleaner, especially since we will have to forward a list of layers to the constructor of PatchData (which will also be a list of PatchDataLayer(s) )

@aserhani aserhani requested a review from tdavidcl January 7, 2026 13:19
Copy link
Member

@tdavidcl tdavidcl left a comment

Choose a reason for hiding this comment

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

Some comments related to formatting.
Please also fix pre-commit @ authorship so that we can test compilation

Comment on lines +45 to +49
inline void create_layers(size_t nlayers) {
for (size_t idx = 0; idx < nlayers; idx++) {
layer_layouts.push_back(std::make_shared<shamrock::patch::PatchDataLayerLayout>());
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
inline void create_layers(size_t nlayers) {
for (size_t idx = 0; idx < nlayers; idx++) {
layer_layouts.push_back(std::make_shared<shamrock::patch::PatchDataLayerLayout>());
}
}

Do it in the constructor

@tdavidcl
Copy link
Member

tdavidcl commented Jan 7, 2026

In general the idea is that this class would have a constructor to select the number of layer PatchDataLayout(u32 nlayers = 1)

then we can just swap the PatchDataLayerLayout by PatchDataLayout and replace all calls to PatchDataLayerLayout through get_layer_ref which make the changes minimal considering that it touches core functionalities

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Workflow report

workflow report corresponding to commit 894b509
Commiter email is anass.serhani@cnrs.fr

Light CI is enabled. This will only run the basic tests and not the full tests.
Merging a PR require the job "on PR / all" to pass which is disabled in this case.

Pre-commit check report

Pre-commit check: ✅

trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check for merge conflicts................................................Passed
check that executables have shebangs.....................................Passed
check that scripts with shebangs are executable..........................Passed
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check for broken symlinks................................................Passed
check yaml...............................................................Passed
detect private key.......................................................Passed
No-tabs checker..........................................................Passed
Tabs remover.............................................................Passed
Validate GitHub Workflows................................................Passed
clang-format.............................................................Passed
black....................................................................Passed
ruff check...............................................................Passed
Check doxygen headers....................................................Passed
Check license headers....................................................Passed
Check #pragma once.......................................................Passed
Check SYCL #include......................................................Passed
No ssh in git submodules remote..........................................Passed

Test pipeline can run.

Doxygen diff with main

Removed warnings : 93
New warnings : 99
Warnings count : 7634 → 7640 (0.1%)

Detailed changes :
- src/shampylib/src/pyShamrockCtx.cpp:107: warning: Compound VecToNumpy< sycl::vec< T, 8 > > is not documented.
+ src/shampylib/src/pyShamrockCtx.cpp:108: warning: Compound VecToNumpy< sycl::vec< T, 8 > > is not documented.
- src/shampylib/src/pyShamrockCtx.cpp:109: warning: Member convert(std::vector< sycl::vec< T, 8 > > vec) (function) of class VecToNumpy< sycl::vec< T, 8 > > is not documented.
+ src/shampylib/src/pyShamrockCtx.cpp:110: warning: Member convert(std::vector< sycl::vec< T, 8 > > vec) (function) of class VecToNumpy< sycl::vec< T, 8 > > is not documented.
- src/shampylib/src/pyShamrockCtx.cpp:131: warning: Compound VecToNumpy< sycl::vec< T, 16 > > is not documented.
+ src/shampylib/src/pyShamrockCtx.cpp:132: warning: Compound VecToNumpy< sycl::vec< T, 16 > > is not documented.
- src/shampylib/src/pyShamrockCtx.cpp:133: warning: Member convert(std::vector< sycl::vec< T, 16 > > vec) (function) of class VecToNumpy< sycl::vec< T, 16 > > is not documented.
+ src/shampylib/src/pyShamrockCtx.cpp:134: warning: Member convert(std::vector< sycl::vec< T, 16 > > vec) (function) of class VecToNumpy< sycl::vec< T, 16 > > is not documented.
- src/shampylib/src/pyShamrockCtx.cpp:164: warning: Member append_to_map(std::string key, std::vector< std::unique_ptr< shamrock::patch::PatchDataLayer > > &lst, py::dict &dic_out) (function) of file pyShamrockCtx.cpp is not documented.
+ src/shampylib/src/pyShamrockCtx.cpp:165: warning: Member append_to_map(std::string key, std::vector< std::unique_ptr< shamrock::patch::PatchDataLayer > > &lst, py::dict &dic_out) (function) of file pyShamrockCtx.cpp is not documented.
- src/shampylib/src/pyShamrockCtx.cpp:214: warning: Member register_patch_transform_class(py::module &m, std::string name) (function) of file pyShamrockCtx.cpp is not documented.
+ src/shampylib/src/pyShamrockCtx.cpp:215: warning: Member register_patch_transform_class(py::module &m, std::string name) (function) of file pyShamrockCtx.cpp is not documented.
- src/shampylib/src/pyShamrockCtx.cpp:233: warning: Member Register_pymod(pyshamrockctxinit) (function) of file pyShamrockCtx.cpp is not documented.
+ src/shampylib/src/pyShamrockCtx.cpp:234: warning: Member Register_pymod(pyshamrockctxinit) (function) of file pyShamrockCtx.cpp is not documented.
- src/shampylib/src/pyShamrockCtx.cpp:29: warning: Compound VecToNumpy is not documented.
+ src/shampylib/src/pyShamrockCtx.cpp:30: warning: Compound VecToNumpy is not documented.
- src/shampylib/src/pyShamrockCtx.cpp:32: warning: Compound VecToNumpy is not documented.
+ src/shampylib/src/pyShamrockCtx.cpp:33: warning: Compound VecToNumpy is not documented.
- src/shampylib/src/pyShamrockCtx.cpp:34: warning: Member convert(std::vector< T > vec) (function) of class VecToNumpy is not documented.
+ src/shampylib/src/pyShamrockCtx.cpp:35: warning: Member convert(std::vector< T > vec) (function) of class VecToNumpy is not documented.
- src/shampylib/src/pyShamrockCtx.cpp:50: warning: Compound VecToNumpy< sycl::vec< T, 2 > > is not documented.
+ src/shampylib/src/pyShamrockCtx.cpp:51: warning: Compound VecToNumpy< sycl::vec< T, 2 > > is not documented.
- src/shampylib/src/pyShamrockCtx.cpp:52: warning: Member convert(std::vector< sycl::vec< T, 2 > > vec) (function) of class VecToNumpy< sycl::vec< T, 2 > > is not documented.
+ src/shampylib/src/pyShamrockCtx.cpp:53: warning: Member convert(std::vector< sycl::vec< T, 2 > > vec) (function) of class VecToNumpy< sycl::vec< T, 2 > > is not documented.
- src/shampylib/src/pyShamrockCtx.cpp:68: warning: Compound VecToNumpy< sycl::vec< T, 3 > > is not documented.
+ src/shampylib/src/pyShamrockCtx.cpp:69: warning: Compound VecToNumpy< sycl::vec< T, 3 > > is not documented.
- src/shampylib/src/pyShamrockCtx.cpp:70: warning: Member convert(std::vector< sycl::vec< T, 3 > > vec) (function) of class VecToNumpy< sycl::vec< T, 3 > > is not documented.
+ src/shampylib/src/pyShamrockCtx.cpp:71: warning: Member convert(std::vector< sycl::vec< T, 3 > > vec) (function) of class VecToNumpy< sycl::vec< T, 3 > > is not documented.
- src/shampylib/src/pyShamrockCtx.cpp:87: warning: Compound VecToNumpy< sycl::vec< T, 4 > > is not documented.
+ src/shampylib/src/pyShamrockCtx.cpp:88: warning: Compound VecToNumpy< sycl::vec< T, 4 > > is not documented.
- src/shampylib/src/pyShamrockCtx.cpp:89: warning: Member convert(std::vector< sycl::vec< T, 4 > > vec) (function) of class VecToNumpy< sycl::vec< T, 4 > > is not documented.
+ src/shampylib/src/pyShamrockCtx.cpp:90: warning: Member convert(std::vector< sycl::vec< T, 4 > > vec) (function) of class VecToNumpy< sycl::vec< T, 4 > > is not documented.
+ src/shamrock/include/shamrock/patch/PatchDataLayout.hpp:31: warning: Member layer_layouts (variable) of class shamrock::patch::PatchDataLayout is not documented.
+ src/shamrock/include/shamrock/patch/PatchDataLayout.hpp:32: warning: Member get_layer_count() const (function) of class shamrock::patch::PatchDataLayout is not documented.
+ src/shamrock/include/shamrock/patch/PatchDataLayout.hpp:34: warning: Member get_layer_layout_ref(size_t idx=0) (function) of class shamrock::patch::PatchDataLayout is not documented.
+ src/shamrock/include/shamrock/patch/PatchDataLayout.hpp:38: warning: Member get_layer_layout(size_t idx=0) const (function) of class shamrock::patch::PatchDataLayout is not documented.
+ src/shamrock/include/shamrock/patch/PatchDataLayout.hpp:42: warning: Member get_layer_layout_ptr(size_t idx=0) (function) of class shamrock::patch::PatchDataLayout is not documented.
+ src/shamrock/include/shamrock/patch/PatchDataLayout.hpp:46: warning: Member create_layers(size_t nlayers) (function) of class shamrock::patch::PatchDataLayout is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:101: warning: Member free_mpi_required_types() (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:103: warning: Member PatchScheduler(const shamrock::patch::PatchDataLayout pdl_ptr, u64 crit_split, u64 crit_merge) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:105: warning: Member dump_status() (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:107: warning: Member dump_status() (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:107: warning: Member update_local_load_value(std::function< u64(shamrock::patch::Patch)> load_function) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:109: warning: Member update_local_load_value(std::function< u64(shamrock::patch::Patch)> load_function) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:116: warning: Member get_box_tranform() (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:118: warning: Member get_box_tranform() (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:119: warning: Member get_box_volume() (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:121: warning: Member get_box_volume() (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:121: warning: Member should_resize_box(bool node_in) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:123: warning: Member should_resize_box(bool node_in) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:154: warning: Member make_patch_base_grid(std::array< u32, dim > patch_count) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:161: warning: Member make_patch_base_grid(std::array< u32, dim > patch_count) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:168: warning: Member format_patch_coord(shamrock::patch::Patch p) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:170: warning: Member check_patchdata_locality_corectness() (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:173: warning: Member dump_local_patches(std::string filename) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:175: warning: Member format_patch_coord(shamrock::patch::Patch p) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:175: warning: Member gather_data(u32 rank) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:177: warning: Member check_patchdata_locality_corectness() (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:180: warning: Member dump_local_patches(std::string filename) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:180: warning: PatchScheduler::add_root_patch has @param documentation sections but no arguments
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:182: warning: Member gather_data(u32 rank) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:187: warning: PatchScheduler::add_root_patch has @param documentation sections but no arguments
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:200: warning: Member sync_build_LB(bool global_patch_sync, bool balance_load) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:203: warning: Member get_patch_transform() (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:207: warning: Member sync_build_LB(bool global_patch_sync, bool balance_load) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:210: warning: Member get_patch_transform() (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:240: warning: Member for_each_patch(Function &&fct) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:247: warning: Member for_each_patch(Function &&fct) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:253: warning: Member for_each_global_patch(std::function< void(const shamrock::patch::Patch)> fct) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:260: warning: Member for_each_global_patch(std::function< void(const shamrock::patch::Patch)> fct) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:261: warning: Member for_each_local_patch(std::function< void(const shamrock::patch::Patch)> fct) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:268: warning: Member for_each_local_patch(std::function< void(const shamrock::patch::Patch)> fct) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:269: warning: Member for_each_local_patchdata(std::function< void(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &)> fct) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:276: warning: Member for_each_local_patchdata(std::function< void(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &)> fct) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:278: warning: Member for_each_local_patch_nonempty(std::function< void(const shamrock::patch::Patch &)> fct) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:285: warning: Member for_each_local_patch_nonempty(std::function< void(const shamrock::patch::Patch &)> fct) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:290: warning: Member get_patch_rank_owner(u64 patch_id) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:296: warning: Member for_each_patchdata_nonempty(std::function< void(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &)> fct) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:297: warning: Member get_patch_rank_owner(u64 patch_id) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:303: warning: Member for_each_patchdata_nonempty(std::function< void(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &)> fct) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:309: warning: Member map_owned_patchdata(std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:316: warning: Member map_owned_patchdata(std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:322: warning: Member distrib_data_local_to_all_simple(shambase::DistributedData< T > &src) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:329: warning: Member distrib_data_local_to_all_simple(shambase::DistributedData< T > &src) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:335: warning: Member distrib_data_local_to_all_load_store(shambase::DistributedData< T > &src) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:342: warning: Member distrib_data_local_to_all_load_store(shambase::DistributedData< T > &src) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:346: warning: Member map_owned_patchdata_fetch_simple(std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:353: warning: Member map_owned_patchdata_fetch_simple(std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:359: warning: Member map_owned_patchdata_fetch_load_store(std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:366: warning: Member map_owned_patchdata_fetch_load_store(std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:372: warning: Member map_owned_to_patch_field_simple(std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:378: warning: Member map_owned_to_patch_field_load_store(std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:379: warning: Member map_owned_to_patch_field_simple(std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:383: warning: Member get_rank_count() (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:385: warning: Member map_owned_to_patch_field_load_store(std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:390: warning: Member get_rank_count() (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:394: warning: Member get_total_obj_count() (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:401: warning: Member get_total_obj_count() (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:401: warning: Member rankgather_field(u32 field_idx) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:408: warning: Member rankgather_field(u32 field_idx) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:459: warning: Member compute_patch_field(Pfield &field, MPI_Datatype &dtype, Function &&lambda) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:466: warning: Member compute_patch_field(Pfield &field, MPI_Datatype &dtype, Function &&lambda) (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:477: warning: Member get_node_set_edge_patchdata_layer_refs() (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:484: warning: Member get_node_set_edge_patchdata_layer_refs() (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:498: warning: Member get_sim_box() (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:500: warning: Member serialize_patch_metadata() (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:505: warning: Member get_sim_box() (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:507: warning: Member serialize_patch_metadata() (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:61: warning: Member max_axis_patch_coord (variable) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:62: warning: Member max_axis_patch_coord_length (variable) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:63: warning: Member max_axis_patch_coord (variable) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:64: warning: Member PatchTree (typedef) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:64: warning: Member max_axis_patch_coord_length (variable) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:65: warning: Member SchedulerPatchData (typedef) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:66: warning: Member PatchTree (typedef) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:67: warning: Member SchedulerPatchData (typedef) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:67: warning: Member pdl_ptr (variable) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:69: warning: Member pdl_ptr (variable) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:80: warning: Member pdl() (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:82: warning: Member get_layout_ptr() const (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:82: warning: Member pdl(size_t layer_idx=0) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:86: warning: Member get_layout_ptr(size_t layer_idx=0) const (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:94: warning: Member init_mpi_required_types() (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:96: warning: Member free_mpi_required_types() (function) of class PatchScheduler is not documented.
- src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:98: warning: Member PatchScheduler(const std::shared_ptr< shamrock::patch::PatchDataLayerLayout > &pdl_ptr, u64 crit_split, u64 crit_merge) (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/PatchScheduler.hpp:99: warning: Member init_mpi_required_types() (function) of class PatchScheduler is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:101: warning: Member dump_status() (function) of class ShamrockCtx is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:105: warning: Member init_sched(u64 crit_split, u64 crit_merge) (function) of class ShamrockCtx is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:109: warning: Member init_sched(u64 crit_split, u64 crit_merge) (function) of class ShamrockCtx is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:115: warning: Member close_sched() (function) of class ShamrockCtx is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:123: warning: Member close_sched() (function) of class ShamrockCtx is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:125: warning: Member gather_data(u32 rank) (function) of class ShamrockCtx is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:129: warning: Member allgather_data() (function) of class ShamrockCtx is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:133: warning: Member gather_data(u32 rank) (function) of class ShamrockCtx is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:137: warning: Member allgather_data() (function) of class ShamrockCtx is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:147: warning: Member set_coord_domain_bound(std::tuple< f64_3, f64_3 > box) (function) of class ShamrockCtx is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:155: warning: Member set_coord_domain_bound(std::tuple< f64_3, f64_3 > box, size_t layer_idx=0) (function) of class ShamrockCtx is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:177: warning: Member scheduler_step(bool do_split_merge, bool do_load_balancing) (function) of class ShamrockCtx is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:184: warning: Member get_patch_list_global() (function) of class ShamrockCtx is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:185: warning: Member scheduler_step(bool do_split_merge, bool do_load_balancing) (function) of class ShamrockCtx is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:192: warning: Member get_patch_list_global() (function) of class ShamrockCtx is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:28: warning: Compound ShamAPIException is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:30: warning: Compound ShamAPIException is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:30: warning: Member ShamAPIException(const char *message) (function) of class ShamAPIException is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:32: warning: Member ShamAPIException(const char *message) (function) of class ShamAPIException is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:32: warning: Member ShamAPIException(const std::string &message) (function) of class ShamAPIException is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:34: warning: Member ShamAPIException(const std::string &message) (function) of class ShamAPIException is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:36: warning: Member what() const noexcept (function) of class ShamAPIException is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:38: warning: Member what() const noexcept (function) of class ShamAPIException is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:39: warning: Member msg_ (variable) of class ShamAPIException is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:41: warning: Member msg_ (variable) of class ShamAPIException is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:42: warning: Compound ShamrockCtx is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:44: warning: Compound ShamrockCtx is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:44: warning: Member pdl (variable) of class ShamrockCtx is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:45: warning: Member sched (variable) of class ShamrockCtx is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:46: warning: Member pdl (variable) of class ShamrockCtx is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:47: warning: Member pdata_layout_new() (function) of class ShamrockCtx is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:47: warning: Member sched (variable) of class ShamrockCtx is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:49: warning: Member pdata_layout_new(size_t nlayers=1) (function) of class ShamrockCtx is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:68: warning: Member get_pdl_write() (function) of class ShamrockCtx is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:70: warning: Member get_pdl_write(size_t layer_idx=0) (function) of class ShamrockCtx is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:76: warning: Member pdata_layout_add_field(std::string fname, u32 nvar) (function) of class ShamrockCtx is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:78: warning: Member pdata_layout_add_field(std::string fname, u32 nvar, size_t layer_idx=0) (function) of class ShamrockCtx is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:83: warning: Member pdata_layout_add_field_t(std::string fname, u32 nvar, std::string type) (function) of class ShamrockCtx is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:85: warning: Member pdata_layout_add_field_t(std::string fname, u32 nvar, std::string type, size_t layer_idx=0) (function) of class ShamrockCtx is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:90: warning: Member pdata_layout_print() (function) of class ShamrockCtx is not documented.
+ src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:93: warning: Member pdata_layout_print(size_t layer_idx=0) (function) of class ShamrockCtx is not documented.
- src/shamrock/include/shamrock/scheduler/ShamrockCtx.hpp:97: warning: Member dump_status() (function) of class ShamrockCtx is not documented.
+ src/shamrock/src/scheduler/PatchScheduler.cpp:252: warning: Member get_box_tranform() (function) of class PatchScheduler is not documented.
- src/shamrock/src/scheduler/PatchScheduler.cpp:253: warning: Member get_box_tranform() (function) of class PatchScheduler is not documented.
+ src/shamrock/src/scheduler/PatchScheduler.cpp:266: warning: Member get_box_tranform() (function) of class PatchScheduler is not documented.
- src/shamrock/src/scheduler/PatchScheduler.cpp:267: warning: Member get_box_tranform() (function) of class PatchScheduler is not documented.
+ src/shamrock/src/scheduler/PatchScheduler.cpp:280: warning: Member get_box_volume() (function) of class PatchScheduler is not documented.
- src/shamrock/src/scheduler/PatchScheduler.cpp:281: warning: Member get_box_volume() (function) of class PatchScheduler is not documented.
+ src/shamrock/src/scheduler/PatchScheduler.cpp:289: warning: Member get_box_volume() (function) of class PatchScheduler is not documented.
- src/shamrock/src/scheduler/PatchScheduler.cpp:290: warning: Member get_box_volume() (function) of class PatchScheduler is not documented.
+ src/shamrock/src/scheduler/PatchScheduler.cpp:298: warning: Member get_box_volume() (function) of class PatchScheduler is not documented.
- src/shamrock/src/scheduler/PatchScheduler.cpp:299: warning: Member get_box_volume() (function) of class PatchScheduler is not documented.
+ src/shamrock/src/scheduler/PatchScheduler.cpp:662: warning: Member check_locality_t(PatchScheduler &sched) (function) of file PatchScheduler.cpp is not documented.
- src/shamrock/src/scheduler/PatchScheduler.cpp:663: warning: Member check_locality_t(PatchScheduler &sched) (function) of file PatchScheduler.cpp is not documented.
+ src/shamrock/src/scheduler/PatchScheduler.cpp:891: warning: Compound Message is not documented.
- src/shamrock/src/scheduler/PatchScheduler.cpp:892: warning: Compound Message is not documented.
+ src/shamrock/src/scheduler/PatchScheduler.cpp:892: warning: Member buf (variable) of struct Message is not documented.
- src/shamrock/src/scheduler/PatchScheduler.cpp:893: warning: Member buf (variable) of struct Message is not documented.
+ src/shamrock/src/scheduler/PatchScheduler.cpp:893: warning: Member rank (variable) of struct Message is not documented.
- src/shamrock/src/scheduler/PatchScheduler.cpp:894: warning: Member rank (variable) of struct Message is not documented.
+ src/shamrock/src/scheduler/PatchScheduler.cpp:894: warning: Member tag (variable) of struct Message is not documented.
- src/shamrock/src/scheduler/PatchScheduler.cpp:895: warning: Member tag (variable) of struct Message is not documented.
+ src/shamrock/src/scheduler/PatchScheduler.cpp:897: warning: Member send_messages(std::vector< Message > &msgs, std::vector< MPI_Request > &rqs) (function) of file PatchScheduler.cpp is not documented.
- src/shamrock/src/scheduler/PatchScheduler.cpp:898: warning: Member send_messages(std::vector< Message > &msgs, std::vector< MPI_Request > &rqs) (function) of file PatchScheduler.cpp is not documented.
+ src/shamrock/src/scheduler/PatchScheduler.cpp:924: warning: Member recv_probe_messages(std::vector< Message > &msgs, std::vector< MPI_Request > &rqs) (function) of file PatchScheduler.cpp is not documented.
- src/shamrock/src/scheduler/PatchScheduler.cpp:925: warning: Member recv_probe_messages(std::vector< Message > &msgs, std::vector< MPI_Request > &rqs) (function) of file PatchScheduler.cpp is not documented.

using SchedulerPatchData = shamrock::scheduler::SchedulerPatchData;

std::shared_ptr<shamrock::patch::PatchDataLayerLayout> pdl_ptr;
shamrock::patch::PatchDataLayout pdl_ptr;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
shamrock::patch::PatchDataLayout pdl_ptr;
std::shared_ptr<shamrock::patch::PatchDataLayout> pdl_ptr;

@tdavidcl
Copy link
Member

tdavidcl commented Jan 8, 2026

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the PatchDataLayerLayout to be managed within a new PatchDataLayout class, which acts as a container for multiple PatchDataLayerLayout instances. This change allows for better handling of multiple data layers. The ShamrockCtx and PatchScheduler classes have been updated to reflect this new structure, including changes to constructors and data access methods. Test files have also been adjusted to use the new PatchDataLayout.

However, there are a few areas that could be improved for maintainability, efficiency, and clarity, particularly regarding the handling of multiple layers in PatchScheduler and the naming of certain methods.

std::vector<std::shared_ptr<shamrock::patch::PatchDataLayerLayout>> layer_layouts;
size_t get_layer_count() const { return layer_layouts.size(); }

inline std::shared_ptr<PatchDataLayerLayout> &get_layer_layout_ref(size_t idx = 0) {

Choose a reason for hiding this comment

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

medium

Returning a non-const reference to a std::shared_ptr can be risky. If the returned shared_ptr itself is modified (e.g., reset or assigned a new pointer), any existing references to it would become dangling. Consider returning const std::shared_ptr<PatchDataLayerLayout>& if the intent is only to read the shared pointer, or std::shared_ptr<PatchDataLayerLayout> by value if the caller needs to take ownership or manage its lifetime independently.

return layer_layouts.at(idx);
}

inline PatchDataLayerLayout &get_layer_layout_ptr(size_t idx = 0) {

Choose a reason for hiding this comment

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

medium

The method name get_layer_layout_ptr is misleading as it returns a reference (PatchDataLayerLayout &), not a pointer. This could lead to confusion for users expecting a raw pointer or std::shared_ptr.

Suggested change
inline PatchDataLayerLayout &get_layer_layout_ptr(size_t idx = 0) {
inline PatchDataLayerLayout &get_layer_layout_ref_to_val(size_t idx = 0) {

Comment on lines +46 to +50
inline void create_layers(size_t nlayers) {
for (size_t idx = 0; idx < nlayers; idx++) {
layer_layouts.push_back(std::make_shared<shamrock::patch::PatchDataLayerLayout>());
}
}

Choose a reason for hiding this comment

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

medium

The create_layers method unconditionally adds new layers. If this method is called multiple times, it will keep adding layers, which might not be the intended behavior. Consider adding a check to clear existing layers or throw an exception if layer_layouts is not empty, depending on the desired semantics for re-initialization.

const std::shared_ptr<shamrock::patch::PatchDataLayerLayout> &pdl_ptr,
u64 crit_split,
u64 crit_merge);
PatchScheduler(const shamrock::patch::PatchDataLayout pdl_ptr, u64 crit_split, u64 crit_merge);

Choose a reason for hiding this comment

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

medium

Passing pdl_ptr by value (const shamrock::patch::PatchDataLayout pdl_ptr) will create a copy of the PatchDataLayout object, including its std::vector of std::shared_ptrs. While shared_ptrs handle copying efficiently, if PatchDataLayout were to become large or contain other non-trivial members, this could incur unnecessary overhead. Consider passing it by const& to avoid copying.

    PatchScheduler(const shamrock::patch::PatchDataLayout &pdl_ptr, u64 crit_split, u64 crit_merge);

Comment on lines +138 to +142
throw std::invalid_argument(
std::string("the main field is not of the correct type to call this function\n")
+ "fct called : " + __PRETTY_FUNCTION__
+ shambase::format("current patch data layout of index {} : ", layer_idx)
+ layer_layout->get_description_str());

Choose a reason for hiding this comment

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

medium

The error message here is quite verbose and includes __PRETTY_FUNCTION__ and shambase::format. While useful for debugging, for a user-facing std::invalid_argument exception, a more concise and actionable message might be preferable. The current message could be simplified to focus on the core issue: the main field type mismatch for the given layer.

ctx.pdata_layout_new();
*ctx.pdl = jmeta_patch.at("patchdata_layout").get<patch::PatchDataLayerLayout>();
ctx.pdl.get_layer_layout_ptr(0) = jmeta_patch.at("patchdata_layout")
.get<patch::PatchDataLayerLayout>(); // ->astodo ->hc

Choose a reason for hiding this comment

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

medium

The comment // ->stodo ->hc indicates a hardcoded value or a TODO item. This suggests that the initialization of ctx.pdl.get_layer_layout_ptr(0) might be a temporary solution and needs to be generalized to handle multiple layers dynamically, rather than always assuming layer 0. This is a maintainability concern.

patch::PatchDataLayer pdat = patch::PatchDataLayer::deserialize_buf(
ser,
std::make_shared<patch::PatchDataLayerLayout>(
ctx.pdl.get_layer_layout_ptr(0))); // ->astodo ->hc

Choose a reason for hiding this comment

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

medium

Similar to the previous comment, // ->stodo ->hc here suggests that the deserialization is hardcoded to layer 0. This will need to be addressed if the system is to support multiple PatchDataLayerLayouts being loaded from a dump file.

const std::shared_ptr<shamrock::patch::PatchDataLayerLayout> &pdl_ptr,
u64 crit_split,
u64 crit_merge)
const shamrock::patch::PatchDataLayout pdl_ptr, u64 crit_split, u64 crit_merge)

Choose a reason for hiding this comment

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

medium

Consistent with the header, pdl_ptr is passed by value. As noted before, consider passing by const& to avoid unnecessary copying of the PatchDataLayout object.

Suggested change
const shamrock::patch::PatchDataLayout pdl_ptr, u64 crit_split, u64 crit_merge)
const shamrock::patch::PatchDataLayout &pdl_ptr, u64 crit_split, u64 crit_merge)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants