]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - dense-linear-algebra-libraries/linalg.git/blob - blis/frame/1/setv/old/bli_setv_unb_var2.c
TI Linear Algebra Library (LINALG) Rlease 1.0.0
[dense-linear-algebra-libraries/linalg.git] / blis / frame / 1 / setv / old / bli_setv_unb_var2.c
1 /*
3    BLIS    
4    An object-based framework for developing high-performance BLAS-like
5    libraries.
7    Copyright (C) 2014, The University of Texas at Austin
9    Redistribution and use in source and binary forms, with or without
10    modification, are permitted provided that the following conditions are
11    met:
12     - Redistributions of source code must retain the above copyright
13       notice, this list of conditions and the following disclaimer.
14     - Redistributions in binary form must reproduce the above copyright
15       notice, this list of conditions and the following disclaimer in the
16       documentation and/or other materials provided with the distribution.
17     - Neither the name of The University of Texas at Austin nor the names
18       of its contributors may be used to endorse or promote products
19       derived from this software without specific prior written permission.
21    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24    A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25    HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28    DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29    THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 */
35 #include "blis.h"
37 #define FUNCPTR_T setv_fp
39 typedef void (*FUNCPTR_T)(
40                            dim_t  n,
41                            void*  beta,
42                            void*  x, inc_t incx
43                          );
45 // If some mixed datatype functions will not be compiled, we initialize
46 // the corresponding elements of the function array to NULL.
47 #ifdef BLIS_ENABLE_MIXED_PRECISION_SUPPORT
48 static FUNCPTR_T GENARRAY2_ALL(ftypes,setv_unb_var2);
49 #else
50 #ifdef BLIS_ENABLE_MIXED_DOMAIN_SUPPORT
51 static FUNCPTR_T GENARRAY2_EXT(ftypes,setv_unb_var2);
52 #else
53 static FUNCPTR_T GENARRAY2_MIN(ftypes,setv_unb_var2);
54 #endif
55 #endif
58 void bli_setv_unb_var2( obj_t*  beta,
59                         obj_t*  x )
60 {
61         num_t     dt_x      = bli_obj_datatype( *x );
63         dim_t     n         = bli_obj_vector_dim( *x );
65         void*     buf_x     = bli_obj_buffer_at_off( *x );
66         inc_t     inc_x     = bli_obj_vector_inc( *x );
68         void*     buf_beta;
69         num_t     dt_beta;
71         FUNCPTR_T f;
73         // If beta is a scalar constant, use dt_x to extract the address of the
74         // corresponding constant value; otherwise, use the datatype encoded
75         // within the beta object and extract the buffer at the beta offset.
76         bli_set_scalar_dt_buffer( beta, dt_x, dt_beta, buf_beta );
78         // Index into the type combination array to extract the correct
79         // function pointer.
80         f = ftypes[dt_beta][dt_x];
82         // Invoke the function.
83         f( n,
84            buf_beta,
85            buf_x, inc_x );
86 }
89 #undef  GENTFUNC2
90 #define GENTFUNC2( ctype_b, ctype_x, chb, chx, varname, kername ) \
91 \
92 void PASTEMAC2(chb,chx,varname)( \
93                                  dim_t  n, \
94                                  void*  beta, \
95                                  void*  x, inc_t incx \
96                                ) \
97 { \
98         ctype_b* beta_cast = beta; \
99         ctype_x* x_cast    = x; \
101         PASTEMAC2(chb,chx,kername)( BLIS_NO_CONJUGATE, \
102                                     n, \
103                                     beta_cast, 0, \
104                                     x_cast,    incx ); \
107 // Define the basic set of functions unconditionally, and then also some
108 // mixed datatype functions if requested.
109 INSERT_GENTFUNC2_BASIC( setv_unb_var2, COPYV_KERNEL )
111 #ifdef BLIS_ENABLE_MIXED_DOMAIN_SUPPORT
112 INSERT_GENTFUNC2_MIX_D( setv_unb_var2, COPYV_KERNEL )
113 #endif
115 #ifdef BLIS_ENABLE_MIXED_PRECISION_SUPPORT
116 INSERT_GENTFUNC2_MIX_P( setv_unb_var2, COPYV_KERNEL )
117 #endif