mirror of
https://github.com/amd/blis.git
synced 2026-06-06 04:34:02 +00:00
Fixed an obscure bug in the 1m implementation.
Details: - Fixed a bug in the way the bli_gemm1m_cntx_ref() function (defined in ref_kernels/bli_cntx_ref.c) initializes its context for 1m execution. Previously, the function probed the context that was in the process of being updated for use with 1m--this context being previously initialized/copied from a native context--for its storage preference to determine which "variant" (row- or column-oriented) of 1m would be needed. However, the _cntx_ref() function was not updating the method field of the context until AFTER this query, and the conditional which depended on it, had taken place, meaning the storage preference query function would mistakenly think the context was for native execution, since the context's method field would still be set to BLIS_NAT. This would lead it to incorrectly grab the storage preference of the complex domain microkernel rather than the corresponding real domain microkernel, which could cause the storage preference predicate to evaluate to the wrong value, which would lead to the _cntx_ref() function choosing the wrong variant. This could lead to undefined behavior at runtime. The method is now explicitly set within the context prior to calling the storage preference query function. - Updated comments in frame/ind/oapi/bli_l3_3m4m1m_oapi.c. - Fixed a typo in the commented-out CFLAGS in config/zen/make_defs.mk, which are appropriate for gcc 6.x and newer. (Mistakenly used -march=bdver4 instead of -march=znver1.)
This commit is contained in:
@@ -69,7 +69,7 @@ CKOPTFLAGS := $(COPTFLAGS)
|
||||
|
||||
ifeq ($(CC_VENDOR),gcc)
|
||||
# gcc 6.3 or later:
|
||||
#CVECFLAGS := -mavx2 -mfpmath=sse -mfma -march=bdver4
|
||||
#CVECFLAGS := -mavx2 -mfpmath=sse -mfma -march=znver1
|
||||
# gcc 5.4:
|
||||
# possibly add zen-specific instructions: -mclzero -madx -mrdseed -mmwaitx -msha -mxsavec -mxsaves -mclflushopt -mpopcnt
|
||||
CVECFLAGS := -mavx2 -mfpmath=sse -mfma -march=bdver4 -mno-fma4 -mno-tbm -mno-xop -mno-lwp
|
||||
|
||||
@@ -82,9 +82,9 @@ void PASTEMAC(opname,imeth) \
|
||||
\
|
||||
/* Query a context for the current induced method. This context is
|
||||
managed and cached by the gks and should not be freed by the caller.
|
||||
Note that we pass in the datatype because it will be needed when
|
||||
bli_gks_query_ind_cntx() eventually calls the bli_ind_cntx_init()
|
||||
family of functions. */ \
|
||||
Note that the datatype argument is needed because it will be passed
|
||||
in when bli_gks_query_ind_cntx() eventually calls the induced method's
|
||||
_cntx_init() function. */ \
|
||||
cntx = bli_gks_query_ind_cntx( ind, dt ); \
|
||||
\
|
||||
/* Some induced methods execute in multiple "stages". */ \
|
||||
@@ -162,9 +162,9 @@ void PASTEMAC(opname,imeth) \
|
||||
\
|
||||
/* Query a context for the current induced method. This context is
|
||||
managed and cached by the gks and should not be freed by the caller.
|
||||
Note that we pass in the datatype because it will be needed when
|
||||
bli_gks_query_ind_cntx() eventually calls the bli_ind_cntx_init()
|
||||
family of functions. */ \
|
||||
Note that the datatype argument is needed because it will be passed
|
||||
in when bli_gks_query_ind_cntx() eventually calls the induced method's
|
||||
_cntx_init() function. */ \
|
||||
cntx = bli_gks_query_ind_cntx( ind, dt ); \
|
||||
\
|
||||
/* Some induced methods execute in multiple "stages". */ \
|
||||
@@ -240,9 +240,9 @@ void PASTEMAC(opname,imeth) \
|
||||
\
|
||||
/* Query a context for the current induced method. This context is
|
||||
managed and cached by the gks and should not be freed by the caller.
|
||||
Note that we pass in the datatype because it will be needed when
|
||||
bli_gks_query_ind_cntx() eventually calls the bli_ind_cntx_init()
|
||||
family of functions. */ \
|
||||
Note that the datatype argument is needed because it will be passed
|
||||
in when bli_gks_query_ind_cntx() eventually calls the induced method's
|
||||
_cntx_init() function. */ \
|
||||
cntx = bli_gks_query_ind_cntx( ind, dt ); \
|
||||
\
|
||||
/* Some induced methods execute in multiple "stages". */ \
|
||||
@@ -309,9 +309,9 @@ void PASTEMAC(opname,imeth) \
|
||||
\
|
||||
/* Query a context for the current induced method. This context is
|
||||
managed and cached by the gks and should not be freed by the caller.
|
||||
Note that we pass in the datatype because it will be needed when
|
||||
bli_gks_query_ind_cntx() eventually calls the bli_ind_cntx_init()
|
||||
family of functions. */ \
|
||||
Note that the datatype argument is needed because it will be passed
|
||||
in when bli_gks_query_ind_cntx() eventually calls the induced method's
|
||||
_cntx_init() function. */ \
|
||||
cntx = bli_gks_query_ind_cntx( ind, dt ); \
|
||||
\
|
||||
/* Some induced methods execute in multiple "stages". */ \
|
||||
@@ -364,9 +364,9 @@ void PASTEMAC(opname,imeth) \
|
||||
\
|
||||
/* Query a context for the current induced method. This context is
|
||||
managed and cached by the gks and should not be freed by the caller.
|
||||
Note that we pass in the datatype because it will be needed when
|
||||
bli_gks_query_ind_cntx() eventually calls the bli_ind_cntx_init()
|
||||
family of functions. */ \
|
||||
Note that the datatype argument is needed because it will be passed
|
||||
in when bli_gks_query_ind_cntx() eventually calls the induced method's
|
||||
_cntx_init() function. */ \
|
||||
cntx = bli_gks_query_ind_cntx( ind, dt ); \
|
||||
\
|
||||
{ \
|
||||
|
||||
@@ -712,6 +712,18 @@ void GENBAINAME(cntx_init)
|
||||
{
|
||||
const bool_t is_pb = FALSE;
|
||||
|
||||
// We MUST set the induced method in the context prior to calling
|
||||
// bli_cntx_l3_ukr_prefers_cols_dt() because that function queries
|
||||
// the induced method. It needs the induced method value in order
|
||||
// to determine whether to evaluate the "prefers column storage"
|
||||
// predicate using the storage preference of the kernel for dt, or
|
||||
// the storage preference of the kernel for the real projection of
|
||||
// dt. Failing to set the induced method here can lead to strange
|
||||
// undefined behavior at runtime if the native complex kernel's
|
||||
// storage preference happens to not equal that of the native real
|
||||
// kernel.
|
||||
bli_cntx_set_method( method, cntx );
|
||||
|
||||
// Initialize the blocksizes according to the micro-kernel preference as
|
||||
// well as the algorithm.
|
||||
if ( bli_cntx_l3_ukr_prefers_cols_dt( dt, BLIS_GEMM_UKR, cntx ) )
|
||||
|
||||
Reference in New Issue
Block a user