double free or corruption (out) on ipiv magma_getrs_gpu

61 Views Asked by At

I have the following code:

magma_int_t *h_ipiv;
magma_imalloc_cpu( &h_ipiv,  k);

for (i=0;i<k;i++){
    h_ipiv[i] = i;
}
magma_dgemm(MagmaTrans, MagmaNoTrans, N, n, m, 1.0, d_G2, m, d_A2, m, 0.0, d_QA, N, queue);

magma_dgemm(MagmaTrans, MagmaNoTrans, N, n, m, 1.0, d_G1, m, d_A1, m, -1.0, d_QA, N, queue);

magma_int_t info_getrs;
magma_dgetrs_gpu(MagmaTrans, Ngaps, n, d_M, N, h_ipiv, d_QA, N, &info_getrs);

On the last line I am getting an error double free or corruption (out): 0x000000001dd18540. I checked the arrays from magma_dgemm and they seem to be correct. Sizes are also correct because I had this code on cpu lapack version and they were the same. So the error seems to be on h_ipiv, but I have no clue on what is wrong with h_ipiv.

Any idea?

1

There are 1 best solutions below

0
eldev09 On

I finally found the solution. Unlike lapack, in magma, to create ipiv for dgetrs_gpu we have to use before dgetrf_gpu.

So the solution is just adding the following lines before the function dgetrs_gpu:

magma_int_t info_getrf;
magma_dgetrf_gpu(Ngaps, Ngaps, d_M, Ngaps, h_ipiv, &info_getrf);