更新时间:2022-05-14 23:30:38
内核参数通过常量内存(或sm_1x中的共享内存)传递,因此没有您建议的复制。
Kernel arguments are passed in via constant memory (or shared memory in sm_1x), so there is no replication as you suggest.
cf 计划指南:
__ global__函数参数传递给设备:
__global__ function parameters are passed to the device:
当然,如果您随后在代码中修改一个变量,您正在修改本地副本(根据C标准),因此每个线程都将有自己的副本,无论是在寄存器中,或者如果需要,在堆栈上。
Of course, if you subsequently modify one of variable in your code then you're modifying a local copy (as per the C standard) and hence each thread will have its own copy, either in registers or, if needed, on the stack.