I am using a global variable say d_myVar, which will be allocated device memory using cudaMalloc in main function. I am not clear, should I use __ device __ in front of it while doing global declaration? I ask this, since if it were local variable in host and was passed to a kernel, we would not write __ device __ in front of it. Let me know if I am wrong.
Share
Globally-scoped
__device__variables are not allocated withcudaMalloc. Simply annotate a variable in the global scope with__device__:The result: