permutation on gpu

Previously I posted something about my project. See https://devtalk.nvidia.com/default/topic/1006621/problem-with-parameter/#5138629 To my knowledge I solves the problems withe the invalid memory access(getIth returned -1 sometimes at the time). However I am now stuck with error 4. I tried using memcheck, and the regular debugging tool in visual studio, but I can’t find the mistake(s) I made. Can anyone help me with this, or just recommend certain tools/ common erros.

I see that you are using in-kernel new. You should read this section of the programming guide carefully:

[url]Programming Guide :: CUDA Toolkit Documentation

Everything that it says there about malloc applies to new also. The default heap space for new is quite limited, and people often exceed it. When you try to allocate more than what the limit allows, the returned pointer will be NULL. This is the standard error reporting method for malloc (when you run out of memory) and it applies here to new also. If you attempt to dereference a NULL pointer in your kernel, you can get error 4. Your comment seems to indicate that you are having trouble with line 107, so that may be the issue, since that array/pointer is obtained via a previous new operation.

It’s good practice to always check the returned pointer for NULL when debugging such code.

Note that you can increase the device limit for the heap allocations.

Thank you for your reply.That was indeed the issue.