1 /*
2 
3    BLIS
4    An object-based framework for developing high-performance BLAS-like
5    libraries.
6 
7    Copyright (C) 2014, The University of Texas at Austin
8 
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(s) of the copyright holder(s) nor the names of its
18       contributors may be used to endorse or promote products derived
19       from this software without specific prior written permission.
20 
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.
32 
33 */
34 
35 #include "blis.h"
36 
37 #undef  GENTFUNC
38 #define GENTFUNC( ctype, ch, varname ) \
39 \
40 void PASTEMAC(ch,varname) \
41      ( \
42        trans_t transa, \
43        conj_t  conjx, \
44        dim_t   m, \
45        dim_t   n, \
46        ctype*  alpha, \
47        ctype*  a, inc_t rs_a, inc_t cs_a, \
48        ctype*  x, inc_t incx, \
49        ctype*  beta, \
50        ctype*  y, inc_t incy, \
51        cntx_t* cntx  \
52      ) \
53 { \
54 	const num_t dt = PASTEMAC(ch,type); \
55 \
56 	ctype*  zero       = PASTEMAC(ch,0); \
57 	ctype*  A1; \
58 	ctype*  x1; \
59 	ctype*  y1; \
60 	dim_t   i; \
61 	dim_t   b_fuse, f; \
62 	dim_t   n_elem, n_iter; \
63 	inc_t   rs_at, cs_at; \
64 	conj_t  conja; \
65 \
66 	bli_set_dims_incs_with_trans( transa, \
67 	                              m, n, rs_a, cs_a, \
68 	                              &n_elem, &n_iter, &rs_at, &cs_at ); \
69 \
70 	conja = bli_extract_conj( transa ); \
71 \
72 	/* If beta is zero, use setv. Otherwise, scale by beta. */ \
73 	if ( PASTEMAC(ch,eq0)( *beta ) ) \
74 	{ \
75 		/* y = 0; */ \
76 		PASTEMAC2(ch,setv,BLIS_TAPI_EX_SUF) \
77 		( \
78 		  BLIS_NO_CONJUGATE, \
79 		  n_elem, \
80 		  zero, \
81 		  y, incy, \
82 		  cntx, \
83 		  NULL  \
84 		); \
85 	} \
86 	else \
87 	{ \
88 		/* y = beta * y; */ \
89 		PASTEMAC2(ch,scalv,BLIS_TAPI_EX_SUF) \
90 		( \
91 		  BLIS_NO_CONJUGATE, \
92 		  n_elem, \
93 		  beta, \
94 		  y, incy, \
95 		  cntx, \
96 		  NULL  \
97 		); \
98 	} \
99 \
100 	PASTECH(ch,axpyf_ker_ft) kfp_af; \
101 \
102 	/* Query the context for the kernel function pointer and fusing factor. */ \
103 	kfp_af = bli_cntx_get_l1f_ker_dt( dt, BLIS_AXPYF_KER, cntx ); \
104 	b_fuse = bli_cntx_get_blksz_def_dt( dt, BLIS_AF, cntx ); \
105 \
106 	for ( i = 0; i < n_iter; i += f ) \
107 	{ \
108 		f  = bli_determine_blocksize_dim_f( i, n_iter, b_fuse ); \
109 \
110 		A1 = a + (0  )*rs_at + (i  )*cs_at; \
111 		x1 = x + (i  )*incx; \
112 		y1 = y + (0  )*incy; \
113 \
114 		/* y = y + alpha * A1 * x1; */ \
115 		kfp_af \
116 		( \
117 		  conja, \
118 		  conjx, \
119 		  n_elem, \
120 		  f, \
121 		  alpha, \
122 		  A1, rs_at, cs_at, \
123 		  x1, incx, \
124 		  y1, incy, \
125 		  cntx  \
126 		); \
127 	} \
128 }
129 
130 INSERT_GENTFUNC_BASIC0( gemv_unf_var2 )
131 
132