Question

I have been happily ignoring this for a while, but it has become quite a problem now - I hope you guys can help me out.

I am calling cudaMallocPitch, but whatever I try, It keeps giving me the red underlining and the 'invalid arguments' error. Even when I copy the source code from the Nvidia CUDA C Programming guide it still gives me the error. I am quite new to CUDA, so please do not hesitate to point out anything you might think would be obvious that could be causing the problem.

Here is the exact code I am referring to:

int width = 64, height = 64;
    float* devPtr;
    size_t pitch;
    cudaMallocPitch(&devPtr, pitch,
                    width * sizeof(float), height);

Any comment is greatly appreciated, cheers.

Was it helpful?

Solution

The second parameter is supposed to be a size_t*, but you're passing a size_t. Try this instead:

cudaMallocPitch(&devPtr, &pitch, width * sizeof(float), height);

Note also that the last parameter type is also size_t. Perhaps height would be better as a size_t.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top