This project is read-only.

Getting error 'Object contains non-primitive or non-blittable data' when I try to run Kernel

Apr 17, 2015 at 12:56 AM
When running my code I get the error 'Object contains non-primitive or non-blittable data'
Here is my code.
CudaDeviceVariable<double3> d_data = h_data;
CudaDeviceVariable<double3> d_output = h_output;
const int ThreadsPerBlock = 1024;
InterpolateKernel.BlockDimensions = ThreadsPerBlock;
InterpolateKernel.GridDimensions = h_output.Length + ThreadsPerBlock - 1 / ThreadsPerBlock;
InterpolateKernel.Run(d_data, d_output, h_output.Length, h_data.Length);
Exception StackTrace indicates that the error is occuring at the following location in CudaKernel.cs
public virtual float Run(params object[] parameters)
    int paramCount = parameters.Length;
    IntPtr[] paramsList = new IntPtr[paramCount];
    GCHandle[] GCHandleList = new GCHandle[paramCount];

    //Get pointers to kernel parameters
    for (int i = 0; i < paramCount; i++)
        GCHandleList[i] = GCHandle.Alloc(parameters[i], GCHandleType.Pinned); // exception occurs here
        paramsList[i] = GCHandleList[i].AddrOfPinnedObject();
Any ideas.
Apr 17, 2015 at 1:04 AM
You need to pass d_data.DevicePointer and d_output.DevicePointer as kernel launch argument:
InterpolateKernel.Run(d_data.DevicePointer, d_output.DevicePointer, h_output.Length, h_data.Length);
Apr 17, 2015 at 1:12 AM

Yes I just figured that out, thanks. Now I am getting the error ‘ErrorInvalidValue’ at location 2303 in CudaKernel.cs. This is right after the launching the kernel. Is there any way to get more extensive error reporting?

Ex. QueryLastError()?

My Array sizes are

d_data 501624 bytes

d_output = 6867360 bytes

Apr 17, 2015 at 8:51 AM
no, managedCuda hasn't more error checking capabilities than the cuda API itself. Every API call is checked and in case of no success an exception is thrown...

ErrorInvalidValue means what it says: One of the passed arguments of the latest API call aren't in a correct range: In your case line 2300.
res = DriverAPINativeMethods.Launch.cuLaunchKernel(...)
Check that the arguments passed to "InterpolateKernel.Run" fit in size and count to your cuda source file.
Also some brackets are missing in your grid-dimension computations.