Merge pull request #527 from flame/obj_t_makeover

Implement proposed new function pointer fields for obj_t.
This commit is contained in:
Devin Matthews
2021-08-14 18:41:35 -05:00
committed by GitHub
2 changed files with 135 additions and 10 deletions

View File

@@ -1187,6 +1187,57 @@ BLIS_INLINE stor3_t bli_obj_stor3_from_strides( obj_t* c, obj_t* a, obj_t* b )
}
// -- User-provided information macros --
// User data query
BLIS_INLINE void* bli_obj_user_data( obj_t* obj )
{
return obj->user_data;
}
// User data modification
BLIS_INLINE void bli_obj_set_user_data( void* data, obj_t* obj )
{
obj->user_data = data;
}
// Function pointer query
BLIS_INLINE obj_pack_fn_t bli_obj_pack_fn( obj_t* obj )
{
return obj->pack;
}
BLIS_INLINE obj_ker_fn_t bli_obj_ker_fn( obj_t* obj )
{
return obj->ker;
}
BLIS_INLINE obj_ukr_fn_t bli_obj_ukr_fn( obj_t* obj )
{
return obj->ukr;
}
// Function pointer modification
BLIS_INLINE void bli_obj_set_pack_fn( obj_pack_fn_t pack, obj_t* obj )
{
obj->pack = pack;
}
BLIS_INLINE void bli_obj_set_ker_fn( obj_ker_fn_t ker, obj_t* obj )
{
obj->ker = ker;
}
BLIS_INLINE void bli_obj_set_ukr_fn( obj_ukr_fn_t ukr, obj_t* obj )
{
obj->ukr = ukr;
}
// -- Initialization-related macros --
// Finish the initialization started by the matrix-specific static initializer

View File

