From 3b2a8a1121d47c0dbf3dec240863370559e5afdc Mon Sep 17 00:00:00 2001 From: James McClung Date: Mon, 5 May 2025 12:42:40 -0400 Subject: [PATCH 1/2] const_accessor_simple: store ref to mprts instead of accessor it was possible for a ConstAccessorSimple to be dropped before its corresponding ConstAccessorPatchSimple --- src/include/const_accessor_simple.hxx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/include/const_accessor_simple.hxx b/src/include/const_accessor_simple.hxx index e0c9b82c19..87f6c67439 100644 --- a/src/include/const_accessor_simple.hxx +++ b/src/include/const_accessor_simple.hxx @@ -1,4 +1,3 @@ - #pragma once // ====================================================================== @@ -181,20 +180,20 @@ struct ConstAccessorPatchSimple uint n_; }; - ConstAccessorPatchSimple(const ConstAccessorSimple& accessor, int p) - : accessor_{accessor}, p_{p} + ConstAccessorPatchSimple(const Mparticles& mprts, int p) + : mprts_{mprts}, p_{p} {} const_iterator begin() const { return {*this, 0}; } const_iterator end() const { return {*this, size()}; } ConstParticleProxy operator[](int n) const { - return {accessor_.data(p_)[n], accessor_.mprts(), p_}; + return {mprts_[p_].begin()[n], mprts_, p_}; } - uint size() const { return accessor_.size(p_); } + uint size() const { return mprts_[p_].size(); } private: - const ConstAccessorSimple& accessor_; + const Mparticles& mprts_; const int p_; }; @@ -210,7 +209,7 @@ struct ConstAccessorSimple ConstAccessorSimple(Mparticles& mprts) : mprts_{mprts} {} - Patch operator[](int p) const { return {*this, p}; } + Patch operator[](int p) const { return {mprts_, p}; } const Mparticles& mprts() const { return mprts_; } uint size(int p) const { return mprts_[p].size(); } typename Mparticles::Patch::iterator data(int p) const From 01d794a36ee386c5b46369e18bfdfb5a15e1c008 Mon Sep 17 00:00:00 2001 From: James McClung Date: Mon, 5 May 2025 12:43:36 -0400 Subject: [PATCH 2/2] mparticles_patch_cuda: fix call to ctor --- src/libpsc/cuda/mparticles_patch_cuda.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libpsc/cuda/mparticles_patch_cuda.hxx b/src/libpsc/cuda/mparticles_patch_cuda.hxx index ea11607861..5c51613f9e 100644 --- a/src/libpsc/cuda/mparticles_patch_cuda.hxx +++ b/src/libpsc/cuda/mparticles_patch_cuda.hxx @@ -27,7 +27,7 @@ struct ConstAccessorCuda off_{mprts.get_offsets()} {} - Patch operator[](int p) const { return {*this, p}; } + Patch operator[](int p) const { return {mprts_, p}; } Mparticles& mprts() const { return mprts_; } const _Particle* data(int p) const { return &data_[off_[p]]; } uint size(int p) const { return off_[p + 1] - off_[p]; }