Commit fd465c15 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Save the result of magma_zinvert in the err variable

parent 1952ceed
Loading
Loading
Loading
Loading
+5 −10
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@

void magma_zinvert(dcomplex **mat, np_int n, int &jer) {
  // magma_int_t result = magma_init();
  magma_int_t result = MAGMA_SUCCESS;
  magma_int_t err = MAGMA_SUCCESS;
  magma_queue_t queue = NULL;
  magma_int_t dev = 0;
  magma_queue_create(dev, &queue);
@@ -26,26 +26,21 @@ void magma_zinvert(dcomplex **mat, np_int n, int &jer) {
  magma_int_t mm = m * m; // size of a, r, c
  magmaDoubleComplex *a = (magmaDoubleComplex *)&(mat[0][0]); // a - mxm matrix on the host
  magmaDoubleComplex *d_a; // d_a - mxm matrix a on the device
  magma_int_t err;
  ldwork = m * magma_get_zgetri_nb(m); // optimal block size
  // allocate matrices
  err = magma_zmalloc(&d_a, mm); // device memory for a
  err = magma_zmalloc(&dwork, ldwork); // dev. mem. for ldwork
  piv = (magma_int_t *)malloc(m*sizeof(magma_int_t )); // host mem.
  piv = new magma_int_t[m]; // host mem.
  magma_zsetmatrix(m, m, a, m, d_a , m, queue); // copy a -> d_a
  // find the inverse matrix: d_a*X=I using the LU factorization
  // with partial pivoting and row interchanges computed by
  // magma_zgetrf_gpu; row i is interchanged with row piv(i);
  // d_a - mxm matrix; d_a is overwritten by the inverse
  
  magma_zgetrf_gpu(m, m, d_a, m, piv, &info);
  magma_zgetri_gpu(m, d_a, m, piv, dwork, ldwork, &info);
  
  magma_zgetmatrix( m, m, d_a , m, a, m, queue); // copy d_a -> a
  free(piv); // free host memory
  delete[] piv; // free host memory
  magma_free(d_a); // free device memory
  magma_queue_destroy(queue); // destroy queue
  // result = magma_finalize();
  jer = (int)result;
  jer = (int)err;
}
#endif