Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
void magma_zinvert(dcomplex **mat, np_int n, int &jer) { void magma_zinvert(dcomplex **mat, np_int n, int &jer) {
// magma_int_t result = magma_init(); // magma_int_t result = magma_init();
magma_int_t result = MAGMA_SUCCESS; magma_int_t err = MAGMA_SUCCESS;
magma_queue_t queue = NULL; magma_queue_t queue = NULL;
magma_int_t dev = 0; magma_int_t dev = 0;
magma_queue_create(dev, &queue); magma_queue_create(dev, &queue);
...@@ -24,28 +24,23 @@ void magma_zinvert(dcomplex **mat, np_int n, int &jer) { ...@@ -24,28 +24,23 @@ void magma_zinvert(dcomplex **mat, np_int n, int &jer) {
magma_int_t *piv , info; // piv - array of indices of inter - magma_int_t *piv , info; // piv - array of indices of inter -
magma_int_t m = (magma_int_t)n; // changed rows; a - mxm matrix magma_int_t m = (magma_int_t)n; // changed rows; a - mxm matrix
magma_int_t mm = m * m; // size of a, r, c magma_int_t mm = m * m; // size of a, r, c
magmaDoubleComplex *a = (magmaDoubleComplex *)&(mat[0][0]); // a- mxm matrix on the host magmaDoubleComplex *a = (magmaDoubleComplex *)&(mat[0][0]); // a - mxm matrix on the host
magmaDoubleComplex *d_a; // d_a - mxm matrix a on the device 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 ldwork = m * magma_get_zgetri_nb(m); // optimal block size
// allocate matrices // allocate matrices
err = magma_zmalloc(&d_a, mm); // device memory for a err = magma_zmalloc(&d_a, mm); // device memory for a
err = magma_zmalloc(&dwork, ldwork); // dev. mem. for ldwork 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 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_zgetrf_gpu(m, m, d_a, m, piv, &info);
magma_zgetri_gpu(m, d_a, m, piv, dwork, ldwork, &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 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_free(d_a); // free device memory
magma_queue_destroy(queue); // destroy queue magma_queue_destroy(queue); // destroy queue
// result = magma_finalize(); // result = magma_finalize();
jer = (int)result; jer = (int)err;
} }
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment