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 addd_fp
39 typedef void (*FUNCPTR_T)(
40 doff_t diagoffx,
41 diag_t diagx,
42 trans_t transx,
43 dim_t m,
44 dim_t n,
45 void* x, inc_t rs_x, inc_t cs_x,
46 void* y, inc_t rs_y, inc_t cs_y
47 );
49 // If some mixed datatype functions will not be compiled, we initialize
50 // the corresponding elements of the function array to NULL.
51 #ifdef BLIS_ENABLE_MIXED_PRECISION_SUPPORT
52 static FUNCPTR_T GENARRAY2_ALL(ftypes,addd_unb_var1);
53 #else
54 #ifdef BLIS_ENABLE_MIXED_DOMAIN_SUPPORT
55 static FUNCPTR_T GENARRAY2_EXT(ftypes,addd_unb_var1);
56 #else
57 static FUNCPTR_T GENARRAY2_MIN(ftypes,addd_unb_var1);
58 #endif
59 #endif
62 void bli_addd_unb_var1( obj_t* x,
63 obj_t* y )
64 {
65 num_t dt_x = bli_obj_datatype( *x );
66 num_t dt_y = bli_obj_datatype( *y );
68 doff_t diagoffx = bli_obj_diag_offset( *x );
69 diag_t diagx = bli_obj_diag( *x );
70 trans_t transx = bli_obj_conjtrans_status( *x );
72 dim_t m = bli_obj_length( *y );
73 dim_t n = bli_obj_width( *y );
75 inc_t rs_x = bli_obj_row_stride( *x );
76 inc_t cs_x = bli_obj_col_stride( *x );
77 void* buf_x = bli_obj_buffer_at_off( *x );
79 inc_t rs_y = bli_obj_row_stride( *y );
80 inc_t cs_y = bli_obj_col_stride( *y );
81 void* buf_y = bli_obj_buffer_at_off( *y );
83 FUNCPTR_T f;
85 // Index into the type combination array to extract the correct
86 // function pointer.
87 f = ftypes[dt_x][dt_y];
89 // Invoke the function.
90 f( diagoffx,
91 diagx,
92 transx,
93 m,
94 n,
95 buf_x, rs_x, cs_x,
96 buf_y, rs_y, cs_y );
97 }
100 #undef GENTFUNC2
101 #define GENTFUNC2( ctype_x, ctype_y, chx, chy, varname, kername ) \
102 \
103 void PASTEMAC2(chx,chy,varname)( \
104 doff_t diagoffx, \
105 diag_t diagx, \
106 trans_t transx, \
107 dim_t m, \
108 dim_t n, \
109 void* x, inc_t rs_x, inc_t cs_x, \
110 void* y, inc_t rs_y, inc_t cs_y \
111 ) \
112 { \
113 ctype_x* x_cast = x; \
114 ctype_y* y_cast = y; \
115 ctype_x* x1; \
116 ctype_y* y1; \
117 conj_t conjx; \
118 dim_t n_elem; \
119 dim_t offx, offy; \
120 inc_t incx, incy; \
121 \
122 if ( bli_zero_dim2( m, n ) ) return; \
123 \
124 if ( bli_is_outside_diag( diagoffx, transx, m, n ) ) return; \
125 \
126 /* Determine the distance to the diagonals, the number of diagonal
127 elements, and the diagonal increments. */ \
128 bli_set_dims_incs_2d( diagoffx, transx, \
129 m, n, rs_x, cs_x, rs_y, cs_y, \
130 offx, offy, n_elem, incx, incy ); \
131 \
132 conjx = bli_extract_conj( transx ); \
133 \
134 if ( bli_is_nonunit_diag( diagx ) ) \
135 { \
136 x1 = x_cast + offx; \
137 y1 = y_cast + offy; \
138 } \
139 else /* if ( bli_is_unit_diag( diagx ) ) */ \
140 { \
141 /* Simulate a unit diagonal for x with a zero increment over a unit
142 scalar. */ \
143 x1 = PASTEMAC(chx,1); \
144 incx = 0; \
145 y1 = y_cast + offy; \
146 } \
147 \
148 PASTEMAC2(chx,chy,kername)( conjx, \
149 n_elem, \
150 x1, incx, \
151 y1, incy ); \
152 }
155 // Define the basic set of functions unconditionally, and then also some
156 // mixed datatype functions if requested.
157 INSERT_GENTFUNC2_BASIC( addd_unb_var1, ADDV_KERNEL )
159 #ifdef BLIS_ENABLE_MIXED_DOMAIN_SUPPORT
160 INSERT_GENTFUNC2_MIX_D( addd_unb_var1, ADDV_KERNEL )
161 #endif
163 #ifdef BLIS_ENABLE_MIXED_PRECISION_SUPPORT
164 INSERT_GENTFUNC2_MIX_P( addd_unb_var1, ADDV_KERNEL )
165 #endif