-
Notifications
You must be signed in to change notification settings - Fork 0
Description
I liked reading through your code. It's really cool how much of image processing you were able to touch on. A lot of things like variational diffusion go right over my head but they've piqued my interest and left me with a list of things to read up on.
Smart pointers and Cuda
Something I haven't had time to look into but has consistently caught my eye when it comes to modern c++ is memory management.
I think a part of your code provides a good opportunity to explore this.
In main, where you use raw pointers for the input and output pixel arrays, I'd be interested to see how using a unique point might make the usage cleaner.
imageProcessing/imageProcessing.cu
Line 289 in 2a1ee69
| inputPixelArrays = imageHandling::allocateImage(depth, width, height); |
imageProcessing/imageProcessing.cu
Line 307 in 2a1ee69
| imageHandling::freeImage(inputPixelArrays, depth); |
What I'm wondering is if there is a clean way to do something like
auto inputPixelArrays = std::make_unique<imageHandleObject>(depth, width, height);
Which would call the imageHandle object's destructor which does the cudafree part. That would require turning your functional library into a class though.
To avoid that, I think it would be possible to create a unique pointer where you pass your function,
imageProcessing/imageHandling.cu
Line 61 in 2a1ee69
| void imageHandling::freeImage(double **pixelArrays, int depth) { |
as the deleter.
I wonder if it would look something like
auto inputPixelArrays = std::make_unique<double>(imageHandling::allocateImage(depth, width, height), imageHandling::freeImage( depth))
Anyway, this still doesn't solve what I'd really like. I'm more interested in cudafree, and it's variants, getting called when the memory goes out of scope. More generally, a way to avoid using cuda malloc and free. Just something I think could be handy.
kSVD
imageProcessing/imageAlgebra.cu
Line 77 in 2a1ee69
| cusolverDnDgesvd( |
I saw that the api you are using was marked legacy by nvidia in their documentation. What I thought was weird is there isn't a link to a newer or preferred method. Did you happen to find anything like that?