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
bli_gemv_blk_var1(obj_t * alpha,obj_t * a,obj_t * x,obj_t * beta,obj_t * y,cntx_t * cntx,gemv_t * cntl)37 void bli_gemv_blk_var1( obj_t* alpha,
38 obj_t* a,
39 obj_t* x,
40 obj_t* beta,
41 obj_t* y,
42 cntx_t* cntx,
43 gemv_t* cntl )
44 {
45 obj_t a1, a1_pack;
46 obj_t y1, y1_pack;
47
48 dim_t m_trans;
49 dim_t i;
50 dim_t b_alg;
51
52 // Initialize objects for packing.
53 bli_obj_init_pack( &a1_pack );
54 bli_obj_init_pack( &y1_pack );
55
56 // Query dimension in partitioning direction.
57 m_trans = bli_obj_length_after_trans( a );
58
59 // Partition along the m dimension.
60 for ( i = 0; i < m_trans; i += b_alg )
61 {
62 // Determine the current algorithmic blocksize.
63 b_alg = bli_determine_blocksize_f( i, m_trans, a,
64 bli_cntl_bszid( cntl ), cntx );
65
66 // Acquire partitions for A1 and y1.
67 bli_acquire_mpart_t2b( BLIS_SUBPART1,
68 i, b_alg, a, &a1 );
69 bli_acquire_vpart_f2b( BLIS_SUBPART1,
70 i, b_alg, y, &y1 );
71
72 // Initialize objects for packing A1 and y1 (if needed).
73 bli_packm_init( &a1, &a1_pack,
74 cntx, bli_cntl_sub_packm_a( cntl ) );
75 bli_packv_init( &y1, &y1_pack,
76 cntx, bli_cntl_sub_packv_y( cntl ) );
77
78 // Copy/pack A1, y1 (if needed).
79 bli_packm_int( &a1, &a1_pack,
80 cntx, bli_cntl_sub_packm_a( cntl ),
81 &BLIS_PACKM_SINGLE_THREADED );
82 bli_packv_int( &y1, &y1_pack,
83 cntx, bli_cntl_sub_packv_y( cntl ) );
84
85 // y1 = beta * y1 + alpha * A1 * x;
86 bli_gemv_int( BLIS_NO_TRANSPOSE,
87 BLIS_NO_CONJUGATE,
88 alpha,
89 &a1_pack,
90 x,
91 beta,
92 &y1_pack,
93 cntx,
94 bli_cntl_sub_gemv( cntl ) );
95
96 // Copy/unpack y1 (if y1 was packed).
97 bli_unpackv_int( &y1_pack, &y1,
98 cntx, bli_cntl_sub_unpackv_y( cntl ) );
99 }
100
101 // If any packing buffers were acquired within packm, release them back
102 // to the memory manager.
103 bli_packm_release( &a1_pack, bli_cntl_sub_packm_a( cntl ) );
104 bli_packv_release( &y1_pack, bli_cntl_sub_packv_y( cntl ) );
105 }
106
107