Closed Yurlungur closed 3 years ago
I also replaced a large fraction of boiler plate in the class with variatic templates. Although the templates are a little harder to read, they improve readability by reducing the number of function overloads by a factor of 6 in some cases.
I'm a fan of these changes. I know that variadic templates can be somewhat impenetrable, but I think this is an excellent usage of them and the reduction in SLOC is a big plus in my book.
There was a comment about one of the functions and that one I need further clarification on before merging if that's alright.
Thanks @dholladay00 ! Yes, let's discuss your comments a bit inline before proceeding.
Thanks for all the feedback @dholladay00 ! I think I've addressed all concerns. Can you click approve if you're happy for now?
I don't see an approve button.
I don't see an approve button.
I found it
Travis CI is refusing to run jobs. I'm merging.
A bug in downstream code
singularity-eos
prompted me to runvalgrind
onSpiner
. I discovered a number of issues withSpiner
's pseudo-reference-counting where it tried to manage its own memory on the host but gave up on the device. This design had several problems:DataBox
that managed memory could not go out of scope. If it did, allDataBox
es that depended on it would be pointing at unitialized memory.I therefore re-design
DataBox
memory management in this PR. I do the following:DataBox
es can allocate memory. They free memory before re-allocating, but otherwise never free memory.DataBox::finalize()
orfree(DataBox&)
methods, which release allocated memory.This provides several advantages.
DataBox
allocates memory more finely. I now provide constructors and "resetter"s that can tellDataBox
where to allocate. You can allocate on the device via, e.g.,and you can always free via
no matter where the data is located.
free()
mechanism allows to subsume our databox to smart pointers and reference count them that way if desired. To enable this, we provide theSpiner::DBDeleter
class defined asThis can be used as, for example,
which will automatically garbage collect the device memory when
pdb
goes out of scope.Thanks to @jdolence and @dholladay00 for useful discussions while I chased this down. Thanks @brryan for the idea about the custom deleter for the shared pointer. @jdolence @dholladay00 please take a look at this and let me know what you think. I'd like to merge it in quickly. Then I will need to update
singularity-eos
to utilize the new API.