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 setid_fp
39 typedef void (*FUNCPTR_T)(
40 doff_t diagoffx,
41 dim_t m,
42 dim_t n,
43 void* beta,
44 void* x, inc_t rs_x, inc_t cs_x
45 );
47 static FUNCPTR_T GENARRAY(ftypes,setid_unb_var1);
50 void bli_setid_unb_var1( obj_t* beta,
51 obj_t* x )
52 {
53 num_t dt_xr = bli_obj_datatype_proj_to_real( *x );
54 num_t dt_x = bli_obj_datatype( *x );
56 doff_t diagoffx = bli_obj_diag_offset( *x );
58 dim_t m = bli_obj_length( *x );
59 dim_t n = bli_obj_width( *x );
61 void* buf_beta = bli_obj_buffer_for_1x1( dt_xr, *beta );
63 void* buf_x = bli_obj_buffer_at_off( *x );
64 inc_t rs_x = bli_obj_row_stride( *x );
65 inc_t cs_x = bli_obj_col_stride( *x );
67 FUNCPTR_T f;
69 // Index into the type combination array to extract the correct
70 // function pointer.
71 f = ftypes[dt_x];
73 // Invoke the function.
74 f( diagoffx,
75 m,
76 n,
77 buf_beta,
78 buf_x, rs_x, cs_x );
79 }
82 #undef GENTFUNCR
83 #define GENTFUNCR( ctype_x, ctype_r, chx, chr, varname, kername ) \
84 \
85 void PASTEMAC(chx,varname)( \
86 doff_t diagoffx, \
87 dim_t m, \
88 dim_t n, \
89 void* beta, \
90 void* x, inc_t rs_x, inc_t cs_x \
91 ) \
92 { \
93 ctype_r* beta_cast = beta; \
94 ctype_x* x_cast = x; \
95 ctype_x* x1; \
96 ctype_x* chi11; \
97 dim_t n_elem; \
98 dim_t offx; \
99 inc_t incx; \
100 dim_t i; \
101 \
102 /* Eliminate unused variable warnings. */ \
103 ( void )beta_cast; \
104 \
105 if ( bli_zero_dim2( m, n ) ) return; \
106 \
107 if ( bli_is_outside_diag( diagoffx, BLIS_NO_TRANSPOSE, m, n ) ) return; \
108 \
109 /* Determine the distance to the diagonal, the number of diagonal
110 elements, and the diagonal increment. */ \
111 bli_set_dims_incs_1d( diagoffx, \
112 m, n, rs_x, cs_x, \
113 offx, n_elem, incx ); \
114 \
115 x1 = x_cast + offx; \
116 \
117 for ( i = 0; i < n_elem; ++i ) \
118 { \
119 chi11 = x1 + (i )*incx; \
120 \
121 PASTEMAC(chx,setis)( *beta_cast, *chi11 ); \
122 } \
123 /* Eliminate unused variable and is used before its value is set warnings */ \
124 ( void )chi11; \
125 }
127 // Define the basic set of functions unconditionally, and then also some
128 // mixed datatype functions if requested.
129 INSERT_GENTFUNCR_BASIC( setid_unb_var1, NULL )