Just like normal C, the two global scope definitions are aliased by the arguments passed in. So any code in your kernel which accesses “c” and “d” will NOT be the globals, but the argument values. You won’t be able to access the globals since they’ve been aliased by the argument definition.
If you want to use c and d as globals, don’t pass them in as arguments at all… they’re already global scope.
Just like normal C, the two global scope definitions are aliased by the arguments passed in. So any code in your kernel which accesses “c” and “d” will NOT be the globals, but the argument values. You won’t be able to access the globals since they’ve been aliased by the argument definition.
If you want to use c and d as globals, don’t pass them in as arguments at all… they’re already global scope.
Thank you . That means now c and b has only the kernel scope ,right ? If we pass pointers to matrices as arguments to the kernel , they will retain the modified values as in
normal c functions so that I don’t have to copy to host and relaunch them again ?
Thank you . That means now c and b has only the kernel scope ,right ? If we pass pointers to matrices as arguments to the kernel , they will retain the modified values as in
normal c functions so that I don’t have to copy to host and relaunch them again ?
No. If you pass pointers to CPU memory areas to the kernel, you’ll probably get an unspecified launch failure because the kernel cannot access CPU memory directly.
Next, if you alloc device memory in your host function and pass a pointer to that to the kernel, the kernel will be able to access that memory fine. But you’ll need to copy that back to the host, since the host cannot access device memory directly.
No. If you pass pointers to CPU memory areas to the kernel, you’ll probably get an unspecified launch failure because the kernel cannot access CPU memory directly.
Next, if you alloc device memory in your host function and pass a pointer to that to the kernel, the kernel will be able to access that memory fine. But you’ll need to copy that back to the host, since the host cannot access device memory directly.