libflame  revision_anchor
Functions
FLASH_Axpy_other.c File Reference

(r)

Functions

FLA_Error FLASH_Axpy_buffer_to_hier (FLA_Obj alpha, dim_t m, dim_t n, void *buffer, dim_t rs, dim_t cs, dim_t i, dim_t j, FLA_Obj H)
 
FLA_Error FLASH_Axpy_hier_to_buffer (FLA_Obj alpha, dim_t i, dim_t j, FLA_Obj H, dim_t m, dim_t n, void *buffer, dim_t rs, dim_t cs)
 
FLA_Error FLASH_Axpy_flat_to_hier (FLA_Obj alpha, FLA_Obj F, dim_t i, dim_t j, FLA_Obj H)
 
FLA_Error FLASH_Axpy_hier_to_flat (FLA_Obj alpha, dim_t i, dim_t j, FLA_Obj H, FLA_Obj F)
 
FLA_Error FLASH_Axpy_hierarchy (int direction, FLA_Obj alpha, FLA_Obj F, FLA_Obj *H)
 

Function Documentation

◆ FLASH_Axpy_buffer_to_hier()

FLA_Error FLASH_Axpy_buffer_to_hier ( FLA_Obj  alpha,
dim_t  m,
dim_t  n,
void *  buffer,
dim_t  rs,
dim_t  cs,
dim_t  i,
dim_t  j,
FLA_Obj  H 
)

References FLA_Check_consistent_object_datatype(), FLA_Check_error_level(), FLA_Check_if_scalar(), FLA_Check_matrix_strides(), FLA_Check_submatrix_dims_and_offset(), FLA_Obj_attach_buffer(), FLA_Obj_create_without_buffer(), FLA_Obj_free_without_buffer(), FLASH_Axpy_flat_to_hier(), and FLASH_Obj_datatype().

14 {
15  FLA_Obj flat_matrix;
16  FLA_Datatype datatype;
17  FLA_Error e_val;
18 
19  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
20  {
21  e_val = FLA_Check_if_scalar( alpha );
22  FLA_Check_error_code( e_val );
23 
24  e_val = FLA_Check_consistent_object_datatype( alpha, H );
25  FLA_Check_error_code( e_val );
26 
27  e_val = FLA_Check_matrix_strides( m, n, rs, cs );
28  FLA_Check_error_code( e_val );
29 
30  e_val = FLA_Check_submatrix_dims_and_offset( m, n, i, j, H );
31  FLA_Check_error_code( e_val );
32  }
33 
34  // Acquire the datatype from the hierarchical matrix object.
35  datatype = FLASH_Obj_datatype( H );
36 
37  // Create a temporary conventional matrix object of the requested datatype
38  // and dimensions and attach the given buffer containing the incoming data.
39  FLA_Obj_create_without_buffer( datatype, m, n, &flat_matrix );
40  FLA_Obj_attach_buffer( buffer, rs, cs, &flat_matrix );
41 
42  // Recurse through H, adding in the corresponding elements of flat_matrix,
43  // starting at the (i,j) element offset.
44  FLASH_Axpy_flat_to_hier( alpha, flat_matrix, i, j, H );
45 
46  // Free the object (but don't free the buffer!).
47  FLA_Obj_free_without_buffer( &flat_matrix );
48 
49  return FLA_SUCCESS;
50 }
FLA_Datatype FLASH_Obj_datatype(FLA_Obj H)
Definition: FLASH_Obj.c:14
FLA_Error FLA_Check_submatrix_dims_and_offset(dim_t m, dim_t n, dim_t i, dim_t j, FLA_Obj A)
Definition: FLA_Check.c:834
FLA_Error FLA_Obj_attach_buffer(void *buffer, dim_t rs, dim_t cs, FLA_Obj *obj)
Definition: FLA_Obj.c:522
FLA_Error FLA_Obj_create_without_buffer(FLA_Datatype datatype, dim_t m, dim_t n, FLA_Obj *obj)
Definition: FLA_Obj.c:362
int FLA_Error
Definition: FLA_type_defs.h:47
Definition: FLA_type_defs.h:158
FLA_Error FLA_Check_matrix_strides(dim_t m, dim_t n, dim_t rs, dim_t cs)
Definition: FLA_Check.c:1146
FLA_Error FLASH_Axpy_flat_to_hier(FLA_Obj alpha, FLA_Obj F, dim_t i, dim_t j, FLA_Obj H)
Definition: FLASH_Axpy_other.c:93
unsigned int FLA_Check_error_level(void)
Definition: FLA_Check.c:18
int FLA_Datatype
Definition: FLA_type_defs.h:49
FLA_Error FLA_Check_if_scalar(FLA_Obj A)
Definition: FLA_Check.c:373
int i
Definition: bl1_axmyv2.c:145
FLA_Error FLA_Obj_free_without_buffer(FLA_Obj *obj)
Definition: FLA_Obj.c:615
FLA_Error FLA_Check_consistent_object_datatype(FLA_Obj A, FLA_Obj B)
Definition: FLA_Check.c:339

