]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - dense-linear-algebra-libraries/linalg.git/blob - blis/frame/0/addsc/bli_addsc_unb_var1.c
Consolidate all git repos of linalg into one.
[dense-linear-algebra-libraries/linalg.git] / blis / frame / 0 / addsc / bli_addsc_unb_var1.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 addsc_fp
39 typedef void (*FUNCPTR_T)(
40                            conj_t conjchi,
41                            void*  chi,
42                            void*  psi
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,addsc_unb_var1);
49 #else
50 #ifdef BLIS_ENABLE_MIXED_DOMAIN_SUPPORT
51 static FUNCPTR_T GENARRAY2_EXT(ftypes,addsc_unb_var1);
52 #else
53 static FUNCPTR_T GENARRAY2_MIN(ftypes,addsc_unb_var1);
54 #endif
55 #endif
58 void bli_addsc_unb_var1( obj_t*  chi,
59                          obj_t*  psi )
60 {
61         conj_t    conjchi   = bli_obj_conj_status( *chi );
63         num_t     dt_psi     = bli_obj_datatype( *psi );
64         void*     buf_psi    = bli_obj_buffer_at_off( *psi );
66         num_t     dt_chi;
67         void*     buf_chi;
69         FUNCPTR_T f;
71         // If chi is a scalar constant, use dt_psi to extract the address of the
72         // corresponding constant value; otherwise, use the datatype encoded
73         // within the chi object and extract the buffer at the chi offset.
74         bli_set_scalar_dt_buffer( chi, dt_psi, dt_chi, buf_chi );
76         // Index into the type combination array to extract the correct
77         // function pointer.
78         f = ftypes[dt_chi][dt_psi];
80         // Invoke the function.
81         f( conjchi,
82            buf_chi,
83            buf_psi );
84 }
87 #undef  GENTFUNC2
88 #define GENTFUNC2( ctype_x, ctype_y, chx, chy, varname ) \
89 \
90 void PASTEMAC2(chx,chy,varname)( \
91                                  conj_t conjchi, \
92                                  void*  chi, \
93                                  void*  psi \
94                                ) \
95 { \
96         ctype_x* chi_cast = chi; \
97         ctype_y* psi_cast = psi; \
98         ctype_x  chi_conj; \
99 \
100         PASTEMAC2(chx,chx,copycjs)( conjchi, *chi_cast, chi_conj ); \
102         PASTEMAC2(chx,chy,adds)( chi_conj, *psi_cast ); \
106 // Define the basic set of functions unconditionally, and then also some
107 // mixed datatype functions if requested.
108 INSERT_GENTFUNC2_BASIC0( addsc_unb_var1 )
110 #ifdef BLIS_ENABLE_MIXED_DOMAIN_SUPPORT
111 INSERT_GENTFUNC2_MIX_D0( addsc_unb_var1 )
112 #endif
114 #ifdef BLIS_ENABLE_MIXED_PRECISION_SUPPORT
115 INSERT_GENTFUNC2_MIX_P0( addsc_unb_var1 )
116 #endif