简体   繁体   中英

magma_dpotrf_gpu gives segmentation fault

I have a cblas and lapack code that I'm trying to "convert" to magma code to take advantage of the GPU. This is my CPU code that works fine:

cblas_dsyrk(CblasColMajor,CblasUpper,CblasTrans,n,m,1.0,A2,m, 0.0,C_theta,n);
cblas_dsyrk(CblasColMajor,CblasUpper,CblasTrans,n,m,1.0,A1,m,-1.0,C_theta,n);
clapack_dpotrf(CblasColMajor,CblasUpper,n,C_theta,n);

Now, for the magma GPU version, I did this:

magma_dmalloc(&d_A1, m*n);
magma_dmalloc(&d_A2, m*n);
magma_dmalloc(&d_C_theta, n*n);

magma_dsetmatrix(m ,n, A1, m, d_A1, m, queue);
magma_dsetmatrix(m ,n, A2, m, d_A2, m, queue);
magma_dsetmatrix(n ,n, C_theta, n, d_C_theta, n, queue);

magma_dsyrk(MagmaUpper, MagmaTrans, n, m, 1.0, d_A2, m, 0.0, d_C_theta, n, queue);
magma_dsyrk(MagmaUpper, MagmaTrans, n, m, 1.0, d_A1, m, -1.0, d_C_theta, n, queue);
magma_int_t *info_potrf; 
magma_dpotrf_gpu(MagmaUpper, n, d_C_theta, n, info_potrf);

And for some reason, the last line is giving segmentation fault. What am I doing wrong here? It all seems correct.

The solution was answered by @RobertCrovella.

The asterisk needs to be removed in order to allocate memory for info_potrf variable, and on the second line, & needs to be added to use the variable address. This is the correct way:

magma_int_t info_potrf; 
magma_dpotrf_gpu(MagmaUpper, n, d_C_theta, n, &info_potrf);

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