Problem with cublasIsamax

Hallo Guys,

I have a 1D array in my GPU Global Memory. If I use the cublasIsamax function I get the index of maximum.

But the function works only if I save the index of the maximum in the PC(CPU) memory. If I will save the index in the GPU memory it does not work.

Here is my code:

int *D_Index;
float *D_Test;

checkCudaErrors( cudaMalloc((void **)&D_Index, sizeof(int)) );
checkCudaErrors( cudaMalloc((void **)&D_Test, 2048 * sizeof(float)) );

checkCudaErrors( cublasIsamax(Cublas_Handle, 2048, D_Test, 1, D_Index) );

I must set the pointer mode to DEVICE

cublasSetPointerMode(Cublas_Handle, CUBLAS_POINTER_MODE_DEVICE);

The cublasPointerMode_t type indicates whether the scalar values are passed by
reference on the host or device. It is important to point out that if several scalar values
are present in the function call, all of them must conform to the same single pointer
mode. The pointer mode can be set and retrieved using cublasSetPointerMode()
and cublasGetPointerMode() routines, respectively.