◆ FLASH_Axpy_flat_to_hier()

FLA_Error FLASH_Axpy_flat_to_hier ( FLA_Obj  alpha,
FLA_Obj  F,
dim_t  i,
dim_t  j,
FLA_Obj  H 
)

References FLA_Obj_length(), FLA_Obj_width(), FLASH_Axpy_hierarchy(), FLASH_Part_create_2x2(), and FLASH_Part_free_2x2().

Referenced by FLASH_Axpy_buffer_to_hier().

94 {
95  FLA_Obj HTL, HTR,
96  HBL, HBR;
97  FLA_Obj HBR_tl, HBR_tr,
98  HBR_bl, HBR_br;
99  dim_t m, n;
100 
101  m = FLA_Obj_length( F );
102  n = FLA_Obj_width( F );
103 
104  FLASH_Part_create_2x2( H, &HTL, &HTR,
105  &HBL, &HBR, i, j, FLA_TL );
106 
107  FLASH_Part_create_2x2( HBR, &HBR_tl, &HBR_tr,
108  &HBR_bl, &HBR_br, m, n, FLA_TL );
109 
110  FLASH_Axpy_hierarchy( FLA_FLAT_TO_HIER, alpha, F, &HBR_tl );
111 
112  FLASH_Part_free_2x2( &HBR_tl, &HBR_tr,
113  &HBR_bl, &HBR_br );
114 
115  FLASH_Part_free_2x2( &HTL, &HTR,
116  &HBL, &HBR );
117 
118  return FLA_SUCCESS;
119 }
FLA_Error FLASH_Part_free_2x2(FLA_Obj *ATL, FLA_Obj *ATR, FLA_Obj *ABL, FLA_Obj *ABR)
Definition: FLASH_View.c:589
unsigned long dim_t
Definition: FLA_type_defs.h:71
FLA_Error FLASH_Part_create_2x2(FLA_Obj A, FLA_Obj *ATL, FLA_Obj *ATR, FLA_Obj *ABL, FLA_Obj *ABR, dim_t n_rows, dim_t n_cols, FLA_Side side)
Definition: FLASH_View.c:177
Definition: FLA_type_defs.h:158
dim_t FLA_Obj_width(FLA_Obj obj)
Definition: FLA_Query.c:123
FLA_Error FLASH_Axpy_hierarchy(int direction, FLA_Obj alpha, FLA_Obj F, FLA_Obj *H)
Definition: FLASH_Axpy_other.c:151
int i
Definition: bl1_axmyv2.c:145
dim_t FLA_Obj_length(FLA_Obj obj)
Definition: FLA_Query.c:116

◆ FLASH_Axpy_hier_to_buffer()

FLA_Error FLASH_Axpy_hier_to_buffer ( FLA_Obj  alpha,
dim_t  i,
dim_t  j,
FLA_Obj  H,
dim_t  m,
dim_t  n,
void *  buffer,
dim_t  rs,
dim_t  cs 
)

References FLA_Check_consistent_object_datatype(), FLA_Check_error_level(), FLA_Check_if_scalar(), FLA_Check_matrix_strides(), FLA_Check_submatrix_dims_and_offset(), FLA_Obj_attach_buffer(), FLA_Obj_create_without_buffer(), FLA_Obj_free_without_buffer(), FLASH_Axpy_hier_to_flat(), and FLASH_Obj_datatype().

