Skip to content

Commit

Permalink
Defined lt, lte, gt, gte + misc. other updates. (#712)
Browse files Browse the repository at this point in the history
Details:
- Changed invertsc operation to be a non-destructive operation; that is,
  it now takes separate input and output operands. This change applies
  to both the object and typed APIs.
- Defined an alternative square root operation, sqrtrsc, which, when
  operating on complex scalars, assumes the imaginary part of the input
  to be zero.
- Changed the semantics of addm, subm, copym, axpym, scal2m, and xpbym 
  so that when the source matrix has an implicit unit diagonal, the
  operation leaves the diagonal of the destination matrix untouched.
  Previously, the operations would interpret an implicit unit diagonal
  on the source matrix as a request to manifest the unit diagonal
  *explicitly* on output (either as something to copy in the case of
  copym, or something to compute with in the cases of addm, subm, axpym,
  scal2m, and xpbym). It turns out that this behavior was too cute by
  half and could cause unintended headaches for practical use cases.
  (This change in behavior also required small modifications to the trmv
  and trsv testsuite modules so that they would properly test matrices
  with unit diagonals.)
- Added missing dependencies for copym to gemv, ger, hemv, trmv, and
  trsv testsuite modules.
- Implemented level-0-like ltsc, ltesc, gtsc, gtesc operations in
  frame/util, which use lt, lte, gt, and gte level-0 scalar macros.
- Trivial variable rename in bli_part.c to harmonize with other
  variable naming conventions.
  • Loading branch information
fgvanzee authored Jan 14, 2023
1 parent 9a366b1 commit 16d2e9e
Show file tree
Hide file tree
Showing 29 changed files with 379 additions and 114 deletions.
2 changes: 1 addition & 1 deletion examples/oapi/04level0.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ int main( int argc, char** argv )
bli_normfsc( &zeta, &alpha );
bli_printm( "alpha := normf( zeta ) # normf() = complex modulus in complex domain.", &alpha, "%4.1f", "" );

bli_invertsc( &gamma );
bli_invertsc( &gamma, &gamma );
bli_printm( "gamma := 1.0 / gamma", &gamma, "%4.2f", "" );


Expand Down
16 changes: 2 additions & 14 deletions frame/0/bli_l0_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,8 @@ GENFRONT( copysc )
GENFRONT( divsc )
GENFRONT( mulsc )
GENFRONT( sqrtsc )
GENFRONT( sqrtrsc )
GENFRONT( subsc )


#undef GENFRONT
#define GENFRONT( opname ) \
\
void PASTEMAC(opname,_check) \
( \
const obj_t* chi \
) \
{ \
bli_l0_xsc_check( chi ); \
}

GENFRONT( invertsc )


Expand Down Expand Up @@ -357,7 +345,7 @@ void bli_l0_xxbsc_check
(
const obj_t* chi,
const obj_t* psi,
const bool* is_eq
const bool* is
)
{
err_t e_val;
Expand Down
13 changes: 2 additions & 11 deletions frame/0/bli_l0_check.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,8 @@ GENTPROT( copysc )
GENTPROT( divsc )
GENTPROT( mulsc )
GENTPROT( sqrtsc )
GENTPROT( sqrtrsc )
GENTPROT( subsc )


#undef GENTPROT
#define GENTPROT( opname ) \
\
void PASTEMAC(opname,_check) \
( \
const obj_t* chi \
);

GENTPROT( invertsc )


Expand Down Expand Up @@ -152,5 +143,5 @@ void bli_l0_xxbsc_check
(
const obj_t* chi,
const obj_t* psi,
const bool* is_eq
const bool* is
);
1 change: 1 addition & 0 deletions frame/0/bli_l0_fpa.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ GENFRONT( mulsc )
GENFRONT( subsc )
GENFRONT( invertsc )
GENFRONT( sqrtsc )
GENFRONT( sqrtrsc )
GENFRONT( unzipsc )
GENFRONT( zipsc )

Expand Down
1 change: 1 addition & 0 deletions frame/0/bli_l0_fpa.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ GENPROT( mulsc )
GENPROT( subsc )
GENPROT( invertsc )
GENPROT( sqrtsc )
GENPROT( sqrtrsc )
GENPROT( unzipsc )
GENPROT( zipsc )

Expand Down
27 changes: 14 additions & 13 deletions frame/0/bli_l0_ft.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
// -- Level-0 function types ---------------------------------------------------
//

// addsc, divsc, subsc
// addsc, divsc, subsc, invertsc

#undef GENTDEF
#define GENTDEF( ctype, ch, opname, tsuf ) \
Expand All @@ -52,18 +52,6 @@ typedef void (*PASTECH2(ch,opname,tsuf)) \
INSERT_GENTDEF( addsc )
INSERT_GENTDEF( divsc )
INSERT_GENTDEF( subsc )

// invertsc

#undef GENTDEF
#define GENTDEF( ctype, ch, opname, tsuf ) \
\
typedef void (*PASTECH2(ch,opname,tsuf)) \
( \
conj_t conjchi, \
ctype* chi \
);

INSERT_GENTDEF( invertsc )

// mulsc
Expand Down Expand Up @@ -119,6 +107,19 @@ typedef void (*PASTECH2(ch,opname,tsuf)) \

INSERT_GENTDEF( sqrtsc )

// sqrtrsc

#undef GENTDEF
#define GENTDEF( ctype, ch, opname, tsuf ) \
\
typedef void (*PASTECH2(ch,opname,tsuf)) \
( \
const ctype* chi, \
ctype* psi \
);

INSERT_GENTDEF( sqrtrsc )

// getsc

#undef GENTDEF
Expand Down
33 changes: 1 addition & 32 deletions frame/0/bli_l0_oapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,38 +115,6 @@ GENFRONT( addsc )
GENFRONT( divsc )
GENFRONT( mulsc )
GENFRONT( subsc )


#undef GENFRONT
#define GENFRONT( opname ) \
\
void PASTEMAC0(opname) \
( \
const obj_t* chi \
) \
{ \
bli_init_once(); \
\
num_t dt = bli_obj_dt( chi ); \
\
conj_t conjchi = bli_obj_conj_status( chi ); \
\
void* buf_chi = bli_obj_buffer_for_1x1( dt, chi ); \
\
if ( bli_error_checking_is_enabled() ) \
PASTEMAC(opname,_check)( chi ); \
\
/* Query a type-specific function pointer, except one that uses
void* for function arguments instead of typed pointers. */ \
PASTECH(opname,_vft) f = PASTEMAC(opname,_qfp)( dt ); \
\
f \
( \
conjchi, \
buf_chi \
); \
}

GENFRONT( invertsc )


Expand Down Expand Up @@ -181,6 +149,7 @@ void PASTEMAC0(opname) \
}

GENFRONT( sqrtsc )
GENFRONT( sqrtrsc )


#undef GENFRONT
Expand Down
11 changes: 1 addition & 10 deletions frame/0/bli_l0_oapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,8 @@ GENPROT( addsc )
GENPROT( divsc )
GENPROT( mulsc )
GENPROT( sqrtsc )
GENPROT( sqrtrsc )
GENPROT( subsc )


#undef GENPROT
#define GENPROT( opname ) \
\
BLIS_EXPORT_BLIS void PASTEMAC0(opname) \
( \
const obj_t* chi \
);

GENPROT( invertsc )


Expand Down
26 changes: 23 additions & 3 deletions frame/0/bli_l0_tapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ INSERT_GENTFUNC_BASIC( subsc, subs )
\
void PASTEMAC(ch,opname) \
( \
conj_t conjchi, \
ctype* chi \
conj_t conjchi, \
const ctype* chi, \
ctype* psi \
) \
{ \
bli_init_once(); \
Expand All @@ -76,7 +77,7 @@ void PASTEMAC(ch,opname) \
\
PASTEMAC(ch,copycjs)( conjchi, *chi, chi_conj ); \
PASTEMAC(ch,kername)( chi_conj ); \
PASTEMAC(ch,copys)( chi_conj, *chi ); \
PASTEMAC(ch,copys)( chi_conj, *psi ); \
}

INSERT_GENTFUNC_BASIC( invertsc, inverts )
Expand Down Expand Up @@ -176,6 +177,25 @@ void PASTEMAC(ch,opname) \
INSERT_GENTFUNC_BASIC0( sqrtsc )


#undef GENTFUNCR
#define GENTFUNCR( ctype, ctype_r, ch, chr, opname ) \
\
void PASTEMAC(ch,opname) \
( \
const ctype* chi, \
ctype* psi \
) \
{ \
bli_init_once(); \
\
const ctype_r chi_r = PASTEMAC(ch,real)( *chi ); \
\
PASTEMAC2(chr,ch,sqrt2s)( chi_r, *psi ); \
}

INSERT_GENTFUNCR_BASIC0( sqrtrsc )


#undef GENTFUNC
#define GENTFUNC( ctype, ch, opname ) \
\
Expand Down
12 changes: 1 addition & 11 deletions frame/0/bli_l0_tapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,6 @@ INSERT_GENTPROT_BASIC0( addsc )
INSERT_GENTPROT_BASIC0( divsc )
INSERT_GENTPROT_BASIC0( mulsc )
INSERT_GENTPROT_BASIC0( subsc )


#undef GENTPROT
#define GENTPROT( ctype, ch, opname ) \
\
BLIS_EXPORT_BLIS void PASTEMAC(ch,opname) \
( \
conj_t conjchi, \
ctype* chi \
);

INSERT_GENTPROT_BASIC0( invertsc )


Expand All @@ -88,6 +77,7 @@ BLIS_EXPORT_BLIS void PASTEMAC(ch,opname) \
);

