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(
)?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With