Reputation: 1849
Supposed that my CUDA kernel has a long list of parameters. For convenience, i put these in a struct:
struct params {
int firstParam;
float secondParam;
...
bool lastParam;
}
Is there a disadvantage when calling the kernel with
myKernel<<<n,m>>>( params );
compared to first copying to constant memory?
cudaMemcpyToSymbol( paramsOnDevice, ¶msOnHost, sizeof(params), 0 );
Upvotes: 0
Views: 537
Reputation: 21128
On devices of compute capability 2.0 and later the limit for the size of the kernel arguments is 4KB (see the programming guide). This means that if your structure is very large then you could run into this limit, but otherwise the behaviour is more-or-less the same since the arguments are passed via constant memory.
One case where copying to a symbol may have a very small benefit is where you launch the same kernel many times with the same arguments, copying explicitly means you only copy once instead of every time. However I would expect the benefit to be small in most practical cases - you could measure this if you were worried!
Upvotes: 3