The function cudaMemcpyFromSymbol
is templated and takes a __device__
variable. We can't give the address of the source, so I don't see how we can pass __device__
variables dynamically (as argument). Maybe with references?
__device__ float d_f;
void test1()
{
float h_f;
cudaMemcpyFromSymbol(&h_f, d_f, sizeof(float)); // Ok
}
void test2(float d_arg_f)
{
float h_f;
cudaMemcpyFromSymbol(&h_f, d_arg_f, sizeof(float)); // Not ok
}
void test3(float& d_arg_f)
{
float h_f;
cudaMemcpyFromSymbol(&h_f, d_arg_f, sizeof(float)); // Is it ok?
}
int main()
{
test1();
test2(d_f);
test3(d_f);
}
EDIT: removed the first question which did actually not compile.