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
ipivfordgetrs_gpuwe have to use beforedgetrf_gpu.So the solution is just adding the following lines before the function dgetrs_gpu: