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 
38 #undef  GENTFUNC
39 #define GENTFUNC( ctype, ch, opname, arch, suf ) \
40 \
41 void PASTEMAC3(ch,opname,arch,suf) \
42      ( \
43        conj_t           conjxt, \
44        conj_t           conjx, \
45        conj_t           conjy, \
46        dim_t            m, \
47        ctype*  restrict alpha, \
48        ctype*  restrict x, inc_t incx, \
49        ctype*  restrict y, inc_t incy, \
50        ctype*  restrict rho, \
51        ctype*  restrict z, inc_t incz, \
52        cntx_t* restrict cntx  \
53      ) \
54 { \
55 	if ( bli_zero_dim1( m ) ) return; \
56 \
57 	if ( incz == 1 && incx == 1 && incy == 1 ) \
58 	{ \
59 		if ( bli_is_noconj( conjx ) ) \
60 		{ \
61 			conj_t conjxt_use = conjxt; \
62 			ctype  dotxy; \
63 \
64 			PASTEMAC(ch,set0s)( dotxy ); \
65 \
66 			if ( bli_is_conj( conjy ) ) \
67 				bli_toggle_conj( &conjxt_use ); \
68 \
69 			if ( bli_is_noconj( conjxt_use ) ) \
70 			{ \
71 				PRAGMA_SIMD \
72 				for ( dim_t i = 0; i < m; ++i ) \
73 				{ \
74 					PASTEMAC(ch,dots)( x[i], y[i], dotxy ); \
75 					PASTEMAC(ch,axpys)( *alpha, x[i], z[i] ); \
76 				} \
77 			} \
78 			else /* bli_is_conj( conjxt_use ) ) */ \
79 			{ \
80 				PRAGMA_SIMD \
81 				for ( dim_t i = 0; i < m; ++i ) \
82 				{ \
83 					PASTEMAC(ch,dotjs)( x[i], y[i], dotxy ); \
84 					PASTEMAC(ch,axpys)( *alpha, x[i], z[i] ); \
85 				} \
86 			} \
87 \
88 			if ( bli_is_conj( conjy ) ) \
89 				PASTEMAC(ch,conjs)( dotxy ); \
90 \
91 			PASTEMAC(ch,copys)( dotxy, *rho ); \
92 		} \
93 		else /* bli_is_conj( conjx ) ) */ \
94 		{ \
95 			conj_t conjxt_use = conjxt; \
96 			ctype  dotxy; \
97 \
98 			PASTEMAC(ch,set0s)( dotxy ); \
99 \
100 			if ( bli_is_conj( conjy ) ) \
101 				bli_toggle_conj( &conjxt_use ); \
102 \
103 			if ( bli_is_noconj( conjxt_use ) ) \
104 			{ \
105 				PRAGMA_SIMD \
106 				for ( dim_t i = 0; i < m; ++i ) \
107 				{ \
108 					PASTEMAC(ch,dots)( x[i], y[i], dotxy ); \
109 					PASTEMAC(ch,axpyjs)( *alpha, x[i], z[i] ); \
110 				} \
111 			} \
112 			else /* bli_is_conj( conjxt_use ) ) */ \
113 			{ \
114 				PRAGMA_SIMD \
115 				for ( dim_t i = 0; i < m; ++i ) \
116 				{ \
117 					PASTEMAC(ch,dotjs)( x[i], y[i], dotxy ); \
118 					PASTEMAC(ch,axpyjs)( *alpha, x[i], z[i] ); \
119 				} \
120 			} \
121 \
122 			if ( bli_is_conj( conjy ) ) \
123 				PASTEMAC(ch,conjs)( dotxy ); \
124 \
125 			PASTEMAC(ch,copys)( dotxy, *rho ); \
126 		} \
127 	} \
128 	else \
129 	{ \
130 \
131 		/* Query the context for the kernel function pointer. */ \
132 		const num_t              dt     = PASTEMAC(ch,type); \
133 		PASTECH(ch,dotv_ker_ft)  kfp_dv \
134 		= \
135 		bli_cntx_get_l1v_ker_dt( dt, BLIS_DOTV_KER, cntx ); \
136 		PASTECH(ch,axpyv_ker_ft) kfp_av \
137 		= \
138 		bli_cntx_get_l1v_ker_dt( dt, BLIS_AXPYV_KER, cntx ); \
139 \
140 		kfp_dv \
141 		( \
142 		  conjxt, \
143 		  conjy, \
144 		  m, \
145 		  x, incx, \
146 		  y, incy, \
147 		  rho, \
148 		  cntx  \
149 		); \
150 \
151 		kfp_av \
152 		( \
153 		  conjx, \
154 		  m, \
155 		  alpha, \
156 		  x, incx, \
157 		  z, incz, \
158 		  cntx  \
159 		); \
160 	} \
161 }
162 
163 INSERT_GENTFUNC_BASIC2( dotaxpyv, BLIS_CNAME_INFIX, BLIS_REF_SUFFIX )
164 
165