Skip to content

Commit

Permalink
Partial addition of 'const' to all interfaces above the (micro)kernel…
Browse files Browse the repository at this point in the history
…s. (#625)

Details:
- Added 'const' qualifier to applicable function arguments wherever the
  the pointed-to object is not internally modified. This change affects 
  all interfaces that reside above the level of the (micro)kernels.
- Typecast certain function return values to discard 'const' qualifier.
- Removed 'restrict' from various arguments, including cntx_t*,
  auxinfo_t*, rntm_t*, thrinfo_t*, mem_t*, and others
- Removed parts of some APIs, such as bli_cntx_*(), due to limited use.
- Merged some variable declarations with their corresponding 
  initialization statements.
- Whitespace changes.
  • Loading branch information
devinamatthews authored Apr 13, 2022
1 parent ae10d94 commit 9fea633
Show file tree
Hide file tree
Showing 446 changed files with 19,651 additions and 19,345 deletions.
4 changes: 2 additions & 2 deletions build/detect/config/config_detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@

int main( int argc, char** argv )
{
arch_t id = bli_cpuid_query_id();
char* s = bli_arch_string( id );
arch_t id = bli_cpuid_query_id();
const char* s = bli_arch_string( id );

printf( "%s\n", s );

Expand Down
2 changes: 1 addition & 1 deletion config/template/kernels/1/bli_axpyv_template_noopt_var1.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void bli_zaxpyv_template_noopt
dcomplex* restrict alpha,
dcomplex* restrict x, inc_t incx,
dcomplex* restrict y, inc_t incy,
cntx_t* restrict cntx
cntx_t* cntx
)
{
/*
Expand Down
4 changes: 2 additions & 2 deletions config/template/kernels/1/bli_dotv_template_noopt_var1.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void bli_zdotv_template_noopt
dcomplex* restrict x, inc_t incx,
dcomplex* restrict y, inc_t incy,
dcomplex* restrict rho,
cntx_t* restrict cntx
cntx_t* cntx
)
{
/*
Expand Down Expand Up @@ -187,7 +187,7 @@ void bli_zdotv_template_noopt
// Initialize accumulator to zero.
bli_zset0s( dotxy );


conjx_use = conjx;

// If y must be conjugated, we compute the result indirectly by first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void bli_zaxpy2v_template_noopt
dcomplex* restrict x, inc_t incx,
dcomplex* restrict y, inc_t incy,
dcomplex* restrict z, inc_t incz,
cntx_t* restrict cntx
cntx_t* cntx
)
{
/*
Expand Down
2 changes: 1 addition & 1 deletion config/template/kernels/1f/bli_axpyf_template_noopt_var1.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void bli_zaxpyf_template_noopt
dcomplex* restrict a, inc_t inca, inc_t lda,
dcomplex* restrict x, inc_t incx,
dcomplex* restrict y, inc_t incy,
cntx_t* restrict cntx
cntx_t* cntx
)
{
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void bli_zdotaxpyv_template_noopt
dcomplex* restrict y, inc_t incy,
dcomplex* restrict rho,
dcomplex* restrict z, inc_t incz,
cntx_t* restrict cntx
cntx_t* cntx
)
{
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void bli_zdotxaxpyf_template_noopt
dcomplex* restrict beta,
dcomplex* restrict y, inc_t incy,
dcomplex* restrict z, inc_t incz,
cntx_t* restrict cntx
cntx_t* cntx
)

{
Expand Down
4 changes: 2 additions & 2 deletions config/template/kernels/1f/bli_dotxf_template_noopt_var1.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void bli_zdotxf_template_noopt
dcomplex* restrict x, inc_t incx,
dcomplex* restrict beta,
dcomplex* restrict y, inc_t incy,
cntx_t* restrict cntx
cntx_t* cntx
)
{
/*
Expand Down Expand Up @@ -239,7 +239,7 @@ void bli_zdotxf_template_noopt
if ( bli_is_conj( conjx ) )
bli_toggle_conj( &conjat_use );


// Iterate over columns of A and rows of x to compute:
// Atx = conjat_use( A^T ) * x;
if ( bli_is_noconj( conjat_use ) )
Expand Down
4 changes: 2 additions & 2 deletions config/template/kernels/3/bli_gemm_template_noopt_mxn.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void bli_zgemm_template_noopt
dcomplex* restrict b1,
dcomplex* restrict beta,
dcomplex* restrict c11, inc_t rs_c, inc_t cs_c,
auxinfo_t* restrict data,
cntx_t* restrict cntx
auxinfo_t* data,
cntx_t* cntx
)
{
/*
Expand Down
4 changes: 2 additions & 2 deletions config/template/kernels/3/bli_gemmtrsm_l_template_noopt_mxn.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ void bli_zgemmtrsm_l_template_noopt
dcomplex* restrict b01,
dcomplex* restrict b11,
dcomplex* restrict c11, inc_t rs_c, inc_t cs_c,
auxinfo_t* restrict data,
cntx_t* restrict cntx
auxinfo_t* data,
cntx_t* cntx
)
{
/*
Expand Down
4 changes: 2 additions & 2 deletions config/template/kernels/3/bli_gemmtrsm_u_template_noopt_mxn.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ void bli_zgemmtrsm_u_template_noopt
dcomplex* restrict b01,
dcomplex* restrict b11,
dcomplex* restrict c11, inc_t rs_c, inc_t cs_c,
auxinfo_t* restrict data,
cntx_t* restrict cntx
auxinfo_t* data,
cntx_t* cntx
)
{
/*
Expand Down
4 changes: 2 additions & 2 deletions config/template/kernels/3/bli_trsm_l_template_noopt_mxn.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ void bli_ztrsm_l_template_noopt
dcomplex* restrict a11,
dcomplex* restrict b11,
dcomplex* restrict c11, inc_t rs_c, inc_t cs_c,
auxinfo_t* restrict data,
cntx_t* restrict cntx
auxinfo_t* data,
cntx_t* cntx
)
{
/*
Expand Down
4 changes: 2 additions & 2 deletions config/template/kernels/3/bli_trsm_u_template_noopt_mxn.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ void bli_ztrsm_u_template_noopt
dcomplex* restrict a11,
dcomplex* restrict b11,
dcomplex* restrict c11, inc_t rs_c, inc_t cs_c,
auxinfo_t* restrict data,
cntx_t* restrict cntx
auxinfo_t* data,
cntx_t* cntx
)
{
/*
Expand Down
50 changes: 25 additions & 25 deletions frame/0/bli_l0_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
\
void PASTEMAC(opname,_check) \
( \
obj_t* chi, \
obj_t* psi \
const obj_t* chi, \
const obj_t* psi \
) \
{ \
bli_l0_xxsc_check( chi, psi ); \
Expand All @@ -63,7 +63,7 @@ GENFRONT( subsc )
\
void PASTEMAC(opname,_check) \
( \
obj_t* chi \
const obj_t* chi \
) \
{ \
bli_l0_xsc_check( chi ); \
Expand All @@ -77,8 +77,8 @@ GENFRONT( invertsc )
\
void PASTEMAC(opname,_check) \
( \
obj_t* chi, \
obj_t* norm \
const obj_t* chi, \
const obj_t* norm \
) \
{ \
bli_l0_xx2sc_check( chi, norm ); \
Expand All @@ -91,9 +91,9 @@ GENFRONT( normfsc )

void bli_getsc_check
(
obj_t* chi,
double* zeta_r,
double* zeta_i
const obj_t* chi,
const double* zeta_r,
const double* zeta_i
)
{
err_t e_val;
Expand All @@ -117,9 +117,9 @@ void bli_getsc_check

void bli_setsc_check
(
double zeta_r,
double zeta_i,
obj_t* chi
double zeta_r,
double zeta_i,
const obj_t* chi
)
{
err_t e_val;
Expand All @@ -143,9 +143,9 @@ void bli_setsc_check

void bli_unzipsc_check
(
obj_t* chi,
obj_t* zeta_r,
obj_t* zeta_i
const obj_t* chi,
const obj_t* zeta_r,
const obj_t* zeta_i
)
{
err_t e_val;
Expand Down Expand Up @@ -199,9 +199,9 @@ void bli_unzipsc_check

void bli_zipsc_check
(
obj_t* zeta_r,
obj_t* zeta_i,
obj_t* chi
const obj_t* zeta_r,
const obj_t* zeta_i,
const obj_t* chi
)
{
err_t e_val;
Expand Down Expand Up @@ -254,7 +254,7 @@ void bli_zipsc_check

void bli_l0_xsc_check
(
obj_t* chi
const obj_t* chi
)
{
err_t e_val;
Expand All @@ -280,8 +280,8 @@ void bli_l0_xsc_check

void bli_l0_xxsc_check
(
obj_t* chi,
obj_t* psi
const obj_t* chi,
const obj_t* psi
)
{
err_t e_val;
Expand Down Expand Up @@ -316,8 +316,8 @@ void bli_l0_xxsc_check

void bli_l0_xx2sc_check
(
obj_t* chi,
obj_t* absq
const obj_t* chi,
const obj_t* absq
)
{
err_t e_val;
Expand Down Expand Up @@ -355,9 +355,9 @@ void bli_l0_xx2sc_check

void bli_l0_xxbsc_check
(
obj_t* chi,
obj_t* psi,
bool* is_eq
const obj_t* chi,
const obj_t* psi,
const bool* is_eq
)
{
err_t e_val;
Expand Down
50 changes: 25 additions & 25 deletions frame/0/bli_l0_check.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
\
void PASTEMAC(opname,_check) \
( \
obj_t* chi, \
obj_t* psi \
const obj_t* chi, \
const obj_t* psi \
);

GENTPROT( addsc )
Expand All @@ -59,7 +59,7 @@ GENTPROT( subsc )
\
void PASTEMAC(opname,_check) \
( \
obj_t* chi \
const obj_t* chi \
);

GENTPROT( invertsc )
Expand All @@ -70,8 +70,8 @@ GENTPROT( invertsc )
\
void PASTEMAC(opname,_check) \
( \
obj_t* chi, \
obj_t* absq \
const obj_t* chi, \
const obj_t* absq \
);

GENTPROT( absqsc )
Expand All @@ -83,9 +83,9 @@ GENTPROT( normfsc )
\
void PASTEMAC(opname,_check) \
( \
obj_t* chi, \
double* zeta_r, \
double* zeta_i \
const obj_t* chi, \
const double* zeta_r, \
const double* zeta_i \
);

GENTPROT( getsc )
Expand All @@ -96,9 +96,9 @@ GENTPROT( getsc )
\
void PASTEMAC(opname,_check) \
( \
double zeta_r, \
double zeta_i, \
obj_t* chi \
double zeta_r, \
double zeta_i, \
const obj_t* chi \
);

GENTPROT( setsc )
Expand All @@ -109,9 +109,9 @@ GENTPROT( setsc )
\
void PASTEMAC(opname,_check) \
( \
obj_t* chi, \
obj_t* zeta_r, \
obj_t* zeta_i \
const obj_t* chi, \
const obj_t* zeta_r, \
const obj_t* zeta_i \
);

GENTPROT( unzipsc )
Expand All @@ -122,9 +122,9 @@ GENTPROT( unzipsc )
\
void PASTEMAC(opname,_check) \
( \
obj_t* zeta_r, \
obj_t* zeta_i, \
obj_t* chi \
const obj_t* zeta_r, \
const obj_t* zeta_i, \
const obj_t* chi \
);

GENTPROT( zipsc )
Expand All @@ -133,24 +133,24 @@ GENTPROT( zipsc )

void bli_l0_xsc_check
(
obj_t* chi
const obj_t* chi
);

void bli_l0_xxsc_check
(
obj_t* chi,
obj_t* psi
const obj_t* chi,
const obj_t* psi
);

void bli_l0_xx2sc_check
(
obj_t* chi,
obj_t* norm
const obj_t* chi,
const obj_t* norm
);

void bli_l0_xxbsc_check
(
obj_t* chi,
obj_t* psi,
bool* is_eq
const obj_t* chi,
const obj_t* psi,
const bool* is_eq
);
Loading

5 comments on commit 9fea633

@arstgr
Copy link

@arstgr arstgr commented on 9fea633 Apr 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit causes this error on zen3

kernels/zen/3/bli_gemm_small.c:104:7: error: conflicting types for ‘bli_gemm_small’
104 | err_t bli_gemm_small
| ^~~~~~~~~~~~~~
compilation terminated due to -Wfatal-errors.
make: *** [Makefile:653: obj/zen3/kernels/zen/3/bli_gemm_small.o] Error 1
Compiling obj/zen3/kernels/zen/3/bli_gemm_small.o ('zen3' CFLAGS for kernels)
kernels/zen/3/bli_gemm_small.c:104:7: error: conflicting types for ‘bli_gemm_small’
104 | err_t bli_gemm_small
| ^~~~~~~~~~~~~~
compilation terminated due to -Wfatal-errors.

@devinamatthews
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fgvanzee ? I thought the "gemm small" codepath was disabled by default? In any case the fix should be simple: making sure the interfaces are consistent w.r.t. const correctness.

@fgvanzee
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fgvanzee ? I thought the "gemm small" codepath was disabled by default? In any case the fix should be simple: making sure the interfaces are consistent w.r.t. const correctness.

bli_gemm_small() is not my codepath (sup). It's AMD's.

@fgvanzee
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But yes, I thought it was disabled by default, too, at least in vanilla.

@fgvanzee
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've applied a fix in 6431c9e, although we still need to decide whether the gemm_small code path should be enabled by default in vanilla BLIS. 🤔

Please sign in to comment.