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