]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - dense-linear-algebra-libraries/linalg.git/blob - blis/frame/2/trsv/bli_trsv_int.c
TI Linear Algebra Library (LINALG) Rlease 1.0.0
[dense-linear-algebra-libraries/linalg.git] / blis / frame / 2 / trsv / bli_trsv_int.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 #define FUNCPTR_T trsv_fp
39 typedef void (*FUNCPTR_T)( obj_t*  alpha,
40                            obj_t*  a,
41                            obj_t*  x,
42                            trsv_t* cntl );
44 static FUNCPTR_T vars[2][3][3] =
45 {
46         // lower triangular
47         {
48                 // unblocked         unblocked with fusing  blocked
49                 { bli_trsv_unb_var1, bli_trsv_unf_var1,     bli_trsv_l_blk_var1 },
50                 { bli_trsv_unb_var2, bli_trsv_unf_var2,     bli_trsv_l_blk_var2 },
51                 { NULL,              NULL,                  NULL                },
52         },
53         // upper triangular
54         {
55                 // unblocked         unblocked with fusing  blocked
56                 { bli_trsv_unb_var1, bli_trsv_unf_var1,     bli_trsv_u_blk_var1 },
57                 { bli_trsv_unb_var2, bli_trsv_unf_var2,     bli_trsv_u_blk_var2 },
58                 { NULL,              NULL,                  NULL                },
59         }
60 };
62 void bli_trsv_int( obj_t*  alpha,
63                    obj_t*  a,
64                    obj_t*  x,
65                    trsv_t* cntl )
66 {
67         varnum_t  n;
68         impl_t    i;
69         bool_t    uplo;
70         FUNCPTR_T f;
71         obj_t     a_local;
73         // Check parameters.
74         if ( bli_error_checking_is_enabled() )
75                 bli_trsv_int_check( alpha, a, x, cntl );
77         // If A or x has a zero dimension, return early.
78         if ( bli_obj_has_zero_dim( *a ) ) return;
79         if ( bli_obj_has_zero_dim( *x ) ) return;
81         // Alias A in case we need to induce a transformation (ie: transposition).
82         bli_obj_alias_to( *a, a_local );
84         // NOTE: to support cases where B is complex and A is real, we will
85         // need to have the default side case be BLIS_RIGHT and then express
86         // the left case in terms of it, rather than the other way around.
88         // Determine uplo (for indexing to the correct function pointer).
89         if ( bli_obj_is_lower( a_local ) ) uplo = 0;
90         else                               uplo = 1;
92         // We do not explicitly implement the cases where A is transposed.
93         // However, we can still handle them. Specifically, if A is marked as
94         // needing a transposition, we simply toggle the uplo value to cause the
95         // correct algorithm to be induced. When that algorithm partitions into
96         // A, it will grab the correct subpartitions, which will inherit A's
97         // transposition bit and thus downstream subproblems will do the right
98         // thing. Alternatively, we could accomplish the same end goal by
99         // inducing a transposition, via bli_obj_induce_trans(), in the code
100         // block below. That macro function swaps dimensions, strides, and
101         // offsets. As an example, given a lower triangular, column-major matrix
102         // that needs a transpose, we would induce that transposition by recasting
103         // the object as an upper triangular, row-major matrix (with no transpose
104         // needed). Note that how we choose to handle transposition here does NOT
105         // affect the optimal choice of kernel (ie: a column-major column panel
106         // matrix with transpose times a vector would use the same kernel as a
107         // row-major row panel matrix with no transpose times a vector).
108         if ( bli_obj_has_trans( a_local ) )
109         {
110                 //bli_obj_induce_trans( a_local );
111                 //bli_obj_set_onlytrans( BLIS_NO_TRANSPOSE, a_local );
112                 bli_toggle_bool( uplo );
113         }
115         // Extract the variant number and implementation type.
116         n = cntl_var_num( cntl );
117         i = cntl_impl_type( cntl );
119         // Index into the variant array to extract the correct function pointer.
120         f = vars[uplo][n][i];
122         // Invoke the variant.
123         f( alpha,
124            &a_local,
125            x,
126            cntl );