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 axpyf_fp
39 typedef void (*FUNCPTR_T)(
40 conj_t conja,
41 conj_t conjx,
42 dim_t m,
43 dim_t b_n,
44 void* alpha,
45 void* a, inc_t inca, inc_t lda,
46 void* x, inc_t incx,
47 void* y, inc_t incy
48 );
50 // If some mixed datatype functions will not be compiled, we initialize
51 // the corresponding elements of the function array to NULL.
52 #ifdef BLIS_ENABLE_MIXED_PRECISION_SUPPORT
53 static FUNCPTR_T GENARRAY3_ALL(ftypes,axpyf_kernel_void);
54 #else
55 #ifdef BLIS_ENABLE_MIXED_DOMAIN_SUPPORT
56 static FUNCPTR_T GENARRAY3_EXT(ftypes,axpyf_kernel_void);
57 #else
58 static FUNCPTR_T GENARRAY3_MIN(ftypes,axpyf_kernel_void);
59 #endif
60 #endif
63 void bli_axpyf_kernel( obj_t* alpha,
64 obj_t* a,
65 obj_t* x,
66 obj_t* y )
67 {
68 num_t dt_a = bli_obj_datatype( *a );
69 num_t dt_x = bli_obj_datatype( *x );
70 num_t dt_y = bli_obj_datatype( *y );
72 conj_t conja = bli_obj_conj_status( *a );
73 conj_t conjx = bli_obj_conj_status( *x );
75 dim_t m = bli_obj_vector_dim( *y );
76 dim_t b_n = bli_obj_vector_dim( *x );
78 void* buf_a = bli_obj_buffer_at_off( *a );
79 inc_t rs_a = bli_obj_row_stride( *a );
80 inc_t cs_a = bli_obj_col_stride( *a );
82 inc_t inc_x = bli_obj_vector_inc( *x );
83 void* buf_x = bli_obj_buffer_at_off( *x );
85 inc_t inc_y = bli_obj_vector_inc( *y );
86 void* buf_y = bli_obj_buffer_at_off( *y );
88 num_t dt_alpha;
89 void* buf_alpha;
91 FUNCPTR_T f;
93 // The datatype of alpha MUST be the type union of a and x. This is to
94 // prevent any unnecessary loss of information during computation.
95 dt_alpha = bli_datatype_union( dt_a, dt_x );
96 buf_alpha = bli_obj_buffer_for_1x1( dt_alpha, *alpha );
98 // Index into the type combination array to extract the correct
99 // function pointer.
100 f = ftypes[dt_a][dt_x][dt_y];
102 // Invoke the function.
103 f( conja,
104 conjx,
105 m,
106 b_n,
107 buf_alpha,
108 buf_a, rs_a, cs_a,
109 buf_x, inc_x,
110 buf_y, inc_y );
111 }
114 #undef GENTFUNC3U12
115 #define GENTFUNC3U12( ctype_a, ctype_x, ctype_y, ctype_ax, cha, chx, chy, chax, varname, kername ) \
116 \
117 void PASTEMAC3(cha,chx,chy,varname)( \
118 conj_t conja, \
119 conj_t conjx, \
120 dim_t m, \
121 dim_t b_n, \
122 void* alpha, \
123 void* a, inc_t inca, inc_t lda, \
124 void* x, inc_t incx, \
125 void* y, inc_t incy \
126 ) \
127 { \
128 PASTEMAC3(cha,chx,chy,kername)( conja, \
129 conjx, \
130 m, \
131 b_n, \
132 alpha, \
133 a, inca, lda, \
134 x, incx, \
135 y, incy ); \
136 }
138 // Define the basic set of functions unconditionally, and then also some
139 // mixed datatype functions if requested.
140 INSERT_GENTFUNC3U12_BASIC( axpyf_kernel_void, AXPYF_KERNEL )
142 #ifdef BLIS_ENABLE_MIXED_DOMAIN_SUPPORT
143 INSERT_GENTFUNC3U12_MIX_D( axpyf_kernel_void, AXPYF_KERNEL )
144 #endif
146 #ifdef BLIS_ENABLE_MIXED_PRECISION_SUPPORT
147 INSERT_GENTFUNC3U12_MIX_P( axpyf_kernel_void, AXPYF_KERNEL )
148 #endif