mirror of
https://github.com/amd/blis.git
synced 2026-04-19 23:28:52 +00:00
Renamed/moved object scalar constant macros.
Details: - Replaced scalar constant macro definitions in bli_const_defs.h with a single, simplier macro in bli_obj_macro_defs.h. - Updated invocations of old macros accordingly. - Removed bli_const_defs.h.
This commit is contained in:
@@ -273,19 +273,19 @@ void bli_obj_create_const( double value, obj_t* obj )
|
||||
|
||||
bli_obj_create( BLIS_CONSTANT, 1, 1, 1, 1, obj );
|
||||
|
||||
temp_i = BLIS_CONST_I_PTR( *obj );
|
||||
temp_s = BLIS_CONST_S_PTR( *obj );
|
||||
temp_d = BLIS_CONST_D_PTR( *obj );
|
||||
temp_c = BLIS_CONST_C_PTR( *obj );
|
||||
temp_z = BLIS_CONST_Z_PTR( *obj );
|
||||
temp_s = bli_obj_buffer_for_const( BLIS_FLOAT, *obj );
|
||||
temp_d = bli_obj_buffer_for_const( BLIS_DOUBLE, *obj );
|
||||
temp_c = bli_obj_buffer_for_const( BLIS_SCOMPLEX, *obj );
|
||||
temp_z = bli_obj_buffer_for_const( BLIS_DCOMPLEX, *obj );
|
||||
temp_i = bli_obj_buffer_for_const( BLIS_INT, *obj );
|
||||
|
||||
*temp_i = ( int ) value;
|
||||
*temp_s = ( float ) value;
|
||||
*temp_d = value;
|
||||
temp_c->real = ( float ) value;
|
||||
temp_c->imag = ( float ) 0.0;
|
||||
temp_z->real = value;
|
||||
temp_z->imag = 0.0;
|
||||
*temp_i = ( int ) value;
|
||||
}
|
||||
|
||||
void bli_obj_create_const_copy_of( obj_t* a, obj_t* b )
|
||||
@@ -302,11 +302,11 @@ void bli_obj_create_const_copy_of( obj_t* a, obj_t* b )
|
||||
|
||||
bli_obj_create( BLIS_CONSTANT, 1, 1, 1, 1, b );
|
||||
|
||||
temp_i = BLIS_CONST_I_PTR( *b );
|
||||
temp_s = BLIS_CONST_S_PTR( *b );
|
||||
temp_d = BLIS_CONST_D_PTR( *b );
|
||||
temp_c = BLIS_CONST_C_PTR( *b );
|
||||
temp_z = BLIS_CONST_Z_PTR( *b );
|
||||
temp_s = bli_obj_buffer_for_const( BLIS_FLOAT, *b );
|
||||
temp_d = bli_obj_buffer_for_const( BLIS_DOUBLE, *b );
|
||||
temp_c = bli_obj_buffer_for_const( BLIS_SCOMPLEX, *b );
|
||||
temp_z = bli_obj_buffer_for_const( BLIS_DCOMPLEX, *b );
|
||||
temp_i = bli_obj_buffer_for_const( BLIS_INT, *b );
|
||||
|
||||
value.real = 0.0;
|
||||
value.imag = 0.0;
|
||||
@@ -333,16 +333,16 @@ void bli_obj_create_const_copy_of( obj_t* a, obj_t* b )
|
||||
}
|
||||
else
|
||||
{
|
||||
bli_abort();
|
||||
bli_check_error_code( BLIS_NOT_YET_IMPLEMENTED );
|
||||
}
|
||||
|
||||
*temp_i = ( int ) value.real;
|
||||
*temp_s = ( float ) value.real;
|
||||
*temp_d = value.real;
|
||||
temp_c->real = ( float ) value.real;
|
||||
temp_c->imag = ( float ) value.imag;
|
||||
temp_z->real = value.real;
|
||||
temp_z->imag = value.imag;
|
||||
*temp_i = ( int ) value.real;
|
||||
}
|
||||
|
||||
void bli_adjust_strides( dim_t m,
|
||||
|
||||
@@ -50,7 +50,12 @@ bli_printm( "b:", b, "%9.2e", "" );
|
||||
dt_a = bli_obj_datatype( *a );
|
||||
dt_b = bli_obj_datatype( *b );
|
||||
|
||||
if ( dt_a != BLIS_CONSTANT ) dt = dt_a;
|
||||
//if ( dt_a != BLIS_CONSTANT && dt_b != BLIS_CONSTANT ) dt = dt_a;
|
||||
//else if ( dt_a != BLIS_CONSTANT && dt_b == BLIS_CONSTANT ) dt = dt_a;
|
||||
//else if ( dt_a == BLIS_CONSTANT && dt_b != BLIS_CONSTANT ) dt = dt_b;
|
||||
//else if ( dt_a == BLIS_CONSTANT && dt_b == BLIS_CONSTANT ) dt = dt_a;
|
||||
|
||||
if ( dt_b == BLIS_CONSTANT ) dt = dt_a;
|
||||
else dt = dt_b;
|
||||
|
||||
buf_a = bli_obj_scalar_buffer( dt, *a );
|
||||
@@ -64,12 +69,20 @@ printf( "bufb: %p\n", buf_b );
|
||||
*/
|
||||
if ( dt == BLIS_CONSTANT )
|
||||
{
|
||||
r_val = r_val || ( *BLIS_CONST_S_PTR( *a ) == *BLIS_CONST_S_PTR( *b ) );
|
||||
r_val = r_val || ( *BLIS_CONST_D_PTR( *a ) == *BLIS_CONST_D_PTR( *b ) );
|
||||
r_val = r_val || ( BLIS_CONST_C_PTR( *a )->real == BLIS_CONST_C_PTR( *b )->real &&
|
||||
BLIS_CONST_C_PTR( *a )->imag == BLIS_CONST_C_PTR( *b )->imag );
|
||||
r_val = r_val || ( BLIS_CONST_Z_PTR( *a )->real == BLIS_CONST_Z_PTR( *b )->real &&
|
||||
BLIS_CONST_Z_PTR( *a )->imag == BLIS_CONST_Z_PTR( *b )->imag );
|
||||
float* ap_s = bli_obj_buffer_for_const( BLIS_FLOAT, *a );
|
||||
double* ap_d = bli_obj_buffer_for_const( BLIS_DOUBLE, *a );
|
||||
scomplex* ap_c = bli_obj_buffer_for_const( BLIS_SCOMPLEX, *a );
|
||||
dcomplex* ap_z = bli_obj_buffer_for_const( BLIS_DCOMPLEX, *a );
|
||||
|
||||
float* bp_s = bli_obj_buffer_for_const( BLIS_FLOAT, *b );
|
||||
double* bp_d = bli_obj_buffer_for_const( BLIS_DOUBLE, *b );
|
||||
scomplex* bp_c = bli_obj_buffer_for_const( BLIS_SCOMPLEX, *b );
|
||||
dcomplex* bp_z = bli_obj_buffer_for_const( BLIS_DCOMPLEX, *b );
|
||||
|
||||
r_val = r_val || ( *ap_s == *bp_s );
|
||||
r_val = r_val || ( *ap_d == *bp_d );
|
||||
r_val = r_val || ( ap_c->real == bp_c->real && ap_c->imag == bp_c->imag );
|
||||
r_val = r_val || ( ap_z->real == bp_z->real && ap_z->imag == bp_z->imag );
|
||||
}
|
||||
else if ( dt == BLIS_FLOAT ) r_val = bli_seqa( buf_a, buf_b );
|
||||
else if ( dt == BLIS_DOUBLE ) r_val = bli_deqa( buf_a, buf_b );
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
|
||||
BLIS
|
||||
An object-based framework for developing high-performance BLAS-like
|
||||
libraries.
|
||||
|
||||
Copyright (C) 2013, The University of Texas
|
||||
|
||||
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 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_CONST_DEFS_H
|
||||
#define BLIS_CONST_DEFS_H
|
||||
|
||||
#define BLIS_CONSTANT_S_OFFSET BLIS_BITVAL_FLOAT_TYPE
|
||||
#define BLIS_CONSTANT_C_OFFSET BLIS_BITVAL_SCOMPLEX_TYPE
|
||||
#define BLIS_CONSTANT_D_OFFSET BLIS_BITVAL_DOUBLE_TYPE
|
||||
#define BLIS_CONSTANT_Z_OFFSET BLIS_BITVAL_DCOMPLEX_TYPE
|
||||
#define BLIS_CONSTANT_I_OFFSET BLIS_BITVAL_INT_TYPE
|
||||
#define BLIS_CONSTANT_SLOT_SIZE sizeof(dcomplex)
|
||||
|
||||
#define BLIS_CONSTANT_SIZE ( 5 * BLIS_CONSTANT_SLOT_SIZE )
|
||||
|
||||
#define BLIS_CONST_S_PTR( x ) \
|
||||
( ( float* ) ( ( ( char * ) ((x).buffer ) + BLIS_CONSTANT_S_OFFSET * \
|
||||
BLIS_CONSTANT_SLOT_SIZE ) ) )
|
||||
#define BLIS_CONST_D_PTR( x ) \
|
||||
( ( double* ) ( ( ( char * ) ((x).buffer ) + BLIS_CONSTANT_D_OFFSET * \
|
||||
BLIS_CONSTANT_SLOT_SIZE ) ) )
|
||||
#define BLIS_CONST_C_PTR( x ) \
|
||||
( ( scomplex* ) ( ( ( char * ) ((x).buffer ) + BLIS_CONSTANT_C_OFFSET * \
|
||||
BLIS_CONSTANT_SLOT_SIZE ) ) )
|
||||
#define BLIS_CONST_Z_PTR( x ) \
|
||||
( ( dcomplex* ) ( ( ( char * ) ((x).buffer ) + BLIS_CONSTANT_Z_OFFSET * \
|
||||
BLIS_CONSTANT_SLOT_SIZE ) ) )
|
||||
#define BLIS_CONST_I_PTR( x ) \
|
||||
( ( int * ) ( ( ( char * ) ((x).buffer ) + BLIS_CONSTANT_I_OFFSET * \
|
||||
BLIS_CONSTANT_SLOT_SIZE ) ) )
|
||||
|
||||
#endif
|
||||
@@ -847,18 +847,29 @@ bli_obj_width_stored( obj )
|
||||
|
||||
|
||||
|
||||
// Submatrix acquisition
|
||||
// Submatrix/scalar buffer acquisition
|
||||
|
||||
#define BLIS_CONSTANT_SLOT_SIZE sizeof(dcomplex)
|
||||
#define BLIS_CONSTANT_SIZE ( 5 * BLIS_CONSTANT_SLOT_SIZE )
|
||||
|
||||
#define bli_obj_buffer_for_const( dt, obj ) \
|
||||
\
|
||||
( void* )( \
|
||||
( ( char* )( (obj).buffer ) ) + dt * BLIS_CONSTANT_SLOT_SIZE \
|
||||
)
|
||||
|
||||
#define bli_obj_buffer_at_off( obj ) \
|
||||
\
|
||||
( void* )( ( ( char* ) (obj).buffer ) + (obj).elem_size * ( (obj).offn * (obj).cs + \
|
||||
(obj).offm * (obj).rs ) \
|
||||
( void* )( \
|
||||
( ( char* )( (obj).buffer ) ) + (obj).elem_size * \
|
||||
( (obj).offn * (obj).cs + \
|
||||
(obj).offm * (obj).rs ) \
|
||||
)
|
||||
|
||||
#define bli_obj_scalar_buffer( dt, obj ) \
|
||||
\
|
||||
( void* )( bli_obj_is_const( obj ) ? ( ( char* ) (obj).buffer ) + ( (dt) * BLIS_CONSTANT_SLOT_SIZE ) \
|
||||
: (obj).buffer \
|
||||
( void* )( bli_obj_is_const( obj ) ? ( bli_obj_buffer_for_const( dt, obj ) ) \
|
||||
: ( bli_obj_buffer_at_off( obj ) ) \
|
||||
)
|
||||
|
||||
// Swap object pointers
|
||||
|
||||
@@ -68,7 +68,6 @@ extern "C" {
|
||||
|
||||
#include "bli_type_defs.h"
|
||||
#include "bli_macro_defs.h"
|
||||
#include "bli_const_defs.h"
|
||||
#include "bli_extern_defs.h"
|
||||
|
||||
|
||||
|
||||
@@ -41,112 +41,111 @@
|
||||
|
||||
#define bli_s2 \
|
||||
\
|
||||
( BLIS_CONST_S_PTR( BLIS_TWO ) )
|
||||
( ( float* ) bli_obj_buffer_for_const( BLIS_FLOAT, BLIS_TWO ) )
|
||||
|
||||
#define bli_d2 \
|
||||
\
|
||||
( BLIS_CONST_D_PTR( BLIS_TWO ) )
|
||||
( ( double* ) bli_obj_buffer_for_const( BLIS_DOUBLE, BLIS_TWO ) )
|
||||
|
||||
#define bli_c2 \
|
||||
\
|
||||
( BLIS_CONST_C_PTR( BLIS_TWO ) )
|
||||
( ( scomplex* ) bli_obj_buffer_for_const( BLIS_SCOMPLEX, BLIS_TWO ) )
|
||||
|
||||
#define bli_z2 \
|
||||
\
|
||||
( BLIS_CONST_Z_PTR( BLIS_TWO ) )
|
||||
( ( dcomplex* ) bli_obj_buffer_for_const( BLIS_DCOMPLEX, BLIS_TWO ) )
|
||||
|
||||
#define bli_i2 \
|
||||
\
|
||||
( BLIS_CONST_I_PTR( BLIS_TWO ) )
|
||||
( ( int* ) bli_obj_buffer_for_const( BLIS_INT, BLIS_TWO ) )
|
||||
|
||||
// 1
|
||||
|
||||
#define bli_s1 \
|
||||
\
|
||||
( BLIS_CONST_S_PTR( BLIS_ONE ) )
|
||||
( ( float* ) bli_obj_buffer_for_const( BLIS_FLOAT, BLIS_ONE ) )
|
||||
|
||||
#define bli_d1 \
|
||||
\
|
||||
( BLIS_CONST_D_PTR( BLIS_ONE ) )
|
||||
( ( double* ) bli_obj_buffer_for_const( BLIS_DOUBLE, BLIS_ONE ) )
|
||||
|
||||
#define bli_c1 \
|
||||
\
|
||||
( BLIS_CONST_C_PTR( BLIS_ONE ) )
|
||||
( ( scomplex* ) bli_obj_buffer_for_const( BLIS_SCOMPLEX, BLIS_ONE ) )
|
||||
|
||||
#define bli_z1 \
|
||||
\
|
||||
( BLIS_CONST_Z_PTR( BLIS_ONE ) )
|
||||
( ( dcomplex* ) bli_obj_buffer_for_const( BLIS_DCOMPLEX, BLIS_ONE ) )
|
||||
|
||||
#define bli_i1 \
|
||||
\
|
||||
( BLIS_CONST_I_PTR( BLIS_ONE ) )
|
||||
( ( int* ) bli_obj_buffer_for_const( BLIS_INT, BLIS_ONE ) )
|
||||
|
||||
// 0
|
||||
|
||||
#define bli_s0 \
|
||||
\
|
||||
( BLIS_CONST_S_PTR( BLIS_ZERO ) )
|
||||
( ( float* ) bli_obj_buffer_for_const( BLIS_FLOAT, BLIS_ZERO ) )
|
||||
|
||||
#define bli_d0 \
|
||||
\
|
||||
( BLIS_CONST_D_PTR( BLIS_ZERO ) )
|
||||
( ( double* ) bli_obj_buffer_for_const( BLIS_DOUBLE, BLIS_ZERO ) )
|
||||
|
||||
#define bli_c0 \
|
||||
\
|
||||
( BLIS_CONST_C_PTR( BLIS_ZERO ) )
|
||||
( ( scomplex* ) bli_obj_buffer_for_const( BLIS_SCOMPLEX, BLIS_ZERO ) )
|
||||
|
||||
#define bli_z0 \
|
||||
\
|
||||
( BLIS_CONST_Z_PTR( BLIS_ZERO ) )
|
||||
( ( dcomplex* ) bli_obj_buffer_for_const( BLIS_DCOMPLEX, BLIS_ZERO ) )
|
||||
|
||||
#define bli_i0 \
|
||||
\
|
||||
( BLIS_CONST_I_PTR( BLIS_ZERO ) )
|
||||
( ( int* ) bli_obj_buffer_for_const( BLIS_INT, BLIS_ZERO ) )
|
||||
|
||||
// -1
|
||||
|
||||
#define bli_sm1 \
|
||||
\
|
||||
( BLIS_CONST_S_PTR( BLIS_MINUS_ONE ) )
|
||||
( ( float* ) bli_obj_buffer_for_const( BLIS_FLOAT, BLIS_MINUS_ONE ) )
|
||||
|
||||
#define bli_dm1 \
|
||||
\
|
||||
( BLIS_CONST_D_PTR( BLIS_MINUS_ONE ) )
|
||||
( ( double* ) bli_obj_buffer_for_const( BLIS_DOUBLE, BLIS_MINUS_ONE ) )
|
||||
|
||||
#define bli_cm1 \
|
||||
\
|
||||
( BLIS_CONST_C_PTR( BLIS_MINUS_ONE ) )
|
||||
( ( scomplex* ) bli_obj_buffer_for_const( BLIS_SCOMPLEX, BLIS_MINUS_ONE ) )
|
||||
|
||||
#define bli_zm1 \
|
||||
\
|
||||
( BLIS_CONST_Z_PTR( BLIS_MINUS_ONE ) )
|
||||
( ( dcomplex* ) bli_obj_buffer_for_const( BLIS_DCOMPLEX, BLIS_MINUS_ONE ) )
|
||||
|
||||
#define bli_im1 \
|
||||
\
|
||||
( BLIS_CONST_I_PTR( BLIS_MINUS_ONE ) )
|
||||
( ( int* ) bli_obj_buffer_for_const( BLIS_INT, BLIS_MINUS_ONE ) )
|
||||
|
||||
// -2
|
||||
|
||||
#define bli_sm2 \
|
||||
\
|
||||
( BLIS_CONST_S_PTR( BLIS_MINUS_TWO ) )
|
||||
( ( float* ) bli_obj_buffer_for_const( BLIS_FLOAT, BLIS_MINUS_TWO ) )
|
||||
|
||||
#define bli_dm2 \
|
||||
\
|
||||
( BLIS_CONST_D_PTR( BLIS_MINUS_TWO ) )
|
||||
( ( double* ) bli_obj_buffer_for_const( BLIS_DOUBLE, BLIS_MINUS_TWO ) )
|
||||
|
||||
#define bli_cm2 \
|
||||
\
|
||||
( BLIS_CONST_C_PTR( BLIS_MINUS_TWO ) )
|
||||
( ( scomplex* ) bli_obj_buffer_for_const( BLIS_SCOMPLEX, BLIS_MINUS_TWO ) )
|
||||
|
||||
#define bli_zm2 \
|
||||
\
|
||||
( BLIS_CONST_Z_PTR( BLIS_MINUS_TWO ) )
|
||||
( ( dcomplex* ) bli_obj_buffer_for_const( BLIS_DCOMPLEX, BLIS_MINUS_TWO ) )
|
||||
|
||||
#define bli_im2 \
|
||||
\
|
||||
( BLIS_CONST_I_PTR( BLIS_MINUS_TWO ) )
|
||||
|
||||
( ( int* ) bli_obj_buffer_for_const( BLIS_INT, BLIS_MINUS_TWO ) )
|
||||
|
||||
// set to constant
|
||||
|
||||
|
||||
@@ -65,11 +65,11 @@ void bli_fprintm( FILE* file, char* s1, obj_t* x, char* format, char* s2 )
|
||||
// Handle constants up front.
|
||||
if ( dt_x == BLIS_CONSTANT )
|
||||
{
|
||||
float* sp = BLIS_CONST_S_PTR( *x );
|
||||
double* dp = BLIS_CONST_D_PTR( *x );
|
||||
scomplex* cp = BLIS_CONST_C_PTR( *x );
|
||||
dcomplex* zp = BLIS_CONST_Z_PTR( *x );
|
||||
int* ip = BLIS_CONST_I_PTR( *x );
|
||||
float* sp = bli_obj_buffer_for_const( BLIS_FLOAT, *x );
|
||||
double* dp = bli_obj_buffer_for_const( BLIS_DOUBLE, *x );
|
||||
scomplex* cp = bli_obj_buffer_for_const( BLIS_SCOMPLEX, *x );
|
||||
dcomplex* zp = bli_obj_buffer_for_const( BLIS_DCOMPLEX, *x );
|
||||
int* ip = bli_obj_buffer_for_const( BLIS_INT, *x );
|
||||
|
||||
fprintf( file, "%s\n", s1 );
|
||||
fprintf( file, " float: %9.2e\n", *sp );
|
||||
|
||||
Reference in New Issue
Block a user