mirror of
https://github.com/amd/blis.git
synced 2026-04-19 23:28:52 +00:00
Defined a new level-1d operation: shiftd.
Details: - Defined a new level-1d operation called 'shiftd', including object and typed APIs. This operation adds a scalar value to every element along an arbitrary diagonal of a matrix. Currently, shiftd is implemented in terms of the addv kernel. (The scalar is passed in as the x vector with an increment of zero.) - Replaced ad-hoc usage of setd and addd (after creating a temporary matrix object) with use of shiftd, which is much more concise, in various test driver files in the testsuite. Similar changes were made to the standalone test drivers and the example code. - Added documentation entries in BLISObjectAPI.md and BLISTypedAPI.md for bli_shiftd() and bli_?shiftd(), respectively. - Added observed object properties to level-1d documentation in BLISObjectAPI.md.
This commit is contained in:
@@ -597,7 +597,7 @@ Notes for interpreting function descriptions:
|
||||
* **[Level-1v](BLISObjectAPI.md#level-1v-operations)**: Operations on vectors:
|
||||
* [addv](BLISObjectAPI.md#addv), [amaxv](BLISObjectAPI.md#amaxv), [axpyv](BLISObjectAPI.md#axpyv), [axpbyv](BLISObjectAPI.md#axpbyv), [copyv](BLISObjectAPI.md#copyv), [dotv](BLISObjectAPI.md#dotv), [dotxv](BLISObjectAPI.md#dotxv), [invertv](BLISObjectAPI.md#invertv), [scal2v](BLISObjectAPI.md#scal2v), [scalv](BLISObjectAPI.md#scalv), [setv](BLISObjectAPI.md#setv), [setrv](BLISObjectAPI.md#setrv), [setiv](BLISObjectAPI.md#setiv), [subv](BLISObjectAPI.md#subv), [swapv](BLISObjectAPI.md#swapv), [xpbyv](BLISObjectAPI.md#xpbyv)
|
||||
* **[Level-1d](BLISObjectAPI.md#level-1d-operations)**: Element-wise operations on matrix diagonals:
|
||||
* [addd](BLISObjectAPI.md#addd), [axpyd](BLISObjectAPI.md#axpyd), [copyd](BLISObjectAPI.md#copyd), [invertd](BLISObjectAPI.md#invertd), [scald](BLISObjectAPI.md#scald), [scal2d](BLISObjectAPI.md#scal2d), [setd](BLISObjectAPI.md#setd), [setid](BLISObjectAPI.md#setid), [subd](BLISObjectAPI.md#subd)
|
||||
* [addd](BLISObjectAPI.md#addd), [axpyd](BLISObjectAPI.md#axpyd), [copyd](BLISObjectAPI.md#copyd), [invertd](BLISObjectAPI.md#invertd), [scald](BLISObjectAPI.md#scald), [scal2d](BLISObjectAPI.md#scal2d), [setd](BLISObjectAPI.md#setd), [setid](BLISObjectAPI.md#setid), [shiftd](BLISObjectAPI.md#shiftd), [subd](BLISObjectAPI.md#subd)
|
||||
* **[Level-1m](BLISObjectAPI.md#level-1m-operations)**: Element-wise operations on matrices:
|
||||
* [addm](BLISObjectAPI.md#addm), [axpym](BLISObjectAPI.md#axpym), [copym](BLISObjectAPI.md#copym), [scalm](BLISObjectAPI.md#scalm), [scal2m](BLISObjectAPI.md#scal2m), [setm](BLISObjectAPI.md#setm), [setrm](BLISObjectAPI.md#setrm), [setim](BLISObjectAPI.md#setim), [subm](BLISObjectAPI.md#subm)
|
||||
* **[Level-1f](BLISObjectAPI.md#level-1f-operations)**: Fused operations on multiple vectors:
|
||||
@@ -771,6 +771,8 @@ Perform
|
||||
```
|
||||
where `x` is a vector of length _n_, and `alpha` is a scalar.
|
||||
|
||||
Observed object properties: `conj?(alpha)`.
|
||||
|
||||
---
|
||||
|
||||
#### scal2v
|
||||
@@ -788,6 +790,8 @@ Perform
|
||||
```
|
||||
where `x` and `y` are vectors of length _n_, and `alpha` is a scalar.
|
||||
|
||||
Observed object properties: `conj?(alpha)`, `conj?(x)`.
|
||||
|
||||
---
|
||||
|
||||
#### setv
|
||||
@@ -804,6 +808,8 @@ Perform
|
||||
```
|
||||
That is, set all elements of an _n_-length vector `x` to scalar `conj?(alpha)`.
|
||||
|
||||
Observed object properties: `conj?(alpha)`.
|
||||
|
||||
---
|
||||
|
||||
#### setrv
|
||||
@@ -856,6 +862,8 @@ Perform
|
||||
```
|
||||
where `x` and `y` are vectors of length _n_.
|
||||
|
||||
Observed object properties: `conj?(x)`.
|
||||
|
||||
---
|
||||
|
||||
#### swapv
|
||||
@@ -885,6 +893,8 @@ Perform
|
||||
```
|
||||
where `x` and `y` are vectors of length _n_, and `beta` is a scalar.
|
||||
|
||||
Observed object properties: `conj?(beta)`, `conj?(x)`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -908,6 +918,8 @@ void bli_addd
|
||||
);
|
||||
```
|
||||
|
||||
Observed object properties: `diagoff(A)`, `diag(A)`, `trans?(A)`.
|
||||
|
||||
---
|
||||
|
||||
#### axpyd
|
||||
@@ -920,6 +932,8 @@ void bli_axpyd
|
||||
);
|
||||
```
|
||||
|
||||
Observed object properties: `conj?(alpha)`, `diagoff(A)`, `diag(A)`, `trans?(A)`.
|
||||
|
||||
---
|
||||
|
||||
#### copyd
|
||||
@@ -931,6 +945,8 @@ void bli_copyd
|
||||
);
|
||||
```
|
||||
|
||||
Observed object properties: `diagoff(A)`, `diag(A)`, `trans?(A)`.
|
||||
|
||||
---
|
||||
|
||||
#### invertd
|
||||
@@ -941,6 +957,8 @@ void bli_invertd
|
||||
);
|
||||
```
|
||||
|
||||
Observed object properties: `diagoff(A)`.
|
||||
|
||||
---
|
||||
|
||||
#### scald
|
||||
@@ -952,6 +970,8 @@ void bli_scald
|
||||
);
|
||||
```
|
||||
|
||||
Observed object properties: `conj?(alpha)`, `diagoff(A)`.
|
||||
|
||||
---
|
||||
|
||||
#### scal2d
|
||||
@@ -964,6 +984,8 @@ void bli_scal2d
|
||||
);
|
||||
```
|
||||
|
||||
Observed object properties: `conj?(alpha)`, `diagoff(A)`, `diag(A)`, `trans?(A)`.
|
||||
|
||||
---
|
||||
|
||||
#### setd
|
||||
@@ -975,6 +997,8 @@ void bli_setd
|
||||
);
|
||||
```
|
||||
|
||||
Observed object properties: `conj?(alpha)`, `diagoff(A)`, `diag(A)`.
|
||||
|
||||
---
|
||||
|
||||
#### setid
|
||||
@@ -985,7 +1009,26 @@ void bli_setid
|
||||
obj_t* a
|
||||
);
|
||||
```
|
||||
Set the imaginary components of a matrix diagonal to a scalar `alpha`.
|
||||
Set the imaginary components of every element along the diagonal of `a`
|
||||
to a scalar `alpha`.
|
||||
Note that the datatype of `alpha` must be the real projection of the datatype
|
||||
of `a`.
|
||||
|
||||
Observed object properties: `diagoff(A)`.
|
||||
|
||||
---
|
||||
|
||||
#### shiftd
|
||||
```c
|
||||
void bli_shiftd
|
||||
(
|
||||
obj_t* alpha,
|
||||
obj_t* a
|
||||
);
|
||||
```
|
||||
Add a constant value `alpha` to every element along the diagonal of `a`.
|
||||
|
||||
Observed object properties: `diagoff(A)`.
|
||||
|
||||
---
|
||||
|
||||
@@ -998,6 +1041,8 @@ void bli_subd
|
||||
);
|
||||
```
|
||||
|
||||
Observed object properties: `diagoff(A)`, `diag(A)`, `trans?(A)`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ Notes for interpreting function descriptions:
|
||||
* **[Level-1v](BLISTypedAPI.md#level-1v-operations)**: Operations on vectors:
|
||||
* [addv](BLISTypedAPI.md#addv), [amaxv](BLISTypedAPI.md#amaxv), [axpyv](BLISTypedAPI.md#axpyv), [axpbyv](BLISTypedAPI.md#axpbyv), [copyv](BLISTypedAPI.md#copyv), [dotv](BLISTypedAPI.md#dotv), [dotxv](BLISTypedAPI.md#dotxv), [invertv](BLISTypedAPI.md#invertv), [scal2v](BLISTypedAPI.md#scal2v), [scalv](BLISTypedAPI.md#scalv), [setv](BLISTypedAPI.md#setv), [subv](BLISTypedAPI.md#subv), [swapv](BLISTypedAPI.md#swapv), [xpbyv](BLISTypedAPI.md#xpbyv)
|
||||
* **[Level-1d](BLISTypedAPI.md#level-1d-operations)**: Element-wise operations on matrix diagonals:
|
||||
* [addd](BLISTypedAPI.md#addd), [axpyd](BLISTypedAPI.md#axpyd), [copyd](BLISTypedAPI.md#copyd), [invertd](BLISTypedAPI.md#invertd), [scald](BLISTypedAPI.md#scald), [scal2d](BLISTypedAPI.md#scal2d), [setd](BLISTypedAPI.md#setd), [setid](BLISTypedAPI.md#setid), [subd](BLISTypedAPI.md#subd)
|
||||
* [addd](BLISTypedAPI.md#addd), [axpyd](BLISTypedAPI.md#axpyd), [copyd](BLISTypedAPI.md#copyd), [invertd](BLISTypedAPI.md#invertd), [scald](BLISTypedAPI.md#scald), [scal2d](BLISTypedAPI.md#scal2d), [setd](BLISTypedAPI.md#setd), [setid](BLISTypedAPI.md#setid), [shiftd](BLISObjectAPI.md#shiftd), [subd](BLISTypedAPI.md#subd)
|
||||
* **[Level-1m](BLISTypedAPI.md#level-1m-operations)**: Element-wise operations on matrices:
|
||||
* [addm](BLISTypedAPI.md#addm), [axpym](BLISTypedAPI.md#axpym), [copym](BLISTypedAPI.md#copym), [scalm](BLISTypedAPI.md#scalm), [scal2m](BLISTypedAPI.md#scal2m), [setm](BLISTypedAPI.md#setm), [subm](BLISTypedAPI.md#subm)
|
||||
* **[Level-1f](BLISTypedAPI.md#level-1f-operations)**: Fused operations on multiple vectors:
|
||||
@@ -476,7 +476,7 @@ where `x` and `y` are vectors of length _n_, and `beta` is a scalar.
|
||||
|
||||
Level-1d operations perform various level-1 BLAS-like operations on matrix diagonals (hence the _d_).
|
||||
|
||||
These operations are similar to their level-1m counterparts, except they only read and update matrix diagonals and therefore do not take any `uplo` arguments. Please see the descriptions for the corresponding level-1m operation for a description of the arguments.
|
||||
Most of these operations are similar to level-1m counterparts, except they only read and update matrix diagonals and therefore do not take any `uplo` arguments. Please see the descriptions for the corresponding level-1m operation for a description of the arguments.
|
||||
|
||||
---
|
||||
|
||||
@@ -592,6 +592,24 @@ void bli_?setd
|
||||
#### setid
|
||||
```c
|
||||
void bli_?setid
|
||||
(
|
||||
doff_t diagoffa,
|
||||
dim_t m,
|
||||
dim_t n,
|
||||
ctype_r* alpha,
|
||||
ctype* a, inc_t rsa, inc_t csa
|
||||
);
|
||||
```
|
||||
Set the imaginary components of every element along the diagonal of `a`, as
|
||||
specified by `diagoffa`, to a scalar `alpha`.
|
||||
Note that the datatype of `alpha` must be the real projection of the datatype
|
||||
of `a`.
|
||||
|
||||
---
|
||||
|
||||
#### shiftd
|
||||
```c
|
||||
void bli_?shiftd
|
||||
(
|
||||
doff_t diagoffa,
|
||||
dim_t m,
|
||||
@@ -600,7 +618,8 @@ void bli_?setid
|
||||
ctype* a, inc_t rsa, inc_t csa
|
||||
);
|
||||
```
|
||||
Set the imaginary components of a matrix diagonal to a scalar `alpha`.
|
||||
Add a constant value `alpha` to every element along the diagonal of `a`, as
|
||||
specified by `diagoffa`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ int main( int argc, char** argv )
|
||||
dim_t m, n;
|
||||
inc_t rs, cs;
|
||||
|
||||
obj_t a, x, y, b, d;
|
||||
obj_t a, x, y, b;
|
||||
obj_t* alpha;
|
||||
obj_t* beta;
|
||||
|
||||
@@ -297,9 +297,7 @@ int main( int argc, char** argv )
|
||||
// Load the diagonal. By setting the diagonal to something of greater
|
||||
// absolute value than the off-diagonal elements, we increase the odds
|
||||
// that the matrix is not singular (singular matrices have no inverse).
|
||||
bli_obj_create( dt, m, m, 0, 0, &d );
|
||||
bli_setd( &BLIS_TWO, &d );
|
||||
bli_addd( &d, &a );
|
||||
bli_shiftd( &BLIS_TWO, &a );
|
||||
|
||||
bli_printm( "a: randomized (zeros in upper triangle)", &a, "%4.1f", "" );
|
||||
bli_printm( "b: initial value", &b, "%4.1f", "" );
|
||||
@@ -320,7 +318,6 @@ int main( int argc, char** argv )
|
||||
// Free the objects.
|
||||
bli_obj_free( &a );
|
||||
bli_obj_free( &b );
|
||||
bli_obj_free( &d );
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -42,7 +42,7 @@ int main( int argc, char** argv )
|
||||
inc_t rs, cs;
|
||||
side_t side;
|
||||
|
||||
obj_t a, b, c, d;
|
||||
obj_t a, b, c;
|
||||
obj_t* alpha;
|
||||
obj_t* beta;
|
||||
|
||||
@@ -299,9 +299,7 @@ int main( int argc, char** argv )
|
||||
// Load the diagonal. By setting the diagonal to something of greater
|
||||
// absolute value than the off-diagonal elements, we increase the odds
|
||||
// that the matrix is not singular (singular matrices have no inverse).
|
||||
bli_obj_create( dt, m, m, 0, 0, &d );
|
||||
bli_setd( &BLIS_TWO, &d );
|
||||
bli_addd( &d, &a );
|
||||
bli_shiftd( &BLIS_TWO, &a );
|
||||
|
||||
bli_printm( "a: randomized (zeros in upper triangle)", &a, "%4.1f", "" );
|
||||
bli_printm( "b: initial value", &b, "%4.1f", "" );
|
||||
@@ -323,7 +321,6 @@ int main( int argc, char** argv )
|
||||
bli_obj_free( &a );
|
||||
bli_obj_free( &b );
|
||||
bli_obj_free( &c );
|
||||
bli_obj_free( &d );
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -41,7 +41,6 @@ int main( int argc, char** argv )
|
||||
double* x;
|
||||
double* y;
|
||||
double* b;
|
||||
double* d;
|
||||
double alpha, beta;
|
||||
dim_t m, n;
|
||||
inc_t rs, cs;
|
||||
@@ -286,10 +285,7 @@ int main( int argc, char** argv )
|
||||
// Load the diagonal. By setting the diagonal to something of greater
|
||||
// absolute value than the off-diagonal elements, we increase the odds
|
||||
// that the matrix is not singular (singular matrices have no inverse).
|
||||
d = malloc( m * m * sizeof( double ) );
|
||||
bli_dsetd( BLIS_NO_CONJUGATE, 0, m, m, &two, d, 1, m );
|
||||
bli_daddd( 0, BLIS_NONUNIT_DIAG, BLIS_NO_TRANSPOSE,
|
||||
m, m, d, 1, m, a, rs, cs );
|
||||
bli_dshiftd( 0, m, m, &two, a, rs, cs );
|
||||
|
||||
bli_dprintm( "a: randomized (zeros in upper triangle)", m, m, a, rs, cs, "%4.1f", "" );
|
||||
bli_dprintm( "b: intial value", 1, m, b, m, 1, "%4.1f", "" );
|
||||
|
||||
@@ -45,7 +45,6 @@ int main( int argc, char** argv )
|
||||
double* a;
|
||||
double* b;
|
||||
double* c;
|
||||
double* d;
|
||||
double alpha, beta;
|
||||
|
||||
// Initialize some basic constants.
|
||||
@@ -311,10 +310,7 @@ int main( int argc, char** argv )
|
||||
// Load the diagonal. By setting the diagonal to something of greater
|
||||
// absolute value than the off-diagonal elements, we increase the odds
|
||||
// that the matrix is not singular (singular matrices have no inverse).
|
||||
d = malloc( m * m * sizeof( double ) );
|
||||
bli_dsetd( BLIS_NO_CONJUGATE, 0, m, m, &two, d, 1, m );
|
||||
bli_daddd( 0, BLIS_NONUNIT_DIAG, BLIS_NO_TRANSPOSE,
|
||||
m, m, d, 1, m, a, rsa, csa );
|
||||
bli_dshiftd( 0, m, m, &two, a, rsa, csa );
|
||||
|
||||
bli_dprintm( "a: randomized (zeros in upper triangle)", m, m, a, rsa, csa, "%4.1f", "" );
|
||||
bli_dprintm( "b: initial value", m, n, b, rsb, csb, "%4.1f", "" );
|
||||
@@ -339,7 +335,6 @@ int main( int argc, char** argv )
|
||||
free( a );
|
||||
free( b );
|
||||
free( c );
|
||||
free( d );
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -101,6 +101,7 @@ void PASTEMAC(opname,_check) \
|
||||
GENFRONT( scald )
|
||||
GENFRONT( setd )
|
||||
GENFRONT( setid )
|
||||
GENFRONT( shiftd )
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -88,6 +88,7 @@ void PASTEMAC(opname,_check) \
|
||||
GENTPROT( scald )
|
||||
GENTPROT( setd )
|
||||
GENTPROT( setid )
|
||||
GENTPROT( shiftd )
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
@@ -59,4 +59,5 @@ GENFRONT( invertd )
|
||||
GENFRONT( scald )
|
||||
GENFRONT( setd )
|
||||
GENFRONT( setid )
|
||||
GENFRONT( shiftd )
|
||||
|
||||
|
||||
@@ -51,3 +51,4 @@ GENPROT( invertd )
|
||||
GENPROT( scald )
|
||||
GENPROT( setd )
|
||||
GENPROT( setid )
|
||||
GENPROT( shiftd )
|
||||
|
||||
@@ -131,3 +131,20 @@ typedef void (*PASTECH3(ch,opname,EX_SUF,tsuf)) \
|
||||
|
||||
INSERT_GENTDEFR( setid )
|
||||
|
||||
// shiftd
|
||||
|
||||
#undef GENTDEF
|
||||
#define GENTDEF( ctype, ch, opname, tsuf ) \
|
||||
\
|
||||
typedef void (*PASTECH3(ch,opname,EX_SUF,tsuf)) \
|
||||
( \
|
||||
doff_t diagoffx, \
|
||||
dim_t m, \
|
||||
dim_t n, \
|
||||
ctype* alpha, \
|
||||
ctype* x, inc_t rs_x, inc_t cs_x \
|
||||
BLIS_TAPI_EX_PARAMS \
|
||||
);
|
||||
|
||||
INSERT_GENTDEF( shiftd )
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ void PASTEMAC(opname,EX_SUF) \
|
||||
/* Create local copy-casts of scalars (and apply internal conjugation
|
||||
as needed). */ \
|
||||
bli_obj_scalar_init_detached_copy_of( dt, BLIS_NO_CONJUGATE, \
|
||||
alpha, &alpha_local ); \
|
||||
alpha, &alpha_local ); \
|
||||
buf_alpha = bli_obj_buffer_for_1x1( dt, &alpha_local ); \
|
||||
\
|
||||
/* Query a type-specific function pointer, except one that uses
|
||||
@@ -312,5 +312,61 @@ void PASTEMAC(opname,EX_SUF) \
|
||||
GENFRONT( setid )
|
||||
|
||||
|
||||
#undef GENFRONT
|
||||
#define GENFRONT( opname ) \
|
||||
\
|
||||
void PASTEMAC(opname,EX_SUF) \
|
||||
( \
|
||||
obj_t* alpha, \
|
||||
obj_t* x \
|
||||
BLIS_OAPI_EX_PARAMS \
|
||||
) \
|
||||
{ \
|
||||
bli_init_once(); \
|
||||
\
|
||||
BLIS_OAPI_EX_DECLS \
|
||||
\
|
||||
num_t dt = bli_obj_dt( x ); \
|
||||
\
|
||||
doff_t diagoffx = bli_obj_diag_offset( x ); \
|
||||
dim_t m = bli_obj_length( x ); \
|
||||
dim_t n = bli_obj_width( x ); \
|
||||
void* buf_x = bli_obj_buffer_at_off( x ); \
|
||||
inc_t rs_x = bli_obj_row_stride( x ); \
|
||||
inc_t cs_x = bli_obj_col_stride( x ); \
|
||||
\
|
||||
void* buf_alpha; \
|
||||
\
|
||||
obj_t alpha_local; \
|
||||
\
|
||||
if ( bli_error_checking_is_enabled() ) \
|
||||
PASTEMAC(opname,_check)( alpha, x ); \
|
||||
\
|
||||
/* Create local copy-casts of scalars (and apply internal conjugation
|
||||
as needed). */ \
|
||||
bli_obj_scalar_init_detached_copy_of( dt, BLIS_NO_CONJUGATE, \
|
||||
alpha, &alpha_local ); \
|
||||
buf_alpha = bli_obj_buffer_for_1x1( dt, &alpha_local ); \
|
||||
\
|
||||
/* Query a type-specific function pointer, except one that uses
|
||||
void* instead of typed pointers. */ \
|
||||
PASTECH2(opname,BLIS_TAPI_EX_SUF,_vft) f = \
|
||||
PASTEMAC2(opname,BLIS_TAPI_EX_SUF,_qfp)( dt ); \
|
||||
\
|
||||
f \
|
||||
( \
|
||||
diagoffx, \
|
||||
m, \
|
||||
n, \
|
||||
buf_alpha, \
|
||||
buf_x, rs_x, cs_x, \
|
||||
cntx, \
|
||||
rntm \
|
||||
); \
|
||||
}
|
||||
|
||||
GENFRONT( shiftd )
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -92,4 +92,5 @@ void PASTEMAC(opname,EX_SUF) \
|
||||
GENTPROT( scald )
|
||||
GENTPROT( setd )
|
||||
GENTPROT( setid )
|
||||
GENTPROT( shiftd )
|
||||
|
||||
|
||||
@@ -387,5 +387,63 @@ void PASTEMAC2(ch,opname,EX_SUF) \
|
||||
INSERT_GENTFUNCR_BASIC2( setid, setv, BLIS_SETV_KER )
|
||||
|
||||
|
||||
#undef GENTFUNC
|
||||
#define GENTFUNC( ctype, ch, opname, kername, kerid ) \
|
||||
\
|
||||
void PASTEMAC2(ch,opname,EX_SUF) \
|
||||
( \
|
||||
doff_t diagoffx, \
|
||||
dim_t m, \
|
||||
dim_t n, \
|
||||
ctype* alpha, \
|
||||
ctype* x, inc_t rs_x, inc_t cs_x \
|
||||
BLIS_TAPI_EX_PARAMS \
|
||||
) \
|
||||
{ \
|
||||
bli_init_once(); \
|
||||
\
|
||||
BLIS_TAPI_EX_DECLS \
|
||||
\
|
||||
const num_t dt = PASTEMAC(ch,type); \
|
||||
\
|
||||
ctype* x1; \
|
||||
dim_t n_elem; \
|
||||
dim_t offx; \
|
||||
inc_t incx; \
|
||||
\
|
||||
if ( bli_zero_dim2( m, n ) ) return; \
|
||||
\
|
||||
if ( bli_is_outside_diag( diagoffx, BLIS_NO_TRANSPOSE, m, n ) ) return; \
|
||||
\
|
||||
/* Determine the distance to the diagonals, the number of diagonal
|
||||
elements, and the diagonal increments. */ \
|
||||
bli_set_dims_incs_1d \
|
||||
( \
|
||||
diagoffx, \
|
||||
m, n, rs_x, cs_x, \
|
||||
&offx, &n_elem, &incx \
|
||||
); \
|
||||
\
|
||||
x1 = x + offx; \
|
||||
\
|
||||
/* Obtain a valid context from the gks if necessary. */ \
|
||||
if ( cntx == NULL ) cntx = bli_gks_query_cntx(); \
|
||||
\
|
||||
/* Query the context for the operation's kernel address. */ \
|
||||
PASTECH2(ch,kername,_ker_ft) f = bli_cntx_get_l1v_ker_dt( dt, kerid, cntx ); \
|
||||
\
|
||||
/* Invoke the kernel with the appropriate parameters. */ \
|
||||
f( \
|
||||
BLIS_NO_CONJUGATE, \
|
||||
n_elem, \
|
||||
alpha, 0, \
|
||||
x1, incx, \
|
||||
cntx \
|
||||
); \
|
||||
}
|
||||
|
||||
INSERT_GENTFUNC_BASIC2( shiftd, addv, BLIS_ADDV_KER )
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -125,3 +125,19 @@ void PASTEMAC2(ch,opname,EX_SUF) \
|
||||
|
||||
INSERT_GENTPROTR_BASIC0( setid )
|
||||
|
||||
|
||||
#undef GENTPROT
|
||||
#define GENTPROT( ctype, ch, opname ) \
|
||||
\
|
||||
void PASTEMAC2(ch,opname,EX_SUF) \
|
||||
( \
|
||||
doff_t diagoffx, \
|
||||
dim_t m, \
|
||||
dim_t n, \
|
||||
ctype* alpha, \
|
||||
ctype* x, inc_t rs_x, inc_t cs_x \
|
||||
BLIS_TAPI_EX_PARAMS \
|
||||
);
|
||||
|
||||
INSERT_GENTPROT_BASIC0( shiftd )
|
||||
|
||||
|
||||
@@ -42,6 +42,27 @@ void zgemm3m_( f77_char*, f77_char*, f77_int*, f77_int*, f77_int*, dcomplex*, dc
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
obj_t kappa, d;
|
||||
num_t dtd = BLIS_DCOMPLEX;
|
||||
|
||||
bli_obj_create( dtd, 1, 1, 0, 0, &kappa );
|
||||
|
||||
bli_setsc( (2.0/1.0), -0.5, &kappa );
|
||||
|
||||
bli_obj_create( dtd, 5, 3, 0, 0, &d );
|
||||
bli_randm( &d );
|
||||
|
||||
bli_printm( "d", &d, "%7.3f", "" );
|
||||
|
||||
bli_shiftd( &kappa, &d );
|
||||
|
||||
bli_printm( "d after", &d, "%7.3f", "" );
|
||||
|
||||
bli_obj_free( &kappa );
|
||||
bli_obj_free( &d );
|
||||
|
||||
return 0;
|
||||
|
||||
obj_t a, b, c;
|
||||
obj_t c_save;
|
||||
obj_t alpha, beta;
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
obj_t a, c, d;
|
||||
obj_t a, c;
|
||||
obj_t c_save;
|
||||
obj_t alpha;
|
||||
dim_t m, n;
|
||||
@@ -163,11 +163,6 @@ int main( int argc, char** argv )
|
||||
//bli_obj_create( dt, m, n, n, 1, &c );
|
||||
bli_obj_create( dt, m, n, 0, 0, &c_save );
|
||||
|
||||
if ( bli_does_trans( side ) )
|
||||
bli_obj_create( dt, m, m, 0, 0, &d );
|
||||
else
|
||||
bli_obj_create( dt, n, n, 0, 0, &d );
|
||||
|
||||
bli_randm( &a );
|
||||
bli_randm( &c );
|
||||
|
||||
@@ -179,8 +174,8 @@ int main( int argc, char** argv )
|
||||
bli_randm( &a );
|
||||
bli_mktrim( &a );
|
||||
|
||||
bli_setd( &BLIS_TWO, &d );
|
||||
bli_addd( &d, &a );
|
||||
// Load the diagonal of A to make it more likely to be invertible.
|
||||
bli_shiftd( &BLIS_TWO, &a );
|
||||
|
||||
bli_setsc( (2.0/1.0), 0.0, &alpha );
|
||||
|
||||
@@ -328,7 +323,6 @@ int main( int argc, char** argv )
|
||||
bli_obj_free( &a );
|
||||
bli_obj_free( &c );
|
||||
bli_obj_free( &c_save );
|
||||
bli_obj_free( &d );
|
||||
}
|
||||
|
||||
//bli_finalize();
|
||||
|
||||
@@ -144,13 +144,14 @@ int main( int argc, char** argv )
|
||||
bli_obj_set_conjtrans( transa, &a );
|
||||
bli_obj_set_diag( diaga, &a );
|
||||
|
||||
// Randomize A, make it densely Hermitian, and zero the unstored
|
||||
// triangle to ensure the implementation reads only from the stored
|
||||
// region.
|
||||
// Randomize A and zero the unstored triangle to ensure the
|
||||
// implementation reads only from the stored region.
|
||||
bli_randm( &a );
|
||||
bli_mkherm( &a );
|
||||
bli_mktrim( &a );
|
||||
|
||||
// Load the diagonal of A to make it more likely to be invertible.
|
||||
bli_shiftd( &BLIS_TWO, &a );
|
||||
|
||||
bli_setsc( (2.0/1.0), 1.0, &alpha );
|
||||
|
||||
|
||||
|
||||
@@ -114,6 +114,14 @@ int main( int argc, char** argv )
|
||||
bli_obj_set_onlytrans( BLIS_NO_TRANSPOSE, &a );
|
||||
bli_obj_set_diag( BLIS_NONUNIT_DIAG, &a );
|
||||
|
||||
// Randomize A and zero the unstored triangle to ensure the
|
||||
// implementation reads only from the stored region.
|
||||
bli_randm( &a );
|
||||
bli_mktrim( &a );
|
||||
|
||||
// Load the diagonal of A to make it more likely to be invertible.
|
||||
bli_shiftd( &BLIS_TWO, &a );
|
||||
|
||||
bli_setsc( (1.0/1.0), 0.0, &alpha );
|
||||
|
||||
|
||||
|
||||
@@ -2291,21 +2291,10 @@ void libblis_test_ceil_pow2( obj_t* alpha )
|
||||
|
||||
void libblis_test_mobj_load_diag( test_params_t* params, obj_t* a )
|
||||
{
|
||||
num_t dt = bli_obj_dt( a );
|
||||
dim_t m = bli_obj_length( a );
|
||||
dim_t n = bli_obj_width( a );
|
||||
|
||||
obj_t d;
|
||||
|
||||
// We assume that all elements of a were intialized on interval [-1,1].
|
||||
|
||||
bli_obj_create( dt, m, n, 0, 0, &d );
|
||||
|
||||
// Initialize the diagonal of d to 2.0 and then add the diagonal of a.
|
||||
bli_setd( &BLIS_TWO, &d );
|
||||
bli_addd( &d, a );
|
||||
|
||||
bli_obj_free( &d );
|
||||
// Load the diagonal by 2.0.
|
||||
bli_shiftd( &BLIS_TWO, a );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user