54 {
55  FLA_Obj flat_matrix;
56  FLA_Datatype datatype;
57  FLA_Error e_val;
58 
59  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
60  {
61  e_val = FLA_Check_if_scalar( alpha );
62  FLA_Check_error_code( e_val );
63 
64  e_val = FLA_Check_consistent_object_datatype( alpha, H );
65  FLA_Check_error_code( e_val );
66 
67  e_val = FLA_Check_matrix_strides( m, n, rs, cs );
68  FLA_Check_error_code( e_val );
69 
70  e_val = FLA_Check_submatrix_dims_and_offset( m, n, i, j, H );
71  FLA_Check_error_code( e_val );
72  }
73 
74  // Acquire the datatype from the hierarchical matrix object.
75  datatype = FLASH_Obj_datatype( H );
76 
77  // Create a temporary conventional matrix object of the requested datatype
78  // and dimensions and attach the given buffer containing the incoming data.
79  FLA_Obj_create_without_buffer( datatype, m, n, &flat_matrix );
80  FLA_Obj_attach_buffer( buffer, rs, cs, &flat_matrix );
81 
82  // Recurse through H, adding in the corresponding elements of flat_matrix,
83  // starting at the (i,j) element offset.
84  FLASH_Axpy_hier_to_flat( alpha, i, j, H, flat_matrix );
85 
86  // Free the object (but don't free the buffer!).
87  FLA_Obj_free_without_buffer( &flat_matrix );
88 
89  return FLA_SUCCESS;
90 }
FLA_Datatype FLASH_Obj_datatype(FLA_Obj H)
Definition: FLASH_Obj.c:14
FLA_Error FLA_Check_submatrix_dims_and_offset(dim_t m, dim_t n, dim_t i, dim_t j, FLA_Obj A)
Definition: FLA_Check.c:834
FLA_Error FLA_Obj_attach_buffer(void *buffer, dim_t rs, dim_t cs, FLA_Obj *obj)
Definition: FLA_Obj.c:522
FLA_Error FLA_Obj_create_without_buffer(FLA_Datatype datatype, dim_t m, dim_t n, FLA_Obj *obj)
Definition: FLA_Obj.c:362
int FLA_Error
Definition: FLA_type_defs.h:47
Definition: FLA_type_defs.h:158
FLA_Error FLA_Check_matrix_strides(dim_t m, dim_t n, dim_t rs, dim_t cs)
Definition: FLA_Check.c:1146
unsigned int FLA_Check_error_level(void)
Definition: FLA_Check.c:18
int FLA_Datatype
Definition: FLA_type_defs.h:49
FLA_Error FLASH_Axpy_hier_to_flat(FLA_Obj alpha, dim_t i, dim_t j, FLA_Obj H, FLA_Obj F)
Definition: FLASH_Axpy_other.c:122
FLA_Error FLA_Check_if_scalar(FLA_Obj A)
Definition: FLA_Check.c:373
int i
Definition: bl1_axmyv2.c:145
FLA_Error FLA_Obj_free_without_buffer(FLA_Obj *obj)
Definition: FLA_Obj.c:615
FLA_Error FLA_Check_consistent_object_datatype(FLA_Obj A, FLA_Obj B)
Definition: FLA_Check.c:339

◆ FLASH_Axpy_hier_to_flat()

FLA_Error FLASH_Axpy_hier_to_flat ( FLA_Obj  alpha,
dim_t  i,
dim_t  j,
FLA_Obj  H,
FLA_Obj  F 
)

References FLA_Obj_length(), FLA_Obj_width(), FLASH_Axpy_hierarchy(), FLASH_Part_create_2x2(), and FLASH_Part_free_2x2().

Referenced by FLASH_Axpy_hier_to_buffer().

