diff --git a/src/libnptm/magma_calls.cpp b/src/libnptm/magma_calls.cpp index da32c805971be85c532239164327ae42fe5daaba..347b6cba26d605f0f8e95f47f960ef224de339a1 100644 --- a/src/libnptm/magma_calls.cpp +++ b/src/libnptm/magma_calls.cpp @@ -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); @@ -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 m = (magma_int_t)n; // changed rows; a - mxm matrix 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 - 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