const-correctness in header files

Open discussion for MAGMA

const-correctness in header files

Postby tmp_hallenser » Wed Nov 20, 2013 5:11 am

Dear all,

I have a question regarding the const-correctness in header files. Let's take for example

magma_int_t magma_dgetrs_gpu( char trans, magma_int_t n, magma_int_t nrhs, double *dA, magma_int_t ldda, magma_int_t *ipiv, double *dB, magma_int_t lddb, magma_int_t *info);

If I look in the source code, I would expect a different definition:

magma_int_t magma_dgetrs_gpu( char trans, magma_int_t n, magma_int_t nrhs, const double *dA, magma_int_t ldda, const magma_int_t *ipiv, double *dB, magma_int_t lddb, magma_int_t *info);

since the matrix A and the vector piv are not changed by the function. The same holds for some other functions.
In contrast, the function magma_dprint and magma_dprint_gpu are defined with the const attribute.
CUBLAS also uses it in the declarations.

So, why are the const attributes often missing in MAGMA? It would be helpful the have them.
tmp_hallenser
 
Posts: 2
Joined: Wed Oct 30, 2013 12:51 pm

Re: const-correctness in header files

Postby mgates3 » Thu Nov 21, 2013 3:46 pm

You are correct. It's a historical oversight that will eventually get fixed, but needs to be propagated down to the lowest level (e.g., BLAS) first.
-mark
mgates3
 
Posts: 438
Joined: Fri Jan 06, 2012 2:13 pm


Return to User discussion

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron