Understanding the character parameter cudaMemcpyFromSymbol ()

Below I have included a standalone example that uses cudaMemcpyFromSymbol() to extract the result from the kernel. The example passes the character parameter (the second parameter in the call) as a regular variable. However, since I understand the CUDA documentation, passing the parameter as a string, i.e.:

 cudaMemcpyFromSymbol(&out, "out_d", sizeof(out_d), 0, cudaMemcpyDeviceToHost); 

(with quotes around the character name) should also work. This does not work for me.

When will the symbol name work and when will the symbol name be displayed as a string?

 #include "cuda_runtime.h" #include <stdio.h> __device__ int out_d; __global__ void test() { out_d = 123; } int main() { test<<<1,1>>>(); int out; cudaMemcpyFromSymbol(&out, out_d, sizeof(out_d), 0, cudaMemcpyDeviceToHost); printf("%d\n", out); return 0; } 
+4
source share
1 answer

Passing a character name as a string parameter was deprecated in CUDA 4.2, and syntax was excluded in cuda 5.0. The reasons were related to the inclusion of a separate device code builder feature, which appeared in CUDA 5. For cuda 5 tools, this change is documented in the release notes . "The use of a character string to indicate a device symbol, which is possible with some API functions, is no longer supported, but instead, the symbol should be used directly."

+8
source

All Articles