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 mksymm_fp
39 typedef void (*FUNCPTR_T)(
40 uplo_t uploa,
41 dim_t m,
42 void* a, inc_t rs_a, inc_t cs_a
43 );
45 static FUNCPTR_T GENARRAY(ftypes,mksymm_unb_var1);
48 void bli_mksymm_unb_var1( obj_t* a )
49 {
50 num_t dt_a = bli_obj_datatype( *a );
52 uplo_t uploa = bli_obj_uplo( *a );
54 dim_t m = bli_obj_length( *a );
56 void* buf_a = bli_obj_buffer_at_off( *a );
57 inc_t rs_a = bli_obj_row_stride( *a );
58 inc_t cs_a = bli_obj_col_stride( *a );
60 FUNCPTR_T f;
62 // Index into the type combination array to extract the correct
63 // function pointer.
64 f = ftypes[dt_a];
66 // Invoke the function.
67 f( uploa,
68 m,
69 buf_a, rs_a, cs_a );
70 }
73 #undef GENTFUNC
74 #define GENTFUNC( ctype, ch, varname ) \
75 \
76 void PASTEMAC(ch,varname)( \
77 uplo_t uploa, \
78 dim_t m, \
79 void* a, inc_t rs_a, inc_t cs_a \
80 ) \
81 { \
82 ctype* a_cast = a; \
83 doff_t diagoffa; \
84 \
85 /* If the dimension is zero, return early. */ \
86 if ( bli_zero_dim1( m ) ) return; \
87 \
88 /* In order to avoid the main diagonal, we must nudge the diagonal either
89 up or down by one, depending on which triangle is currently stored. */ \
90 if ( bli_is_upper( uploa ) ) diagoffa = 1; \
91 else /*if ( bli_is_lower( uploa ) )*/ diagoffa = -1; \
92 \
93 /* We will be reflecting the stored region over the diagonal into the
94 unstored region, so a transposition is necessary. */ \
95 PASTEMAC2(ch,ch,copym)( diagoffa, \
96 BLIS_NONUNIT_DIAG, \
97 uploa, \
98 BLIS_TRANSPOSE, \
99 m, \
100 m, \
101 a_cast, rs_a, cs_a, \
102 a_cast, rs_a, cs_a ); \
103 }
106 INSERT_GENTFUNC_BASIC0( mksymm_unb_var1 )