I only want to test the device memory visit mode , but failed.
It seems that I have not understood the basic memory access rule.
Anyone can explain it to me. Thank you in advance.
[codebox]#include <stdio.h>
int Ah;
int Bh;
device int Ad;
device int Bd;
global void test_kernel(void);
int main(void)
{
Ah=100;
cudaMemcpy(&Ad,&Ah,sizeof(int),cudaMemcpyHostToDevice);
printf(“HOST A=%d\n”,Ah);
test_kernel<<<1,1>>>();
cudaMemcpy(&Bh,&Bd,sizeof(int),cudaMemcpyDeviceToHost);
printf(“HOST B=%d\n”,Bh);
return 0;
}
global void test_kernel(void)
{
Bd=Ad;
return;
}[/codebox]