123 {
124  FLA_Obj HTL, HTR,
125  HBL, HBR;
126  FLA_Obj HBR_tl, HBR_tr,
127  HBR_bl, HBR_br;
128  dim_t m, n;
129 
130  m = FLA_Obj_length( F );
131  n = FLA_Obj_width( F );
132 
133  FLASH_Part_create_2x2( H, &HTL, &HTR,
134  &HBL, &HBR, i, j, FLA_TL );
135 
136  FLASH_Part_create_2x2( HBR, &HBR_tl, &HBR_tr,
137  &HBR_bl, &HBR_br, m, n, FLA_TL );
138 
139  FLASH_Axpy_hierarchy( FLA_HIER_TO_FLAT, alpha, F, &HBR_tl );
140 
141  FLASH_Part_free_2x2( &HBR_tl, &HBR_tr,
142  &HBR_bl, &HBR_br );
143 
144  FLASH_Part_free_2x2( &HTL, &HTR,
145  &HBL, &HBR );
146 
147  return FLA_SUCCESS;
148 }
FLA_Error FLASH_Part_free_2x2(FLA_Obj *ATL, FLA_Obj *ATR, FLA_Obj *ABL, FLA_Obj *ABR)
Definition: FLASH_View.c:589
unsigned long dim_t
Definition: FLA_type_defs.h:71
FLA_Error FLASH_Part_create_2x2(FLA_Obj A, FLA_Obj *ATL, FLA_Obj *ATR, FLA_Obj *ABL, FLA_Obj *ABR, dim_t n_rows, dim_t n_cols, FLA_Side side)
Definition: FLASH_View.c:177
Definition: FLA_type_defs.h:158
dim_t FLA_Obj_width(FLA_Obj obj)
Definition: FLA_Query.c:123
FLA_Error FLASH_Axpy_hierarchy(int direction, FLA_Obj alpha, FLA_Obj F, FLA_Obj *H)
Definition: FLASH_Axpy_other.c:151
int i
Definition: bl1_axmyv2.c:145
dim_t FLA_Obj_length(FLA_Obj obj)
Definition: FLA_Query.c:116

◆ FLASH_Axpy_hierarchy()

FLA_Error FLASH_Axpy_hierarchy ( int  direction,
FLA_Obj  alpha,
FLA_Obj  F,
FLA_Obj H 
)

References FLA_Axpy_external(), FLA_Cont_with_1x3_to_1x2(), FLA_Cont_with_3x1_to_2x1(), FLA_is_owner(), FLA_Obj_elemtype(), FLA_Obj_length(), FLA_Obj_width(), FLA_Part_1x2(), FLA_Part_2x1(), FLA_Repart_1x2_to_1x3(), FLA_Repart_2x1_to_3x1(), FLASH_Obj_scalar_length(), and FLASH_Obj_scalar_width().

Referenced by FLASH_Axpy_flat_to_hier(), and FLASH_Axpy_hier_to_flat().

