I have a .NET program that is utilizing CUDA.
The CUDA is accessed through a C DLL.
What I am doing is initializing my CUDA application by allocating buffers (cudaMalloc) on the device at program startup. Pointers to these buffers are then maintained in static variables declared in the DLL. Data is copied to and from the buffers throughout the program. Upon program termination the previously allocated buffers are freed.
Is it ok to maintain pointers to the allocated device memory or should I be reallocating every time I execute the kernel (which would seem to be very inefficient)?
I haven't noticed any side effects at present, but just wanted to confirm that this usage pattern is preferred and acceptable.