Debian Codegraph @

frame/2/hemv/other/bli_hemv_blk_var3.c

raw symbols SCIP
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 void bli_hemv_blk_var3( conj_t conjh,
38 obj_t* alpha,
39 obj_t* a,
40 obj_t* x,
41 obj_t* beta,
42 obj_t* y,
43 cntx_t* cntx,
44 hemv_t* cntl )
45 {
46 obj_t a11, a11_pack;
47 obj_t a21;
48 obj_t x1, x1_pack;
49 obj_t x2;
50 obj_t y1, y1_pack;
51 obj_t y2;
52
53 dim_t mn;
54 dim_t ij;
55 dim_t b_alg;
56
57 // Even though this blocked algorithm is expressed only in terms of the
58 // lower triangular case, the upper triangular case is still supported:
59 // when bli_acquire_mpart_tl2br() is passed a matrix that is stored in
60 // in the upper triangle, and the requested subpartition resides in the
61 // lower triangle (as is the case for this algorithm), the routine fills
62 // the request as if the caller had actually requested the corresponding
63 // "mirror" subpartition in the upper triangle, except that it marks the
64 // subpartition for transposition (and conjugation).
65
66 // Initialize objects for packing.
67 bli_obj_init_pack( &a11_pack );
68 bli_obj_init_pack( &x1_pack );
69 bli_obj_init_pack( &y1_pack );
70
71 // Query dimension.
72 mn = bli_obj_length( a );
73
74 // y = beta * y;
75 bli_scalv_int( beta,
76 y,
77 cntx, bli_cntl_sub_scalv( cntl ) );
78
79 // Partition diagonally.
80 for ( ij = 0; ij < mn; ij += b_alg )
81 {
82 // Determine the current algorithmic blocksize.
83 b_alg = bli_determine_blocksize_f( ij, mn, a,
84 bli_cntl_bszid( cntl ), cntx );
85
86 // Acquire partitions for A11, A10, x1, x0, y1, and y0.
87 bli_acquire_mpart_tl2br( BLIS_SUBPART11,
88 ij, b_alg, a, &a11 );
89 bli_acquire_mpart_tl2br( BLIS_SUBPART21,
90 ij, b_alg, a, &a21 );
91 bli_acquire_vpart_f2b( BLIS_SUBPART1,
92 ij, b_alg, x, &x1 );
93 bli_acquire_vpart_f2b( BLIS_SUBPART2,
94 ij, b_alg, x, &x2 );
95 bli_acquire_vpart_f2b( BLIS_SUBPART1,
96 ij, b_alg, y, &y1 );
97 bli_acquire_vpart_f2b( BLIS_SUBPART2,
98 ij, b_alg, y, &y2 );
99
100 // Initialize objects for packing A11, x1, and y1 (if needed).
101 bli_packm_init( &a11, &a11_pack,
102 cntx, bli_cntl_sub_packm_a11( cntl ) );
103 bli_packv_init( &x1, &x1_pack,
104 cntx, bli_cntl_sub_packv_x1( cntl ) );
105 bli_packv_init( &y1, &y1_pack,
106 cntx, bli_cntl_sub_packv_y1( cntl ) );
107
108 // Copy/pack A11, x1, y1 (if needed).
109 bli_packm_int( &a11, &a11_pack,
110 cntx, bli_cntl_sub_packm_a11( cntl ),
111 &BLIS_PACKM_SINGLE_THREADED );
112 bli_packv_int( &x1, &x1_pack,
113 cntx, bli_cntl_sub_packv_x1( cntl ) );
114 bli_packv_int( &y1, &y1_pack,
115 cntx, bli_cntl_sub_packv_y1( cntl ) );
116
117 // y1 = y1 + alpha * A21' * x2;
118 bli_gemv_int( bli_apply_conj( conjh, BLIS_TRANSPOSE ),
119 BLIS_NO_CONJUGATE,
120 alpha,
121 &a21,
122 &x2,
123 &BLIS_ONE,
124 &y1_pack,
125 cntx,
126 bli_cntl_sub_gemv_t_cp( cntl ) );
127
128 // y1 = y1 + alpha * A11 * x1;
129 bli_hemv_int( conjh,
130 alpha,
131 &a11_pack,
132 &x1_pack,
133 &BLIS_ONE,
134 &y1_pack,
135 cntx,
136 bli_cntl_sub_hemv( cntl ) );
137
138 // y2 = y2 + alpha * A21 * x1;
139 bli_gemv_int( BLIS_NO_TRANSPOSE,
140 BLIS_NO_CONJUGATE,
141 alpha,
142 &a21,
143 &x1_pack,
144 &BLIS_ONE,
145 &y2,
146 cntx,
147 bli_cntl_sub_gemv_n_cp( cntl ) );
148
149 // Copy/unpack y1 (if y1 was packed).
150 bli_unpackv_int( &y1_pack, &y1,
151 cntx, bli_cntl_sub_unpackv_y1( cntl ) );
152 }
153
154 // If any packing buffers were acquired within packm, release them back
155 // to the memory manager.
156 bli_packm_release( &a11_pack, bli_cntl_sub_packm_a11( cntl ) );
157 bli_packv_release( &x1_pack, bli_cntl_sub_packv_x1( cntl ) );
158 bli_packv_release( &y1_pack, bli_cntl_sub_packv_y1( cntl ) );
159 }
160