152 {
153  // Once we get down to a submatrix whose elements are scalars, we are down
154  // to our base case.
155  if ( FLA_Obj_elemtype( *H ) == FLA_SCALAR )
156  {
157  // Depending on which top-level function invoked us, we either axpy
158  // the source data in the flat matrix to the leaf-level submatrix of
159  // the hierarchical matrix, or axpy the data in the hierarchical
160  // submatrix to the flat matrix.
161  if ( direction == FLA_FLAT_TO_HIER )
162  {
163 #ifdef FLA_ENABLE_SCC
164  if ( FLA_is_owner() )
165 #endif
166  FLA_Axpy_external( alpha, F, *H );
167  }
168  else if ( direction == FLA_HIER_TO_FLAT )
169  {
170 #ifdef FLA_ENABLE_SCC
171  if ( FLA_is_owner() )
172 #endif
173  FLA_Axpy_external( alpha, *H, F );
174  }
175  }
176  else
177  {
178  FLA_Obj HL, HR, H0, H1, H2;
179  FLA_Obj FL, FR, F0, F1, F2;
180 
181  FLA_Obj H1T, H01,
182  H1B, H11,
183  H21;
184  FLA_Obj F1T, F01,
185  F1B, F11,
186  F21;
187 
188  dim_t b_m;
189  dim_t b_n;
190 
191  FLA_Part_1x2( *H, &HL, &HR, 0, FLA_LEFT );
192  FLA_Part_1x2( F, &FL, &FR, 0, FLA_LEFT );
193 
194  while ( FLA_Obj_width( HL ) < FLA_Obj_width( *H ) )
195  {
196  FLA_Repart_1x2_to_1x3( HL, /**/ HR, &H0, /**/ &H1, &H2,
197  1, FLA_RIGHT );
198 
199  // Get the scalar width of H1 and use that to determine the
200  // width of F1.
201  b_n = FLASH_Obj_scalar_width( H1 );
202 
203  FLA_Repart_1x2_to_1x3( FL, /**/ FR, &F0, /**/ &F1, &F2,
204  b_n, FLA_RIGHT );
205 
206  // -------------------------------------------------------------
207 
208  FLA_Part_2x1( H1, &H1T,
209  &H1B, 0, FLA_TOP );
210  FLA_Part_2x1( F1, &F1T,
211  &F1B, 0, FLA_TOP );
212 
213  while ( FLA_Obj_length( H1T ) < FLA_Obj_length( H1 ) )
214  {
215  FLA_Repart_2x1_to_3x1( H1T, &H01,
216  /* ** */ /* *** */
217  &H11,
218  H1B, &H21, 1, FLA_BOTTOM );
219 
220  // Get the scalar length of H11 and use that to determine the
221  // length of F11.
222  b_m = FLASH_Obj_scalar_length( H11 );
223 
224  FLA_Repart_2x1_to_3x1( F1T, &F01,
225  /* ** */ /* *** */
226  &F11,
227  F1B, &F21, b_m, FLA_BOTTOM );
228  // -------------------------------------------------------------
229 
230  // Recursively axpy between F11 and H11.
231  FLASH_Axpy_hierarchy( direction, alpha, F11,
232  FLASH_OBJ_PTR_AT( H11 ) );
233 
234  // -------------------------------------------------------------
235 
236  FLA_Cont_with_3x1_to_2x1( &H1T, H01,
237  H11,
238  /* ** */ /* *** */
239  &H1B, H21, FLA_TOP );
240  FLA_Cont_with_3x1_to_2x1( &F1T, F01,
241  F11,
242  /* ** */ /* *** */
243  &F1B, F21, FLA_TOP );
244  }
245 
246  // -------------------------------------------------------------
247 
248  FLA_Cont_with_1x3_to_1x2( &HL, /**/ &HR, H0, H1, /**/ H2,
249  FLA_LEFT );
250  FLA_Cont_with_1x3_to_1x2( &FL, /**/ &FR, F0, F1, /**/ F2,
251  FLA_LEFT );
252  }
253  }
254 
255  return FLA_SUCCESS;
256 }
FLA_Error FLA_Repart_2x1_to_3x1(FLA_Obj AT, FLA_Obj *A0, FLA_Obj *A1, FLA_Obj AB, FLA_Obj *A2, dim_t mb, FLA_Side side)
Definition: FLA_View.c:226
FLA_Error FLA_Repart_1x2_to_1x3(FLA_Obj AL, FLA_Obj AR, FLA_Obj *A0, FLA_Obj *A1, FLA_Obj *A2, dim_t nb, FLA_Side side)
Definition: FLA_View.c:267
unsigned long dim_t
Definition: FLA_type_defs.h:71
FLA_Error FLA_Axpy_external(FLA_Obj alpha, FLA_Obj A, FLA_Obj B)
Definition: FLA_Axpy_external.c:13
FLA_Error FLA_Cont_with_3x1_to_2x1(FLA_Obj *AT, FLA_Obj A0, FLA_Obj A1, FLA_Obj *AB, FLA_Obj A2, FLA_Side side)
Definition: FLA_View.c:428
dim_t FLASH_Obj_scalar_length(FLA_Obj H)
Definition: FLASH_View.c:600
Definition: FLA_type_defs.h:158
dim_t FLA_Obj_width(FLA_Obj obj)
Definition: FLA_Query.c:123
FLA_Error FLA_Cont_with_1x3_to_1x2(FLA_Obj *AL, FLA_Obj *AR, FLA_Obj A0, FLA_Obj A1, FLA_Obj A2, FLA_Side side)
Definition: FLA_View.c:475
FLA_Bool FLA_is_owner(void)
Definition: FLA_Obj.c:33
FLA_Error FLA_Part_2x1(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t mb, FLA_Side side)
Definition: FLA_View.c:76
FLA_Error FLA_Part_1x2(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t nb, FLA_Side side)
Definition: FLA_View.c:110
FLA_Error FLASH_Axpy_hierarchy(int direction, FLA_Obj alpha, FLA_Obj F, FLA_Obj *H)
Definition: FLASH_Axpy_other.c:151
dim_t FLASH_Obj_scalar_width(FLA_Obj H)
Definition: FLASH_View.c:641
dim_t FLA_Obj_length(FLA_Obj obj)
Definition: FLA_Query.c:116
FLA_Elemtype FLA_Obj_elemtype(FLA_Obj obj)
Definition: FLA_Query.c:51