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_trsv_l_blk_var1( obj_t* alpha,
38 obj_t* a,
39 obj_t* x,
40 trsv_t* cntl )
41 {
42 obj_t a11, a11_pack;
43 obj_t a10;
44 obj_t x1, x1_pack;
45 obj_t x0;
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 // x = alpha * x;
59 bli_scalv_int( alpha,
60 x,
61 cntl_sub_scalv( cntl ) );
63 // Partition diagonally.
64 for ( ij = 0; ij < mn; ij += b_alg )
65 {
66 // Determine the current algorithmic blocksize.
67 b_alg = bli_determine_blocksize_f( ij, mn, a,
68 cntl_blocksize( cntl ) );
70 // Acquire partitions for A11, A10, x1, and x0.
71 bli_acquire_mpart_tl2br( BLIS_SUBPART11,
72 ij, b_alg, a, &a11 );
73 bli_acquire_mpart_tl2br( BLIS_SUBPART10,
74 ij, b_alg, a, &a10 );
75 bli_acquire_vpart_f2b( BLIS_SUBPART1,
76 ij, b_alg, x, &x1 );
77 bli_acquire_vpart_f2b( BLIS_SUBPART0,
78 ij, b_alg, x, &x0 );
80 // Initialize objects for packing A11 and x1 (if needed).
81 bli_packm_init( &a11, &a11_pack,
82 cntl_sub_packm_a11( cntl ) );
83 bli_packv_init( &x1, &x1_pack,
84 cntl_sub_packv_x1( cntl ) );
86 // Copy/pack A11, x1 (if needed).
87 bli_packm_int( &a11, &a11_pack,
88 cntl_sub_packm_a11( cntl ),
89 &BLIS_PACKM_SINGLE_THREADED );
90 bli_packv_int( &x1, &x1_pack,
91 cntl_sub_packv_x1( cntl ) );
93 // x1 = x1 - A10 * x0;
94 bli_gemv_int( BLIS_NO_TRANSPOSE,
95 BLIS_NO_CONJUGATE,
96 &BLIS_MINUS_ONE,
97 &a10,
98 &x0,
99 &BLIS_ONE,
100 &x1_pack,
101 cntl_sub_gemv_rp( cntl ) );
103 // x1 = x1 / tril( A11 );
104 bli_trsv_int( &BLIS_ONE,
105 &a11_pack,
106 &x1_pack,
107 cntl_sub_trsv( cntl ) );
109 // Copy/unpack x1 (if x1 was packed).
110 bli_unpackv_int( &x1_pack, &x1,
111 cntl_sub_unpackv_x1( cntl ) );
112 }
114 // If any packing buffers were acquired within packm, release them back
115 // to the memory manager.
116 bli_obj_release_pack( &a11_pack , cntl_sub_packm_a11( cntl ) );
117 bli_obj_release_pack( &x1_pack , cntl_sub_packv_x1( cntl ));
118 }