Data passing between projects


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:

#include "manipulator.h"

#include "renderer.h"

foo() {

  Manipulator myM();

  Renderer myR();

 //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).

thanks a lot! One question left:

ok, clear. My problem is, that I’m using classes like this:

class CLASS_DECLSPEC Manipulator




extern "C" void some_great_cuda_func(uchar *data);



    //use some_great_cuda_func

    //do other stuff


I’m using the standard compiler for this, and nvcc only for the cuda stuff.

Is there a way to keep this structure and still pass cudaArray *?

The optimum woud be to have a function like

cudaArray *Manipulator::returnCudaArray(){return myCudaArray;};

Thanks again :)


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.

great, thx! now it works :D