INSERT_GENTPROT_BASIC0( sqrtsc )
INSERT_GENTPROT_BASIC0( sqrtrsc )


#undef GENTPROT
Expand Down
30 changes: 30 additions & 0 deletions frame/1m/bli_l1m_tapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ void PASTEMAC2(ch,opname,EX_SUF) \
\
/* When the diagonal of an upper- or lower-stored matrix is unit,
we handle it with a separate post-processing step. */ \
/* NOTE: This code was disabled after I realized that when matrix A has the
properties of having a unit diagonal (and being lower or upper stored),
the operation should only read the strictly lower/upper triangle and
leave the diagonal of B untouched. */ \
/*
if ( bli_is_upper_or_lower( uplox ) && \
bli_is_unit_diag( diagx ) ) \
{ \
Expand All @@ -98,6 +103,7 @@ void PASTEMAC2(ch,opname,EX_SUF) \
rntm \
); \
} \
*/ \
}

INSERT_GENTFUNC_BASIC( addm, addd )
Expand Down Expand Up @@ -146,6 +152,11 @@ void PASTEMAC2(ch,opname,EX_SUF) \
\
/* When the diagonal of an upper- or lower-stored matrix is unit,
we handle it with a separate post-processing step. */ \
/* NOTE: This code was disabled after I realized that when matrix A has the
properties of having a unit diagonal (and being lower or upper stored),
the operation should only read the strictly lower/upper triangle and
leave the diagonal of B untouched. */ \
/*
if ( bli_is_upper_or_lower( uplox ) && \
bli_is_unit_diag( diagx ) ) \
{ \
Expand All @@ -167,6 +178,7 @@ void PASTEMAC2(ch,opname,EX_SUF) \
rntm \
); \
} \
*/ \
}

