Files
blis/frame/base/bli_func.c
Field G. Van Zee d0eec4bddd Added optional row preference to ukernel config.
Details:
- Added the ability for the kernel developer to indicate the gemm micro-
  kernel as having a preference for accessing the micro-tile of C via
  contiguous rows (as opposed to contiguous columns). This property may
  be encoded in bli_kernel.h as BLIS_?GEMM_UKERNEL_PREFERS_CONTIG_ROWS,
  which may be defined or left undefined. Leaving it undefined leads to
  the default assumption of column preference.
- Changed conditionals in frame/3/*/*_front.c that induce transposition
  of the operation so that the transposition is induced only if there
  is disagreement between the storage of C and the preference of the
  micro-kernel. Previously, the only conditional that needed to be met
  was that C was row-stored, which is to say that we assumed the micro-
  kernel preferred column-contiguous access on C.
- Added a "prefers_contig_rows" property to func_t objects, and updated
  calls to bli_func_obj_create() in _cntl.c files in order to support
  the above changes.
- Removed the row-storage optimization from bli_trsm_front.c because
  it is actually ineffective. This is because the right-side case of
  trsm flips the A and B micro-panel operands (since BLIS only requires
  left-side gemmtrsm/trsm kernels), meaning any transposition done
  at the high level is then undone at the low level.
- Tweaked trmm, trmm3 _front.c files to eliminate a possible redundant
  invocation of the bli_obj_swap() macro.
2014-08-19 15:49:19 -05:00

120 lines
3.7 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 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.
*/
#include "blis.h"
func_t* bli_func_obj_create( void* ptr_s, bool_t pref_s,
void* ptr_d, bool_t pref_d,
void* ptr_c, bool_t pref_c,
void* ptr_z, bool_t pref_z )
{
func_t* f;
f = ( func_t* ) bli_malloc( sizeof(func_t) );
bli_func_obj_init( f,
ptr_s, pref_s,
ptr_d, pref_d,
ptr_c, pref_c,
ptr_z, pref_z );
return f;
}
void bli_func_obj_init( func_t* f,
void* ptr_s, bool_t pref_s,
void* ptr_d, bool_t pref_d,
void* ptr_c, bool_t pref_c,
void* ptr_z, bool_t pref_z )
{
f->ptr[BLIS_BITVAL_FLOAT_TYPE] = ptr_s;
f->ptr[BLIS_BITVAL_DOUBLE_TYPE] = ptr_d;
f->ptr[BLIS_BITVAL_SCOMPLEX_TYPE] = ptr_c;
f->ptr[BLIS_BITVAL_DCOMPLEX_TYPE] = ptr_z;
f->prefers_contig_rows[BLIS_BITVAL_FLOAT_TYPE] = pref_s;
f->prefers_contig_rows[BLIS_BITVAL_DOUBLE_TYPE] = pref_d;
f->prefers_contig_rows[BLIS_BITVAL_SCOMPLEX_TYPE] = pref_c;
f->prefers_contig_rows[BLIS_BITVAL_DCOMPLEX_TYPE] = pref_z;
}
void bli_func_obj_free( func_t* f )
{
bli_free( f );
}
void* bli_func_obj_query( num_t dt,
func_t* f )
{
return f->ptr[ dt ];
}
bool_t bli_func_prefers_contig_rows( num_t dt,
func_t* f )
{
return f->prefers_contig_rows[ dt ];
}
bool_t bli_func_prefers_contig_cols( num_t dt,
func_t* f )
{
return !(f->prefers_contig_rows[ dt ]);
}
bool_t bli_func_pref_is_sat_by( obj_t* a,
func_t* f )
{
num_t dt = bli_obj_datatype( *a );
bool_t r_val = FALSE;
if ( ( bli_obj_is_row_stored( *a ) &&
bli_func_prefers_contig_rows( dt, f ) ) ||
( bli_obj_is_col_stored( *a ) &&
bli_func_prefers_contig_cols( dt, f ) ) )
r_val = TRUE;
return r_val;
}
bool_t bli_func_pref_is_unsat_by( obj_t* a,
func_t* f )
{
return !bli_func_pref_is_sat_by( a, f );
}