-
Notifications
You must be signed in to change notification settings - Fork 21
[GSPH] add SerialPatchTreeRefEdge for solvergraph integration #1581
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
base: main
Are you sure you want to change the base?
[GSPH] add SerialPatchTreeRefEdge for solvergraph integration #1581
Conversation
Use existing SerialPatchTreeRefEdge from shamrock/solvergraph/ to register the serial patch tree in the solver graph for explicit data dependency tracking. Changes: - Add solver_graph and serial_patch_tree_ref edge to SolverStorage - Register edge in init_solver_graph() - Set reference in gen_serial_patch_tree() after tree is built - Clear reference in reset_serial_patch_tree() The tree storage remains as Component<SerialPatchTree<Tvec>> while the solvergraph edge holds a reference for dependency tracking.
|
Thanks @Guo-astro for opening this PR! You can do multiple things directly here: Once the workflow completes a message will appear displaying informations related to the run. Also the PR gets automatically reviewed by gemini, you can: |
Summary of ChangesHello @Guo-astro, 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 integrates the serial patch tree into the solver graph framework, a crucial step in the GSPH solvergraph migration. By introducing a dedicated reference edge, the system can now explicitly track data dependencies related to the serial patch tree, enhancing the overall data flow management and consistency within the solver. This change lays the groundwork for more robust and transparent data handling in future solver operations. Highlights
Using Gemini Code AssistThe 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
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 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
|
Workflow reportworkflow report corresponding to commit 30a341a Pre-commit check reportSome failures were detected in base source checks checks. Suggested changesDetailed changes :diff --git a/src/shammodels/gsph/src/Solver.cpp b/src/shammodels/gsph/src/Solver.cpp
index bdc7d8df..99f8c91a 100644
--- a/src/shammodels/gsph/src/Solver.cpp
+++ b/src/shammodels/gsph/src/Solver.cpp
@@ -129,7 +129,8 @@ void shammodels::gsph::Solver<Tvec, Kern>::gen_serial_patch_tree() {
storage.serial_patch_tree.set(std::move(_sptree));
// Set solvergraph edge reference to the stored tree
- shambase::get_check_ref(storage.serial_patch_tree_ref).patch_tree = storage.serial_patch_tree.get();
+ shambase::get_check_ref(storage.serial_patch_tree_ref).patch_tree
+ = storage.serial_patch_tree.get();
}
template<class Tvec, template<class> class Kern>
|
There was a problem hiding this 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 integrates the SerialPatchTree with the solvergraph for dependency tracking by introducing a SerialPatchTreeRefEdge. The changes correctly add the new solvergraph edge, register it, and manage its lifecycle by setting the reference after tree creation and clearing it before destruction. A critical concern has been raised regarding a potential memory management bug. The method free_alloc() is called on a non-owning reference wrapper, which could lead to a double-free if it deallocates the raw pointer it holds. A detailed comment has been provided on this potential issue. Apart from this concern, the changes look correct and align with the PR's objective.
| inline void reset_serial_patch_tree() { | ||
| shambase::get_check_ref(storage.serial_patch_tree_ref).free_alloc(); | ||
| storage.serial_patch_tree.reset(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of free_alloc() on serial_patch_tree_ref is concerning. SerialPatchTreeRefEdge holds a non-owning raw pointer (patch_tree) to an object managed by storage.serial_patch_tree. The name free_alloc strongly implies deallocation. If this method attempts to delete the raw pointer, it will lead to a double-free when storage.serial_patch_tree is reset, which is a critical memory corruption bug.
If the intention of free_alloc() is simply to nullify the internal pointer (e.g., patch_tree = nullptr;), the method is dangerously misnamed and should be renamed to something like clear_reference() or reset() to avoid confusion and prevent future misuse.
Given the potential for a critical bug, please verify the implementation of SerialPatchTreeRefEdge::free_alloc() and consider renaming it for clarity and safety.
Summary
Use existing
SerialPatchTreeRefEdgefromshamrock/solvergraph/to register the serial patch tree in the solver graph for explicit data dependency tracking.Part of GSPH solvergraph migration (1 object per PR per maintainer request).
Changes:
solver_graphandserial_patch_tree_refedge toSolverStorageinit_solver_graph()gen_serial_patch_tree()after tree is builtreset_serial_patch_tree()The tree storage remains as
Component<SerialPatchTree<Tvec>>while the solvergraph edge holds a reference for dependency tracking.Test plan