INSERT_GENTFUNC_BASIC0( copym )
Expand Down Expand Up @@ -219,6 +231,11 @@ void PASTEMAC2(ch,opname,EX_SUF) \
\
/* When the diagonal of an upper- or lower-stored matrix is unit,
we handle it with a separate post-processing step. */ \
/* NOTE: This code was disabled after I realized that when matrix A has the
properties of having a unit diagonal (and being lower or upper stored),
the operation should only read the strictly lower/upper triangle and
leave the diagonal of B untouched. */ \
/*
if ( bli_is_upper_or_lower( uplox ) && \
bli_is_unit_diag( diagx ) ) \
{ \
Expand All @@ -236,6 +253,7 @@ void PASTEMAC2(ch,opname,EX_SUF) \
rntm \
); \
} \
*/ \
}

INSERT_GENTFUNC_BASIC0( axpym )
Expand Down Expand Up @@ -307,6 +325,11 @@ void PASTEMAC2(ch,opname,EX_SUF) \
\
/* When the diagonal of an upper- or lower-stored matrix is unit,
we handle it with a separate post-processing step. */ \
/* NOTE: This code was disabled after I realized that when matrix A has the
properties of having a unit diagonal (and being lower or upper stored),
the operation should only read the strictly lower/upper triangle and
leave the diagonal of B untouched. */ \
/*
if ( bli_is_upper_or_lower( uplox ) && \
bli_is_unit_diag( diagx ) ) \
{ \
Expand All @@ -327,6 +350,7 @@ void PASTEMAC2(ch,opname,EX_SUF) \
rntm \
); \
} \
*/ \
}

INSERT_GENTFUNC_BASIC0( scal2m )
Expand Down Expand Up @@ -441,6 +465,11 @@ void PASTEMAC2(ch,opname,EX_SUF) \
\
/* When the diagonal of an upper- or lower-stored matrix is unit,
we handle it with a separate post-processing step. */ \
/* NOTE: This code was disabled after I realized that when matrix A has the
properties of having a unit diagonal (and being lower or upper stored),
the operation should only read the strictly lower/upper triangle and
leave the diagonal of B untouched. */ \
/*
if ( bli_is_upper_or_lower( uplox ) && \
bli_is_unit_diag( diagx ) ) \
{ \
Expand All @@ -458,6 +487,7 @@ void PASTEMAC2(ch,opname,EX_SUF) \
rntm \
); \
} \
*/ \
}

INSERT_GENTFUNC_BASIC0( xpbym )
Expand Down
Loading

0 comments on commit 16d2e9e

Please sign in to comment.