]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - dense-linear-algebra-libraries/linalg.git/blob - blis/frame/1f/axpyf/bli_axpyf_ref.c
Consolidate all git repos of linalg into one.
[dense-linear-algebra-libraries/linalg.git] / blis / frame / 1f / axpyf / bli_axpyf_ref.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 /*
38 #define FUNCPTR_T axpyf_fp
40 typedef void (*FUNCPTR_T)(
41                            conj_t conja,
42                            conj_t conjx,
43                            dim_t  m,
44                            dim_t  b_n,
45                            void*  alpha,
46                            void*  a, inc_t inca, inc_t lda,
47                            void*  x, inc_t incx,
48                            void*  y, inc_t incy
49                          );
51 // If some mixed datatype functions will not be compiled, we initialize
52 // the corresponding elements of the function array to NULL.
53 #ifdef BLIS_ENABLE_MIXED_PRECISION_SUPPORT
54 static FUNCPTR_T GENARRAY3_ALL(ftypes,axpyf_ref);
55 #else
56 #ifdef BLIS_ENABLE_MIXED_DOMAIN_SUPPORT
57 static FUNCPTR_T GENARRAY3_EXT(ftypes,axpyf_ref);
58 #else
59 static FUNCPTR_T GENARRAY3_MIN(ftypes,axpyf_ref);
60 #endif
61 #endif
64 void bli_axpyf_ref( obj_t*  alpha,
65                          obj_t*  a,
66                          obj_t*  x,
67                          obj_t*  y )
68 {
69         num_t     dt_a      = bli_obj_datatype( *a );
70         num_t     dt_x      = bli_obj_datatype( *x );
71         num_t     dt_y      = bli_obj_datatype( *y );
73         conj_t    conja     = bli_obj_conj_status( *a );
74         conj_t    conjx     = bli_obj_conj_status( *x );
76         dim_t     m         = bli_obj_vector_dim( *y );
77         dim_t     b_n       = bli_obj_vector_dim( *x );
79         void*     buf_a     = bli_obj_buffer_at_off( *a );
80         inc_t     rs_a      = bli_obj_row_stride( *a );
81         inc_t     cs_a      = bli_obj_col_stride( *a );
83         inc_t     inc_x     = bli_obj_vector_inc( *x );
84         void*     buf_x     = bli_obj_buffer_at_off( *x );
86         inc_t     inc_y     = bli_obj_vector_inc( *y );
87         void*     buf_y     = bli_obj_buffer_at_off( *y );
89         num_t     dt_alpha;
90         void*     buf_alpha;
92         FUNCPTR_T f;
94         // The datatype of alpha MUST be the type union of a and x. This is to
95         // prevent any unnecessary loss of information during computation.
96         dt_alpha  = bli_datatype_union( dt_a, dt_x );
97         buf_alpha = bli_obj_buffer_for_1x1( dt_alpha, *alpha );
99         // Index into the type combination array to extract the correct
100         // function pointer.
101         f = ftypes[dt_a][dt_x][dt_y];
103         // Invoke the function.
104         f( conja,
105            conjx,
106            m,
107            b_n,
108            buf_alpha,
109            buf_a, rs_a, cs_a,
110            buf_x, inc_x,
111            buf_y, inc_y );
113 */
116 #undef  GENTFUNC3U12
117 #define GENTFUNC3U12( ctype_a, ctype_x, ctype_y, ctype_ax, cha, chx, chy, chax, varname, kername ) \
119 void PASTEMAC3(cha,chx,chy,varname) \
120      ( \
121        conj_t             conja, \
122        conj_t             conjx, \
123        dim_t              m, \
124        dim_t              b_n, \
125        ctype_ax* restrict alpha, \
126        ctype_a*  restrict a, inc_t inca, inc_t lda, \
127        ctype_x*  restrict x, inc_t incx, \
128        ctype_y*  restrict y, inc_t incy  \
129      ) \
130 { \
131         ctype_ax* alpha_cast = alpha; \
132         ctype_a*  a_cast     = a; \
133         ctype_x*  x_cast     = x; \
134         ctype_y*  y_cast     = y; \
135         ctype_a*  a1; \
136         ctype_x*  chi1; \
137         ctype_y*  y1; \
138         ctype_ax  alpha_chi1; \
139         dim_t     i; \
141         for ( i = 0; i < b_n; ++i ) \
142         { \
143                 a1   = a_cast + (0  )*inca + (i  )*lda; \
144                 chi1 = x_cast + (i  )*incx; \
145                 y1   = y_cast + (0  )*incy; \
147                 PASTEMAC2(chx,chax,copycjs)( conjx, *chi1, alpha_chi1 ); \
148                 PASTEMAC2(chax,chax,scals)( *alpha_cast, alpha_chi1 ); \
150                 PASTEMAC3(chax,cha,chy,kername)( conja, \
151                                                  m, \
152                                                  &alpha_chi1, \
153                                                  a1, inca, \
154                                                  y1, incy ); \
155         } \
158 // Define the basic set of functions unconditionally, and then also some
159 // mixed datatype functions if requested.
160 INSERT_GENTFUNC3U12_BASIC( axpyf_ref, AXPYV_KERNEL )
162 #ifdef BLIS_ENABLE_MIXED_DOMAIN_SUPPORT
163 INSERT_GENTFUNC3U12_MIX_D( axpyf_ref, AXPYV_KERNEL )
164 #endif
166 #ifdef BLIS_ENABLE_MIXED_PRECISION_SUPPORT
167 INSERT_GENTFUNC3U12_MIX_P( axpyf_ref, AXPYV_KERNEL )
168 #endif