invalid device symbol

global.cu

__device__ __constant__ MyParam cParams;

main.cpp

#include "update.h"

int main()

{

MyParam mp;

Host_UpdateParam(&mp);

}

update.h

void Host_UpdateParam(MyParam* mp);

update.cu

"#include "update.h"

"#include "global.cu"

void Host_UpdateParam(MyParam* mp)

{

CUDA_SAFE_CALL(cudaMemcpyToSymbol (cParams, mp, sizeof(MyParam) ) );

CUDA_SAFE_CALL(cudaThreadSynchronize());

}

I got cuda error in file ‘update.cu’ at line with

CUDA_SAFE_CALL(cudaMemcpyToSymbol (cParams, mp, sizeof(MyParam) ) );

Any suggestion? Thanks!

according to
http://forums.nvidia.com/index.php?showtopic=104029
(constant seems to be only file scope!)

And here’s some experiment
http://forums.nvidia.com/index.php?showtopic=108893
(Summary: Unable to set constant when working with separate .cu and .cpp files. When using single .cu program everything is fine. In emulation everything is fine.)

um… is it impossible?

according to
http://forums.nvidia.com/index.php?showtopic=104029
(constant seems to be only file scope!)

And here’s some experiment
http://forums.nvidia.com/index.php?showtopic=108893
(Summary: Unable to set constant when working with separate .cu and .cpp files. When using single .cu program everything is fine. In emulation everything is fine.)

um… is it impossible?

You r right bout the scope. But surely theres another way to get around this… As for emulation: dont depend on it! It was removed in 3.1 cause code that runs fine in emulation could fail in device mode and the other way round.

You r right bout the scope. But surely theres another way to get around this… As for emulation: dont depend on it! It was removed in 3.1 cause code that runs fine in emulation could fail in device mode and the other way round.