I could not find anything in the CUDA documentation to explain why cudaMemcpyToSymbol fails (with cudaErrorInvalidSymbol) in the following
__constant__ float dev[2];
struct Struct
{
void construct()
{
float host[2] = {1, 2};
cudaError_t error = cudaMemcpyToSymbol(dev, host, sizeof(host));
printf(cudaGetErrorString(error));
}
};
class Class
{
public:
Class()
{
s.construct();
}
private:
Struct s;
};
static Class instance;
int main()
{
}
while it works when construct() is called from a method:
class Class
{
public:
void foo()
{
s.construct();
}
private:
Struct s;
};
static Class instance;
int main()
{
instance.foo();
}