mrzv / reeber

a library for shared- and distributed-memory parallel computation of merge trees
Other
7 stars 5 forks source link

Add support for non-owning data pointer to FabBlock constructor #3

Open n8xm opened 1 week ago

n8xm commented 1 week ago

Currently, FabBlock's destructor frees the data that is passed into its constructor as T* data. This behavior assumes that FabBlock owns the data.

In order to avoid a double free, there should be a way to support construction of a FabBlock from a non-owning pointer. Perhaps a flag could be added to the FabBlock's constructor in order to indicate that a non-owning pointer is being passed.

The above summarizes a discussion I had with @anigmetov after encountering a double free error when using Reeber for in-situ halo finding in the Nyx cosmology code.

mrzv commented 1 week ago

@anigmetov Do you remember why this was done in the first place? I can't imagine a situation where we want to take ownership of the data in the first place.

Either way, the proposed solution sounds good to me.

anigmetov commented 1 week ago

@mrzv Probably, I added the destructor for a specific setup that we had in our experiments for the paper: in order to avoid IO, the data were read from disk once and then we ran Reeber many times on the same data that were copied into a block, to report average running time of the algorithm. If you don't have any other case where we need to take ownership, getting rid of the destructor altogether may be a better solution.