From 1abbf768afafc158d44e4d5c4a135cfd9e277f13 Mon Sep 17 00:00:00 2001 From: "Field G. Van Zee" Date: Mon, 4 Nov 2013 15:50:00 -0600 Subject: [PATCH] Fixed bugs in scalv and setv. Details: - Fixed bugs similar to those addressed in cca1e1f51dc6, whereby a segmentation fault may occur if beta is not the same type as the vector operand for scalv and setv. - Changed axpyv and scal2v front-ends in a similar fashion. --- frame/1/axpyv/bli_axpyv.c | 15 ++++++++- frame/1/scal2v/bli_scal2v.c | 26 ++++++++------- frame/1/scalv/bli_scalv.c | 33 +++++++++--------- frame/1/setv/bli_setv.c | 21 +++++++----- frame/1/setv/bli_setv.h | 2 ++ frame/1/setv/bli_setv_check.c | 63 +++++++++++++++++++++++++++++++++++ frame/1/setv/bli_setv_check.h | 39 ++++++++++++++++++++++ 7 files changed, 162 insertions(+), 37 deletions(-) create mode 100644 frame/1/setv/bli_setv_check.c create mode 100644 frame/1/setv/bli_setv_check.h diff --git a/frame/1/axpyv/bli_axpyv.c b/frame/1/axpyv/bli_axpyv.c index 9f61e57e1..45388df15 100644 --- a/frame/1/axpyv/bli_axpyv.c +++ b/frame/1/axpyv/bli_axpyv.c @@ -47,10 +47,23 @@ void PASTEMAC0(opname)( \ obj_t* y \ ) \ { \ + num_t dt_x; \ + obj_t alpha_local; \ +\ if ( bli_error_checking_is_enabled() ) \ PASTEMAC(opname,_check)( alpha, x, y ); \ \ - PASTEMAC0(varname)( alpha, \ + /* Use the datatype of x as the target type for beta (since we do + not assume mixed domain/type support is enabled). */ \ + dt_x = bli_obj_datatype( *x ); \ +\ + /* Create an object to hold a copy-cast of alpha. */ \ + bli_obj_init_scalar_copy_of( dt_x, \ + BLIS_NO_CONJUGATE, \ + alpha, \ + &alpha_local ); \ +\ + PASTEMAC0(varname)( &alpha_local, \ x, \ y ); \ } diff --git a/frame/1/scal2v/bli_scal2v.c b/frame/1/scal2v/bli_scal2v.c index 6c5cd8b5e..1984c500b 100644 --- a/frame/1/scal2v/bli_scal2v.c +++ b/frame/1/scal2v/bli_scal2v.c @@ -34,17 +34,6 @@ #include "blis.h" -/* -void bli_scal2v( obj_t* beta, - obj_t* x, - obj_t* y ) -{ - if ( bli_error_checking_is_enabled() ) - bli_scal2v_check( beta, x, y ); - - bli_scal2v_unb_var1( beta, x, y ); -} -*/ // // Define object-based interface. @@ -58,10 +47,23 @@ void PASTEMAC0(opname)( \ obj_t* y \ ) \ { \ + num_t dt_x; \ + obj_t beta_local; \ +\ if ( bli_error_checking_is_enabled() ) \ PASTEMAC(opname,_check)( beta, x, y ); \ \ - PASTEMAC0(varname)( beta, \ + /* Use the datatype of x as the target type for beta (since we do + not assume mixed domain/type support is enabled). */ \ + dt_x = bli_obj_datatype( *x ); \ +\ + /* Create an object to hold a copy-cast of beta. */ \ + bli_obj_init_scalar_copy_of( dt_x, \ + BLIS_NO_CONJUGATE, \ + beta, \ + &beta_local ); \ +\ + PASTEMAC0(varname)( &beta_local, \ x, \ y ); \ } diff --git a/frame/1/scalv/bli_scalv.c b/frame/1/scalv/bli_scalv.c index 99a8070f4..f2c9e794d 100644 --- a/frame/1/scalv/bli_scalv.c +++ b/frame/1/scalv/bli_scalv.c @@ -34,18 +34,6 @@ #include "blis.h" -/* -extern scalv_t* scalv_cntl; - -void bli_scalv( obj_t* beta, - obj_t* x ) -{ - //bli_scalv_int( beta, - // x, - // scalv_cntl ); - bli_scalv_unb_var1( beta, x ); -} -*/ // // Define object-based interface. @@ -58,11 +46,24 @@ void PASTEMAC0(opname)( \ obj_t* x \ ) \ { \ - if ( bli_error_checking_is_enabled() ) \ - PASTEMAC(opname,_check)( beta, x ); \ + num_t dt_x; \ + obj_t beta_local; \ \ - PASTEMAC0(varname)( beta, \ - x ); \ + if ( bli_error_checking_is_enabled() ) \ + PASTEMAC(opname,_check)( beta, x ); \ +\ + /* Use the datatype of x as the target type for beta (since we do + not assume mixed domain/type support is enabled). */ \ + dt_x = bli_obj_datatype( *x ); \ +\ + /* Create an object to hold a copy-cast of beta. */ \ + bli_obj_init_scalar_copy_of( dt_x, \ + BLIS_NO_CONJUGATE, \ + beta, \ + &beta_local ); \ +\ + PASTEMAC0(varname)( &beta_local, \ + x ); \ } GENFRONT( scalv, SCALV_KERNEL ) diff --git a/frame/1/setv/bli_setv.c b/frame/1/setv/bli_setv.c index be813d719..23c59a51d 100644 --- a/frame/1/setv/bli_setv.c +++ b/frame/1/setv/bli_setv.c @@ -34,13 +34,6 @@ #include "blis.h" -/* -void bli_setv( obj_t* beta, - obj_t* x ) -{ - bli_setv_unb_var1( beta, x ); -} -*/ // // Define object-based interface. @@ -53,12 +46,24 @@ void PASTEMAC0(opname)( \ obj_t* x \ ) \ { \ + num_t dt_x; \ + obj_t beta_local; \ /* if ( bli_error_checking_is_enabled() ) \ PASTEMAC(opname,_check)( beta, x ); \ */ \ \ - PASTEMAC0(varname)( beta, \ + /* Use the datatype of x as the target type for beta (since we do + not assume mixed domain/type support is enabled). */ \ + dt_x = bli_obj_datatype( *x ); \ +\ + /* Create an object to hold a copy-cast of beta. */ \ + bli_obj_init_scalar_copy_of( dt_x, \ + BLIS_NO_CONJUGATE, \ + beta, \ + &beta_local ); \ +\ + PASTEMAC0(varname)( &beta_local, \ x ); \ } diff --git a/frame/1/setv/bli_setv.h b/frame/1/setv/bli_setv.h index dc68ae5db..f47589eaa 100644 --- a/frame/1/setv/bli_setv.h +++ b/frame/1/setv/bli_setv.h @@ -32,6 +32,8 @@ */ +#include "bli_setv_check.h" + #include "bli_setv_unb_var1.h" #include "bli_setv_unb_var2.h" diff --git a/frame/1/setv/bli_setv_check.c b/frame/1/setv/bli_setv_check.c new file mode 100644 index 000000000..50aa61c87 --- /dev/null +++ b/frame/1/setv/bli_setv_check.c @@ -0,0 +1,63 @@ +/* + + 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. + +*/ + +#include "blis.h" + +void bli_setv_basic_check( obj_t* beta, + obj_t* x ) +{ + err_t e_val; + + // Check object datatypes. + + e_val = bli_check_noninteger_object( beta ); + bli_check_error_code( e_val ); + + e_val = bli_check_floating_object( x ); + bli_check_error_code( e_val ); + + // Check object dimensions. + + e_val = bli_check_scalar_object( beta ); + bli_check_error_code( e_val ); +} + +void bli_setv_check( obj_t* beta, + obj_t* x ) +{ + // Check basic properties of the operation. + + bli_setv_basic_check( beta, x ); +} + diff --git a/frame/1/setv/bli_setv_check.h b/frame/1/setv/bli_setv_check.h new file mode 100644 index 000000000..190d6501b --- /dev/null +++ b/frame/1/setv/bli_setv_check.h @@ -0,0 +1,39 @@ +/* + + 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. + +*/ + +void bli_setv_basic_check( obj_t* beta, + obj_t* x ); + +void bli_setv_check( obj_t* beta, + obj_t* x );