About cudaHostGetDevicePointer problem

My Board is GTX 285.

CUDA version is 2.2Beta

I think it support Zero copy access.

But to run the code below and called cudaHostGetDevicePointer function retruned error code “5” which is not list in reference document(only 0, 1, 2 are listed).

Is there anybody know why?

unsigned short *ptrS_h, *ptrS_d;

char *ptrD1_h, *ptrD1_d,*ptrD2_h, *ptrD2_d;

const int SizeX=8192;

const int SizeY=5000;

int cudaError;

cudaSetDevice(0);

cudaSetDeviceFlags( cudaDeviceMapHost );

cudaError=cudaHostAlloc( (void**) &(ptrS_h), sizeof(unsigned short) * SizeX*SizeY, cudaHostAllocMapped | cudaHostAllocPortable );

cudaError=cudaHostAlloc( (void**) &(ptrD1_h), sizeof(char) * SizeX*SizeY, cudaHostAllocMapped | cudaHostAllocPortable );

cudaError=cudaHostAlloc( (void**) &(ptrD2_h), sizeof(char) * SizeX*SizeY, cudaHostAllocMapped | cudaHostAllocPortable );

if (cudaError) printf ("Failed to allocate pinned memory \n");

cudaError=cudaHostGetDevicePointer( (void**) &(ptrS_d), ptrS_h, 0 );

cudaError=cudaHostGetDevicePointer( (void**) &(ptrD1_d), ptrD1_h, 0 );

cudaError=cudaHostGetDevicePointer( (void**) &(ptrD2_d), ptrD2_h, 0 );

if (cudaError) printf ("Failed to get device pointer,Error Code = %d\n",cudaError);

printf ("Sucess \n");

getch();

return 0;

I found that after I put cudaSetDeviceFlags( cudaDeviceMapHost ) before cudaSetDevice(0);

then it worked, why?