Skip to content

Conversation

@pdziekan
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings January 15, 2026 16:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the particle tracking system to use thrust_size_t instead of real_t for particle ID vectors (lft_id and rgt_id), and implements a temporary vector pool system for cell index storage (i, j, k). The change improves type correctness by using integer types for indices rather than misusing floating-point temporary vectors.

Changes:

  • Changed lft_id and rgt_id to use thrust_size_t instead of real_t across all related functions
  • Refactored cell indices (i, j, k) to use temporary vectors from tmp_device_size_part pool via guard pointers
  • Updated temporary vector allocation logic to support the new pool-based cell index management

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
src/impl/particles_impl_unpack.ipp Updated lft_id and rgt_id type declarations to thrust_size_t
src/impl/particles_impl_subs.ipp Added acquisition of k cell index from guard pool
src/impl/particles_impl_rlx_dry_distros.ipp Replaced direct vector resizing with pool-based management; added guard acquisition for i, j, k
src/impl/particles_impl_reserve_hskpng_npart.ipp Uncommented tmp_device_size_part reserve call; commented out direct i, j, k reserves
src/impl/particles_impl_rcyc.ipp Added note about need to call hskpng_ijk after recycling
src/impl/particles_impl_pack.ipp Updated lft_id and rgt_id type declarations to thrust_size_t
src/impl/particles_impl_init_xyz.ipp Refactored to acquire cell indices from guard pool dynamically
src/impl/particles_impl_hskpng_resize.ipp Uncommented tmp_device_size_part resize call
src/impl/particles_impl_hskpng_remove.ipp Commented out direct cell index removal logic; added note about hskpng_ijk requirement
src/impl/particles_impl_hskpng_ijk.ipp Added guard acquisitions for cell indices in all relevant functions; added missing break statements
src/impl/particles_impl_bcnd.ipp Updated to use tmp_device_size_part instead of tmp_device_real_part for lft_id/rgt_id; added cell index guard reset
src/impl/particles_impl_adve.ipp Added guard acquisition for i, j, k before use
src/impl/particles_impl.ipp Removed i, j, k as permanent vectors; added them as guard pointers; updated pool initialization logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

assert(out_n_bfr.size() >= rgt_count * distmem_n_vctrs.size());

