It seems that the NVCC compiler can not check if external device variables really exsits.
For example, the following single file only denots an external device variable named ADEV, but no definition file is supplied. But when I comile the single file test.cu.
The compiler can generate executable file named a.exe.
Example source: test.cu
[codebox]
#include <stdio.h>
extern device constant int ADEV;
global void test(void)
{
int B;
B=ADEV;
}
int main(void)
{
int A;
int ierr;
A=1234;
ierr=cudaMemcpyToSymbol("ADEV",&A,sizeof(int));
printf("cudaMemcpyToSymbol return ierr=%d \n",ierr);
test<<<1,1>>>();
return 0;
}
[/codebox]
In contrast, if it is on host side, this un-defined variables can be pointed out and can not generate the exe file.
[codebox]
#include <stdio.h>
extern int A;
int main(void)
{
A=1234;
return 0;
}
[/codebox]
Anyone can tell me why and how can I let the nvcc compiler tell me if one external variable has been defined.
Thank you in advance.