]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - dense-linear-algebra-libraries/linalg.git/blob - blis/frame/2/trmv/bli_trmv_l_blk_var2.c
TI Linear Algebra Library (LINALG) Rlease 1.0.0
[dense-linear-algebra-libraries/linalg.git] / blis / frame / 2 / trmv / bli_trmv_l_blk_var2.c
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 void bli_trmv_l_blk_var2( obj_t*  alpha,
38                           obj_t*  a,
39                           obj_t*  x,
40                           trmv_t* cntl )
41 {
42         obj_t   a11, a11_pack;
43         obj_t   a21;
44         obj_t   x1, x1_pack;
45         obj_t   x2;
47         dim_t   mn;
48         dim_t   ij;
49         dim_t   b_alg;
51         // Initialize objects for packing.
52         bli_obj_init_pack( &a11_pack );
53         bli_obj_init_pack( &x1_pack );
55         // Query dimension.
56         mn = bli_obj_length( *a );
58         // Partition diagonally.
59         for ( ij = 0; ij < mn; ij += b_alg )
60         {
61                 // Determine the current algorithmic blocksize.
62                 b_alg = bli_determine_blocksize_b( ij, mn, a,
63                                                    cntl_blocksize( cntl ) );
65                 // Acquire partitions for A11, A21, x1, and x2.
66                 bli_acquire_mpart_br2tl( BLIS_SUBPART11,
67                                          ij, b_alg, a, &a11 );
68                 bli_acquire_mpart_br2tl( BLIS_SUBPART21,
69                                          ij, b_alg, a, &a21 );
70                 bli_acquire_vpart_b2f( BLIS_SUBPART1,
71                                        ij, b_alg, x, &x1 );
72                 bli_acquire_vpart_b2f( BLIS_SUBPART2,
73                                        ij, b_alg, x, &x2 );
75                 // Initialize objects for packing A11 and x1 (if needed).
76                 bli_packm_init( &a11, &a11_pack,
77                                 cntl_sub_packm_a11( cntl ) );
78                 bli_packv_init( &x1, &x1_pack,
79                                 cntl_sub_packv_x1( cntl ) );
81                 // Copy/pack A11, x1 (if needed).
82                 bli_packm_int( &a11, &a11_pack,
83                                cntl_sub_packm_a11( cntl ),
84                        &BLIS_PACKM_SINGLE_THREADED );
85                 bli_packv_int( &x1, &x1_pack,
86                                cntl_sub_packv_x1( cntl ) );
88                 // x2 = x2 + alpha * A21 * x1;
89                 bli_gemv_int( BLIS_NO_TRANSPOSE,
90                               BLIS_NO_CONJUGATE,
91                           alpha,
92                               &a21,
93                               &x1_pack,
94                               &BLIS_ONE,
95                               &x2,
96                               cntl_sub_gemv_cp( cntl ) );
98                 // x1 = alpha * tril( A11 ) * x1;
99                 bli_trmv_int( alpha,
100                               &a11_pack,
101                               &x1_pack,
102                               cntl_sub_trmv( cntl ) );
104                 // Copy/unpack x1 (if x1 was packed).
105                 bli_unpackv_int( &x1_pack, &x1,
106                                  cntl_sub_unpackv_x1( cntl ) );
107         }
109         // If any packing buffers were acquired within packm, release them back
110         // to the memory manager.
111         bli_obj_release_pack( &a11_pack , cntl_sub_packm_a11( cntl ));
112         bli_obj_release_pack( &x1_pack , cntl_sub_packv_x1( cntl ));