I got two projects, one renders 3d textures, the other manipulates 3d textures, both build static libs. Is there a way include both projects and pass information (e.g. a cuda texture handle) between them, without copying to the CPU first?
I would like to do something like this:
//alloc cuda memory x on device
CUDA texture handles are implicit static variables, so they only exist within the .cu file that contains the kernel.
You can pass the cudaArray* between the libraries and just have the 2nd library bind it to its own texture handle (binding is very cheap). This is assuming that both all code you are executing shares the same cuda context (i.e. it is in the same host thread).
Of course you can do that. The cudaArray* is just a pointer after all. #include <cuda_runtime.h> in your standard compiler c++ files, so cudaArray is defined of course. If you aren’t aware, you can call cudaMalloc, cudaMemcpy, etc… from functions compiled by the standard compiler too: there is nothing magical about them :) The only things that must be done in nvcc compiled files are kernel defintions, kernel<<<…>>> calls, and texture binds.