From e88a5b8da8c26caebd2b0fb73b30836fb5417c9c Mon Sep 17 00:00:00 2001 From: "Field G. Van Zee" Date: Mon, 18 Jun 2018 15:56:26 -0500 Subject: [PATCH] Implemented castm, castv operations. Details: - Implemented castm and castv operations, which behave like copym and copyv except where the obj_t operands can be of different datatypes. These new operations, however, unlike copym/copyv, do not build upon existing level-1v kernels. - Reorganized projm, projv into a 'proj' subdirectory of frame/base (to match the newly added frame/base/cast directory). - Added new macros to bli_gentfunc_macro_defs.h, _gentprot_macro_defs.h that insert GENTFUNC2/GENTPROT2 macros for all non-homogeneous datatype combinations. Previously, one had to invoke two additional macros--one which mixed domains only and another that included all remaining cases--in order to get full type combination coverage. - Defined a new static function, bli_set_dims_incs_2m(), to aid in the setting of various variables in the implementations of bli_??castm(). This static function joins others like it in bli_param_macro_defs.h. - Comment update to bli_copysc.h. --- frame/0/copysc/bli_copysc.h | 2 +- frame/base/cast/bli_castm.c | 267 ++++++++++++++++++ frame/base/cast/bli_castm.h | 73 +++++ frame/base/cast/bli_castv.c | 211 ++++++++++++++ frame/base/cast/bli_castv.h | 72 +++++ frame/base/cast/old/bli_cast_check.c | 118 ++++++++ .../{bli_proj.h => cast/old/bli_cast_check.h} | 6 +- frame/base/{bli_proj.c => proj/bli_projm.c} | 66 ++--- frame/base/proj/bli_projm.h | 46 +++ frame/base/proj/bli_projv.c | 127 +++++++++ frame/base/proj/bli_projv.h | 46 +++ .../base/{check => proj/old}/bli_proj_check.c | 0 .../base/{check => proj/old}/bli_proj_check.h | 0 frame/include/bli_gentfunc_macro_defs.h | 45 +++ frame/include/bli_gentprot_macro_defs.h | 44 +++ frame/include/bli_param_macro_defs.h | 37 ++- frame/include/blis.h | 6 +- 17 files changed, 1122 insertions(+), 44 deletions(-) create mode 100644 frame/base/cast/bli_castm.c create mode 100644 frame/base/cast/bli_castm.h create mode 100644 frame/base/cast/bli_castv.c create mode 100644 frame/base/cast/bli_castv.h create mode 100644 frame/base/cast/old/bli_cast_check.c rename frame/base/{bli_proj.h => cast/old/bli_cast_check.h} (96%) rename frame/base/{bli_proj.c => proj/bli_projm.c} (72%) create mode 100644 frame/base/proj/bli_projm.h create mode 100644 frame/base/proj/bli_projv.c create mode 100644 frame/base/proj/bli_projv.h rename frame/base/{check => proj/old}/bli_proj_check.c (100%) rename frame/base/{check => proj/old}/bli_proj_check.h (100%) diff --git a/frame/0/copysc/bli_copysc.h b/frame/0/copysc/bli_copysc.h index dbddb5079..8022f4889 100644 --- a/frame/0/copysc/bli_copysc.h +++ b/frame/0/copysc/bli_copysc.h @@ -49,7 +49,7 @@ GENFRONT( copysc ) // -// Define BLAS-like interfaces with heterogeneous-typed operands. +// Prototype BLAS-like interfaces with heterogeneous-typed operands. // #undef GENTPROT2 diff --git a/frame/base/cast/bli_castm.c b/frame/base/cast/bli_castm.c new file mode 100644 index 000000000..84d4c8ca6 --- /dev/null +++ b/frame/base/cast/bli_castm.c @@ -0,0 +1,267 @@ +/* + + 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" + +// NOTE: This is one of the few functions in BLIS that is defined +// with heterogeneous type support. This is done so that we have +// an operation that can be used to typecast (copy-cast) a matrix +// of one datatype to a scalar of another datatype. + +typedef void (*FUNCPTR_T) + ( + trans_t transa, + dim_t m, + dim_t n, + void* restrict a, inc_t rs_a, inc_t cs_a, + void* restrict b, inc_t rs_b, inc_t cs_b + ); + +static FUNCPTR_T GENARRAY2_ALL(ftypes,castm); + +// +// Define object-based interface. +// + +void bli_castm + ( + obj_t* a, + obj_t* b + ) +{ + num_t dt_a = bli_obj_dt( a ); + num_t dt_b = bli_obj_dt( b ); + + trans_t transa = bli_obj_conjtrans_status( a ); + + dim_t m = bli_obj_length( b ); + dim_t n = bli_obj_width( b ); + + void* buf_a = bli_obj_buffer_at_off( a ); + inc_t rs_a = bli_obj_row_stride( a ); + inc_t cs_a = bli_obj_col_stride( a ); + + void* buf_b = bli_obj_buffer_at_off( b ); + inc_t rs_b = bli_obj_row_stride( b ); + inc_t cs_b = bli_obj_col_stride( b ); + + FUNCPTR_T f; + + // Check parameters. + if ( bli_error_checking_is_enabled() ) + bli_castm_check( a, b ); + +#if 0 + if ( bli_obj_dt( a ) == bli_obj_dt( b ) ) + { + // If a and b share the same datatype, we can simply use copym. + bli_copym( a, b ); + return; + } +#endif + + // Index into the type combination array to extract the correct + // function pointer. + f = ftypes[dt_a][dt_b]; + + // Invoke the void pointer-based function. + f + ( + transa, + m, + n, + buf_a, rs_a, cs_a, + buf_b, rs_b, cs_b + ); +} + +// ----------------------------------------------------------------------------- + +// +// Define BLAS-like interfaces with typed operands. +// + +#undef GENTFUNC2 +#define GENTFUNC2( ctype_a, ctype_b, cha, chb, opname ) \ +\ +void PASTEMAC2(cha,chb,opname) \ + ( \ + trans_t transa, \ + dim_t m, \ + dim_t n, \ + void* restrict a, inc_t rs_a, inc_t cs_a, \ + void* restrict b, inc_t rs_b, inc_t cs_b \ + ) \ +{ \ + ctype_a* restrict a_cast = a; \ + ctype_b* restrict b_cast = b; \ + conj_t conja; \ + dim_t n_iter; \ + dim_t n_elem; \ + inc_t lda, inca; \ + inc_t ldb, incb; \ + dim_t j, i; \ +\ + /* Set various loop parameters. */ \ + bli_set_dims_incs_2m \ + ( \ + transa, \ + m, n, rs_a, cs_a, rs_b, cs_b, \ + &n_elem, &n_iter, &inca, &lda, &incb, &ldb \ + ); \ +\ + /* Extract the conjugation component from the transa parameter. */ \ + conja = bli_extract_conj( transa ); \ +\ + if ( bli_is_conj( conja ) ) \ + { \ + if ( inca == 1 && incb == 1 ) \ + { \ + for ( j = 0; j < n_iter; ++j ) \ + { \ + ctype_a* restrict a1 = a_cast + (j )*lda + (0 )*inca; \ + ctype_b* restrict b1 = b_cast + (j )*ldb + (0 )*incb; \ +\ + for ( i = 0; i < n_elem; ++i ) \ + { \ + PASTEMAC2(cha,chb,copyjs)( a1[i], b1[i] ); \ + } \ + } \ + } \ + else \ + { \ + for ( j = 0; j < n_iter; ++j ) \ + { \ + ctype_a* restrict a1 = a_cast + (j )*lda + (0 )*inca; \ + ctype_b* restrict b1 = b_cast + (j )*ldb + (0 )*incb; \ +\ + for ( i = 0; i < n_elem; ++i ) \ + { \ + PASTEMAC2(cha,chb,copyjs)( *a1, *b1 ); \ +\ + a1 += inca; \ + b1 += incb; \ + } \ + } \ + } \ + } \ + else \ + { \ + if ( inca == 1 && incb == 1 ) \ + { \ + for ( j = 0; j < n_iter; ++j ) \ + { \ + ctype_a* restrict a1 = a_cast + (j )*lda + (0 )*inca; \ + ctype_b* restrict b1 = b_cast + (j )*ldb + (0 )*incb; \ +\ + for ( i = 0; i < n_elem; ++i ) \ + { \ + PASTEMAC2(cha,chb,copys)( a1[i], b1[i] ); \ + } \ + } \ + } \ + else \ + { \ + for ( j = 0; j < n_iter; ++j ) \ + { \ + ctype_a* restrict a1 = a_cast + (j )*lda + (0 )*inca; \ + ctype_b* restrict b1 = b_cast + (j )*ldb + (0 )*incb; \ +\ + for ( i = 0; i < n_elem; ++i ) \ + { \ + PASTEMAC2(cha,chb,copys)( *a1, *b1 ); \ +\ + a1 += inca; \ + b1 += incb; \ + } \ + } \ + } \ + } \ +} + +INSERT_GENTFUNC2_BASIC0( castm ) +INSERT_GENTFUNC2_MIXDP0( castm ) + +// ----------------------------------------------------------------------------- + +// +// Define object-based _check() function. +// + +void bli_castm_check + ( + obj_t* a, + obj_t* b + ) +{ + err_t e_val; + + // Check object datatypes. + + e_val = bli_check_floating_object( a ); + bli_check_error_code( e_val ); + + e_val = bli_check_floating_object( b ); + bli_check_error_code( e_val ); + + // Check structure. + // NOTE: We enforce general structure for now in order to simplify the + // implementation. + + bli_check_general_object( a ); + bli_check_error_code( e_val ); + + bli_check_general_object( b ); + bli_check_error_code( e_val ); + + // Check object dimensions. + + e_val = bli_check_matrix_object( a ); + bli_check_error_code( e_val ); + + e_val = bli_check_matrix_object( b ); + bli_check_error_code( e_val ); + + e_val = bli_check_conformal_dims( a, b ); + bli_check_error_code( e_val ); + + // Check object buffers (for non-NULLness). + + e_val = bli_check_object_buffer( a ); + bli_check_error_code( e_val ); + + e_val = bli_check_object_buffer( b ); + bli_check_error_code( e_val ); +} + diff --git a/frame/base/cast/bli_castm.h b/frame/base/cast/bli_castm.h new file mode 100644 index 000000000..353f25f33 --- /dev/null +++ b/frame/base/cast/bli_castm.h @@ -0,0 +1,73 @@ +/* + + 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. + +*/ + +// +// Prototype object-based interface. +// + +void bli_castm + ( + obj_t* a, + obj_t* b + ); + +// +// Prototype BLAS-like interfaces with heterogeneous-typed operands. +// + +#undef GENTPROT2 +#define GENTPROT2( ctype_a, ctype_b, cha, chb, opname ) \ +\ +void PASTEMAC2(cha,chb,opname) \ + ( \ + trans_t transa, \ + dim_t m, \ + dim_t n, \ + void* a, inc_t rs_a, inc_t cs_a, \ + void* b, inc_t rs_b, inc_t cs_b \ + ); + +INSERT_GENTPROT2_BASIC0( castm ) +INSERT_GENTPROT2_MIXDP0( castm ) + +// +// Prototype object-based _check() function. +// + +void bli_castm_check + ( + obj_t* a, + obj_t* b + ); + diff --git a/frame/base/cast/bli_castv.c b/frame/base/cast/bli_castv.c new file mode 100644 index 000000000..e6af84f3b --- /dev/null +++ b/frame/base/cast/bli_castv.c @@ -0,0 +1,211 @@ +/* + + 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" + +// NOTE: This is one of the few functions in BLIS that is defined +// with heterogeneous type support. This is done so that we have +// an operation that can be used to typecast (copy-cast) a matrix +// of one datatype to a scalar of another datatype. + +typedef void (*FUNCPTR_T) + ( + conj_t conjx, + dim_t n, + void* restrict x, inc_t inc_x, + void* restrict y, inc_t inc_y + ); + +static FUNCPTR_T GENARRAY2_ALL(ftypes,castv); + +// +// Define object-based interface. +// + +void bli_castv + ( + obj_t* x, + obj_t* y + ) +{ + num_t dt_x = bli_obj_dt( x ); + num_t dt_y = bli_obj_dt( y ); + + conj_t conjx = bli_obj_conj_status( x ); + + dim_t n = bli_obj_vector_dim( x ); + + void* buf_x = bli_obj_buffer_at_off( x ); + inc_t inc_x = bli_obj_vector_inc( x ); + + void* buf_y = bli_obj_buffer_at_off( y ); + inc_t inc_y = bli_obj_vector_inc( y ); + + FUNCPTR_T f; + + // Check parameters. + if ( bli_error_checking_is_enabled() ) + bli_castv_check( x, y ); + +#if 0 + if ( bli_obj_dt( x ) == bli_obj_dt( y ) ) + { + // If x and y share the same datatype, we can simply use copyv. + bli_copyv( x, y ); + return; + } +#endif + + // Index into the type combination array to extract the correct + // function pointer. + f = ftypes[dt_x][dt_y]; + + // Invoke the void pointer-based function. + f + ( + conjx, + n, + buf_x, inc_x, + buf_y, inc_y + ); +} + +// ----------------------------------------------------------------------------- + +// +// Define BLAS-like interfaces with typed operands. +// + +#undef GENTFUNC2 +#define GENTFUNC2( ctype_x, ctype_y, chx, chy, opname ) \ +\ +void PASTEMAC2(chx,chy,opname) \ + ( \ + conj_t conjx, \ + dim_t n, \ + void* restrict x, inc_t incx, \ + void* restrict y, inc_t incy \ + ) \ +{ \ + ctype_x* restrict x1 = x; \ + ctype_y* restrict y1 = y; \ + dim_t i; \ +\ + if ( bli_is_conj( conjx ) ) \ + { \ + if ( incx == 1 && incy == 1 ) \ + { \ + for ( i = 0; i < n; ++i ) \ + { \ + PASTEMAC2(chx,chy,copyjs)( x1[i], y1[i] ); \ + } \ + } \ + else \ + { \ + for ( i = 0; i < n; ++i ) \ + { \ + PASTEMAC2(chx,chy,copyjs)( *x1, *y1 ); \ +\ + x1 += incx; \ + y1 += incy; \ + } \ + } \ + } \ + else \ + { \ + if ( incx == 1 && incy == 1 ) \ + { \ + for ( i = 0; i < n; ++i ) \ + { \ + PASTEMAC2(chx,chy,copys)( x1[i], y1[i] ); \ + } \ + } \ + else \ + { \ + for ( i = 0; i < n; ++i ) \ + { \ + PASTEMAC2(chx,chy,copys)( *x1, *y1 ); \ +\ + x1 += incx; \ + y1 += incy; \ + } \ + } \ + } \ +} + +INSERT_GENTFUNC2_BASIC0( castv ) +INSERT_GENTFUNC2_MIXDP0( castv ) + +// ----------------------------------------------------------------------------- + +// +// Define object-based _check() function. +// + +void bli_castv_check + ( + obj_t* x, + obj_t* y + ) +{ + err_t e_val; + + // Check object datatypes. + + e_val = bli_check_floating_object( x ); + bli_check_error_code( e_val ); + + e_val = bli_check_floating_object( y ); + bli_check_error_code( e_val ); + + // Check object dimensions. + + e_val = bli_check_vector_object( x ); + bli_check_error_code( e_val ); + + e_val = bli_check_vector_object( y ); + bli_check_error_code( e_val ); + + e_val = bli_check_equal_vector_lengths( x, y ); + bli_check_error_code( e_val ); + + // Check object buffers (for non-NULLness). + + e_val = bli_check_object_buffer( x ); + bli_check_error_code( e_val ); + + e_val = bli_check_object_buffer( y ); + bli_check_error_code( e_val ); +} + diff --git a/frame/base/cast/bli_castv.h b/frame/base/cast/bli_castv.h new file mode 100644 index 000000000..1e1175184 --- /dev/null +++ b/frame/base/cast/bli_castv.h @@ -0,0 +1,72 @@ +/* + + 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. + +*/ + +// +// Prototype object-based interface. +// + +void bli_castv + ( + obj_t* x, + obj_t* y + ); + +// +// Prototype BLAS-like interfaces with heterogeneous-typed operands. +// + +#undef GENTPROT2 +#define GENTPROT2( ctype_x, ctype_y, chx, chy, opname ) \ +\ +void PASTEMAC2(chx,chy,opname) \ + ( \ + conj_t conjx, \ + dim_t n, \ + void* x, inc_t incx, \ + void* y, inc_t incy \ + ); + +INSERT_GENTPROT2_BASIC0( castv ) +INSERT_GENTPROT2_MIXDP0( castv ) + +// +// Prototype object-based _check() function. +// + +void bli_castv_check + ( + obj_t* x, + obj_t* y + ); + diff --git a/frame/base/cast/old/bli_cast_check.c b/frame/base/cast/old/bli_cast_check.c new file mode 100644 index 000000000..3d2ea0b6f --- /dev/null +++ b/frame/base/cast/old/bli_cast_check.c @@ -0,0 +1,118 @@ +/* + + 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" + +void bli_castm_check + ( + obj_t* a, + obj_t* b + ) +{ + err_t e_val; + + // Check object datatypes. + + e_val = bli_check_floating_object( a ); + bli_check_error_code( e_val ); + + e_val = bli_check_floating_object( b ); + bli_check_error_code( e_val ); + + // Check structure. + // NOTE: We enforce general structure for now in order to simplify the + // implementation. + + bli_check_general_object( a ); + bli_check_error_code( e_val ); + + bli_check_general_object( b ); + bli_check_error_code( e_val ); + + // Check object dimensions. + + e_val = bli_check_matrix_object( a ); + bli_check_error_code( e_val ); + + e_val = bli_check_matrix_object( b ); + bli_check_error_code( e_val ); + + e_val = bli_check_conformal_dims( a, b ); + bli_check_error_code( e_val ); + + // Check object buffers (for non-NULLness). + + e_val = bli_check_object_buffer( a ); + bli_check_error_code( e_val ); + + e_val = bli_check_object_buffer( b ); + bli_check_error_code( e_val ); +} + +void bli_castv_check + ( + obj_t* x, + obj_t* y + ) +{ + err_t e_val; + + // Check object datatypes. + + e_val = bli_check_floating_object( x ); + bli_check_error_code( e_val ); + + e_val = bli_check_floating_object( y ); + bli_check_error_code( e_val ); + + // Check object dimensions. + + e_val = bli_check_vector_object( x ); + bli_check_error_code( e_val ); + + e_val = bli_check_vector_object( y ); + bli_check_error_code( e_val ); + + e_val = bli_check_equal_vector_lengths( x, y ); + bli_check_error_code( e_val ); + + // Check object buffers (for non-NULLness). + + e_val = bli_check_object_buffer( x ); + bli_check_error_code( e_val ); + + e_val = bli_check_object_buffer( y ); + bli_check_error_code( e_val ); +} + diff --git a/frame/base/bli_proj.h b/frame/base/cast/old/bli_cast_check.h similarity index 96% rename from frame/base/bli_proj.h rename to frame/base/cast/old/bli_cast_check.h index 39e02f7be..eb3356b8e 100644 --- a/frame/base/bli_proj.h +++ b/frame/base/cast/old/bli_cast_check.h @@ -32,15 +32,13 @@ */ -#include "bli_proj_check.h" - -void bli_projm +void bli_castm_check ( obj_t* a, obj_t* b ); -void bli_projv +void bli_castv_check ( obj_t* x, obj_t* y diff --git a/frame/base/bli_proj.c b/frame/base/proj/bli_projm.c similarity index 72% rename from frame/base/bli_proj.c rename to frame/base/proj/bli_projm.c index 5a09a2c51..e208a79f3 100644 --- a/frame/base/bli_proj.c +++ b/frame/base/proj/bli_projm.c @@ -84,52 +84,44 @@ void bli_projm } } -void bli_projv +// ----------------------------------------------------------------------------- + +void bli_projm_check ( - obj_t* x, - obj_t* y + obj_t* a, + obj_t* b ) { - // Check parameters. - if ( bli_error_checking_is_enabled() ) - bli_projv_check( x, y ); + err_t e_val; - if ( ( bli_obj_is_real( x ) && bli_obj_is_real( y ) ) || - ( bli_obj_is_complex( x ) && bli_obj_is_complex( y ) ) ) - { - // If x and y are both real or both complex, we can simply use - // copyv. - bli_copyv( x, y ); - } - else - { - // This branch handles the case where one operand is real and - // the other is complex. + // Check object datatypes. - if ( bli_obj_is_real( x ) /* && bli_obj_is_complex( y ) */ ) - { - // If x is real and y is complex, we must obtain the real part - // of y so that we can copy x into the real part (after - // initializing all of y, including imaginary components, to - // zero). + e_val = bli_check_floating_object( a ); + bli_check_error_code( e_val ); - obj_t yr; + e_val = bli_check_floating_object( b ); + bli_check_error_code( e_val ); - bli_obj_real_part( y, &yr ); + e_val = bli_check_consistent_object_precisions( a, b ); + bli_check_error_code( e_val ); - bli_setv( &BLIS_ZERO, y ); - bli_copyv( x, &yr ); - } - else // bli_obj_is_complex( x ) && bli_obj_is_real( y ) - { - // If x is complex and y is real, we can simply copy the - // real part of x into y. + // Check object dimensions. - obj_t xr; + e_val = bli_check_matrix_object( a ); + bli_check_error_code( e_val ); - bli_obj_real_part( x, &xr ); + e_val = bli_check_matrix_object( b ); + bli_check_error_code( e_val ); - bli_copyv( &xr, y ); - } - } + e_val = bli_check_conformal_dims( a, b ); + bli_check_error_code( e_val ); + + // Check object buffers (for non-NULLness). + + e_val = bli_check_object_buffer( a ); + bli_check_error_code( e_val ); + + e_val = bli_check_object_buffer( b ); + bli_check_error_code( e_val ); } + diff --git a/frame/base/proj/bli_projm.h b/frame/base/proj/bli_projm.h new file mode 100644 index 000000000..154b67ed2 --- /dev/null +++ b/frame/base/proj/bli_projm.h @@ -0,0 +1,46 @@ +/* + + 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. + +*/ + +void bli_projm + ( + obj_t* a, + obj_t* b + ); + +void bli_projm_check + ( + obj_t* a, + obj_t* b + ); + diff --git a/frame/base/proj/bli_projv.c b/frame/base/proj/bli_projv.c new file mode 100644 index 000000000..fcad4d890 --- /dev/null +++ b/frame/base/proj/bli_projv.c @@ -0,0 +1,127 @@ +/* + + 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" + +void bli_projv + ( + obj_t* x, + obj_t* y + ) +{ + // Check parameters. + if ( bli_error_checking_is_enabled() ) + bli_projv_check( x, y ); + + if ( ( bli_obj_is_real( x ) && bli_obj_is_real( y ) ) || + ( bli_obj_is_complex( x ) && bli_obj_is_complex( y ) ) ) + { + // If x and y are both real or both complex, we can simply use + // copyv. + bli_copyv( x, y ); + } + else + { + // This branch handles the case where one operand is real and + // the other is complex. + + if ( bli_obj_is_real( x ) /* && bli_obj_is_complex( y ) */ ) + { + // If x is real and y is complex, we must obtain the real part + // of y so that we can copy x into the real part (after + // initializing all of y, including imaginary components, to + // zero). + + obj_t yr; + + bli_obj_real_part( y, &yr ); + + bli_setv( &BLIS_ZERO, y ); + bli_copyv( x, &yr ); + } + else // bli_obj_is_complex( x ) && bli_obj_is_real( y ) + { + // If x is complex and y is real, we can simply copy the + // real part of x into y. + + obj_t xr; + + bli_obj_real_part( x, &xr ); + + bli_copyv( &xr, y ); + } + } +} + +// ----------------------------------------------------------------------------- + +void bli_projv_check + ( + obj_t* x, + obj_t* y + ) +{ + err_t e_val; + + // Check object datatypes. + + e_val = bli_check_floating_object( x ); + bli_check_error_code( e_val ); + + e_val = bli_check_floating_object( y ); + bli_check_error_code( e_val ); + + e_val = bli_check_consistent_object_precisions( x, y ); + bli_check_error_code( e_val ); + + // Check object dimensions. + + e_val = bli_check_vector_object( x ); + bli_check_error_code( e_val ); + + e_val = bli_check_vector_object( y ); + bli_check_error_code( e_val ); + + e_val = bli_check_equal_vector_lengths( x, y ); + bli_check_error_code( e_val ); + + // Check object buffers (for non-NULLness). + + e_val = bli_check_object_buffer( x ); + bli_check_error_code( e_val ); + + e_val = bli_check_object_buffer( y ); + bli_check_error_code( e_val ); +} + diff --git a/frame/base/proj/bli_projv.h b/frame/base/proj/bli_projv.h new file mode 100644 index 000000000..8b504a685 --- /dev/null +++ b/frame/base/proj/bli_projv.h @@ -0,0 +1,46 @@ +/* + + 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. + +*/ + +void bli_projv + ( + obj_t* x, + obj_t* y + ); + +void bli_projv_check + ( + obj_t* x, + obj_t* y + ); + diff --git a/frame/base/check/bli_proj_check.c b/frame/base/proj/old/bli_proj_check.c similarity index 100% rename from frame/base/check/bli_proj_check.c rename to frame/base/proj/old/bli_proj_check.c diff --git a/frame/base/check/bli_proj_check.h b/frame/base/proj/old/bli_proj_check.h similarity index 100% rename from frame/base/check/bli_proj_check.h rename to frame/base/proj/old/bli_proj_check.h diff --git a/frame/include/bli_gentfunc_macro_defs.h b/frame/include/bli_gentfunc_macro_defs.h index 6d980b1fa..a52904cc4 100644 --- a/frame/include/bli_gentfunc_macro_defs.h +++ b/frame/include/bli_gentfunc_macro_defs.h @@ -402,6 +402,51 @@ GENTFUNC2( dcomplex, scomplex, z, c, tfuncname, varname ) \ +// -- Mixed domain/precision (all) two-operand macro -- + +// -- (no auxiliary arguments) -- + +#define INSERT_GENTFUNC2_MIXDP0( tfuncname ) \ +\ +GENTFUNC2( float, double, s, d, tfuncname ) \ +GENTFUNC2( float, scomplex, s, c, tfuncname ) \ +GENTFUNC2( float, dcomplex, s, z, tfuncname ) \ +\ +GENTFUNC2( double, float, d, s, tfuncname ) \ +GENTFUNC2( double, scomplex, d, c, tfuncname ) \ +GENTFUNC2( double, dcomplex, d, z, tfuncname ) \ +\ +GENTFUNC2( scomplex, float, c, s, tfuncname ) \ +GENTFUNC2( scomplex, double, c, d, tfuncname ) \ +GENTFUNC2( scomplex, dcomplex, c, z, tfuncname ) \ +\ +GENTFUNC2( dcomplex, float, z, s, tfuncname ) \ +GENTFUNC2( dcomplex, double, z, d, tfuncname ) \ +GENTFUNC2( dcomplex, scomplex, z, c, tfuncname ) + + +// -- (one auxiliary argument) -- + +#define INSERT_GENTFUNC2_MIX_DP( tfuncname, varname ) \ +\ +GENTFUNC2( float, double, s, d, tfuncname, varname ) \ +GENTFUNC2( float, scomplex, s, c, tfuncname, varname ) \ +GENTFUNC2( float, dcomplex, s, z, tfuncname, varname ) \ +\ +GENTFUNC2( double, float, d, s, tfuncname, varname ) \ +GENTFUNC2( double, scomplex, d, c, tfuncname, varname ) \ +GENTFUNC2( double, dcomplex, d, z, tfuncname, varname ) \ +\ +GENTFUNC2( scomplex, float, c, s, tfuncname, varname ) \ +GENTFUNC2( scomplex, double, c, d, tfuncname, varname ) \ +GENTFUNC2( scomplex, dcomplex, c, z, tfuncname, varname ) \ +\ +GENTFUNC2( dcomplex, float, z, s, tfuncname, varname ) \ +GENTFUNC2( dcomplex, double, z, d, tfuncname, varname ) \ +GENTFUNC2( dcomplex, scomplex, z, c, tfuncname, varname ) + + + // -- Basic two-operand with real projection of first operand -- // -- (no auxiliary arguments) -- diff --git a/frame/include/bli_gentprot_macro_defs.h b/frame/include/bli_gentprot_macro_defs.h index 5d685cc56..e0ba84ff9 100644 --- a/frame/include/bli_gentprot_macro_defs.h +++ b/frame/include/bli_gentprot_macro_defs.h @@ -395,6 +395,50 @@ GENTPROT2( dcomplex, scomplex, z, c, tfuncname, varname ) \ +// -- Mixed domain/precision (all) two-operand macro -- + +// -- (no auxiliary arguments) -- + +#define INSERT_GENTPROT2_MIXDP0( funcname ) \ +\ +GENTPROT2( float, double, s, d, funcname ) \ +GENTPROT2( float, scomplex, s, c, funcname ) \ +GENTPROT2( float, dcomplex, s, z, funcname ) \ +\ +GENTPROT2( double, float, d, s, funcname ) \ +GENTPROT2( double, scomplex, d, c, funcname ) \ +GENTPROT2( double, dcomplex, d, z, funcname ) \ +\ +GENTPROT2( scomplex, float, c, s, funcname ) \ +GENTPROT2( scomplex, double, c, d, funcname ) \ +GENTPROT2( scomplex, dcomplex, c, z, funcname ) \ +\ +GENTPROT2( dcomplex, float, z, s, funcname ) \ +GENTPROT2( dcomplex, double, z, d, funcname ) \ +GENTPROT2( dcomplex, scomplex, z, c, funcname ) + +// -- (one auxiliary argument) -- + +#define INSERT_GENTPROT2_MIX_DP( tfuncname, varname ) \ +\ +GENTPROT2( float, double, s, d, tfuncname, varname ) \ +GENTPROT2( float, scomplex, s, c, tfuncname, varname ) \ +GENTPROT2( float, dcomplex, s, z, tfuncname, varname ) \ +\ +GENTPROT2( double, float, d, s, tfuncname, varname ) \ +GENTPROT2( double, scomplex, d, c, tfuncname, varname ) \ +GENTPROT2( double, dcomplex, d, z, tfuncname, varname ) \ +\ +GENTPROT2( scomplex, float, c, s, tfuncname, varname ) \ +GENTPROT2( scomplex, double, c, d, tfuncname, varname ) \ +GENTPROT2( scomplex, dcomplex, c, z, tfuncname, varname ) \ +\ +GENTPROT2( dcomplex, float, z, s, tfuncname, varname ) \ +GENTPROT2( dcomplex, double, z, d, tfuncname, varname ) \ +GENTPROT2( dcomplex, scomplex, z, c, tfuncname, varname ) + + + // -- Basic two-operand with real projection of first operand -- // -- (no auxiliary arguments) -- diff --git a/frame/include/bli_param_macro_defs.h b/frame/include/bli_param_macro_defs.h index ee61b5728..5584f8ed0 100644 --- a/frame/include/bli_param_macro_defs.h +++ b/frame/include/bli_param_macro_defs.h @@ -990,6 +990,41 @@ void bli_set_dims_incs_uplo_1m_noswap } } +// Set dimensions and increments for TWO matrix arguments. + +static +void bli_set_dims_incs_2m + ( + trans_t transa, + dim_t m, dim_t n, inc_t rs_a, inc_t cs_a, + inc_t rs_b, inc_t cs_b, + dim_t* n_elem, dim_t* n_iter, inc_t* inca, inc_t* lda, + inc_t* incb, inc_t* ldb + ) +{ + { + *n_iter = n; + *n_elem = m; + *inca = rs_a; + *lda = cs_a; + *incb = rs_b; + *ldb = cs_b; + + if ( bli_does_trans( transa ) ) + { + bli_swap_incs( inca, lda ); + } + + if ( bli_is_row_tilted( *n_elem, *n_iter, *incb, *ldb ) && + bli_is_row_tilted( *n_elem, *n_iter, *inca, *lda ) ) + { + bli_swap_dims( n_iter, n_elem ); + bli_swap_incs( inca, lda ); + bli_swap_incs( incb, ldb ); + } + } +} + // Set dimensions, increments, effective uplo/diagoff, etc for TWO matrix // arguments. @@ -1033,7 +1068,7 @@ void bli_set_dims_incs_uplo_2m if ( bli_is_stored_subpart( diagoffa_use_, transa, uploa, m, n ) ) uploa = BLIS_DENSE; - n_iter_max_ = n; + n_iter_max_ = n; *n_elem_max = m; *inca = rs_a; *lda = cs_a; diff --git a/frame/include/blis.h b/frame/include/blis.h index 25f6f53af..8e1803f4b 100644 --- a/frame/include/blis.h +++ b/frame/include/blis.h @@ -122,9 +122,13 @@ extern "C" { #include "bli_cpuid.h" #include "bli_string.h" #include "bli_setgetij.h" -#include "bli_proj.h" #include "bli_setri.h" +#include "bli_castm.h" +#include "bli_castv.h" +#include "bli_projm.h" +#include "bli_projv.h" + // -- Level-0 operations --