Open mxmlnkn opened 8 years ago
I already tried to implement a class-using version but this led to not-easy-to-understand CUDA errors. With an eye on the schedule I think this is a important task but a task for the future.
I think it would be a tad cooler, if it wasn't inside the write out functions, but if instead taskQueue.cu
could create a [lambda]-wrapper which calls first the write out function and then delete[]
. That way the user doesn't have to add it to their customized write out functions and writeOutPNG
and writeOutHDF5
could be used for debugging output without having to worry about involuntary frees.
Having the free hardcoded into taskQueue.cu
could lead to problems when the user doesn't want to free the pointer. But I don't know if that's an actual use-case.
The example
imresh/examples/threadedExample.cpp
suggests the following call to free the allocated data where justFree is just a wrapper todelete[]
. This will be run in parallel and is bad (Segmentation fault).Possible fixes:
delete[]
inside taskQueue.cu after join(). In this case we need to store the pointers to the data to freeThe problem with letting the user do it are plentiful, because it breaks paralellism or is just too complex. My suggestion is to convert taskQueue.cu into a class e.g. called
ShrinkWrapBatch
so that adding tasks could be as easy as:Note that no call to initialize is necessary anymore because it would be included in the constructor. Also no need to call deinit is necessary, because the outer scope will call the Destructor. Each data given is freed either by
batch.add
orbatch.~batch