@@ -150,7 +150,7 @@ typedef uint32_t objbits_t; // object information bit field
// interoperability with BLIS.
#ifndef _DEFINED_SCOMPLEX
#define _DEFINED_SCOMPLEX
typedef struct
typedef struct scomplex
{
float real;
float imag;
@@ -161,7 +161,7 @@ typedef uint32_t objbits_t; // object information bit field
// interoperability with BLIS.
#ifndef _DEFINED_DCOMPLEX
#define _DEFINED_DCOMPLEX
typedef struct
typedef struct dcomplex
{
double real;
double imag;
@@ -385,7 +385,7 @@ typedef void (*free_ft) ( void* p );
#define BLIS_BITVAL_SINGLE_PREC 0x0
#define BLIS_BITVAL_DOUBLE_PREC BLIS_PRECISION_BIT
#define BLIS_BITVAL_FLOAT_TYPE 0x0
#define BLIS_BITVAL_SCOMPLEX_TYPE BLIS_DOMAIN_BIT
#define BLIS_BITVAL_SCOMPLEX_TYPE BLIS_DOMAIN_BIT
#define BLIS_BITVAL_DOUBLE_TYPE BLIS_PRECISION_BIT
#define BLIS_BITVAL_DCOMPLEX_TYPE ( BLIS_DOMAIN_BIT | BLIS_PRECISION_BIT )
#define BLIS_BITVAL_INT_TYPE 0x04
@@ -395,10 +395,10 @@ typedef void (*free_ft) ( void* p );
#define BLIS_BITVAL_NO_CONJ 0x0
#define BLIS_BITVAL_CONJ BLIS_CONJ_BIT
#define BLIS_BITVAL_CONJ_TRANS ( BLIS_CONJ_BIT | BLIS_TRANS_BIT )
#define BLIS_BITVAL_ZEROS 0x0
#define BLIS_BITVAL_ZEROS 0x0
#define BLIS_BITVAL_UPPER ( BLIS_UPPER_BIT | BLIS_DIAG_BIT )
#define BLIS_BITVAL_LOWER ( BLIS_LOWER_BIT | BLIS_DIAG_BIT )
#define BLIS_BITVAL_DENSE BLIS_UPLO_BITS
#define BLIS_BITVAL_DENSE BLIS_UPLO_BITS
#define BLIS_BITVAL_NONUNIT_DIAG 0x0
#define BLIS_BITVAL_UNIT_DIAG BLIS_UNIT_DIAG_BIT
#define BLIS_BITVAL_INVERT_DIAG BLIS_INVERT_DIAG_BIT
@@ -1232,6 +1232,47 @@ typedef struct constdata_s
// -- BLIS object type definitions ---------------------------------------------
//
// Forward declarations for function pointer types
struct obj_s;
struct cntx_s;
struct rntm_s;
struct thrinfo_s;
typedef void (*obj_pack_fn_t)
(
mdim_t mat,
mem_t* mem,
struct obj_s* a,
struct obj_s* ap,
struct cntx_s* cntx,
struct rntm_s* rntm,
struct thrinfo_s* thread
);
typedef void (*obj_ker_fn_t)
(
struct obj_s* a,
struct obj_s* b,
struct obj_s* c,
struct cntx_s* cntx,
struct rntm_s* rntm,
struct thrinfo_s* thread
);
typedef void (*obj_ukr_fn_t)
(
dim_t m,
dim_t n,
dim_t k,
void* restrict alpha,
void* restrict a, inc_t rs_a, inc_t cs_a,
void* restrict b, inc_t rs_b, inc_t cs_b,
void* restrict beta,
void* restrict c, inc_t rs_c, inc_t cs_c,
auxinfo_t* restrict data,
struct cntx_s* restrict cntx
);
typedef struct obj_s
{
// Basic fields
@@ -1261,6 +1302,15 @@ typedef struct obj_s
// usually MR or NR)
dim_t m_panel; // m dimension of a "full" panel
dim_t n_panel; // n dimension of a "full" panel
// User data pointer
void* user_data;
// Function pointers
obj_pack_fn_t pack;
obj_ker_fn_t ker;
obj_ukr_fn_t ukr;
} obj_t;
// Pre-initializors. Things that must be set afterwards:
@@ -1297,7 +1347,13 @@ typedef struct obj_s
.ps = 0, \
.pd = 0, \
.m_panel = 0, \
.n_panel = 0 \
.n_panel = 0, \
\
.user_data = NULL, \
\
.pack = NULL, \
.ker = NULL, \
.ukr = NULL \
}
#define BLIS_OBJECT_INITIALIZER_1X1 \
@@ -1325,7 +1381,13 @@ typedef struct obj_s
.ps = 0, \
.pd = 0, \
.m_panel = 0, \
.n_panel = 0 \
.n_panel = 0, \
\
.user_data = NULL, \
\
.pack = NULL, \
.ker = NULL, \
.ukr = NULL \
}
// Define these macros here since they must be updated if contents of
@@ -1359,6 +1421,12 @@ BLIS_INLINE void bli_obj_init_full_shallow_copy_of( obj_t* a, obj_t* b )
b->pd = a->pd;
b->m_panel = a->m_panel;
b->n_panel = a->n_panel;
b->user_data = a->user_data;
b->pack = a->pack;
b->ker = a->ker;
b->ukr = a->ukr;
}
BLIS_INLINE void bli_obj_init_subpart_from( obj_t* a, obj_t* b )
@@ -1392,6 +1460,12 @@ BLIS_INLINE void bli_obj_init_subpart_from( obj_t* a, obj_t* b )
b->pd = a->pd;
b->m_panel = a->m_panel;
b->n_panel = a->n_panel;
b->user_data = a->user_data;
b->pack = a->pack;
b->ker = a->ker;
b->ukr = a->ukr;
}
// Initializors for global scalar constants.
@@ -1546,13 +1620,13 @@ typedef enum
BLIS_INVALID_COL_STRIDE = ( -51),
BLIS_INVALID_DIM_STRIDE_COMBINATION = ( -52),
// Structure-specific errors
// Structure-specific errors
BLIS_EXPECTED_GENERAL_OBJECT = ( -60),
BLIS_EXPECTED_HERMITIAN_OBJECT = ( -61),
BLIS_EXPECTED_SYMMETRIC_OBJECT = ( -62),
BLIS_EXPECTED_TRIANGULAR_OBJECT = ( -63),
// Storage-specific errors
// Storage-specific errors
BLIS_EXPECTED_UPPER_OR_LOWER_OBJECT = ( -70),
// Partitioning-specific errors
@@ -1566,7 +1640,7 @@ typedef enum
// Packing-specific errors
BLIS_PACK_SCHEMA_NOT_SUPPORTED_FOR_UNPACK = (-100),
// Buffer-specific errors
// Buffer-specific errors
BLIS_EXPECTED_NONNULL_OBJECT_BUFFER = (-110),
// Memory errors