ManagedCUDA "Struct" instead of "Class"

Hi,

As I wanted to run my CUDA C/C++ program from a C# application, some people advised me to use ManagedCUDA, so it’s what I did and, with some example, after reading some topics and more failure and test I finally figured out how it works… more or less…

I read that ManagedCUDA doesn’t allow to pass class to kernels so we need to declare it as a structure, that’s what I did. But in theses class I got few function (between 1 and 20) and few class (~8). I’m wondering if it’s possible to just declare the function and define it in the .cu file or if I must declare it in C# and int CUDA. If we can, how to proceed ? I’m not that familiar neither with managedCUDA nor with C#, I’m still learning.

And I also wanted to know how can I allocate variable in a structure with managedCUDA ? 'cause I did something like this :

class program
{
  struct foo
  {
   int geo;
  }

  void main(string[] args)
  {
   CudaDeviceVariable<int>foo.geo = new CudaDeviceVariable<int>(100);
   //got error on "foo.geo" -> "expected ;"
   //use it some way I donc know..
   foo.geo.Dispose()
   // CudaDeviceVariable does not contain a definition of geo
  }

So how can I do something like this. I did something very similar in CUDA C/C++ and it works

class foo
{
 int *tabgeo;
}

int main(void)
{
 foo geo;

 cudaMalloc((void **)&geo.tabgeo, sizeof(int) * 100);
 // and i can use it in kernel
 cudaFree(geo.tabgeo); 
}