thrust_device::vector<real_t> &rgt_id(rgt_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many availableassert(in_n_bfr.size() >= rgt_count * distmem_n_vctrs.size());
thrust_device::vector<thrust_size_t> &rgt_id(rgt_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many availableassert(in_n_bfr.size() >= rgt_count * distmem_n_vctrs.size());
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The assert statement is concatenated to the comment on the same line. This should be split into a separate line to ensure the assert is properly executed.

Suggested change
thrust_device::vector<thrust_size_t> &rgt_id(rgt_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many availableassert(in_n_bfr.size() >= rgt_count * distmem_n_vctrs.size());
thrust_device::vector<thrust_size_t> &rgt_id(rgt_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many available
assert(in_n_bfr.size() >= rgt_count * distmem_n_vctrs.size());

Copilot uses AI. Check for mistakes.
reset_guardp(i_gp, tmp_device_size_part); // acquire tmp array to store i
thrust_device::vector<thrust_size_t> &i(i_gp->get());

thrust::copy(ijk.begin() + begin_shift, ijk.end(), i.begin() + begin_shift); // only x
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

Missing break statement after case 1. Without a break, execution will fall through to case 0, which may not be the intended behavior.

Suggested change
thrust::copy(ijk.begin() + begin_shift, ijk.end(), i.begin() + begin_shift); // only x
thrust::copy(ijk.begin() + begin_shift, ijk.end(), i.begin() + begin_shift); // only x
break;

Copilot uses AI. Check for mistakes.
void particles_t<real_t, device>::impl::flag_lft()
{
thrust_device::vector<real_t> &lft_id(lft_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many available
thrust_device::vector<thrust_size_t> &lft_id(lft_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many available
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The comment is outdated. It still mentions using 'real_t tmp vector' but the code now correctly uses thrust_size_t. Update the comment to reflect the current implementation.

Copilot uses AI. Check for mistakes.
void particles_t<real_t, device>::impl::flag_rgt()
{
thrust_device::vector<real_t> &rgt_id(rgt_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many available
thrust_device::vector<thrust_size_t> &rgt_id(rgt_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many available
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The comment is outdated. It still mentions using 'real_t tmp vector' but the code now correctly uses thrust_size_t. Update the comment to reflect the current implementation.

Copilot uses AI. Check for mistakes.
assert(in_n_bfr.size() >= lft_count * distmem_n_vctrs.size());

thrust_device::vector<real_t> &lft_id(lft_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many available
thrust_device::vector<thrust_size_t> &lft_id(lft_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many available
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The comment is outdated. It still mentions using 'real_t tmp vector' but the code now correctly uses thrust_size_t. Update the comment to reflect the current implementation.

Copilot uses AI. Check for mistakes.
assert(in_real_bfr.size() >= rgt_count * distmem_real_vctrs.size());

thrust_device::vector<real_t> &rgt_id(rgt_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many available
thrust_device::vector<thrust_size_t> &rgt_id(rgt_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many available
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The comment is outdated. It still mentions using 'real_t tmp vector' but the code now correctly uses thrust_size_t. Update the comment to reflect the current implementation.

Copilot uses AI. Check for mistakes.
void particles_t<real_t, device>::impl::bcnd_remote_lft(const real_t &x0, const real_t &x1)
{
thrust_device::vector<real_t> &lft_id(lft_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many available
thrust_device::vector<thrust_size_t> &lft_id(lft_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many available
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The comment is outdated. It still mentions using 'real_t tmp vector' but the code now correctly uses thrust_size_t. Update the comment to reflect the current implementation.

Copilot uses AI. Check for mistakes.
void particles_t<real_t, device>::impl::bcnd_remote_rgt(const real_t &x1, const real_t &x0)
{
thrust_device::vector<real_t> &rgt_id(rgt_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many available
thrust_device::vector<thrust_size_t> &rgt_id(rgt_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many available
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The comment is outdated. It still mentions using 'real_t tmp vector' but the code now correctly uses thrust_size_t. Update the comment to reflect the current implementation.

Copilot uses AI. Check for mistakes.
Comment on lines 112 to 117
// release tmp vectors for reuse as lft/rgt_id; cell indices (i,j,k,ijk) are anyway udefined by distmem copy and will be recalculated in post_copy
i_gp.reset();
k_gp.reset();

reset_guardp(lft_id_gp, tmp_device_size_part);
thrust_device::vector<thrust_size_t> &lft_id(lft_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many available
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The comment is outdated. It still mentions using 'real_t tmp vector' but the code now correctly uses thrust_size_t. Update the comment to reflect the current implementation.

Suggested change
// release tmp vectors for reuse as lft/rgt_id; cell indices (i,j,k,ijk) are anyway udefined by distmem copy and will be recalculated in post_copy
i_gp.reset();
k_gp.reset();
reset_guardp(lft_id_gp, tmp_device_size_part);
thrust_device::vector<thrust_size_t> &lft_id(lft_id_gp->get()); // id type is thrust_size_t, but we use real_t tmp vector because there are many available
// release tmp vectors for reuse as lft/rgt_id; cell indices (i,j,k,ijk) are anyway undefined by distmem copy and will be recalculated in post_copy
i_gp.reset();
k_gp.reset();
reset_guardp(lft_id_gp, tmp_device_size_part);
thrust_device::vector<thrust_size_t> &lft_id(lft_id_gp->get()); // id type is thrust_size_t

Copilot uses AI. Check for mistakes.
@pdziekan pdziekan merged commit 963ebc0 into igfuw:master Jan 16, 2026
26 checks passed
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.

1 participant