Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cudaMemcpy() vs cudaMemcpyFromSymbol()

Tags:

cuda

I'm trying to figure out why cudaMemcpyFromSymbol() exists. It seems everything that 'symbol' func can do, the nonSymbol cmds can do.

The symbol func appears to make it easy for part of an array or index to be moved, but this could just as easily be done with the nonSymbol function. I suspect the nonSymbol approach will run faster as there is no symbol-lookup needed. (It is not clear if the symbol look up calculation is done at compile or run time.)

Why would I use cudaMemcpyFromSymbol() vs cudaMemcpy()?

like image 569
Doug Avatar asked Feb 11 '13 17:02

Doug


1 Answers

cudaMemcpyFromSymbol is the canonical way to copy from any statically defined variable in device memory.

cudaMemcpy can't be directly use to copy to or from a statically defined device variable because it requires a device pointer, and that isn't known to host code at runtime. Therefore, an API call which can interrogate the device context symbol table is required. The two choices are either, cudaMemcpyFromSymbol which does the symbol lookup and copy in one operation, or cudaGetSymbolAddress which returns an address which can be passed to cudaMemcpy. The former is probably more efficient if you only want to do one copy, the latter if you want to use the address multiple times in host code.

like image 52
talonmies Avatar answered Nov 19 '22 15:11

talonmies