mirror of
https://github.com/amd/blis.git
synced 2026-04-23 09:08:51 +00:00
Details: - Fixed a bug that broke the use of 1m for dcomplex when the single- precision real and double-precision real ukernels had opposing I/O preferences (row-preferential sgemm ukernel + column-preferential dgemm ukernel, or vice versa). The fix involved adjusting the API to bli_cntx_set_ind_blkszs() so that the induced method context init function (e.g., bli_cntx_init_<subconfig>_ind()) could call that function for only one datatype at a time. This allowed the blocksize scaling (which varies depending on whether we're doing 1m_r or 1m_c) to happen on a per-datatype basis. This fixes issue #557. Thanks to Devin Matthews and RuQing Xu for helping discover and report this bug. - The aforementioned 1m fix required moving the 1m_r/1m_c logic from bli_cntx_ref.c into a new function, bli_l3_set_schemas(), which is called from each level-3 _front() function. The pack_t schemas in the cntx_t were also removed entirely, along with the associated accessor functions. This in turn required updating the trsm1m-related virtual ukernels to read the pack schema for B from the auxinfo_t struct rather than the context. This also required slight tweaks to bli_gemm_md.c. - Repositioned the logic for transposing the operation to accommodate the microkernel IO preference. This mostly only affects gemm. Thanks to Devin Matthews for his help with this. - Updated dpackm pack ukernels in the 'armsve' kernel set to avoid querying pack_t schemas from the context. - Removed the num_t dt argument from the ind_cntx_init_ft type defined in bli_gks.c. The context initialization functions for induced methods were previously passed a dt argument, but I can no longer figure out *why* they were passed this value. To reduce confusion, I've removed the dt argument (including also from the function defintion + prototype). - Commented out setting of cntx_t schemas in bli_cntx_ind_stage.c. This breaks high-leve implementations of 3m and 4m, but this is okay since those implementations will be removed very soon. - Removed some older blocks of preprocessor-disabled code. - Comment update to test_libblis.c.
250 lines
7.8 KiB
C
250 lines
7.8 KiB
C
/*
|
|
|
|
BLIS
|
|
An object-based framework for developing high-performance BLAS-like
|
|
libraries.
|
|
|
|
Copyright (C) 2014, The University of Texas at Austin
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
modification, are permitted provided that the following conditions are
|
|
met:
|
|
- Redistributions of source code must retain the above copyright
|
|
notice, this list of conditions and the following disclaimer.
|
|
- Redistributions in binary form must reproduce the above copyright
|
|
notice, this list of conditions and the following disclaimer in the
|
|
documentation and/or other materials provided with the distribution.
|
|
- Neither the name(s) of the copyright holder(s) nor the names of its
|
|
contributors may be used to endorse or promote products derived
|
|
from this software without specific prior written permission.
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
#include "blis.h"
|
|
|
|
#undef GENTFUNCCO
|
|
#define GENTFUNCCO( ctype, ctype_r, ch, chr, opname, arch, suf, trsmkerid ) \
|
|
\
|
|
void PASTEMAC3(ch,opname,arch,suf) \
|
|
( \
|
|
dim_t k, \
|
|
ctype* restrict alpha, \
|
|
ctype* restrict a1x, \
|
|
ctype* restrict a11, \
|
|
ctype* restrict bx1, \
|
|
ctype* restrict b11, \
|
|
ctype* restrict c11, inc_t rs_c, inc_t cs_c, \
|
|
auxinfo_t* restrict data, \
|
|
cntx_t* restrict cntx \
|
|
) \
|
|
{ \
|
|
const num_t dt = PASTEMAC(ch,type); \
|
|
const num_t dt_r = PASTEMAC(chr,type); \
|
|
\
|
|
PASTECH(chr,gemm_ukr_ft) \
|
|
rgemm_ukr = bli_cntx_get_l3_nat_ukr_dt( dt_r, BLIS_GEMM_UKR, cntx ); \
|
|
\
|
|
PASTECH(ch,trsm_ukr_ft) \
|
|
ctrsm_vir_ukr = bli_cntx_get_l3_vir_ukr_dt( dt, trsmkerid, cntx ); \
|
|
\
|
|
const bool col_pref = bli_cntx_l3_nat_ukr_prefers_cols_dt( dt_r, BLIS_GEMM_UKR, cntx ); \
|
|
\
|
|
const dim_t mr = bli_cntx_get_blksz_def_dt( dt, BLIS_MR, cntx ); \
|
|
const dim_t nr = bli_cntx_get_blksz_def_dt( dt, BLIS_NR, cntx ); \
|
|
\
|
|
const dim_t mr_r = bli_cntx_get_blksz_def_dt( dt_r, BLIS_MR, cntx ); \
|
|
const dim_t nr_r = bli_cntx_get_blksz_def_dt( dt_r, BLIS_NR, cntx ); \
|
|
\
|
|
ctype bt[ BLIS_STACK_BUF_MAX_SIZE \
|
|
/ sizeof( ctype ) ] \
|
|
__attribute__((aligned(BLIS_STACK_BUF_ALIGN_SIZE))); \
|
|
inc_t rs_bt; \
|
|
inc_t cs_bt; \
|
|
\
|
|
inc_t rs_bt_r; \
|
|
inc_t cs_bt_r; \
|
|
\
|
|
const dim_t packnr = bli_cntx_get_blksz_max_dt( dt, BLIS_NR, cntx ); \
|
|
\
|
|
const pack_t schema_b = bli_auxinfo_schema_b( data ); \
|
|
\
|
|
const dim_t k2 = 2 * k; \
|
|
\
|
|
ctype_r* restrict a1x_r = ( ctype_r* )a1x; \
|
|
\
|
|
ctype_r* restrict bx1_r = ( ctype_r* )bx1; \
|
|
\
|
|
const inc_t rs_b = packnr; \
|
|
const inc_t cs_b = 1; \
|
|
\
|
|
ctype_r* restrict zero_r = PASTEMAC(chr,0); \
|
|
ctype_r* restrict minus_one_r = PASTEMAC(chr,m1); \
|
|
\
|
|
const ctype_r alpha_r = PASTEMAC(ch,real)( *alpha ); \
|
|
const ctype_r alpha_i = PASTEMAC(ch,imag)( *alpha ); \
|
|
\
|
|
ctype_r* b_use; \
|
|
inc_t rs_b_use; \
|
|
inc_t cs_b_use; \
|
|
\
|
|
\
|
|
/* Handle alphas with non-zero imaginary components. */ \
|
|
/* NOTE: This branch should never execute because alphas with
|
|
non-zero imaginary components should be applied during
|
|
packing, and so the only alphas we should see here are
|
|
those exclusively in the real domain, either because the
|
|
value originally had no imaginary compoent (e.g. 4.0) or
|
|
because a 1.0 was sent in as a placeholder since the alpha
|
|
was applied during packing. */ \
|
|
if ( 0 ) \
|
|
if ( !PASTEMAC(chr,eq0)( alpha_i ) ) \
|
|
{ \
|
|
bli_abort(); \
|
|
\
|
|
/*
|
|
ctype_r* restrict one_r = PASTEMAC(chr,1); \
|
|
\
|
|
const inc_t ld_b = rs_b; \
|
|
\
|
|
PASTEMAC(ch,scal1ms_mxn)( schema_b, \
|
|
mr, \
|
|
nr, \
|
|
alpha, \
|
|
b11, rs_b, cs_b, ld_b ); \
|
|
\
|
|
alpha_r = *one_r; \
|
|
*/ \
|
|
} \
|
|
\
|
|
\
|
|
{ \
|
|
/* Set the strides for the temporary bt matrix based on the native
|
|
real domain micro-kernel storage preferences. */ \
|
|
if ( col_pref ) { rs_bt = 1; cs_bt = mr; \
|
|
rs_bt_r = 1; cs_bt_r = mr_r; } \
|
|
else { rs_bt = nr; cs_bt = 1; \
|
|
rs_bt_r = nr_r; cs_bt_r = 1; } \
|
|
\
|
|
b_use = ( ctype_r* )bt; \
|
|
rs_b_use = rs_bt_r; \
|
|
cs_b_use = cs_bt_r; \
|
|
} \
|
|
\
|
|
\
|
|
/* Since b11 is stored in the 1e or 1r schema, we cannot update it
|
|
directly, and instead must compute the matrix product in a local
|
|
temporary microtile and then accumulate it into b11 according to
|
|
its schema. */ \
|
|
\
|
|
\
|
|
/* lower: bt = -1.0 * a10 * b01;
|
|
upper: bt = -1.0 * a12 * b21; */ \
|
|
rgemm_ukr \
|
|
( \
|
|
k2, \
|
|
minus_one_r, \
|
|
a1x_r, \
|
|
bx1_r, \
|
|
zero_r, \
|
|
b_use, rs_b_use, cs_b_use, \
|
|
data, \
|
|
cntx \
|
|
); \
|
|
\
|
|
\
|
|
if ( bli_is_1e_packed( schema_b ) ) \
|
|
{ \
|
|
const inc_t ld_b = rs_b; \
|
|
\
|
|
ctype* restrict b11_ri = ( ctype* )b11; \
|
|
ctype* restrict b11_ir = ( ctype* )b11 + ld_b/2; \
|
|
\
|
|
dim_t i, j; \
|
|
\
|
|
/* b11 = alpha * b11 + bt; */ \
|
|
for ( j = 0; j < nr; ++j ) \
|
|
for ( i = 0; i < mr; ++i ) \
|
|
{ \
|
|
ctype* restrict beta11t = bt + i*rs_bt + j*cs_bt; \
|
|
ctype_r* restrict beta11t_r = &PASTEMAC(ch,real)( *beta11t ); \
|
|
ctype_r* restrict beta11t_i = &PASTEMAC(ch,imag)( *beta11t ); \
|
|
ctype* restrict beta11_ri = b11_ri + i*rs_b + j*cs_b; \
|
|
ctype_r* restrict beta11_r = &PASTEMAC(ch,real)( *beta11_ri ); \
|
|
ctype_r* restrict beta11_i = &PASTEMAC(ch,imag)( *beta11_ri ); \
|
|
ctype* restrict beta11_ir = b11_ir + i*rs_b + j*cs_b; \
|
|
\
|
|
PASTEMAC3(ch,chr,ch,xpbyris) \
|
|
( \
|
|
*beta11t_r, \
|
|
*beta11t_i, \
|
|
alpha_r, \
|
|
alpha_i, /* alpha_i not referenced */ \
|
|
*beta11_r, \
|
|
*beta11_i \
|
|
); \
|
|
\
|
|
PASTEMAC(ch,sets)( -*beta11_i, \
|
|
*beta11_r, *beta11_ir ); \
|
|
} \
|
|
} \
|
|
else /* if ( bli_is_1r_packed( schema_b ) ) */ \
|
|
{ \
|
|
const inc_t ld_b = rs_b; \
|
|
const inc_t rs_b2 = 2 * rs_b; \
|
|
const inc_t cs_b2 = cs_b; \
|
|
\
|
|
ctype_r* restrict b11_r = ( ctype_r* )b11; \
|
|
ctype_r* restrict b11_i = ( ctype_r* )b11 + ld_b; \
|
|
\
|
|
dim_t i, j; \
|
|
\
|
|
/* b11 = alpha * b11 + bt; */ \
|
|
for ( j = 0; j < nr; ++j ) \
|
|
for ( i = 0; i < mr; ++i ) \
|
|
{ \
|
|
ctype* restrict beta11t = bt + i*rs_bt + j*cs_bt; \
|
|
ctype_r* restrict beta11t_r = &PASTEMAC(ch,real)( *beta11t ); \
|
|
ctype_r* restrict beta11t_i = &PASTEMAC(ch,imag)( *beta11t ); \
|
|
ctype_r* restrict beta11_r = b11_r + i*rs_b2 + j*cs_b2; \
|
|
ctype_r* restrict beta11_i = b11_i + i*rs_b2 + j*cs_b2; \
|
|
\
|
|
PASTEMAC3(ch,chr,ch,xpbyris) \
|
|
( \
|
|
*beta11t_r, \
|
|
*beta11t_i, \
|
|
alpha_r, \
|
|
alpha_i, /* alpha_i not referenced */ \
|
|
*beta11_r, \
|
|
*beta11_i \
|
|
); \
|
|
} \
|
|
} \
|
|
\
|
|
\
|
|
/* b11 = inv(a11) * b11;
|
|
c11 = b11; */ \
|
|
ctrsm_vir_ukr \
|
|
( \
|
|
a11, \
|
|
b11, \
|
|
c11, rs_c, cs_c, \
|
|
data, \
|
|
cntx \
|
|
); \
|
|
}
|
|
|
|
INSERT_GENTFUNCCO_BASIC3( gemmtrsm1m_l, BLIS_CNAME_INFIX, BLIS_REF_SUFFIX, BLIS_TRSM_L_UKR )
|
|
INSERT_GENTFUNCCO_BASIC3( gemmtrsm1m_u, BLIS_CNAME_INFIX, BLIS_REF_SUFFIX, BLIS_TRSM_U_UKR )
|