This project is read-only.

Where to ask questions??

Sep 13, 2012 at 5:25 AM
Edited Sep 13, 2012 at 6:18 AM


I was trying to do something with ManagedCuda, but I came across a problem... I was searching for answers, but I couldn't find any... is there a place dedicated to managed cuda?? (haven't tried asking in stackoverflow)

by the way, awesome wrapper, very helpful!! :D




PD: here is my question:

Sep 14, 2012 at 4:29 PM


No there's no other place for managedCuda than here on codeplex...

Regarding your question: I answered it directly on stackoverflow.


Hope it helps and have fun with CUDA


Jul 24, 2013 at 3:51 PM
Regarding the question there about constant memory:
I have a couple of kernels (on the same context) and I want to use the same constant memroy for both of them (correct me if I'm wrong, but as far as I know, constant memory is shared context-wise... or, isn't it?). I tried setting the constant memory from one kernel, and them accessing it from the other, but for the other kernel the constant memory was blank.
Here's an unchecked example of what I mean:
__constant__ int MyConst[1024];

/* Run with a 1x1x1 grid and a 1024x1x1 block... */
__global__ void TestReadingConst1()
   int index = threadIdx.x;

   int foo = MyConst[index];

/* Run with a 1x1x1 grid and a 1024x1x1 block... */
__global__ void TestReadingConst2()
   int index = threadIdx.x;

   int foo = MyConst[index];
int[] constData = new int[1024]; 

// ... Populate constData ...

CudaContext context = new CudaContext();

CudaKernel TestReadingConst1Kernel = context.LoadKernel("Test.cubin", "TestReadingConst1");
TestReadingConst1Kernel.GridDimensions = new dim3(1);
TestReadingConst1Kernel.BlockDimensions = new dim3(1024);

TestReadingConst1Kernel.SetConstantVariable("MyConst", constData);

CudaKernel TestReadingConst2Kernel = context.LoadKernel("Test.cubin", "TestReadingConst2");
TestReadingConst2Kernel.GridDimensions = new dim3(1);
TestReadingConst2Kernel.BlockDimensions = new dim3(1024);

If you debug TestReadingConst1() you'll see the constData was copied to MyConst, but for TestReadingConst2() MyConst will be all 0s.

By the way, if it matters any, I have GeForce GTX 560, I'm running on a win 7, 64-bit, with latest NVidia driver (, Cuda 5.0 toolkit, and latest 64-bit NSight for debugging.
Jul 24, 2013 at 5:15 PM

I currently can’t test things so everything here is just a guess…
But, constant memory is shared in CUmodule scope, not per context. And you create internally two independent CUmodules using context.LoadKernel(…).
If you use instead the same CUmodule for both kernels like in
CUmodule module = context.LoadModulePTX(…);
CudaKernel Kernel1 = new CudaKernel(…, module,…);
CudaKernel Kernel2 = new CudaKernel(…, module,…);
things should work out as expected.

Jul 4, 2014 at 11:14 AM

If constant memory has CUmodule scope, why then is it copied using kernel scope method? I understand that you may want to change it kernel-wise, however I miss module scope version. However it was quite straightforward to use code from CUDAKernel and write my own module scope version because at lower levels the concepts are separated well. I have though that you may consider implementing it.

Best regards, Martin.
Jul 4, 2014 at 3:22 PM
You're right that the copy methods are missing in CUmodule scope, but I decided against it with the following two reasons:
  • Nvidia defines relatively weak what a module actually is: what a module is depends on what you write in your cu-files, but also on how you load the cubin/ptx-files. This got even weaker with the introduction of the cuda linker. The only other module-scoped elements are texture references, which got replaced by texture objects.
  • It is generally good practice to write one cu-file for one kernel, just like one class per file in C++ etc. This means, that a module is the same as a kernel, if you load it just once.