Commit 4adf04ea authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Convert maxindex to 0-based index in cublas_calls.cpp

parent 438029ae
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ void cublas_zinvert(dcomplex **mat, np_int n, int device_id, const RuntimeSettin
      cublascall(CUIZAMAX(handle, mm, d_a_residual, 1, &maxindex));
      cuDoubleComplex cublasmax;
      // transfer the maximum value to the host
      cudacall(cudaMemcpy(&cublasmax, d_a_residual+maxindex, sizeof(cuDoubleComplex), cudaMemcpyDeviceToHost));
      cudacall(cudaMemcpy(&cublasmax, d_a_residual+maxindex-1, sizeof(cuDoubleComplex), cudaMemcpyDeviceToHost));
      // take the module
      oldmax = cabs( (((double *) &(cublasmax))[0]) + I*(((double *) &(cublasmax))[1]));
      //printf("Initial max residue = %g\n", oldmax);
@@ -170,7 +170,7 @@ void cublas_zinvert(dcomplex **mat, np_int n, int device_id, const RuntimeSettin
	  cublascall(CUIZAMAX(handle, mm, d_a_residual, 1, &maxindex));
	  // transfer the maximum value to the host
	  cuDoubleComplex cublasmax;
	  cudacall(cudaMemcpy(&cublasmax, d_a_residual+maxindex, sizeof(cuDoubleComplex), cudaMemcpyDeviceToHost));
	  cudacall(cudaMemcpy(&cublasmax, d_a_residual+maxindex-1, sizeof(cuDoubleComplex), cudaMemcpyDeviceToHost));
	  // take the module
	  double newmax = cabs( (((double *) &(cublasmax))[0]) + I*(((double *) &(cublasmax))[1]));
	  sprintf(buffer, "DEBUG: Maximum residue after %d iterations = %.5le\n", iter+1, newmax);