mirror of
https://github.com/amd/blis.git
synced 2026-04-29 20:11:12 +00:00
- Query pack schemas in level-3 bli_*_front() functions and store those values in the schema bitfields of the correponding obj_t's when the cntx's method is not BLIS_NAT. (When method is BLIS_NAT, the default native schemas are stored to the obj_t's.) - In bli_l3_cntl_create_if(), query the schemas stored to the obj_t's in bli_*_front(), clear the schema bitfields, and pass the queried values into bli_gemm_cntl_create() and bli_trsm_cntl_create(). - Updated APIs for bli_gemm_cntl_create() and bli_trsm_cntl_create() to take schemas for A and B, and use these values to initialize the appropriate control tree nodes. (Also cpp-disabled the panel-block cntl tree creation variant, bli_gemmpb_cntl_create(), as it has not been employed by BLIS in quite some time.) - Simplified querying of schema in bli_packm_init() thanks to above changes. - Updated openmp and pthreads definitions of bli_l3_thread_decorator() so that thread-local aliases of matrix operands are guaranteed, even if aliasing is disabled within the internal back-end functions (e.g. bli_gemm_int.c). Also added a comment to bli_thrcomm_single.c explaining why the extra aliasing is not needed there. - Change bli_gemm() and level-3 friends so that the operation's ind() function is called only if all matrix operands have the same datatype, and only if that datatype is complex. The former condition is needed in preparation for work related to mixed domain operands, while the latter helps with readability, especially for those who don't want to venture into frame/ind. - Reshuffled arguments in bli_cntx_set_thrloop_from_env() to be consistent with BLIS calling conventions (modified argument(s) are last), and updated all invocations in the level-3 _front() functions. - Comment updates to bli_cntx_set_thrloop_from_env().
692 lines
18 KiB
C
692 lines
18 KiB
C
/*
|
|
|
|
BLIS
|
|
An object-based framework for developing high-performance BLAS-like
|
|
libraries.
|
|
|
|
Copyright (C) 2014, The University of Texas at Austin
|
|
Copyright (C) 2016, Hewlett Packard Enterprise Development LP
|
|
|
|
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 of The University of Texas at Austin 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.
|
|
|
|
*/
|
|
|
|
#ifndef BLIS_CNTX_H
|
|
#define BLIS_CNTX_H
|
|
|
|
|
|
// Context object type (defined in bli_type_defs.h)
|
|
|
|
/*
|
|
typedef struct cntx_s
|
|
{
|
|
blksz_t* blkszs;
|
|
bszid_t* bmults;
|
|
|
|
func_t* l3_vir_ukrs;
|
|
func_t* l3_nat_ukrs;
|
|
mbool_t* l3_nat_ukrs_prefs;
|
|
|
|
func_t* l1f_kers;
|
|
func_t* l1v_kers;
|
|
|
|
func_t* packm_kers;
|
|
func_t* unpackm_kers;
|
|
|
|
ind_t method;
|
|
pack_t schema_a;
|
|
pack_t schema_b;
|
|
pack_t schema_c;
|
|
|
|
bool_t anti_pref;
|
|
|
|
dim_t* thrloop;
|
|
|
|
membrk_t* membrk;
|
|
} cntx_t;
|
|
*/
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
//
|
|
// -- cntx_t query (fields only) -----------------------------------------------
|
|
//
|
|
|
|
static blksz_t* bli_cntx_blkszs_buf( cntx_t* cntx )
|
|
{
|
|
return cntx->blkszs;
|
|
}
|
|
static bszid_t* bli_cntx_bmults_buf( cntx_t* cntx )
|
|
{
|
|
return cntx->bmults;
|
|
}
|
|
static func_t* bli_cntx_l3_vir_ukrs_buf( cntx_t* cntx )
|
|
{
|
|
return cntx->l3_vir_ukrs;
|
|
}
|
|
static func_t* bli_cntx_l3_nat_ukrs_buf( cntx_t* cntx )
|
|
{
|
|
return cntx->l3_nat_ukrs;
|
|
}
|
|
static mbool_t* bli_cntx_l3_nat_ukrs_prefs_buf( cntx_t* cntx )
|
|
{
|
|
return cntx->l3_nat_ukrs_prefs;
|
|
}
|
|
static func_t* bli_cntx_l1f_kers_buf( cntx_t* cntx )
|
|
{
|
|
return cntx->l1f_kers;
|
|
}
|
|
static func_t* bli_cntx_l1v_kers_buf( cntx_t* cntx )
|
|
{
|
|
return cntx->l1v_kers;
|
|
}
|
|
static func_t* bli_cntx_packm_kers_buf( cntx_t* cntx )
|
|
{
|
|
return cntx->packm_kers;
|
|
}
|
|
static func_t* bli_cntx_unpackm_kers_buf( cntx_t* cntx )
|
|
{
|
|
return cntx->unpackm_kers;
|
|
}
|
|
static ind_t bli_cntx_method( cntx_t* cntx )
|
|
{
|
|
return cntx->method;
|
|
}
|
|
static pack_t bli_cntx_schema_a_block( cntx_t* cntx )
|
|
{
|
|
return cntx->schema_a_block;
|
|
}
|
|
static pack_t bli_cntx_schema_b_panel( cntx_t* cntx )
|
|
{
|
|
return cntx->schema_b_panel;
|
|
}
|
|
static pack_t bli_cntx_schema_c_panel( cntx_t* cntx )
|
|
{
|
|
return cntx->schema_c_panel;
|
|
}
|
|
static bool_t bli_cntx_anti_pref( cntx_t* cntx )
|
|
{
|
|
return cntx->anti_pref;
|
|
}
|
|
static dim_t* bli_cntx_thrloop( cntx_t* cntx )
|
|
{
|
|
return cntx->thrloop;
|
|
}
|
|
static membrk_t* bli_cntx_get_membrk( cntx_t* cntx )
|
|
{
|
|
return cntx->membrk;
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
//
|
|
// -- cntx_t modification (fields only) ----------------------------------------
|
|
//
|
|
|
|
static void bli_cntx_set_method( ind_t method, cntx_t* cntx )
|
|
{
|
|
cntx->method = method;
|
|
}
|
|
static void bli_cntx_set_schema_a_block( pack_t schema, cntx_t* cntx )
|
|
{
|
|
cntx->schema_a_block = schema;
|
|
}
|
|
static void bli_cntx_set_schema_b_panel( pack_t schema, cntx_t* cntx )
|
|
{
|
|
cntx->schema_b_panel = schema;
|
|
}
|
|
static void bli_cntx_set_schema_c_panel( pack_t schema, cntx_t* cntx )
|
|
{
|
|
cntx->schema_c_panel = schema;
|
|
}
|
|
static void bli_cntx_set_schema_ab_blockpanel( pack_t sa, pack_t sb, cntx_t* cntx )
|
|
{
|
|
bli_cntx_set_schema_a_block( sa, cntx );
|
|
bli_cntx_set_schema_b_panel( sb, cntx );
|
|
}
|
|
static void bli_cntx_set_anti_pref( bool_t anti_pref, cntx_t* cntx )
|
|
{
|
|
cntx->anti_pref = anti_pref;
|
|
}
|
|
static void bli_cntx_set_membrk( membrk_t* membrk, cntx_t* cntx )
|
|
{
|
|
cntx->membrk = membrk;
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
//
|
|
// -- cntx_t query (complex) ---------------------------------------------------
|
|
//
|
|
|
|
static blksz_t* bli_cntx_get_blksz( bszid_t bs_id, cntx_t* cntx )
|
|
{
|
|
blksz_t* blkszs = bli_cntx_blkszs_buf( cntx );
|
|
blksz_t* blksz = &blkszs[ bs_id ];
|
|
|
|
// Return the address of the blksz_t identified by bs_id.
|
|
return blksz;
|
|
}
|
|
|
|
static dim_t bli_cntx_get_blksz_def_dt( num_t dt, bszid_t bs_id, cntx_t* cntx )
|
|
{
|
|
blksz_t* blksz = bli_cntx_get_blksz( bs_id, cntx );
|
|
dim_t bs_dt = bli_blksz_get_def( dt, blksz );
|
|
|
|
// Return the main (default) blocksize value for the datatype given.
|
|
return bs_dt;
|
|
}
|
|
|
|
static dim_t bli_cntx_get_blksz_max_dt( num_t dt, bszid_t bs_id, cntx_t* cntx )
|
|
{
|
|
blksz_t* blksz = bli_cntx_get_blksz( bs_id, cntx );
|
|
dim_t bs_dt = bli_blksz_get_max( dt, blksz );
|
|
|
|
// Return the auxiliary (maximum) blocksize value for the datatype given.
|
|
return bs_dt;
|
|
}
|
|
|
|
static bszid_t bli_cntx_get_bmult_id( bszid_t bs_id, cntx_t* cntx )
|
|
{
|
|
bszid_t* restrict bmults = bli_cntx_bmults_buf( cntx );
|
|
bszid_t bm_id = bmults[ bs_id ];
|
|
|
|
return bm_id;
|
|
}
|
|
|
|
static blksz_t* bli_cntx_get_bmult( bszid_t bs_id, cntx_t* cntx )
|
|
{
|
|
bszid_t bm_id = bli_cntx_get_bmult_id( bs_id, cntx );
|
|
blksz_t* restrict bmult = bli_cntx_get_blksz( bm_id, cntx );
|
|
|
|
return bmult;
|
|
}
|
|
|
|
static dim_t bli_cntx_get_bmult_dt( num_t dt, bszid_t bs_id, cntx_t* cntx )
|
|
{
|
|
blksz_t* bmult = bli_cntx_get_bmult( bs_id, cntx );
|
|
dim_t bm_dt = bli_blksz_get_def( dt, bmult );
|
|
|
|
return bm_dt;
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
static func_t* bli_cntx_get_l3_ukrs( l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
func_t* funcs;
|
|
|
|
if ( bli_cntx_method( (cntx) ) != BLIS_NAT )
|
|
funcs = bli_cntx_l3_vir_ukrs_buf( cntx );
|
|
else
|
|
funcs = bli_cntx_l3_nat_ukrs_buf( cntx );
|
|
|
|
func_t* func = &funcs[ ukr_id ];
|
|
|
|
return func;
|
|
}
|
|
|
|
static void* bli_cntx_get_l3_ukr_dt( num_t dt, l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
func_t* func = bli_cntx_get_l3_ukrs( ukr_id, cntx );
|
|
|
|
return bli_func_get_dt( dt, func );
|
|
}
|
|
|
|
static func_t* bli_cntx_get_l3_vir_ukrs( l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
func_t* funcs = bli_cntx_l3_vir_ukrs_buf( cntx );
|
|
func_t* func = &funcs[ ukr_id ];
|
|
|
|
return func;
|
|
}
|
|
|
|
static void* bli_cntx_get_l3_vir_ukr_dt( num_t dt, l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
func_t* func = bli_cntx_get_l3_vir_ukrs( ukr_id, cntx );
|
|
|
|
return bli_func_get_dt( dt, func );
|
|
}
|
|
|
|
static func_t* bli_cntx_get_l3_nat_ukrs( l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
func_t* funcs = bli_cntx_l3_nat_ukrs_buf( cntx );
|
|
func_t* func = &funcs[ ukr_id ];
|
|
|
|
return func;
|
|
}
|
|
|
|
static void* bli_cntx_get_l3_nat_ukr_dt( num_t dt, l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
func_t* func = bli_cntx_get_l3_nat_ukrs( ukr_id, cntx );
|
|
|
|
return bli_func_get_dt( dt, func );
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
static mbool_t* bli_cntx_get_l3_nat_ukr_prefs( l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
mbool_t* mbools = bli_cntx_l3_nat_ukrs_prefs_buf( cntx );
|
|
mbool_t* mbool = &mbools[ ukr_id ];
|
|
|
|
return mbool;
|
|
}
|
|
|
|
static bool_t bli_cntx_get_l3_nat_ukr_prefs_dt( num_t dt, l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
mbool_t* mbool = bli_cntx_get_l3_nat_ukr_prefs( ukr_id, cntx );
|
|
|
|
return bli_mbool_get_dt( dt, mbool );
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
static func_t* bli_cntx_get_l1f_kers( l1fkr_t ker_id, cntx_t* cntx )
|
|
{
|
|
func_t* funcs = bli_cntx_l1f_kers_buf( cntx );
|
|
func_t* func = &funcs[ ker_id ];
|
|
|
|
return func;
|
|
}
|
|
|
|
static void* bli_cntx_get_l1f_ker_dt( num_t dt, l1fkr_t ker_id, cntx_t* cntx )
|
|
{
|
|
func_t* func = bli_cntx_get_l1f_kers( ker_id, cntx );
|
|
|
|
return bli_func_get_dt( dt, func );
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
static func_t* bli_cntx_get_l1v_kers( l1vkr_t ker_id, cntx_t* cntx )
|
|
{
|
|
func_t* funcs = bli_cntx_l1v_kers_buf( cntx );
|
|
func_t* func = &funcs[ ker_id ];
|
|
|
|
return func;
|
|
}
|
|
|
|
static void* bli_cntx_get_l1v_ker_dt( num_t dt, l1vkr_t ker_id, cntx_t* cntx )
|
|
{
|
|
func_t* func = bli_cntx_get_l1v_kers( ker_id, cntx );
|
|
|
|
return bli_func_get_dt( dt, func );
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
static func_t* bli_cntx_get_packm_kers( l1mkr_t ker_id, cntx_t* cntx )
|
|
{
|
|
func_t* func = NULL;
|
|
|
|
// Only index to the requested packm func_t if the packm kernel being
|
|
// requested is one that is explicitly supported.
|
|
if ( 0 <= ( gint_t )ker_id &&
|
|
( gint_t )ker_id < BLIS_NUM_PACKM_KERS )
|
|
{
|
|
func_t* funcs = bli_cntx_packm_kers_buf( cntx );
|
|
|
|
func = &funcs[ ker_id ];
|
|
}
|
|
|
|
return func;
|
|
}
|
|
|
|
static void* bli_cntx_get_packm_ker_dt( num_t dt, l1mkr_t ker_id, cntx_t* cntx )
|
|
{
|
|
void* fp = NULL;
|
|
|
|
// Only query the context for the packm func_t (and then extract the
|
|
// datatype-specific function pointer) if the packm kernel being
|
|
// requested is one that is explicitly supported.
|
|
if ( 0 <= ( gint_t )ker_id &&
|
|
( gint_t )ker_id < BLIS_NUM_PACKM_KERS )
|
|
{
|
|
func_t* func = bli_cntx_get_packm_kers( ker_id, cntx );
|
|
|
|
fp = bli_func_get_dt( dt, func );
|
|
}
|
|
|
|
return fp;
|
|
}
|
|
|
|
static func_t* bli_cntx_get_unpackm_kers( l1mkr_t ker_id, cntx_t* cntx )
|
|
{
|
|
func_t* func = NULL;
|
|
|
|
// Only index to the requested unpackm func_t if the unpackm kernel being
|
|
// requested is one that is explicitly supported.
|
|
if ( 0 <= ( gint_t )ker_id &&
|
|
( gint_t )ker_id < BLIS_NUM_UNPACKM_KERS )
|
|
{
|
|
func_t* funcs = bli_cntx_unpackm_kers_buf( cntx );
|
|
|
|
func = &funcs[ ker_id ];
|
|
}
|
|
|
|
return func;
|
|
}
|
|
|
|
static void* bli_cntx_get_unpackm_ker_dt( num_t dt, l1mkr_t ker_id, cntx_t* cntx )
|
|
{
|
|
void* fp = NULL;
|
|
|
|
// Only query the context for the unpackm func_t (and then extract the
|
|
// datatype-specific function pointer) if the unpackm kernel being
|
|
// requested is one that is explicitly supported.
|
|
if ( 0 <= ( gint_t )ker_id &&
|
|
( gint_t )ker_id < BLIS_NUM_UNPACKM_KERS )
|
|
{
|
|
func_t* func = bli_cntx_get_unpackm_kers( ker_id, cntx );
|
|
|
|
fp = bli_func_get_dt( dt, func );
|
|
}
|
|
|
|
return fp;
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
static dim_t bli_cntx_jc_way( cntx_t* cntx )
|
|
{
|
|
return cntx->thrloop[ BLIS_NC ];
|
|
}
|
|
static dim_t bli_cntx_pc_way( cntx_t* cntx )
|
|
{
|
|
return cntx->thrloop[ BLIS_KC ];
|
|
}
|
|
static dim_t bli_cntx_ic_way( cntx_t* cntx )
|
|
{
|
|
return cntx->thrloop[ BLIS_MC ];
|
|
}
|
|
static dim_t bli_cntx_jr_way( cntx_t* cntx )
|
|
{
|
|
return cntx->thrloop[ BLIS_NR ];
|
|
}
|
|
static dim_t bli_cntx_ir_way( cntx_t* cntx )
|
|
{
|
|
return cntx->thrloop[ BLIS_MR ];
|
|
}
|
|
static dim_t bli_cntx_pr_way( cntx_t* cntx )
|
|
{
|
|
return cntx->thrloop[ BLIS_KR ];
|
|
}
|
|
|
|
static dim_t bli_cntx_way_for_bszid( bszid_t bszid, cntx_t* cntx )
|
|
{
|
|
return cntx->thrloop[ bszid ];
|
|
}
|
|
|
|
static dim_t bli_cntx_get_num_threads( cntx_t* cntx )
|
|
{
|
|
return bli_cntx_jc_way( cntx ) *
|
|
bli_cntx_pc_way( cntx ) *
|
|
bli_cntx_ic_way( cntx ) *
|
|
bli_cntx_jr_way( cntx ) *
|
|
bli_cntx_ir_way( cntx );
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
static bool_t bli_cntx_l3_nat_ukr_prefers_rows_dt( num_t dt, l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
bool_t prefs = bli_cntx_get_l3_nat_ukr_prefs_dt( dt, ukr_id, cntx );
|
|
|
|
// A ukernel preference of TRUE means the ukernel prefers row storage.
|
|
return prefs == TRUE;
|
|
}
|
|
|
|
static bool_t bli_cntx_l3_nat_ukr_prefers_cols_dt( num_t dt, l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
bool_t prefs = bli_cntx_get_l3_nat_ukr_prefs_dt( dt, ukr_id, cntx );
|
|
|
|
// A ukernel preference of FALSE means the ukernel prefers column storage.
|
|
return prefs == FALSE;
|
|
}
|
|
|
|
static bool_t bli_cntx_l3_nat_ukr_prefers_storage_of( obj_t* obj, l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
const num_t dt = bli_obj_dt( obj );
|
|
const bool_t ukr_prefers_rows
|
|
= bli_cntx_l3_nat_ukr_prefers_rows_dt( dt, ukr_id, cntx );
|
|
const bool_t ukr_prefers_cols
|
|
= bli_cntx_l3_nat_ukr_prefers_cols_dt( dt, ukr_id, cntx );
|
|
bool_t r_val = FALSE;
|
|
|
|
if ( bli_obj_is_row_stored( obj ) && ukr_prefers_rows ) r_val = TRUE;
|
|
else if ( bli_obj_is_col_stored( obj ) && ukr_prefers_cols ) r_val = TRUE;
|
|
|
|
return r_val;
|
|
}
|
|
|
|
static bool_t bli_cntx_l3_nat_ukr_dislikes_storage_of( obj_t* obj, l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
return !bli_cntx_l3_nat_ukr_prefers_storage_of( obj, ukr_id, cntx );
|
|
}
|
|
|
|
static bool_t bli_cntx_l3_nat_ukr_eff_prefers_storage_of( obj_t* obj, l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
bool_t r_val = bli_cntx_l3_nat_ukr_prefers_storage_of( obj, ukr_id, cntx );
|
|
|
|
// If the anti-preference is set, negate the result.
|
|
if ( bli_cntx_anti_pref( cntx ) ) r_val = !r_val;
|
|
|
|
return r_val;
|
|
}
|
|
|
|
static bool_t bli_cntx_l3_nat_ukr_eff_dislikes_storage_of( obj_t* obj, l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
bool_t r_val = bli_cntx_l3_nat_ukr_dislikes_storage_of( obj, ukr_id, cntx );
|
|
|
|
// If the anti-preference is set, negate the result.
|
|
if ( bli_cntx_anti_pref( cntx ) ) r_val = !r_val;
|
|
|
|
return r_val;
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
static bool_t bli_cntx_l3_ukr_prefers_rows_dt( num_t dt, l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
// For induced methods, return the ukernel storage preferences of the
|
|
// corresponding real micro-kernel.
|
|
if ( bli_cntx_method( cntx ) != BLIS_NAT )
|
|
dt = bli_dt_proj_to_real( dt );
|
|
|
|
return bli_cntx_l3_nat_ukr_prefers_rows_dt( dt, ukr_id, cntx );
|
|
}
|
|
|
|
static bool_t bli_cntx_l3_ukr_prefers_cols_dt( num_t dt, l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
// For induced methods, return the ukernel storage preferences of the
|
|
// corresponding real micro-kernel.
|
|
if ( bli_cntx_method( cntx ) != BLIS_NAT )
|
|
dt = bli_dt_proj_to_real( dt );
|
|
|
|
return bli_cntx_l3_nat_ukr_prefers_cols_dt( dt, ukr_id, cntx );
|
|
}
|
|
|
|
static bool_t bli_cntx_l3_ukr_prefers_storage_of( obj_t* obj, l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
const num_t dt = bli_obj_dt( obj );
|
|
const bool_t ukr_prefers_rows
|
|
= bli_cntx_l3_ukr_prefers_rows_dt( dt, ukr_id, cntx );
|
|
const bool_t ukr_prefers_cols
|
|
= bli_cntx_l3_ukr_prefers_cols_dt( dt, ukr_id, cntx );
|
|
bool_t r_val = FALSE;
|
|
|
|
if ( bli_obj_is_row_stored( obj ) && ukr_prefers_rows ) r_val = TRUE;
|
|
else if ( bli_obj_is_col_stored( obj ) && ukr_prefers_cols ) r_val = TRUE;
|
|
|
|
return r_val;
|
|
}
|
|
|
|
static bool_t bli_cntx_l3_ukr_dislikes_storage_of( obj_t* obj, l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
return !bli_cntx_l3_ukr_prefers_storage_of( obj, ukr_id, cntx );
|
|
}
|
|
|
|
static bool_t bli_cntx_l3_ukr_eff_prefers_storage_of( obj_t* obj, l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
bool_t r_val = bli_cntx_l3_ukr_prefers_storage_of( obj, ukr_id, cntx );
|
|
|
|
// If the anti-preference is set, negate the result.
|
|
if ( bli_cntx_anti_pref( cntx ) ) r_val = !r_val;
|
|
|
|
return r_val;
|
|
}
|
|
|
|
static bool_t bli_cntx_l3_ukr_eff_dislikes_storage_of( obj_t* obj, l3ukr_t ukr_id, cntx_t* cntx )
|
|
{
|
|
bool_t r_val = bli_cntx_l3_ukr_dislikes_storage_of( obj, ukr_id, cntx );
|
|
|
|
// If the anti-preference is set, negate the result.
|
|
if ( bli_cntx_anti_pref( cntx ) ) r_val = !r_val;
|
|
|
|
return r_val;
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
//
|
|
// -- cntx_t modification (complex) --------------------------------------------
|
|
//
|
|
|
|
static void bli_cntx_set_blksz( bszid_t bs_id, blksz_t* blksz, bszid_t mult_id, cntx_t* cntx )
|
|
{
|
|
blksz_t* blkszs = bli_cntx_blkszs_buf( cntx );
|
|
bszid_t* bmults = bli_cntx_bmults_buf( cntx );
|
|
|
|
blkszs[ bs_id ] = *blksz;
|
|
bmults[ bs_id ] = mult_id;
|
|
}
|
|
|
|
static void bli_cntx_set_l3_vir_ukr( l3ukr_t ukr_id, func_t* func, cntx_t* cntx )
|
|
{
|
|
func_t* funcs = bli_cntx_l3_vir_ukrs_buf( cntx );
|
|
|
|
funcs[ ukr_id ] = *func;
|
|
}
|
|
|
|
static void bli_cntx_set_l3_nat_ukr( l3ukr_t ukr_id, func_t* func, cntx_t* cntx )
|
|
{
|
|
func_t* funcs = bli_cntx_l3_nat_ukrs_buf( cntx );
|
|
|
|
funcs[ ukr_id ] = *func;
|
|
}
|
|
|
|
static void bli_cntx_set_l3_nat_ukr_prefs( l3ukr_t ukr_id, mbool_t* prefs, cntx_t* cntx )
|
|
{
|
|
mbool_t* mbools = bli_cntx_l3_nat_ukrs_prefs_buf( cntx );
|
|
|
|
mbools[ ukr_id ] = *prefs;
|
|
}
|
|
|
|
static void bli_cntx_set_l1f_ker( l1fkr_t ker_id, func_t* func, cntx_t* cntx )
|
|
{
|
|
func_t* funcs = bli_cntx_l1f_kers_buf( cntx );
|
|
|
|
funcs[ ker_id ] = *func;
|
|
}
|
|
|
|
static void bli_cntx_set_l1v_ker( l1vkr_t ker_id, func_t* func, cntx_t* cntx )
|
|
{
|
|
func_t* funcs = bli_cntx_l1v_kers_buf( cntx );
|
|
|
|
funcs[ ker_id ] = *func;
|
|
}
|
|
|
|
static void bli_cntx_set_packm_ker( l1mkr_t ker_id, func_t* func, cntx_t* cntx )
|
|
{
|
|
func_t* funcs = bli_cntx_get_packm_kers( ker_id, cntx );
|
|
|
|
funcs[ ker_id ] = *func;
|
|
}
|
|
|
|
static void bli_cntx_set_packm_ker_dt( void* fp, num_t dt, l1mkr_t ker_id, cntx_t* cntx )
|
|
{
|
|
func_t* func = bli_cntx_get_packm_ker_dt( dt, ker_id, cntx );
|
|
|
|
bli_func_set_dt( fp, dt, func );
|
|
}
|
|
|
|
static void bli_cntx_set_unpackm_ker( l1mkr_t ker_id, func_t* func, cntx_t* cntx )
|
|
{
|
|
func_t* funcs = bli_cntx_get_unpackm_kers( ker_id, cntx );
|
|
|
|
funcs[ ker_id ] = *func;
|
|
}
|
|
|
|
static void bli_cntx_set_unpackm_ker_dt( void* fp, num_t dt, l1mkr_t ker_id, cntx_t* cntx )
|
|
{
|
|
func_t* func = bli_cntx_get_unpackm_ker_dt( dt, ker_id, cntx );
|
|
|
|
bli_func_set_dt( fp, dt, func );
|
|
}
|
|
|
|
static void bli_cntx_set_thrloop( dim_t jc, dim_t pc, dim_t ic, dim_t jr, dim_t ir, cntx_t* cntx )
|
|
{
|
|
cntx->thrloop[ BLIS_NC ] = jc;
|
|
cntx->thrloop[ BLIS_KC ] = pc;
|
|
cntx->thrloop[ BLIS_MC ] = ic;
|
|
cntx->thrloop[ BLIS_NR ] = jr;
|
|
cntx->thrloop[ BLIS_MR ] = ir;
|
|
cntx->thrloop[ BLIS_KR ] = 1;
|
|
}
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Function prototypes
|
|
|
|
void bli_cntx_clear( cntx_t* cntx );
|
|
|
|
dim_t bli_cntx_get_num_threads_in( cntx_t* cntx, cntl_t* cntl );
|
|
|
|
void bli_cntx_set_blkszs( ind_t method, dim_t n_bs, ... );
|
|
|
|
void bli_cntx_set_ind_blkszs( ind_t method, dim_t n_bs, ... );
|
|
|
|
void bli_cntx_set_l3_nat_ukrs( dim_t n_ukrs, ... );
|
|
void bli_cntx_set_l1f_kers( dim_t n_kers, ... );
|
|
void bli_cntx_set_l1v_kers( dim_t n_kers, ... );
|
|
void bli_cntx_set_packm_kers( dim_t n_kers, ... );
|
|
|
|
void bli_cntx_set_thrloop_from_env
|
|
(
|
|
opid_t l3_op,
|
|
side_t side,
|
|
dim_t m,
|
|
dim_t n,
|
|
dim_t k,
|
|
cntx_t* cntx
|
|
);
|
|
|
|
void bli_cntx_print( cntx_t* cntx );
|
|
|
|
|
|
#endif
|
|
|