简体   繁体   中英

double free or corruption (out) on ipiv magma_getrs_gpu

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?

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM