diff --git a/README.md b/README.md index 1d9a5123a..c654c1104 100644 --- a/README.md +++ b/README.md @@ -188,7 +188,7 @@ This wiki contains detailed instructions on running the BLIS test suite, located in the top-level directory testsuite. Also included: a walkthrough of the BLAS test drivers, which exercise the BLAS compatibility layer that is, by default, included in BLIS. - * [Release Notes](https://github.com/flame/blis/wiki/ReleaseNotes). + * [Release notes](https://github.com/flame/blis/wiki/ReleaseNotes). This wiki contains a summary of new features provided by each new tagged version (release) of BLIS, along with the date the release. diff --git a/common.mk b/common.mk index 85480a271..1ea1128a4 100644 --- a/common.mk +++ b/common.mk @@ -224,7 +224,7 @@ KERNELS_PATH := $(DIST_PATH)/$(KERNELS_DIR) LIBBLIS_NAME := libblis # Construct the base path for the library. -BASE_LIB_PATH := ./$(LIB_DIR)/$(CONFIG_NAME) +BASE_LIB_PATH := $(LIB_DIR)/$(CONFIG_NAME) # Note: These names will be modified later to include the configuration and # version strings. diff --git a/frame/0/copysc/bli_copysc.c b/frame/0/copysc/bli_copysc.c index 6be9e3eed..c3a1c6609 100644 --- a/frame/0/copysc/bli_copysc.c +++ b/frame/0/copysc/bli_copysc.c @@ -39,11 +39,12 @@ // an operation that can be used to typecast (copy-cast) a scalar // of one datatype to a scalar of another datatype. -typedef void (*FUNCPTR_T)( - conj_t conjchi, - void* chi, - void* psi - ); +typedef void (*FUNCPTR_T) + ( + conj_t conjchi, + void* chi, + void* psi + ); static FUNCPTR_T GENARRAY2_ALL(ftypes,copysc); diff --git a/frame/base/bli_machval.c b/frame/base/bli_machval.c index 79137070f..e7fd6c738 100644 --- a/frame/base/bli_machval.c +++ b/frame/base/bli_machval.c @@ -72,10 +72,11 @@ void bli_machval( machval_t mval, #undef GENTFUNCR #define GENTFUNCR( ctype_v, ctype_vr, chv, chvr, opname, varname ) \ \ -void PASTEMAC(chv,opname)( \ - machval_t mval, \ - void* v \ - ) \ +void PASTEMAC(chv,opname) \ + ( \ + machval_t mval, \ + void* v \ + ) \ { \ static ctype_vr pvals[ BLIS_NUM_MACH_PARAMS ]; \ \ diff --git a/frame/base/bli_machval.h b/frame/base/bli_machval.h index bf3ae3c48..3f2b39551 100644 --- a/frame/base/bli_machval.h +++ b/frame/base/bli_machval.h @@ -49,10 +49,11 @@ void bli_machval( machval_t mval, #undef GENTPROTR #define GENTPROTR( ctype_v, ctype_vr, chv, chvr, opname ) \ \ -void PASTEMAC(chv,opname)( \ - machval_t mval, \ - void* v \ - ); +void PASTEMAC(chv,opname) \ + ( \ + machval_t mval, \ + void* v \ + ); INSERT_GENTPROTR_BASIC0( machval ) diff --git a/frame/base/bli_obj.c b/frame/base/bli_obj.c index e8289d769..8ed40fc6f 100644 --- a/frame/base/bli_obj.c +++ b/frame/base/bli_obj.c @@ -71,6 +71,8 @@ void bli_obj_create_without_buffer( num_t dt, siz_t elem_size; void* s; + bli_init_once(); + if ( bli_error_checking_is_enabled() ) bli_obj_create_without_buffer_check( dt, m, n, obj ); @@ -121,6 +123,8 @@ void bli_obj_alloc_buffer( inc_t rs, siz_t buffer_size; void* p; + bli_init_once(); + // Query the dimensions of the object we are allocating. m = bli_obj_length( *obj ); n = bli_obj_width( *obj ); @@ -180,6 +184,11 @@ void bli_obj_attach_buffer( void* p, inc_t is, obj_t* obj ) { + bli_init_once(); + + // Interpret is = 0 as a request for the default, which is is = 1; + if ( is == 0 ) is = 1; + // Check that the strides and lengths are compatible. Note that the // user *must* specify valid row and column strides when attaching an // external buffer. @@ -209,6 +218,17 @@ void bli_obj_create_1x1_with_attached_buffer( num_t dt, bli_obj_attach_buffer( p, 1, 1, 1, obj ); } +void bli_obj_create_conf_to( obj_t* s, obj_t* d ) +{ + const num_t dt = bli_obj_datatype( *s ); + const dim_t m = bli_obj_length( *s ); + const dim_t n = bli_obj_width( *s ); + const inc_t rs = bli_obj_row_stride( *s ); + const inc_t cs = bli_obj_col_stride( *s ); + + bli_obj_create( dt, m, n, rs, cs, d ); +} + void bli_obj_free( obj_t* obj ) { if ( bli_error_checking_is_enabled() ) @@ -410,6 +430,23 @@ siz_t bli_datatype_size( num_t dt ) return dt_sizes[dt]; } +static char* dt_names[ BLIS_NUM_FP_TYPES+1 ] = +{ + "float", + "scomplex", + "double", + "dcomplex", + "int" +}; + +char* bli_datatype_string( num_t dt ) +{ + if ( bli_error_checking_is_enabled() ) + bli_datatype_string_check( dt ); + + return dt_names[dt]; +} + dim_t bli_align_dim_to_mult( dim_t dim, dim_t dim_mult ) { // We return the dimension unmodified if the multiple is zero diff --git a/frame/base/bli_obj.h b/frame/base/bli_obj.h index fd3a311e1..82a0639c4 100644 --- a/frame/base/bli_obj.h +++ b/frame/base/bli_obj.h @@ -72,6 +72,8 @@ void bli_obj_create_1x1_with_attached_buffer( num_t dt, void* p, obj_t* obj ); +void bli_obj_create_conf_to( obj_t* s, obj_t* d ); + void bli_obj_free( obj_t* obj ); //void bli_obj_create_const( double value, obj_t* obj ); @@ -86,6 +88,7 @@ void bli_adjust_strides( dim_t m, inc_t* is ); siz_t bli_datatype_size( num_t dt ); +char* bli_datatype_string( num_t dt ); dim_t bli_align_dim_to_mult( dim_t dim, dim_t dim_mult ); dim_t bli_align_dim_to_size( dim_t dim, siz_t elem_size, siz_t align_size ); diff --git a/frame/base/bli_setgetij.c b/frame/base/bli_setgetij.c new file mode 100644 index 000000000..90f66a89f --- /dev/null +++ b/frame/base/bli_setgetij.c @@ -0,0 +1,202 @@ +/* + + 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" + +typedef void (*setijm_fp) + ( + double ar, + double ai, + dim_t i, + dim_t j, + void* restrict b, inc_t rs, inc_t cs + ); +static setijm_fp GENARRAY(ftypes_setijm,setijm); + +err_t bli_setijm + ( + double ar, + double ai, + dim_t i, + dim_t j, + obj_t* b + ) +{ + dim_t m = bli_obj_length( *b ); + dim_t n = bli_obj_width( *b ); + dim_t rs = bli_obj_row_stride( *b ); + dim_t cs = bli_obj_col_stride( *b ); + num_t dt = bli_obj_datatype( *b ); + + // Return error if i or j is beyond bounds of matrix/vector. + if ( m <= i ) return BLIS_FAILURE; + if ( n <= j ) return BLIS_FAILURE; + + // Don't modify scalar constants. + if ( dt == BLIS_CONSTANT ) return BLIS_FAILURE; + + // Query the pointer to the buffer at the adjusted offsets. + void* b_p = bli_obj_buffer_at_off( *b ); + + // Index into the function pointer array. + setijm_fp f = ftypes_setijm[ dt ]; + + // Invoke the type-specific function. + f + ( + ar, + ai, + i, + j, + b_p, rs, cs + ); + + return BLIS_SUCCESS; +} + +#undef GENTFUNC +#define GENTFUNC( ctype, ch, opname ) \ +\ +void PASTEMAC(ch,opname) \ + ( \ + double ar, \ + double ai, \ + dim_t i, \ + dim_t j, \ + void* restrict b, inc_t rs, inc_t cs \ + ) \ +{ \ + ctype* restrict b_cast = ( ctype* )b; \ +\ + ctype* restrict b_ij = b_cast + (i )*rs + (j )*cs; \ +\ + PASTEMAC2(z,ch,sets)( ar, ai, *b_ij ); \ +} + +INSERT_GENTFUNC_BASIC0( setijm ) + +// ----------------------------------------------------------------------------- + +typedef void (*getijm_fp) + ( + dim_t i, + dim_t j, + void* restrict b, inc_t rs, inc_t cs, + double* ar, + double* ai + ); +static getijm_fp GENARRAY(ftypes_getijm,getijm); + +err_t bli_getijm + ( + dim_t i, + dim_t j, + obj_t* b, + double* ar, + double* ai + ) +{ + dim_t m = bli_obj_length( *b ); + dim_t n = bli_obj_width( *b ); + dim_t rs = bli_obj_row_stride( *b ); + dim_t cs = bli_obj_col_stride( *b ); + num_t dt = bli_obj_datatype( *b ); + + // Return error if i or j is beyond bounds of matrix/vector. + if ( m <= i ) return BLIS_FAILURE; + if ( n <= j ) return BLIS_FAILURE; + + void* b_p; + +#if 0 + // Handle scalar constants separately. + if ( dt == BLIS_CONSTANT ) + { + if ( i == 0 && j == 0 ) + { + dt = BLIS_DCOMPLEX; + b_p = bli_obj_buffer_for_const( dt, *b ) + } + else return BLIS_FAILURE; + } + else + { + // Query the pointer to the buffer at the adjusted offsets. + b_p = bli_obj_buffer_at_off( *b ); + } +#else + // Disallow access into scalar constants. + if ( dt == BLIS_CONSTANT ) return BLIS_FAILURE; + + // Query the pointer to the buffer at the adjusted offsets. + b_p = bli_obj_buffer_at_off( *b ); +#endif + + // Index into the function pointer array. + getijm_fp f = ftypes_getijm[ dt ]; + + // Invoke the type-specific function. + f + ( + i, + j, + b_p, rs, cs, + ar, + ai + ); + + return BLIS_SUCCESS; +} + +#undef GENTFUNC +#define GENTFUNC( ctype, ch, opname ) \ +\ +void PASTEMAC(ch,opname) \ + ( \ + dim_t i, \ + dim_t j, \ + void* restrict b, inc_t rs, inc_t cs, \ + double* ar, \ + double* ai \ + ) \ +{ \ + ctype* restrict b_cast = ( ctype* )b; \ +\ + ctype* restrict b_ij = b_cast + (i )*rs + (j )*cs; \ +\ + PASTEMAC2(ch,z,gets)( *b_ij, *ar, *ai ); \ +} + +INSERT_GENTFUNC_BASIC0( getijm ) + diff --git a/frame/base/bli_setgetij.h b/frame/base/bli_setgetij.h new file mode 100644 index 000000000..46a4fc32a --- /dev/null +++ b/frame/base/bli_setgetij.h @@ -0,0 +1,82 @@ +/* + + 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. + +*/ + +err_t bli_setijm + ( + double ar, + double ai, + dim_t i, + dim_t j, + obj_t* b + ); + +#undef GENTPROT +#define GENTPROT( ctype, ch, opname ) \ +\ +void PASTEMAC(ch,opname) \ + ( \ + double ar, \ + double ai, \ + dim_t i, \ + dim_t j, \ + void* restrict b, inc_t rs, inc_t cs \ + ); + +INSERT_GENTPROT_BASIC0( setijm ) + +// ----------------------------------------------------------------------------- + +err_t bli_getijm + ( + dim_t i, + dim_t j, + obj_t* b, + double* ar, + double* ai + ); + +#undef GENTPROT +#define GENTPROT( ctype, ch, opname ) \ +\ +void PASTEMAC(ch,opname) \ + ( \ + dim_t i, \ + dim_t j, \ + void* restrict b, inc_t rs, inc_t cs, \ + double* ar, \ + double* ai \ + ); + +INSERT_GENTPROT_BASIC0( getijm ) + diff --git a/frame/base/check/bli_obj_check.c b/frame/base/check/bli_obj_check.c index 85e2ba0e8..7e061450d 100644 --- a/frame/base/check/bli_obj_check.c +++ b/frame/base/check/bli_obj_check.c @@ -166,6 +166,14 @@ void bli_datatype_size_check( num_t dt ) bli_check_error_code( e_val ); } +void bli_datatype_string_check( num_t dt ) +{ + err_t e_val; + + e_val = bli_check_nonconstant_datatype( dt ); + bli_check_error_code( e_val ); +} + void bli_datatype_union_check( num_t dt1, num_t dt2 ) { err_t e_val; diff --git a/frame/base/check/bli_obj_check.h b/frame/base/check/bli_obj_check.h index 60beb7275..a5bbcd3b9 100644 --- a/frame/base/check/bli_obj_check.h +++ b/frame/base/check/bli_obj_check.h @@ -66,6 +66,8 @@ void bli_obj_create_const_copy_of_check( obj_t* a, obj_t* b ); void bli_datatype_size_check( num_t dt ); +void bli_datatype_string_check( num_t dt ); + void bli_datatype_union_check( num_t dt1, num_t dt2 ); void bli_obj_print_check( char* label, obj_t* obj ); diff --git a/frame/include/blis.h b/frame/include/blis.h index 7e76bc025..d9ab7756c 100644 --- a/frame/include/blis.h +++ b/frame/include/blis.h @@ -125,6 +125,7 @@ extern "C" { #include "bli_arch.h" #include "bli_cpuid.h" #include "bli_string.h" +#include "bli_setgetij.h" // -- Level-0 operations -- diff --git a/frame/util/bli_util_unb_var1.c b/frame/util/bli_util_unb_var1.c index 6f499524b..feac43a4d 100644 --- a/frame/util/bli_util_unb_var1.c +++ b/frame/util/bli_util_unb_var1.c @@ -851,7 +851,6 @@ void PASTEMAC(ch,opname) \ chi1 += incx; \ } \ \ - fprintf( file, "\n" ); \ fprintf( file, "%s\n", s2 ); \ }