libflame  revision_anchor
Functions
FLASH_main_prototypes.h File Reference

(r)

Go to the source code of this file.

Functions

FLA_Error FLASH_Obj_blocksizes_check (FLA_Obj H, dim_t *b_m, dim_t *b_n)
 
FLA_Error FLASH_Obj_create_helper_check (FLA_Bool without_buffer, FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
 
FLA_Error FLASH_Obj_create_hierarchy_check (FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *elem_sizes_m, dim_t *elem_sizes_n, FLA_Obj flat_matrix, FLA_Obj *H, unsigned long id, dim_t depth_overall, dim_t *depth_sizes_m, dim_t *depth_sizes_n, dim_t *m_offsets, dim_t *n_offsets)
 
FLA_Error FLASH_Obj_create_conf_to_check (FLA_Trans trans, FLA_Obj H_cur, FLA_Obj *H_new)
 
FLA_Error FLASH_Obj_create_hier_conf_to_flat_check (FLA_Trans trans, FLA_Obj F, dim_t depth, dim_t *b_mn, FLA_Obj *H)
 
FLA_Error FLASH_Obj_create_hier_conf_to_flat_ext_check (FLA_Trans trans, FLA_Obj F, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
 
FLA_Error FLASH_Obj_create_flat_conf_to_hier_check (FLA_Trans trans, FLA_Obj H, FLA_Obj *F)
 
FLA_Error FLASH_Obj_create_hier_copy_of_flat_check (FLA_Obj F, dim_t depth, dim_t *b_mn, FLA_Obj *H)
 
FLA_Error FLASH_Obj_create_hier_copy_of_flat_ext_check (FLA_Obj F, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
 
FLA_Error FLASH_Obj_create_flat_copy_of_hier_check (FLA_Obj H, FLA_Obj *F)
 
FLA_Error FLASH_Obj_free_check (FLA_Obj *H)
 
FLA_Error FLASH_Obj_free_without_buffer_check (FLA_Obj *H)
 
FLA_Error FLASH_Obj_free_hierarchy_check (FLA_Obj *H)
 
FLA_Error FLASH_Obj_attach_buffer_check (void *buffer, dim_t rs, dim_t cs, FLA_Obj *H)
 
FLA_Error FLASH_Obj_attach_buffer_hierarchy_check (FLA_Obj F, FLA_Obj *H)
 
FLA_Error FLASH_Part_create_2x1 (FLA_Obj A, FLA_Obj *AT, FLA_Obj *AB, dim_t n_rows, FLA_Side side)
 
FLA_Error FLASH_Part_create_1x2 (FLA_Obj A, FLA_Obj *AL, FLA_Obj *AR, dim_t n_cols, FLA_Side side)
 
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)
 
FLA_Error FLASH_Part_free_2x1 (FLA_Obj *AT, FLA_Obj *AB)
 
FLA_Error FLASH_Part_free_1x2 (FLA_Obj *AL, FLA_Obj *AR)
 
FLA_Error FLASH_Part_free_2x2 (FLA_Obj *ATL, FLA_Obj *ATR, FLA_Obj *ABL, FLA_Obj *ABR)
 
FLA_Error FLASH_Obj_adjust_views (FLA_Bool attach_buffer, dim_t offm, dim_t offn, dim_t m, dim_t n, FLA_Obj A, FLA_Obj *S)
 
FLA_Error FLASH_Obj_adjust_views_hierarchy (FLA_Bool attach_buffer, dim_t offm, dim_t offn, dim_t m, dim_t n, FLA_Obj A, FLA_Obj *S)
 
dim_t FLASH_Obj_scalar_length (FLA_Obj H)
 
dim_t FLASH_Obj_scalar_width (FLA_Obj H)
 
dim_t FLASH_Obj_scalar_min_dim (FLA_Obj H)
 
dim_t FLASH_Obj_scalar_max_dim (FLA_Obj H)
 
dim_t FLASH_Obj_scalar_vector_dim (FLA_Obj H)
 
dim_t FLASH_Obj_scalar_row_offset (FLA_Obj H)
 
dim_t FLASH_Obj_scalar_col_offset (FLA_Obj H)
 
dim_t FLASH_Obj_scalar_length_tl (FLA_Obj H)
 
dim_t FLASH_Obj_scalar_width_tl (FLA_Obj H)
 
dim_t FLASH_Obj_base_scalar_length (FLA_Obj H)
 
dim_t FLASH_Obj_base_scalar_width (FLA_Obj H)
 
FLA_Error FLASH_Obj_show (char *header, FLA_Obj H, char *elem_format, char *footer)
 
FLA_Error FLASH_Obj_show_hierarchy (FLA_Obj H, dim_t i, char *elem_format)
 
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)
 
FLA_Error FLASH_Copy_buffer_to_hier (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_Copy_hier_to_buffer (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_Copy_flat_to_hier (FLA_Obj F, dim_t i, dim_t j, FLA_Obj H)
 
FLA_Error FLASH_Copy_hier_to_flat (dim_t i, dim_t j, FLA_Obj H, FLA_Obj F)
 
FLA_Error FLASH_Copy_hierarchy (int direction, FLA_Obj F, FLA_Obj *H)
 
FLA_Datatype FLASH_Obj_datatype (FLA_Obj H)
 
dim_t FLASH_Obj_depth (FLA_Obj H)
 
dim_t FLASH_Obj_blocksizes (FLA_Obj H, dim_t *b_m, dim_t *b_n)
 
FLA_Error FLASH_Obj_create (FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *b_mn, FLA_Obj *H)
 
FLA_Error FLASH_Obj_create_ext (FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
 
FLA_Error FLASH_Obj_create_without_buffer (FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *b_mn, FLA_Obj *H)
 
FLA_Error FLASH_Obj_create_without_buffer_ext (FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
 
FLA_Error FLASH_Obj_create_helper (FLA_Bool without_buffer, FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
 
FLA_Error FLASH_Obj_create_hierarchy (FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *elem_sizes_m, dim_t *elem_sizes_n, FLA_Obj flat_matrix, FLA_Obj *H, unsigned long id, dim_t depth_overall, dim_t *depth_sizes_m, dim_t *depth_sizes_n, dim_t *m_offsets, dim_t *n_offsets)
 
FLA_Error FLASH_Obj_create_conf_to (FLA_Trans trans, FLA_Obj H_cur, FLA_Obj *H_new)
 
FLA_Error FLASH_Obj_create_hier_conf_to_flat (FLA_Trans trans, FLA_Obj F, dim_t depth, dim_t *b_mn, FLA_Obj *H)
 
FLA_Error FLASH_Obj_create_hier_conf_to_flat_ext (FLA_Trans trans, FLA_Obj F, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
 
FLA_Error FLASH_Obj_create_flat_conf_to_hier (FLA_Trans trans, FLA_Obj H, FLA_Obj *F)
 
FLA_Error FLASH_Obj_create_copy_of (FLA_Trans trans, FLA_Obj H_cur, FLA_Obj *H_new)
 
FLA_Error FLASH_Obj_create_hier_copy_of_flat (FLA_Obj F, dim_t depth, dim_t *b_mn, FLA_Obj *H)
 
FLA_Error FLASH_Obj_create_hier_copy_of_flat_ext (FLA_Obj F, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
 
FLA_Error FLASH_Obj_create_flat_copy_of_hier (FLA_Obj H, FLA_Obj *F)
 
void FLASH_Obj_free (FLA_Obj *H)
 
void FLASH_Obj_free_hierarchy (FLA_Obj *H)
 
void FLASH_Obj_free_without_buffer (FLA_Obj *H)
 
FLA_Error FLASH_Obj_attach_buffer (void *buffer, dim_t rs, dim_t cs, FLA_Obj *H)
 
FLA_Error FLASH_Obj_attach_buffer_hierarchy (FLA_Obj F, FLA_Obj *H)
 
FLA_Error FLASH_Obj_flatten (FLA_Obj H, FLA_Obj F)
 
FLA_Error FLASH_Obj_hierarchify (FLA_Obj F, FLA_Obj H)
 
void * FLASH_Obj_extract_buffer (FLA_Obj H)
 
void FLASH_print_struct (FLA_Obj H)
 
void FLASH_print_struct_helper (FLA_Obj H, int indent)
 

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 
)
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_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
FLA_Datatype FLASH_Obj_datatype(FLA_Obj H)
Definition: FLASH_Obj.c:14
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 FLA_Check_if_scalar(FLA_Obj A)
Definition: FLA_Check.c:373
FLA_Error FLA_Obj_create_without_buffer(FLA_Datatype datatype, dim_t m, dim_t n, FLA_Obj *obj)
Definition: FLA_Obj.c:362
FLA_Error FLA_Obj_free_without_buffer(FLA_Obj *obj)
Definition: FLA_Obj.c:615
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_Check_consistent_object_datatype(FLA_Obj A, FLA_Obj B)
Definition: FLA_Check.c:339
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
unsigned int FLA_Check_error_level(void)
Definition: FLA_Check.c:18
int FLA_Error
Definition: FLA_type_defs.h:47
int FLA_Datatype
Definition: FLA_type_defs.h:49
int i
Definition: bl1_axmyv2.c:145
Definition: FLA_type_defs.h:159

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(), FLASH_Obj_datatype(), and i.

◆ 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 
)
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_Axpy_hierarchy(int direction, FLA_Obj alpha, FLA_Obj F, FLA_Obj *H)
Definition: FLASH_Axpy_other.c:151
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
FLA_Error FLASH_Part_free_2x2(FLA_Obj *ATL, FLA_Obj *ATR, FLA_Obj *ABL, FLA_Obj *ABR)
Definition: FLASH_View.c:589
dim_t FLA_Obj_width(FLA_Obj obj)
Definition: FLA_Query.c:123
dim_t FLA_Obj_length(FLA_Obj obj)
Definition: FLA_Query.c:116
unsigned long dim_t
Definition: FLA_type_defs.h:71

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

Referenced by FLASH_Axpy_buffer_to_hier().

◆ 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 
)
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_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

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(), FLASH_Obj_datatype(), and i.

◆ 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 
)
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 }

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

Referenced by FLASH_Axpy_hier_to_buffer().

◆ FLASH_Axpy_hierarchy()

FLA_Error FLASH_Axpy_hierarchy ( int  direction,
FLA_Obj  alpha,
FLA_Obj  F,
FLA_Obj H 
)
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 }
dim_t FLASH_Obj_scalar_length(FLA_Obj H)
Definition: FLASH_View.c:600
dim_t FLASH_Obj_scalar_width(FLA_Obj H)
Definition: FLASH_View.c:641
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
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_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_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 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_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
FLA_Bool FLA_is_owner(void)
Definition: FLA_Obj.c:33
FLA_Elemtype FLA_Obj_elemtype(FLA_Obj obj)
Definition: FLA_Query.c:51

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_Axpy_hierarchy(), FLASH_Obj_scalar_length(), and FLASH_Obj_scalar_width().

Referenced by FLASH_Axpy_flat_to_hier(), FLASH_Axpy_hier_to_flat(), and FLASH_Axpy_hierarchy().

◆ FLASH_Copy_buffer_to_hier()

FLA_Error FLASH_Copy_buffer_to_hier ( dim_t  m,
dim_t  n,
void *  buffer,
dim_t  rs,
dim_t  cs,
dim_t  i,
dim_t  j,
FLA_Obj  H 
)
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_matrix_strides( m, n, rs, cs );
22  FLA_Check_error_code( e_val );
23 
24  e_val = FLA_Check_submatrix_dims_and_offset( m, n, i, j, H );
25  FLA_Check_error_code( e_val );
26  }
27 
28  // Acquire the datatype from the hierarchical matrix object.
29  datatype = FLASH_Obj_datatype( H );
30 
31  // Create a temporary conventional matrix object of the requested datatype
32  // and dimensions and attach the given buffer containing the incoming data.
33  FLA_Obj_create_without_buffer( datatype, m, n, &flat_matrix );
34  FLA_Obj_attach_buffer( buffer, rs, cs, &flat_matrix );
35 
36  // Recurse through H, adding in the corresponding elements of flat_matrix,
37  // starting at the (i,j) element offset.
38  FLASH_Copy_flat_to_hier( flat_matrix, i, j, H );
39 
40  // Free the object (but don't free the buffer!).
41  FLA_Obj_free_without_buffer( &flat_matrix );
42 
43  return FLA_SUCCESS;
44 }
FLA_Error FLASH_Copy_flat_to_hier(FLA_Obj F, dim_t i, dim_t j, FLA_Obj H)
Definition: FLASH_Copy_other.c:81

References FLA_Check_error_level(), 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_Copy_flat_to_hier(), FLASH_Obj_datatype(), and i.

◆ FLASH_Copy_flat_to_hier()

FLA_Error FLASH_Copy_flat_to_hier ( FLA_Obj  F,
dim_t  i,
dim_t  j,
FLA_Obj  H 
)
82 {
83  FLA_Obj HTL, HTR,
84  HBL, HBR;
85  FLA_Obj HBR_tl, HBR_tr,
86  HBR_bl, HBR_br;
87  dim_t m, n;
88 
89  m = FLA_Obj_length( F );
90  n = FLA_Obj_width( F );
91 
92  FLASH_Part_create_2x2( H, &HTL, &HTR,
93  &HBL, &HBR, i, j, FLA_TL );
94 
95  FLASH_Part_create_2x2( HBR, &HBR_tl, &HBR_tr,
96  &HBR_bl, &HBR_br, m, n, FLA_TL );
97 
98  FLASH_Copy_hierarchy( FLA_FLAT_TO_HIER, F, &HBR_tl );
99 
100  FLASH_Part_free_2x2( &HBR_tl, &HBR_tr,
101  &HBR_bl, &HBR_br );
102 
103  FLASH_Part_free_2x2( &HTL, &HTR,
104  &HBL, &HBR );
105 
106  return FLA_SUCCESS;
107 }
FLA_Error FLASH_Copy_hierarchy(int direction, FLA_Obj F, FLA_Obj *H)
Definition: FLASH_Copy_other.c:139

References FLA_Obj_length(), FLA_Obj_width(), FLASH_Copy_hierarchy(), FLASH_Part_create_2x2(), FLASH_Part_free_2x2(), and i.

Referenced by FLA_LQ_UT_macro_task(), FLA_LU_piv_macro_task(), FLA_QR_UT_macro_task(), FLASH_Copy_buffer_to_hier(), FLASH_Obj_create_hier_copy_of_flat(), FLASH_Obj_create_hier_copy_of_flat_ext(), and FLASH_Obj_hierarchify().

◆ FLASH_Copy_hier_to_buffer()

FLA_Error FLASH_Copy_hier_to_buffer ( dim_t  i,
dim_t  j,
FLA_Obj  H,
dim_t  m,
dim_t  n,
void *  buffer,
dim_t  rs,
dim_t  cs 
)
48 {
49  FLA_Obj flat_matrix;
50  FLA_Datatype datatype;
51  FLA_Error e_val;
52 
53  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
54  {
55  e_val = FLA_Check_matrix_strides( m, n, rs, cs );
56  FLA_Check_error_code( e_val );
57 
58  e_val = FLA_Check_submatrix_dims_and_offset( m, n, i, j, H );
59  FLA_Check_error_code( e_val );
60  }
61 
62  // Acquire the datatype from the hierarchical matrix object.
63  datatype = FLASH_Obj_datatype( H );
64 
65  // Create a temporary conventional matrix object of the requested datatype
66  // and dimensions and attach the given buffer containing the incoming data.
67  FLA_Obj_create_without_buffer( datatype, m, n, &flat_matrix );
68  FLA_Obj_attach_buffer( buffer, rs, cs, &flat_matrix );
69 
70  // Recurse through H, adding in the corresponding elements of flat_matrix,
71  // starting at the (i,j) element offset.
72  FLASH_Copy_hier_to_flat( i, j, H, flat_matrix );
73 
74  // Free the object (but don't free the buffer!).
75  FLA_Obj_free_without_buffer( &flat_matrix );
76 
77  return FLA_SUCCESS;
78 }
FLA_Error FLASH_Copy_hier_to_flat(dim_t i, dim_t j, FLA_Obj H, FLA_Obj F)
Definition: FLASH_Copy_other.c:110

References FLA_Check_error_level(), 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_Copy_hier_to_flat(), FLASH_Obj_datatype(), and i.

◆ FLASH_Copy_hier_to_flat()

FLA_Error FLASH_Copy_hier_to_flat ( dim_t  i,
dim_t  j,
FLA_Obj  H,
FLA_Obj  F 
)
111 {
112  FLA_Obj HTL, HTR,
113  HBL, HBR;
114  FLA_Obj HBR_tl, HBR_tr,
115  HBR_bl, HBR_br;
116  dim_t m, n;
117 
118  m = FLA_Obj_length( F );
119  n = FLA_Obj_width( F );
120 
121  FLASH_Part_create_2x2( H, &HTL, &HTR,
122  &HBL, &HBR, i, j, FLA_TL );
123 
124  FLASH_Part_create_2x2( HBR, &HBR_tl, &HBR_tr,
125  &HBR_bl, &HBR_br, m, n, FLA_TL );
126 
127  FLASH_Copy_hierarchy( FLA_HIER_TO_FLAT, F, &HBR_tl );
128 
129  FLASH_Part_free_2x2( &HBR_tl, &HBR_tr,
130  &HBR_bl, &HBR_br );
131 
132  FLASH_Part_free_2x2( &HTL, &HTR,
133  &HBL, &HBR );
134 
135  return FLA_SUCCESS;
136 }

References FLA_Obj_length(), FLA_Obj_width(), FLASH_Copy_hierarchy(), FLASH_Part_create_2x2(), FLASH_Part_free_2x2(), and i.

Referenced by FLASH_Copy_hier_to_buffer(), FLASH_Obj_create_flat_copy_of_hier(), and FLASH_Obj_flatten().

◆ FLASH_Copy_hierarchy()

FLA_Error FLASH_Copy_hierarchy ( int  direction,
FLA_Obj  F,
FLA_Obj H 
)
140 {
141  // Once we get down to a submatrix whose elements are scalars, we are down
142  // to our base case.
143  if ( FLA_Obj_elemtype( *H ) == FLA_SCALAR )
144  {
145  // Depending on which top-level function invoked us, we either copy
146  // the source data in the flat matrix to the leaf-level submatrix of
147  // the hierarchical matrix, or copy the data in the hierarchical
148  // submatrix to the flat matrix.
149  if ( direction == FLA_FLAT_TO_HIER )
150  {
151 #ifdef FLA_ENABLE_SCC
152  if ( FLA_is_owner() )
153 #endif
154  FLA_Copy_external( F, *H );
155  }
156  else if ( direction == FLA_HIER_TO_FLAT )
157  {
158 #ifdef FLA_ENABLE_SCC
159  if ( FLA_is_owner() )
160 #endif
161  FLA_Copy_external( *H, F );
162  }
163  }
164  else
165  {
166  FLA_Obj HL, HR, H0, H1, H2;
167  FLA_Obj FL, FR, F0, F1, F2;
168 
169  FLA_Obj H1T, H01,
170  H1B, H11,
171  H21;
172  FLA_Obj F1T, F01,
173  F1B, F11,
174  F21;
175 
176  dim_t b_m;
177  dim_t b_n;
178 
179  FLA_Part_1x2( *H, &HL, &HR, 0, FLA_LEFT );
180  FLA_Part_1x2( F, &FL, &FR, 0, FLA_LEFT );
181 
182  while ( FLA_Obj_width( HL ) < FLA_Obj_width( *H ) )
183  {
184  FLA_Repart_1x2_to_1x3( HL, /**/ HR, &H0, /**/ &H1, &H2,
185  1, FLA_RIGHT );
186 
187  // Get the scalar width of H1 and use that to determine the
188  // width of F1.
189  b_n = FLASH_Obj_scalar_width( H1 );
190 
191  FLA_Repart_1x2_to_1x3( FL, /**/ FR, &F0, /**/ &F1, &F2,
192  b_n, FLA_RIGHT );
193 
194  // -------------------------------------------------------------
195 
196  FLA_Part_2x1( H1, &H1T,
197  &H1B, 0, FLA_TOP );
198  FLA_Part_2x1( F1, &F1T,
199  &F1B, 0, FLA_TOP );
200 
201  while ( FLA_Obj_length( H1T ) < FLA_Obj_length( H1 ) )
202  {
203  FLA_Repart_2x1_to_3x1( H1T, &H01,
204  /* ** */ /* *** */
205  &H11,
206  H1B, &H21, 1, FLA_BOTTOM );
207 
208  // Get the scalar length of H11 and use that to determine the
209  // length of F11.
210  b_m = FLASH_Obj_scalar_length( H11 );
211 
212  FLA_Repart_2x1_to_3x1( F1T, &F01,
213  /* ** */ /* *** */
214  &F11,
215  F1B, &F21, b_m, FLA_BOTTOM );
216  // -------------------------------------------------------------
217 
218  // Recursively copy between F11 and H11.
219  FLASH_Copy_hierarchy( direction, F11,
220  FLASH_OBJ_PTR_AT( H11 ) );
221 
222  // -------------------------------------------------------------
223 
224  FLA_Cont_with_3x1_to_2x1( &H1T, H01,
225  H11,
226  /* ** */ /* *** */
227  &H1B, H21, FLA_TOP );
228  FLA_Cont_with_3x1_to_2x1( &F1T, F01,
229  F11,
230  /* ** */ /* *** */
231  &F1B, F21, FLA_TOP );
232  }
233 
234  // -------------------------------------------------------------
235 
236  FLA_Cont_with_1x3_to_1x2( &HL, /**/ &HR, H0, H1, /**/ H2,
237  FLA_LEFT );
238  FLA_Cont_with_1x3_to_1x2( &FL, /**/ &FR, F0, F1, /**/ F2,
239  FLA_LEFT );
240  }
241  }
242 
243  return FLA_SUCCESS;
244 }
FLA_Error FLA_Copy_external(FLA_Obj A, FLA_Obj B)
Definition: FLA_Copy_external.c:13

References FLA_Cont_with_1x3_to_1x2(), FLA_Cont_with_3x1_to_2x1(), FLA_Copy_external(), 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_Copy_hierarchy(), FLASH_Obj_scalar_length(), and FLASH_Obj_scalar_width().

Referenced by FLASH_Copy_flat_to_hier(), FLASH_Copy_hier_to_flat(), and FLASH_Copy_hierarchy().

◆ FLASH_Obj_adjust_views()

FLA_Error FLASH_Obj_adjust_views ( FLA_Bool  attach_buffer,
dim_t  offm,
dim_t  offn,
dim_t  m,
dim_t  n,
FLA_Obj  A,
FLA_Obj S 
)
276 {
277 
278  FLASH_Obj_adjust_views_hierarchy( attach_buffer, offm, offn, m, n, A, S );
279 
280  return FLA_SUCCESS;
281 }
FLA_Error FLASH_Obj_adjust_views_hierarchy(FLA_Bool attach_buffer, dim_t offm, dim_t offn, dim_t m, dim_t n, FLA_Obj A, FLA_Obj *S)
Definition: FLASH_View.c:283

References FLASH_Obj_adjust_views_hierarchy().

Referenced by FLASH_Obj_create_conf_to(), FLASH_Part_create_1x2(), FLASH_Part_create_2x1(), and FLASH_Part_create_2x2().

◆ FLASH_Obj_adjust_views_hierarchy()

FLA_Error FLASH_Obj_adjust_views_hierarchy ( FLA_Bool  attach_buffer,
dim_t  offm,
dim_t  offn,
dim_t  m,
dim_t  n,
FLA_Obj  A,
FLA_Obj S 
)
284 {
285  FLA_Obj ATL, ATR,
286  ABL, ABR;
287 
288  FLA_Obj STL, STR,
289  SBL, SBR;
290 
291  // Base case.
292  if ( FLA_Obj_elemtype( A ) == FLA_SCALAR )
293  {
294  // Repartition to exclude elements above and to the left of our
295  // submatrix of interest.
296  FLA_Part_2x2( A, &ATL, &ATR,
297  &ABL, &ABR, offm, offn, FLA_TL );
298  FLA_Part_2x2( *S, &STL, &STR,
299  &SBL, &SBR, offm, offn, FLA_TL );
300 
301  // Overwrite the existing views with ones that have updated offsets.
302  A = ABR;
303  *S = SBR;
304 
305  // Repartition to exclude elements below and to the right of our
306  // submatrix of interest.
307  FLA_Part_2x2( A, &ATL, &ATR,
308  &ABL, &ABR, m, n, FLA_TL );
309  FLA_Part_2x2( *S, &STL, &STR,
310  &SBL, &SBR, m, n, FLA_TL );
311 
312  // Overwrite the existing view of S with the view of A so that S
313  // Refers to the correct base object.
314  A = ATL;
315  *S = STL;
316 
317  // Adjust the _inner fields in the view to reflect the number of
318  // elements we have in each dimension.
319  S->m_inner = m;
320  S->n_inner = n;
321 
322  // Copy over buffer, stride, and object ID information if requested.
323  if ( attach_buffer )
324  {
325  // Copy over the address of the numerical data buffer and its
326  // corresponding row and column strides. This is obviously
327  // necessary since we are creating a hierarchial view into an
328  // existing hierarhical matrix, not a separate/new matrix
329  // altogether.
330  S->base->buffer = A.base->buffer;
331  S->base->rs = A.base->rs;
332  S->base->cs = A.base->cs;
333 
334  // Copy over the id field of the original matrix. This is used
335  // by SuperMatrix to distinguish between distinct hierarchical
336  // matrices. Since again, we are not creating a new matrix, we
337  // will use the original object's id value.
338  S->base->id = A.base->id;
339  }
340  }
341  else // if ( FLA_Obj_elemtype( A ) == FLA_MATRIX )
342  {
343  FLA_Obj AL, AR, A0, A1, A2;
344 
345  FLA_Obj SL, SR, S0, S1, S2;
346 
347  FLA_Obj A1T, A01,
348  A1B, A11,
349  A21;
350 
351  FLA_Obj S1T, S01,
352  S1B, S11,
353  S21;
354  dim_t b_m_full;
355  dim_t b_n_full;
356  dim_t offm_relA;
357  dim_t offn_relA;
358  dim_t offm_abs;
359  dim_t offn_abs;
360  dim_t offm_cur;
361  dim_t offn_cur;
362  dim_t offm_rem;
363  dim_t offn_rem;
364  dim_t offm_next;
365  dim_t offn_next;
366  dim_t m_next;
367  dim_t n_next;
368  dim_t m_ahead;
369  dim_t n_ahead;
370  dim_t m_behind;
371  dim_t n_behind;
372 
373  // Acquire the scalar length and width of the top-left (full) block
374  // at the current hierarchical level.
375  b_m_full = FLASH_Obj_scalar_length_tl( A );
376  b_n_full = FLASH_Obj_scalar_width_tl( A );
377 /*
378 printf( "-----------------\n" );
379 printf( "b_m/n_full: %d %d\n", b_m_full, b_n_full );
380 printf( "offm/n: %d %d\n", offm, offn );
381 printf( "r/c offsets: %d %d\n", FLA_Obj_row_offset( A ), FLA_Obj_col_offset( A ) );
382 */
383  // Compute the offsets for the top-left corner of the submatrix of
384  // interest relative to the view at the current level of the
385  // hierarchy of A.
386  offm_relA = offm / b_m_full - FLA_Obj_row_offset( A );
387  offn_relA = offn / b_n_full - FLA_Obj_col_offset( A );
388 
389  // Compute the offsets for the top-left corner of the submatrix of
390  // interest in absolute units, from the top-left edge of the
391  // overall allocated matrix. This will be used to partition into S
392  // Since its view has (presumably) not yet been changed since it
393  // was created.
394  offm_abs = offm / b_m_full;
395  offn_abs = offn / b_n_full;
396 /*
397 printf( "offm/n_relA: %d %d\n", offm_relA, offn_relA );
398 printf( "offm/n_abs: %d %d\n", offm_abs, offn_abs );
399 */
400  // Repartition to exclude blocks above and to the left of our
401  // submatrix of interest.
402  FLA_Part_2x2( A, &ATL, &ATR,
403  &ABL, &ABR, offm_relA, offn_relA, FLA_TL );
404  FLA_Part_2x2( *S, &STL, &STR,
405  &SBL, &SBR, offm_abs, offn_abs, FLA_TL );
406 /*
407 printf( "ABR.offm/n %d %d\n", FLA_Obj_row_offset( ABR ), FLA_Obj_col_offset( ABR ) );
408 printf( "ABR is %d %d\n", FLA_Obj_length( ABR ), FLA_Obj_width( ABR ) );
409 printf( "SBR.offm/n %d %d\n", FLA_Obj_row_offset( SBR ), FLA_Obj_col_offset( SBR ) );
410 printf( "SBR is %d %d\n", FLA_Obj_length( SBR ), FLA_Obj_width( SBR ) );
411 */
412  // Overwrite the existing views with ones that have updated offsets
413  // (for this level in the hierarchy).
414  A = ABR;
415  *S = SBR;
416 
417  // Compute the new offsets within SBR, which is the remaining
418  // distance after you subtract out the distance spanned by the
419  // partitioning we just did.
420  offm_rem = offm - offm_abs * b_m_full;
421  offn_rem = offn - offn_abs * b_n_full;
422 
423 //printf( "offm/n_rem: %d %d\n", offm_rem, offn_rem );
424 
425  // Compute a new set of offsets corresponding to the bottom-right
426  // edge of the desired submatrix. We'll use this to partition away
427  // the remaining (bottom and right) parts of the FLASH matrix at
428  // this level.
429  offm_cur = ( offm_rem + m ) / b_m_full;
430  offn_cur = ( offn_rem + n ) / b_n_full;
431  offm_cur += ( (offm_rem + m) % b_m_full ? 1 : 0 );
432  offn_cur += ( (offn_rem + n) % b_n_full ? 1 : 0 );
433 
434 //printf( "offm/n_cur: %d %d\n", offm_cur, offn_cur );
435 
436  // Repartition to exclude blocks below and to the right of our
437  // submatrix of interest.
438  FLA_Part_2x2( A, &ATL, &ATR,
439  &ABL, &ABR, offm_cur, offn_cur, FLA_TL );
440  FLA_Part_2x2( *S, &STL, &STR,
441  &SBL, &SBR, offm_cur, offn_cur, FLA_TL );
442 /*
443 printf( "ATL.offm/n %d %d\n", FLA_Obj_row_offset( ATL ), FLA_Obj_col_offset( ATL ) );
444 printf( "ATL is %d %d\n", FLA_Obj_length( ATL ), FLA_Obj_width( ATL ) );
445 printf( "STL.offm/n %d %d\n", FLA_Obj_row_offset( STL ), FLA_Obj_col_offset( STL ) );
446 printf( "STL is %d %d\n", FLA_Obj_length( STL ), FLA_Obj_width( STL ) );
447 */
448 
449  // Overwrite the existing views with ones that have updated offsets
450  // (for this level in the hierarchy).
451  A = ATL;
452  *S = STL;
453 
454  // Adjust the _inner fields in the view to reflect the number of
455  // elements we will eventually have in each dimension.
456  S->m_inner = m;
457  S->n_inner = n;
458 
459  // Initialize a counter that keeps track of the n offset relative to
460  // the top-left most edge of the submatrix of interest.
461  n_behind = 0;
462 
463  FLA_Part_1x2( A, &AL, &AR, 0, FLA_LEFT );
464  FLA_Part_1x2( *S, &SL, &SR, 0, FLA_LEFT );
465 
466  while ( FLA_Obj_width( AL ) < FLA_Obj_width( A ) )
467  {
468  FLA_Repart_1x2_to_1x3( AL, /**/ AR, &A0, /**/ &A1, &A2,
469  1, FLA_RIGHT );
470  FLA_Repart_1x2_to_1x3( SL, /**/ SR, &S0, /**/ &S1, &S2,
471  1, FLA_RIGHT );
472 
473  // -------------------------------------------------------------
474 
475  // Set the n offset for the next levels of recursion based
476  // on which panel of A we are in.
477  if ( FLA_Obj_width( AL ) == 0 ) offn_next = offn_rem;
478  else offn_next = 0;
479 
480  // Compute the number of columns left to be visited in the
481  // submatrix of interset.
482  n_ahead = n - n_behind;
483 
484  // Set the n dimensions for the next level of recursion
485  // depending on whether the submatrix continues beyond the
486  // current block.
487  if ( offn_next + n_ahead > b_n_full ) n_next = b_n_full - offn_next;
488  else n_next = n_ahead;
489 
490  // Initialize a counter that keeps track of the m offset relative
491  // to the top-left most edge of the submatrix of interest.
492  m_behind = 0;
493 
494  FLA_Part_2x1( A1, &A1T,
495  &A1B, 0, FLA_TOP );
496  FLA_Part_2x1( S1, &S1T,
497  &S1B, 0, FLA_TOP );
498 
499  while ( FLA_Obj_length( A1T ) < FLA_Obj_length( A1 ) )
500  {
501  FLA_Repart_2x1_to_3x1( A1T, &A01,
502  /* ** */ /* ** */
503  &A11,
504  A1B, &A21, 1, FLA_BOTTOM );
505  FLA_Repart_2x1_to_3x1( S1T, &S01,
506  /* ** */ /* ** */
507  &S11,
508  S1B, &S21, 1, FLA_BOTTOM );
509 
510  // -------------------------------------------------------------
511 
512  // Set the m offset for the next levels of recursion based
513  // on which block of A1 we are in.
514  if ( FLA_Obj_length( A1T ) == 0 ) offm_next = offm_rem;
515  else offm_next = 0;
516 
517  // Compute the number of rows left to be visited in the
518  // submatrix of interset.
519  m_ahead = m - m_behind;
520 
521  // Set the m dimensions for the next level of recursion
522  // depending on whether the submatrix continues beyond the
523  // current block.
524  if ( offm_next + m_ahead > b_m_full ) m_next = b_m_full - offm_next;
525  else m_next = m_ahead;
526 
527 //printf( "offm/n_next m/n_next: %d %d %d %d\n", offm_next, offn_next, m_next, n_next );
528  // Recursively call ourselves with new, smaller offsets
529  // and the submatrix corresponding to FLASH blocks captured by ABR.
530  FLASH_Obj_adjust_views_hierarchy( attach_buffer,
531  offm_next,
532  offn_next,
533  m_next,
534  n_next,
535  *FLASH_OBJ_PTR_AT( A11 ),
536  FLASH_OBJ_PTR_AT( S11 ) );
537 
538  // Increment m_behind to keep track of our absolute m offset.
539  m_behind += m_next;
540 
541  // -------------------------------------------------------------
542 
543  FLA_Cont_with_3x1_to_2x1( &A1T, A01,
544  A11,
545  /* ** */ /* ** */
546  &A1B, A21, FLA_TOP );
547  FLA_Cont_with_3x1_to_2x1( &S1T, S01,
548  S11,
549  /* ** */ /* ** */
550  &S1B, S21, FLA_TOP );
551  }
552 
553  // Increment n_behind to keep track of our absolute n offset.
554  n_behind += n_next;
555 
556  // -------------------------------------------------------------
557 
558  FLA_Cont_with_1x3_to_1x2( &AL, /**/ &AR, A0, A1, /**/ A2,
559  FLA_LEFT );
560  FLA_Cont_with_1x3_to_1x2( &SL, /**/ &SR, S0, S1, /**/ S2,
561  FLA_LEFT );
562  }
563  }
564 
565  return FLA_SUCCESS;
566 }
dim_t FLASH_Obj_scalar_length_tl(FLA_Obj H)
Definition: FLASH_View.c:723
dim_t FLASH_Obj_scalar_width_tl(FLA_Obj H)
Definition: FLASH_View.c:737
FLA_Error FLA_Part_2x2(FLA_Obj A, FLA_Obj *A11, FLA_Obj *A12, FLA_Obj *A21, FLA_Obj *A22, dim_t mb, dim_t nb, FLA_Quadrant quadrant)
Definition: FLA_View.c:17
dim_t FLA_Obj_col_offset(FLA_Obj obj)
Definition: FLA_Query.c:186
dim_t FLA_Obj_row_offset(FLA_Obj obj)
Definition: FLA_Query.c:180
dim_t rs
Definition: FLA_type_defs.h:129
unsigned long id
Definition: FLA_type_defs.h:133
dim_t cs
Definition: FLA_type_defs.h:130
void * buffer
Definition: FLA_type_defs.h:138
dim_t n_inner
Definition: FLA_type_defs.h:166
dim_t m_inner
Definition: FLA_type_defs.h:165
FLA_Base_obj * base
Definition: FLA_type_defs.h:168

References FLA_Obj_view::base, FLA_Obj_struct::buffer, FLA_Obj_struct::cs, FLA_Cont_with_1x3_to_1x2(), FLA_Cont_with_3x1_to_2x1(), FLA_Obj_col_offset(), FLA_Obj_elemtype(), FLA_Obj_length(), FLA_Obj_row_offset(), FLA_Obj_width(), FLA_Part_1x2(), FLA_Part_2x1(), FLA_Part_2x2(), FLA_Repart_1x2_to_1x3(), FLA_Repart_2x1_to_3x1(), FLASH_Obj_adjust_views_hierarchy(), FLASH_Obj_scalar_length_tl(), FLASH_Obj_scalar_width_tl(), FLA_Obj_struct::id, FLA_Obj_view::m_inner, FLA_Obj_view::n_inner, and FLA_Obj_struct::rs.

Referenced by FLASH_Obj_adjust_views(), and FLASH_Obj_adjust_views_hierarchy().

◆ FLASH_Obj_attach_buffer()

FLA_Error FLASH_Obj_attach_buffer ( void *  buffer,
dim_t  rs,
dim_t  cs,
FLA_Obj H 
)
782 {
783  FLA_Obj flat_matrix;
784  dim_t m_base, n_base;
785  FLA_Datatype datatype;
786 
787  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
788  FLASH_Obj_attach_buffer_check( buffer, rs, cs, H );
789 
790  // Extract the scalar dimensions of the base object(s) and get its
791  // numerical datatype. (These fields will be set even if it has a NULL
792  // buffer, which it probably does since this function was just invoked.)
793  m_base = FLASH_Obj_base_scalar_length( *H );
794  n_base = FLASH_Obj_base_scalar_width( *H );
795  datatype = FLASH_Obj_datatype( *H );
796 
797  // Create a temporary conventional object and attach the given buffer.
798  // Segments of this buffer will be partitioned out to the various
799  // leaf-level matrices of the hierarchical matrix H.
800  FLA_Obj_create_without_buffer( datatype, m_base, n_base, &flat_matrix );
801  FLA_Obj_attach_buffer( buffer, rs, cs, &flat_matrix );
802 
803  // Recurse through the hierarchical matrix, assigning segments of
804  // flat_matrix to the various leaf-level matrices, similar to what
805  // we would do if we were creating the object outright.
806  FLASH_Obj_attach_buffer_hierarchy( flat_matrix, H );
807 
808  // Free the object (but don't free the buffer!).
809  FLA_Obj_free_without_buffer( &flat_matrix );
810 
811  return FLA_SUCCESS;
812 }
dim_t FLASH_Obj_base_scalar_length(FLA_Obj H)
Definition: FLASH_Obj.c:83
dim_t FLASH_Obj_base_scalar_width(FLA_Obj H)
Definition: FLASH_Obj.c:113
FLA_Error FLASH_Obj_attach_buffer_hierarchy(FLA_Obj F, FLA_Obj *H)
Definition: FLASH_Obj.c:815
FLA_Datatype FLASH_Obj_datatype(FLA_Obj H)
Definition: FLASH_Obj.c:14
FLA_Error FLASH_Obj_attach_buffer_check(void *buffer, dim_t rs, dim_t cs, FLA_Obj *H)
Definition: FLASH_Obj_attach_buffer_check.c:13

References FLA_Check_error_level(), FLA_Obj_attach_buffer(), FLA_Obj_create_without_buffer(), FLA_Obj_free_without_buffer(), FLASH_Obj_attach_buffer_check(), FLASH_Obj_attach_buffer_hierarchy(), FLASH_Obj_base_scalar_length(), FLASH_Obj_base_scalar_width(), and FLASH_Obj_datatype().

◆ FLASH_Obj_attach_buffer_check()

FLA_Error FLASH_Obj_attach_buffer_check ( void *  buffer,
dim_t  rs,
dim_t  cs,
FLA_Obj H 
)
14 {
15  FLA_Error e_val;
16 
17  e_val = FLA_Check_null_pointer( H );
18  FLA_Check_error_code( e_val );
19 
21  FLA_Check_error_code( e_val );
22 
23  return FLA_SUCCESS;
24 }
dim_t FLASH_Obj_base_scalar_length(FLA_Obj H)
Definition: FLASH_Obj.c:83
dim_t FLASH_Obj_base_scalar_width(FLA_Obj H)
Definition: FLASH_Obj.c:113
FLA_Error FLA_Check_null_pointer(void *ptr)
Definition: FLA_Check.c:518

References FLA_Check_matrix_strides(), FLA_Check_null_pointer(), FLASH_Obj_base_scalar_length(), and FLASH_Obj_base_scalar_width().

Referenced by FLASH_Obj_attach_buffer().

◆ FLASH_Obj_attach_buffer_hierarchy()

FLA_Error FLASH_Obj_attach_buffer_hierarchy ( FLA_Obj  F,
FLA_Obj H 
)
816 {
817  FLA_Obj FL, FR, F0, F1, F2;
818 
819  FLA_Obj HL, HR, H0, H1, H2;
820 
821  FLA_Obj F1T, F01,
822  F1B, F11,
823  F21;
824 
825  FLA_Obj H1T, H01,
826  H1B, H11,
827  H21;
828 
829  dim_t b_m, b_n;
830 
831  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
833 
834  if ( FLA_Obj_elemtype( *H ) == FLA_SCALAR )
835  {
836  // If we've recursed down to a leaf node, then we can simply attach
837  // the matrix buffer to the current leaf-level submatrix.
838  // Notice we use FLA_Obj_buffer_at_view() because we want to attach
839  // the buffer address referenced by the view of F.
841  FLA_Obj_row_stride( F ),
842  FLA_Obj_col_stride( F ), H );
843  }
844  else
845  {
846  FLA_Part_1x2( *H, &HL, &HR, 0, FLA_LEFT );
847 
848  FLA_Part_1x2( F, &FL, &FR, 0, FLA_LEFT );
849 
850  while ( FLA_Obj_width( HL ) < FLA_Obj_width( *H ) )
851  {
852 
853  FLA_Repart_1x2_to_1x3( HL, /**/ HR, &H0, /**/ &H1, &H2,
854  1, FLA_RIGHT );
855 
856  b_n = FLASH_Obj_base_scalar_width( H1 );
857 
858  FLA_Repart_1x2_to_1x3( FL, /**/ FR, &F0, /**/ &F1, &F2,
859  b_n, FLA_RIGHT );
860 
861  /*------------------------------------------------------------*/
862 
863  FLA_Part_2x1( H1, &H1T,
864  &H1B, 0, FLA_TOP );
865 
866  FLA_Part_2x1( F1, &F1T,
867  &F1B, 0, FLA_TOP );
868 
869  while ( FLA_Obj_length( H1T ) < FLA_Obj_length( H1 ) )
870  {
871 
872  FLA_Repart_2x1_to_3x1( H1T, &H01,
873  /* ** */ /* ** */
874  &H11,
875  H1B, &H21, 1, FLA_BOTTOM );
876 
877  b_m = FLASH_Obj_base_scalar_length( H11 );
878 
879  FLA_Repart_2x1_to_3x1( F1T, &F01,
880  /* ** */ /* ** */
881  &F11,
882  F1B, &F21, b_m, FLA_BOTTOM );
883 
884  /*------------------------------------------------------------*/
885 
887  FLASH_OBJ_PTR_AT( H11 ) );
888 
889  /*------------------------------------------------------------*/
890 
891  FLA_Cont_with_3x1_to_2x1( &H1T, H01,
892  H11,
893  /* ** */ /* ** */
894  &H1B, H21, FLA_TOP );
895 
896  FLA_Cont_with_3x1_to_2x1( &F1T, F01,
897  F11,
898  /* ** */ /* ** */
899  &F1B, F21, FLA_TOP );
900  }
901 
902  /*------------------------------------------------------------*/
903 
904  FLA_Cont_with_1x3_to_1x2( &HL, /**/ &HR, H0, H1, /**/ H2,
905  FLA_LEFT );
906 
907  FLA_Cont_with_1x3_to_1x2( &FL, /**/ &FR, F0, F1, /**/ F2,
908  FLA_LEFT );
909 
910  }
911  }
912 
913  return FLA_SUCCESS;
914 }
FLA_Error FLASH_Obj_attach_buffer_hierarchy_check(FLA_Obj F, FLA_Obj *H)
Definition: FLASH_Obj_attach_buffer_hierarchy_check.c:13
dim_t FLA_Obj_row_stride(FLA_Obj obj)
Definition: FLA_Query.c:167
dim_t FLA_Obj_col_stride(FLA_Obj obj)
Definition: FLA_Query.c:174
void * FLA_Obj_buffer_at_view(FLA_Obj obj)
Definition: FLA_Query.c:215

References FLA_Check_error_level(), FLA_Cont_with_1x3_to_1x2(), FLA_Cont_with_3x1_to_2x1(), FLA_Obj_attach_buffer(), FLA_Obj_buffer_at_view(), FLA_Obj_col_stride(), FLA_Obj_elemtype(), FLA_Obj_length(), FLA_Obj_row_stride(), FLA_Obj_width(), FLA_Part_1x2(), FLA_Part_2x1(), FLA_Repart_1x2_to_1x3(), FLA_Repart_2x1_to_3x1(), FLASH_Obj_attach_buffer_hierarchy(), FLASH_Obj_attach_buffer_hierarchy_check(), FLASH_Obj_base_scalar_length(), and FLASH_Obj_base_scalar_width().

Referenced by FLASH_Obj_attach_buffer(), and FLASH_Obj_attach_buffer_hierarchy().

◆ FLASH_Obj_attach_buffer_hierarchy_check()

FLA_Error FLASH_Obj_attach_buffer_hierarchy_check ( FLA_Obj  F,
FLA_Obj H 
)
14 {
15  FLA_Error e_val;
16 
17  e_val = FLA_Check_null_pointer( H );
18  FLA_Check_error_code( e_val );
19 
20  return FLA_SUCCESS;
21 }

References FLA_Check_null_pointer().

Referenced by FLASH_Obj_attach_buffer_hierarchy().

◆ FLASH_Obj_base_scalar_length()

dim_t FLASH_Obj_base_scalar_length ( FLA_Obj  H)
84 {
85  FLA_Obj* buffer;
86  dim_t m;
87  dim_t rs, cs;
88  dim_t i;
89  dim_t m_base = 0;
90 
91  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
92  return FLA_Obj_base_length( H );
93 
94  // Notice we use the base buffer since we are interested in the
95  // whole object, not just the part referened by the view.
96  buffer = FLA_Obj_base_buffer( H );
97  m = FLA_Obj_base_length( H );
98  rs = FLA_Obj_row_stride( H );
99  cs = FLA_Obj_col_stride( H );
100 
101  // Add up the row dimensions of all the base objects in the 0th
102  // column of objects.
103  for ( i = 0; i < m; ++i )
104  {
105  FLA_Obj hij = buffer[ i*rs + 0*cs ];
106 
107  m_base += (hij.base)->m_inner;
108  }
109 
110  return m_base;
111 }
dim_t FLA_Obj_base_length(FLA_Obj obj)
Definition: FLA_Query.c:192
void * FLA_Obj_base_buffer(FLA_Obj obj)
Definition: FLA_Query.c:210

References FLA_Obj_view::base, FLA_Obj_base_buffer(), FLA_Obj_base_length(), FLA_Obj_col_stride(), FLA_Obj_elemtype(), FLA_Obj_row_stride(), and i.

Referenced by FLASH_Obj_attach_buffer(), FLASH_Obj_attach_buffer_check(), FLASH_Obj_attach_buffer_hierarchy(), FLASH_Obj_create_conf_to(), FLASH_Obj_scalar_length_tl(), FLASH_Part_create_1x2(), FLASH_Part_create_2x1(), and FLASH_Part_create_2x2().

◆ FLASH_Obj_base_scalar_width()

dim_t FLASH_Obj_base_scalar_width ( FLA_Obj  H)
114 {
115  FLA_Obj* buffer;
116  dim_t n;
117  dim_t rs, cs;
118  dim_t j;
119  dim_t n_base = 0;
120 
121  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
122  return FLA_Obj_base_width( H );
123 
124  // Notice we use the base buffer since we are interested in the
125  // whole object, not just the part referened by the view.
126  buffer = FLA_Obj_base_buffer( H );
127  n = FLA_Obj_base_width( H );
128  rs = FLA_Obj_row_stride( H );
129  cs = FLA_Obj_col_stride( H );
130 
131  // Add up the column dimensions of all the base objects in the 0th
132  // row of objects.
133  for ( j = 0; j < n; ++j )
134  {
135  FLA_Obj hij = buffer[ 0*rs + j*cs ];
136 
137  n_base += (hij.base)->n_inner;
138  }
139 
140  return n_base;
141 }
dim_t FLA_Obj_base_width(FLA_Obj obj)
Definition: FLA_Query.c:198

References FLA_Obj_view::base, FLA_Obj_base_buffer(), FLA_Obj_base_width(), FLA_Obj_col_stride(), FLA_Obj_elemtype(), and FLA_Obj_row_stride().

Referenced by FLASH_Obj_attach_buffer(), FLASH_Obj_attach_buffer_check(), FLASH_Obj_attach_buffer_hierarchy(), FLASH_Obj_create_conf_to(), FLASH_Obj_scalar_width_tl(), FLASH_Part_create_1x2(), FLASH_Part_create_2x1(), and FLASH_Part_create_2x2().

◆ FLASH_Obj_blocksizes()

dim_t FLASH_Obj_blocksizes ( FLA_Obj  H,
dim_t b_m,
dim_t b_n 
)
50 {
51  FLA_Elemtype elemtype;
52  FLA_Obj* buffer_H;
53  dim_t depth = 0;
54 
55  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
56  FLASH_Obj_blocksizes_check( H, b_m, b_n );
57 
58  // Recurse through the hierarchy to the first leaf node. We initialize
59  // the recursion here:
60  elemtype = FLA_Obj_elemtype( H );
61  buffer_H = ( FLA_Obj* ) FLA_Obj_base_buffer( H );
62 
63  while ( elemtype == FLA_MATRIX )
64  {
65  b_m[depth] = FLA_Obj_base_length( buffer_H[0] );
66  b_n[depth] = FLA_Obj_base_width( buffer_H[0] );
67  ++depth;
68 
69  // Get the element type of the top-leftmost underlying object. Also,
70  // get a pointer to the first element of the top-leftmost object and
71  // assume that it is of type FLA_Obj* in case elemtype is once again
72  // FLA_MATRIX.
73  elemtype = FLA_Obj_elemtype( buffer_H[0] );
74  buffer_H = ( FLA_Obj * ) FLA_Obj_base_buffer( buffer_H[0] );
75  }
76 
77  // At this point, the first depth elements of blocksizes have been filled
78  // with the blocksizes of H's various hierarchical levels. Return the
79  // matrix depth as a confirmation of how many blocksizes were found.
80  return depth;
81 }
FLA_Error FLASH_Obj_blocksizes_check(FLA_Obj H, dim_t *b_m, dim_t *b_n)
Definition: FLASH_Obj_blocksizes_check.c:13
int FLA_Elemtype
Definition: FLA_type_defs.h:50

References FLA_Check_error_level(), FLA_Obj_base_buffer(), FLA_Obj_base_length(), FLA_Obj_base_width(), FLA_Obj_elemtype(), and FLASH_Obj_blocksizes_check().

Referenced by FLASH_Obj_create_conf_to(), FLASH_Part_create_1x2(), FLASH_Part_create_2x1(), and FLASH_Part_create_2x2().

◆ FLASH_Obj_blocksizes_check()

FLA_Error FLASH_Obj_blocksizes_check ( FLA_Obj  H,
dim_t b_m,
dim_t b_n 
)
14 {
15  FLA_Error e_val;
16 
17  e_val = FLA_Check_null_pointer( b_m );
18  FLA_Check_error_code( e_val );
19 
20  e_val = FLA_Check_null_pointer( b_n );
21  FLA_Check_error_code( e_val );
22 
23  return FLA_SUCCESS;
24 }

References FLA_Check_null_pointer().

Referenced by FLASH_Obj_blocksizes().

◆ FLASH_Obj_create()

FLA_Error FLASH_Obj_create ( FLA_Datatype  datatype,
dim_t  m,
dim_t  n,
dim_t  depth,
dim_t b_mn,
FLA_Obj H 
)
144 {
145  FLASH_Obj_create_helper( FALSE, datatype, m, n, depth, b_mn, b_mn, H );
146 
147  return FLA_SUCCESS;
148 }
FLA_Error FLASH_Obj_create_helper(FLA_Bool without_buffer, FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
Definition: FLASH_Obj.c:175

References FLASH_Obj_create_helper().

Referenced by FLASH_Obj_create_diag_panel(), and FLASH_Obj_create_hier_conf_to_flat().

◆ FLASH_Obj_create_conf_to()

FLA_Error FLASH_Obj_create_conf_to ( FLA_Trans  trans,
FLA_Obj  H_cur,
FLA_Obj H_new 
)
407 {
408  FLA_Datatype datatype;
409  dim_t m_base, n_base;
410  dim_t m_view, n_view;
411  dim_t offm_scalar, offn_scalar;
412  dim_t depth;
413  dim_t* b_m;
414  dim_t* b_n;
415 
416  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
417  FLASH_Obj_create_conf_to_check( trans, H, H_new );
418 
419  // Acquire some properties of the hierarchical matrix object.
420  datatype = FLASH_Obj_datatype( H );
421  m_base = FLASH_Obj_base_scalar_length( H );
422  n_base = FLASH_Obj_base_scalar_width( H );
423  m_view = FLASH_Obj_scalar_length( H );
424  n_view = FLASH_Obj_scalar_width( H );
425  offm_scalar = FLASH_Obj_scalar_row_offset( H );
426  offn_scalar = FLASH_Obj_scalar_col_offset( H );
427  depth = FLASH_Obj_depth( H );
428 
429  // Allocate a pair of temporary arrays for the blocksizes, whose lengths
430  // are equal to the object's hierarchical depth.
431  b_m = ( dim_t* ) FLA_malloc( depth * sizeof( dim_t ) );
432  b_n = ( dim_t* ) FLA_malloc( depth * sizeof( dim_t ) );
433 
434  // Accumulate the blocksizes into the blocksize buffer.
435  FLASH_Obj_blocksizes( H, b_m, b_n );
436 
437  // Handle the transposition, if requested.
438  if ( trans == FLA_TRANSPOSE )
439  {
440  FLA_Check_error_code( FLA_NOT_YET_IMPLEMENTED );
441  }
442 
443  // Create the new hierarchical matrix object with the same base dimensions
444  // as the original object..
445  FLASH_Obj_create_ext( datatype, m_base, n_base, depth, b_m, b_n, H_new );
446 
447  // Adjust the hierarchical view of the new object to match that of the
448  // original object.
449  FLASH_Obj_adjust_views( FALSE, offm_scalar, offn_scalar, m_view, n_view, H, H_new );
450 
451  // Free the temporary blocksize buffers.
452  FLA_free( b_m );
453  FLA_free( b_n );
454 
455  return FLA_SUCCESS;
456 }
dim_t FLASH_Obj_blocksizes(FLA_Obj H, dim_t *b_m, dim_t *b_n)
Definition: FLASH_Obj.c:49
FLA_Error FLASH_Obj_create_ext(FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
Definition: FLASH_Obj.c:151
dim_t FLASH_Obj_depth(FLA_Obj H)
Definition: FLASH_Obj.c:20
FLA_Error FLASH_Obj_create_conf_to_check(FLA_Trans trans, FLA_Obj H_cur, FLA_Obj *H_new)
Definition: FLASH_Obj_create_conf_to_check.c:13
dim_t FLASH_Obj_scalar_row_offset(FLA_Obj H)
Definition: FLASH_View.c:693
dim_t FLASH_Obj_scalar_col_offset(FLA_Obj H)
Definition: FLASH_View.c:708
FLA_Error FLASH_Obj_adjust_views(FLA_Bool attach_buffer, dim_t offm, dim_t offn, dim_t m, dim_t n, FLA_Obj A, FLA_Obj *S)
Definition: FLASH_View.c:275
void FLA_free(void *ptr)
Definition: FLA_Memory.c:247
void * FLA_malloc(size_t size)
Definition: FLA_Memory.c:111

References FLA_Check_error_level(), FLA_free(), FLA_malloc(), FLASH_Obj_adjust_views(), FLASH_Obj_base_scalar_length(), FLASH_Obj_base_scalar_width(), FLASH_Obj_blocksizes(), FLASH_Obj_create_conf_to_check(), FLASH_Obj_create_ext(), FLASH_Obj_datatype(), FLASH_Obj_depth(), FLASH_Obj_scalar_col_offset(), FLASH_Obj_scalar_length(), FLASH_Obj_scalar_row_offset(), and FLASH_Obj_scalar_width().

Referenced by FLASH_CAQR_UT_inc_create_hier_matrices(), FLASH_Eig_gest(), and FLASH_Obj_create_copy_of().

◆ FLASH_Obj_create_conf_to_check()

FLA_Error FLASH_Obj_create_conf_to_check ( FLA_Trans  trans,
FLA_Obj  H_cur,
FLA_Obj H_new 
)
14 {
15  FLA_Error e_val;
16 
17  e_val = FLA_Check_valid_real_trans( trans );
18  FLA_Check_error_code( e_val );
19 
20  e_val = FLA_Check_null_pointer( H_new );
21  FLA_Check_error_code( e_val );
22 
23  return FLA_SUCCESS;
24 }
FLA_Error FLA_Check_valid_real_trans(FLA_Trans trans)
Definition: FLA_Check.c:917

References FLA_Check_null_pointer(), and FLA_Check_valid_real_trans().

Referenced by FLASH_Obj_create_conf_to().

◆ FLASH_Obj_create_copy_of()

FLA_Error FLASH_Obj_create_copy_of ( FLA_Trans  trans,
FLA_Obj  H_cur,
FLA_Obj H_new 
)
562 {
563  // Create a new object conformal to the current object.
564  FLASH_Obj_create_conf_to( trans, H_cur, H_new );
565 
566  // This is a workaround until we implement a FLASH_Copyt().
567  if ( trans == FLA_NO_TRANSPOSE || trans == FLA_CONJ_NO_TRANSPOSE )
568  {
569  // Copy the contents of the current object to the new object.
570  FLASH_Copy( H_cur, *H_new );
571 
572  // NOTE: we don't currently honor requests to conjugate!
573  // We could, if we had FLASH_Conj() implemented, but we don't
574  // currently.
575  }
576  else // if ( trans == FLA_TRANSPOSE || trans == FLA_CONJ_TRANSPOSE )
577  {
578  FLA_Obj F, F_trans;
579 
581  FLA_Obj_create_copy_of( trans, F, &F_trans );
582  FLASH_Obj_hierarchify( F_trans, *H_new );
583  FLA_Obj_free( &F );
584  FLA_Obj_free( &F_trans );
585  }
586 
587  return FLA_SUCCESS;
588 }
FLA_Error FLASH_Obj_create_flat_copy_of_hier(FLA_Obj H, FLA_Obj *F)
Definition: FLASH_Obj.c:623
FLA_Error FLASH_Obj_hierarchify(FLA_Obj F, FLA_Obj H)
Definition: FLASH_Obj.c:773
FLA_Error FLASH_Obj_create_conf_to(FLA_Trans trans, FLA_Obj H, FLA_Obj *H_new)
Definition: FLASH_Obj.c:406
FLA_Error FLASH_Copy(FLA_Obj A, FLA_Obj B)
Definition: FLASH_Copy.c:15
FLA_Error FLA_Obj_create_copy_of(FLA_Trans trans, FLA_Obj old, FLA_Obj *obj)
Definition: FLA_Obj.c:345
FLA_Error FLA_Obj_free(FLA_Obj *obj)
Definition: FLA_Obj.c:588

References FLA_Obj_create_copy_of(), FLA_Obj_free(), FLASH_Copy(), FLASH_Obj_create_conf_to(), FLASH_Obj_create_flat_copy_of_hier(), and FLASH_Obj_hierarchify().

Referenced by FLASH_CAQR_UT_inc_solve(), FLASH_QR_UT_inc_solve(), FLASH_QR_UT_solve(), and FLASH_UDdate_UT_inc_update_rhs().

◆ FLASH_Obj_create_ext()

FLA_Error FLASH_Obj_create_ext ( FLA_Datatype  datatype,
dim_t  m,
dim_t  n,
dim_t  depth,
dim_t b_m,
dim_t b_n,
FLA_Obj H 
)

◆ FLASH_Obj_create_flat_conf_to_hier()

FLA_Error FLASH_Obj_create_flat_conf_to_hier ( FLA_Trans  trans,
FLA_Obj  H,
FLA_Obj F 
)
528 {
529  FLA_Datatype datatype;
530  dim_t m_H, n_H;
531  dim_t m_F, n_F;
532 
533  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
535 
536  // Acquire the numerical datatype, length, and width of the
537  // hierarchical matrix object.
538  datatype = FLASH_Obj_datatype( H );
539  m_H = FLASH_Obj_scalar_length( H );
540  n_H = FLASH_Obj_scalar_width( H );
541 
542  // Factor in the transposition, if requested.
543  if ( trans == FLA_NO_TRANSPOSE )
544  {
545  m_F = m_H;
546  n_F = n_H;
547  }
548  else
549  {
550  m_F = n_H;
551  n_F = m_H;
552  }
553 
554  // Create the flat matrix object. Default to column-major storage.
555  FLA_Obj_create( datatype, m_F, n_F, 0, 0, F );
556 
557  return FLA_SUCCESS;
558 }
FLA_Error FLASH_Obj_create_flat_conf_to_hier_check(FLA_Trans trans, FLA_Obj H, FLA_Obj *F)
Definition: FLASH_Obj_create_flat_conf_to_hier_check.c:13
FLA_Error FLA_Obj_create(FLA_Datatype datatype, dim_t m, dim_t n, dim_t rs, dim_t cs, FLA_Obj *obj)
Definition: FLA_Obj.c:55

References FLA_Check_error_level(), FLA_Obj_create(), FLASH_Obj_create_flat_conf_to_hier_check(), FLASH_Obj_datatype(), FLASH_Obj_scalar_length(), and FLASH_Obj_scalar_width().

Referenced by FLASH_Obj_create_flat_copy_of_hier().

◆ FLASH_Obj_create_flat_conf_to_hier_check()

FLA_Error FLASH_Obj_create_flat_conf_to_hier_check ( FLA_Trans  trans,
FLA_Obj  H,
FLA_Obj F 
)
14 {
15  FLA_Error e_val;
16 
17  e_val = FLA_Check_valid_real_trans( trans );
18  FLA_Check_error_code( e_val );
19 
20  e_val = FLA_Check_null_pointer( F );
21  FLA_Check_error_code( e_val );
22 
23  return FLA_SUCCESS;
24 }

References FLA_Check_null_pointer(), and FLA_Check_valid_real_trans().

Referenced by FLASH_Obj_create_flat_conf_to_hier().

◆ FLASH_Obj_create_flat_copy_of_hier()

FLA_Error FLASH_Obj_create_flat_copy_of_hier ( FLA_Obj  H,
FLA_Obj F 
)
624 {
625  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
627 
628  // Create a flat object conformal to the hierarchical object.
629  FLASH_Obj_create_flat_conf_to_hier( FLA_NO_TRANSPOSE, H, F );
630 
631  // Flatten the hierarchical object's contents into the new flat object.
632  FLASH_Copy_hier_to_flat( 0, 0, H, *F );
633 
634  return FLA_SUCCESS;
635 }
FLA_Error FLASH_Obj_create_flat_conf_to_hier(FLA_Trans trans, FLA_Obj H, FLA_Obj *F)
Definition: FLASH_Obj.c:527
FLA_Error FLASH_Obj_create_flat_copy_of_hier_check(FLA_Obj H, FLA_Obj *F)
Definition: FLASH_Obj_create_flat_copy_of_hier_check.c:13
FLA_Error FLASH_Copy_hier_to_flat(dim_t i, dim_t j, FLA_Obj H, FLA_Obj F)
Definition: FLASH_Copy_other.c:110

References FLA_Check_error_level(), FLASH_Copy_hier_to_flat(), FLASH_Obj_create_flat_conf_to_hier(), and FLASH_Obj_create_flat_copy_of_hier_check().

Referenced by FLA_LQ_UT_macro_task(), FLA_LU_piv_macro_task(), FLA_QR_UT_macro_task(), FLASH_Hermitianize(), FLASH_Max_elemwise_diff(), FLASH_Norm1(), FLASH_Obj_create_copy_of(), FLASH_Random_matrix(), FLASH_Random_spd_matrix(), FLASH_Set(), FLASH_Shift_diag(), and FLASH_Triangularize().

◆ FLASH_Obj_create_flat_copy_of_hier_check()

FLA_Error FLASH_Obj_create_flat_copy_of_hier_check ( FLA_Obj  H,
FLA_Obj F 
)
14 {
15  FLA_Error e_val;
16 
17  e_val = FLA_Check_null_pointer( F );
18  FLA_Check_error_code( e_val );
19 
20  return FLA_SUCCESS;
21 }

References FLA_Check_null_pointer().

Referenced by FLASH_Obj_create_flat_copy_of_hier().

◆ FLASH_Obj_create_helper()

FLA_Error FLASH_Obj_create_helper ( FLA_Bool  without_buffer,
FLA_Datatype  datatype,
dim_t  m,
dim_t  n,
dim_t  depth,
dim_t b_m,
dim_t b_n,
FLA_Obj H 
)
176 {
177  dim_t i;
178  FLA_Obj flat_matrix;
179 
180  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
181  FLASH_Obj_create_helper_check( without_buffer, datatype, m, n, depth, b_m, b_n, H );
182 
183  if ( depth == 0 )
184  {
185  // Base case: create a single contiguous matrix block. If we are
186  // creating an object with a buffer, then we use column-major order.
187  if ( without_buffer == FALSE )
188  FLA_Obj_create( datatype, m, n, 0, 0, H );
189  else
190  FLA_Obj_create_without_buffer( datatype, m, n, H );
191  }
192  else
193  {
194  // We need temporary arrays the same length as the blocksizes arrays.
195  dim_t* elem_sizes_m = ( dim_t * ) FLA_malloc( depth * sizeof( dim_t ) );
196  dim_t* elem_sizes_n = ( dim_t * ) FLA_malloc( depth * sizeof( dim_t ) );
197  dim_t* depth_sizes_m = ( dim_t * ) FLA_malloc( depth * sizeof( dim_t ) );
198  dim_t* depth_sizes_n = ( dim_t * ) FLA_malloc( depth * sizeof( dim_t ) );
199  dim_t* m_offsets = ( dim_t * ) FLA_malloc( depth * sizeof( dim_t ) );
200  dim_t* n_offsets = ( dim_t * ) FLA_malloc( depth * sizeof( dim_t ) );
201 
202  // Fill two sets of arrays: elem_sizes_m/elem_sizes_n and depth_sizes_m/
203  // depth_sizes_n.
204  // - elem_sizes_m[i] will contain the number of numerical elements that span
205  // the row dimension of a block at the ith level of the hierarchy. This is
206  // just the product of all row blocksizes "internal" to and including the
207  // current blocking level. (The elem_sizes_n array tracks similar values
208  // in the column dimension.)
209  // - depth_sizes_m[i] is similar to elem_sizes_m[i]. The only difference is
210  // that instead of tracking the number of numerical elements in the row
211  // dimension, it tracks the number of "storage" blocks that span the m
212  // dimension of a block at the ith level, where the m dimension of a
213  // storage block is the block size given in b_m[depth-1], ie:
214  // the inner-most row dimension block size. (The depth_sizes_n array
215  // tracks similar values in the column dimension.)
216  elem_sizes_m[depth-1] = b_m[depth-1];
217  elem_sizes_n[depth-1] = b_n[depth-1];
218  depth_sizes_m[depth-1] = 1;
219  depth_sizes_n[depth-1] = 1;
220  for ( i = depth - 1; i > 0; --i )
221  {
222  elem_sizes_m[i-1] = elem_sizes_m[i] * b_m[i-1];
223  elem_sizes_n[i-1] = elem_sizes_n[i] * b_n[i-1];
224  depth_sizes_m[i-1] = depth_sizes_m[i] * b_m[i-1];
225  depth_sizes_n[i-1] = depth_sizes_n[i] * b_n[i-1];
226  }
227 
228  // Initialize the m_offsets and n_offsets arrays to zero.
229  for ( i = 0; i < depth; i++ )
230  {
231  m_offsets[i] = 0;
232  n_offsets[i] = 0;
233  }
234 
235  // Create a "flat" matrix object. All leaf-level child objects will refer
236  // to various offsets within this object's buffer. Whether we create the
237  // object with row- or column-major storage is moot, since either way it
238  // will be a 1-by-mn length matrix which we will partition through later
239  // on in FLASH_Obj_create_hierarchy(). Note that it is IMPORTANT that the
240  // matrix be 1-by-mn, and NOT m-by-n, since we want to use the 1x2
241  // partitioning routines to walk through it as we attach various parts of
242  // the buffer to the matrix hierarchy.
243  if ( without_buffer == FALSE )
244  FLA_Obj_create( datatype, 1, m*n, 0, 0, &flat_matrix );
245  else
246  FLA_Obj_create_without_buffer( datatype, m, n, &flat_matrix );
247 
248  // Recursively create the matrix hierarchy.
249  FLASH_Obj_create_hierarchy( datatype, m, n, depth, elem_sizes_m, elem_sizes_n, flat_matrix, H, 0, depth, depth_sizes_m, depth_sizes_n, m_offsets, n_offsets );
250 
251  // Free the flat_matrix object, but not its buffer. If we created a
252  // normal object with a buffer, we don't want to free the buffer because
253  // it is being used by the hierarchical objected we just created. If we
254  // created a bufferless object, we don't want to free the buffer because
255  // there was no buffer allocated in the first place.
256  FLA_Obj_free_without_buffer( &flat_matrix );
257 
258  // Free the local arrays.
259  FLA_free( elem_sizes_m );
260  FLA_free( elem_sizes_n );
261  FLA_free( depth_sizes_m );
262  FLA_free( depth_sizes_n );
263  FLA_free( m_offsets );
264  FLA_free( n_offsets );
265  }
266 
267  return FLA_SUCCESS;
268 }
FLA_Error FLASH_Obj_create_hierarchy(FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *elem_sizes_m, dim_t *elem_sizes_n, FLA_Obj flat_matrix, FLA_Obj *H, unsigned long id, dim_t depth_overall, dim_t *depth_sizes_m, dim_t *depth_sizes_n, dim_t *m_offsets, dim_t *n_offsets)
Definition: FLASH_Obj.c:271
FLA_Error FLASH_Obj_create_helper_check(FLA_Bool without_buffer, FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
Definition: FLASH_Obj_create_helper_check.c:13

References FLA_Check_error_level(), FLA_free(), FLA_malloc(), FLA_Obj_create(), FLA_Obj_create_without_buffer(), FLA_Obj_free_without_buffer(), FLASH_Obj_create_helper_check(), FLASH_Obj_create_hierarchy(), and i.

Referenced by FLASH_Obj_create(), FLASH_Obj_create_ext(), FLASH_Obj_create_without_buffer(), and FLASH_Obj_create_without_buffer_ext().

◆ FLASH_Obj_create_helper_check()

FLA_Error FLASH_Obj_create_helper_check ( FLA_Bool  without_buffer,
FLA_Datatype  datatype,
dim_t  m,
dim_t  n,
dim_t  depth,
dim_t b_m,
dim_t b_n,
FLA_Obj H 
)
14 {
15  FLA_Error e_val;
16 
17  e_val = FLA_Check_valid_datatype( datatype );
18  FLA_Check_error_code( e_val );
19 
20  e_val = FLA_Check_null_pointer( b_m );
21  FLA_Check_error_code( e_val );
22 
23  e_val = FLA_Check_null_pointer( b_n );
24  FLA_Check_error_code( e_val );
25 
26  e_val = FLA_Check_null_pointer( H );
27  FLA_Check_error_code( e_val );
28 
29  // A value of depth < 0 should cause an error.
30 
31  // Values of m < 1, n < 1 should cause an error. (or < 0?)
32 
33  // First depth entries in blocksize_m, _n should be checked; values < 1 should cause error.
34 
35  return FLA_SUCCESS;
36 }
FLA_Error FLA_Check_valid_datatype(FLA_Datatype datatype)
Definition: FLA_Check.c:156

References FLA_Check_null_pointer(), and FLA_Check_valid_datatype().

Referenced by FLASH_Obj_create_helper().

◆ FLASH_Obj_create_hier_conf_to_flat()

FLA_Error FLASH_Obj_create_hier_conf_to_flat ( FLA_Trans  trans,
FLA_Obj  F,
dim_t  depth,
dim_t b_mn,
FLA_Obj H 
)
460 {
461  FLA_Datatype datatype;
462  dim_t m_H, n_H;
463  dim_t m_F, n_F;
464 
465  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
466  FLASH_Obj_create_hier_conf_to_flat_check( trans, F, depth, b_mn, H );
467 
468  // Acquire the numerical datatype, length, and width of the flat matrix
469  // object.
470  datatype = FLA_Obj_datatype( F );
471  m_F = FLA_Obj_length( F );
472  n_F = FLA_Obj_width( F );
473 
474  // Factor in the transposition, if requested.
475  if ( trans == FLA_NO_TRANSPOSE )
476  {
477  m_H = m_F;
478  n_H = n_F;
479  }
480  else
481  {
482  m_H = n_F;
483  n_H = m_F;
484  }
485 
486  // Create the hierarchical matrix object.
487  FLASH_Obj_create( datatype, m_H, n_H, depth, b_mn, H );
488 
489  return FLA_SUCCESS;
490 }
FLA_Error FLASH_Obj_create(FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *b_mn, FLA_Obj *H)
Definition: FLASH_Obj.c:143
FLA_Error FLASH_Obj_create_hier_conf_to_flat_check(FLA_Trans trans, FLA_Obj F, dim_t depth, dim_t *blocksizes, FLA_Obj *H)
Definition: FLASH_Obj_create_hier_conf_to_flat_check.c:13
FLA_Datatype FLA_Obj_datatype(FLA_Obj obj)
Definition: FLA_Query.c:13

References FLA_Check_error_level(), FLA_Obj_datatype(), FLA_Obj_length(), FLA_Obj_width(), FLASH_Obj_create(), and FLASH_Obj_create_hier_conf_to_flat_check().

Referenced by FLASH_Obj_create_hier_copy_of_flat().

◆ FLASH_Obj_create_hier_conf_to_flat_check()

FLA_Error FLASH_Obj_create_hier_conf_to_flat_check ( FLA_Trans  trans,
FLA_Obj  F,
dim_t  depth,
dim_t b_mn,
FLA_Obj H 
)
14 {
15  FLA_Error e_val;
16 
17  e_val = FLA_Check_valid_real_trans( trans );
18  FLA_Check_error_code( e_val );
19 
20  e_val = FLA_Check_null_pointer( blocksizes );
21  FLA_Check_error_code( e_val );
22 
23  e_val = FLA_Check_null_pointer( H );
24  FLA_Check_error_code( e_val );
25 
26  // A value of depth < 0 should cause an error.
27 
28  // First depth entries in blocksize should be checked; values < 1 should cause error.
29 
30  return FLA_SUCCESS;
31 }

References FLA_Check_null_pointer(), and FLA_Check_valid_real_trans().

Referenced by FLASH_Obj_create_hier_conf_to_flat().

◆ FLASH_Obj_create_hier_conf_to_flat_ext()

FLA_Error FLASH_Obj_create_hier_conf_to_flat_ext ( FLA_Trans  trans,
FLA_Obj  F,
dim_t  depth,
dim_t b_m,
dim_t b_n,
FLA_Obj H 
)
494 {
495  FLA_Datatype datatype;
496  dim_t m_H, n_H;
497  dim_t m_F, n_F;
498 
499  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
500  FLASH_Obj_create_hier_conf_to_flat_ext_check( trans, F, depth, b_m, b_n, H );
501 
502  // Acquire the numerical datatype, length, and width of the flat matrix
503  // object.
504  datatype = FLA_Obj_datatype( F );
505  m_F = FLA_Obj_length( F );
506  n_F = FLA_Obj_width( F );
507 
508  // Factor in the transposition, if requested.
509  if ( trans == FLA_NO_TRANSPOSE )
510  {
511  m_H = m_F;
512  n_H = n_F;
513  }
514  else
515  {
516  m_H = n_F;
517  n_H = m_F;
518  }
519 
520  // Create the hierarchical matrix object.
521  FLASH_Obj_create_ext( datatype, m_H, n_H, depth, b_m, b_n, H );
522 
523  return FLA_SUCCESS;
524 }
FLA_Error FLASH_Obj_create_hier_conf_to_flat_ext_check(FLA_Trans trans, FLA_Obj F, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
Definition: FLASH_Obj_create_hier_conf_to_flat_ext_check.c:13

References FLA_Check_error_level(), FLA_Obj_datatype(), FLA_Obj_length(), FLA_Obj_width(), FLASH_Obj_create_ext(), and FLASH_Obj_create_hier_conf_to_flat_ext_check().

Referenced by FLASH_Obj_create_hier_copy_of_flat_ext().

◆ FLASH_Obj_create_hier_conf_to_flat_ext_check()

FLA_Error FLASH_Obj_create_hier_conf_to_flat_ext_check ( FLA_Trans  trans,
FLA_Obj  F,
dim_t  depth,
dim_t b_m,
dim_t b_n,
FLA_Obj H 
)
14 {
15  FLA_Error e_val;
16 
17  e_val = FLA_Check_valid_real_trans( trans );
18  FLA_Check_error_code( e_val );
19 
20  e_val = FLA_Check_null_pointer( b_m );
21  FLA_Check_error_code( e_val );
22 
23  e_val = FLA_Check_null_pointer( b_n );
24  FLA_Check_error_code( e_val );
25 
26  e_val = FLA_Check_null_pointer( H );
27  FLA_Check_error_code( e_val );
28 
29  // A value of depth < 0 should cause an error.
30 
31  // First depth entries in blocksize should be checked; values < 1 should cause error.
32 
33  return FLA_SUCCESS;
34 }

References FLA_Check_null_pointer(), and FLA_Check_valid_real_trans().

Referenced by FLASH_Obj_create_hier_conf_to_flat_ext().

◆ FLASH_Obj_create_hier_copy_of_flat()

FLA_Error FLASH_Obj_create_hier_copy_of_flat ( FLA_Obj  F,
dim_t  depth,
dim_t b_mn,
FLA_Obj H 
)
592 {
593  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
594  FLASH_Obj_create_hier_copy_of_flat_check( F, depth, b_mn, H );
595 
596  // Create a hierarchical object conformal to the flat object.
597  FLASH_Obj_create_hier_conf_to_flat( FLA_NO_TRANSPOSE, F, depth, b_mn, H );
598 
599  // Initialize the contents of the hierarchical matrix object with the
600  // contents of the flat matrix object.
601  FLASH_Copy_flat_to_hier( F, 0, 0, *H );
602 
603  return FLA_SUCCESS;
604 }
FLA_Error FLASH_Obj_create_hier_conf_to_flat(FLA_Trans trans, FLA_Obj F, dim_t depth, dim_t *b_mn, FLA_Obj *H)
Definition: FLASH_Obj.c:459
FLA_Error FLASH_Obj_create_hier_copy_of_flat_check(FLA_Obj F, dim_t depth, dim_t *blocksizes, FLA_Obj *H)
Definition: FLASH_Obj_create_hier_copy_of_flat_check.c:13
FLA_Error FLASH_Copy_flat_to_hier(FLA_Obj F, dim_t i, dim_t j, FLA_Obj H)
Definition: FLASH_Copy_other.c:81

References FLA_Check_error_level(), FLASH_Copy_flat_to_hier(), FLASH_Obj_create_hier_conf_to_flat(), and FLASH_Obj_create_hier_copy_of_flat_check().

Referenced by FLASH_CAQR_UT_inc_create_hier_matrices(), FLASH_LQ_UT_create_hier_matrices(), FLASH_LU_incpiv_create_hier_matrices(), FLASH_QR_UT_create_hier_matrices(), FLASH_QR_UT_inc_create_hier_matrices(), and FLASH_UDdate_UT_inc_create_hier_matrices().

◆ FLASH_Obj_create_hier_copy_of_flat_check()

FLA_Error FLASH_Obj_create_hier_copy_of_flat_check ( FLA_Obj  F,
dim_t  depth,
dim_t b_mn,
FLA_Obj H 
)
14 {
15  FLA_Error e_val;
16 
17  e_val = FLA_Check_null_pointer( blocksizes );
18  FLA_Check_error_code( e_val );
19 
20  e_val = FLA_Check_null_pointer( H );
21  FLA_Check_error_code( e_val );
22 
23  // A value of depth < 0 should cause an error.
24 
25  // First depth entries in blocksize should be checked; values < 1 should cause error.
26 
27  return FLA_SUCCESS;
28 }

References FLA_Check_null_pointer().

Referenced by FLASH_Obj_create_hier_copy_of_flat().

◆ FLASH_Obj_create_hier_copy_of_flat_ext()

FLA_Error FLASH_Obj_create_hier_copy_of_flat_ext ( FLA_Obj  F,
dim_t  depth,
dim_t b_m,
dim_t b_n,
FLA_Obj H 
)
608 {
609  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
610  FLASH_Obj_create_hier_copy_of_flat_ext_check( F, depth, b_m, b_n, H );
611 
612  // Create a hierarchical object conformal to the flat object.
613  FLASH_Obj_create_hier_conf_to_flat_ext( FLA_NO_TRANSPOSE, F, depth, b_m, b_n, H );
614 
615  // Initialize the contents of the hierarchical matrix object with the
616  // contents of the flat matrix object.
617  FLASH_Copy_flat_to_hier( F, 0, 0, *H );
618 
619  return FLA_SUCCESS;
620 }
FLA_Error FLASH_Obj_create_hier_conf_to_flat_ext(FLA_Trans trans, FLA_Obj F, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
Definition: FLASH_Obj.c:493
FLA_Error FLASH_Obj_create_hier_copy_of_flat_ext_check(FLA_Obj F, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
Definition: FLASH_Obj_create_hier_copy_of_flat_ext_check.c:13

References FLA_Check_error_level(), FLASH_Copy_flat_to_hier(), FLASH_Obj_create_hier_conf_to_flat_ext(), and FLASH_Obj_create_hier_copy_of_flat_ext_check().

◆ FLASH_Obj_create_hier_copy_of_flat_ext_check()

FLA_Error FLASH_Obj_create_hier_copy_of_flat_ext_check ( FLA_Obj  F,
dim_t  depth,
dim_t b_m,
dim_t b_n,
FLA_Obj H 
)
14 {
15  FLA_Error e_val;
16 
17  e_val = FLA_Check_null_pointer( b_m );
18  FLA_Check_error_code( e_val );
19 
20  e_val = FLA_Check_null_pointer( b_n );
21  FLA_Check_error_code( e_val );
22 
23  e_val = FLA_Check_null_pointer( H );
24  FLA_Check_error_code( e_val );
25 
26  // A value of depth < 0 should cause an error.
27 
28  // First depth entries in blocksize should be checked; values < 1 should cause error.
29 
30  return FLA_SUCCESS;
31 }

References FLA_Check_null_pointer().

Referenced by FLASH_Obj_create_hier_copy_of_flat_ext().

◆ FLASH_Obj_create_hierarchy()

FLA_Error FLASH_Obj_create_hierarchy ( FLA_Datatype  datatype,
dim_t  m,
dim_t  n,
dim_t  depth,
dim_t elem_sizes_m,
dim_t elem_sizes_n,
FLA_Obj  flat_matrix,
FLA_Obj H,
unsigned long  id,
dim_t  depth_overall,
dim_t depth_sizes_m,
dim_t depth_sizes_n,
dim_t m_offsets,
dim_t n_offsets 
)
272 {
273  dim_t i, j, b;
274  dim_t next_m, next_n;
275  dim_t num_m, num_n;
276  dim_t m_inner, n_inner;
277  dim_t elem_size_m_cur;
278  dim_t elem_size_n_cur;
279  FLA_Obj FL, FR, F0, F1, F2;
280  FLA_Obj* buffer_H;
281 
282  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
283  FLASH_Obj_create_hierarchy_check( datatype, m, n, depth, elem_sizes_m, elem_sizes_n, flat_matrix, H, id, depth_overall, depth_sizes_m, depth_sizes_n, m_offsets, n_offsets );
284 
285  if ( depth == 0 )
286  {
287  // If we're asked to create a zero-depth matrix, we interpret that as
288  // a request to create leaf-level objects using the remaining portion
289  // of the segment of the flat_matrix buffer that was passed in.
290  FLA_Obj_create_without_buffer( datatype, m, n, H );
291  FLA_Obj_attach_buffer( FLA_Obj_buffer_at_view( flat_matrix ), 1, m, H );
292 #ifdef FLA_ENABLE_SUPERMATRIX
293  FLASH_Queue_set_block_size( m * n * FLA_Obj_datatype_size( datatype ) );
294 #endif
295  H->base->id = id;
296 
297  // Fill in the m_index and n_index variables, which identify the
298  // location of the current leaf node, in units of storage blocks,
299  // within the overall matrix.
300  for ( i = 0; i < depth_overall; i++ )
301  {
302  H->base->m_index += m_offsets[i] * depth_sizes_m[i];
303  H->base->n_index += n_offsets[i] * depth_sizes_n[i];
304  }
305  }
306  else
307  {
308  // The "current" level's elem_size value. That is, the number of numerical
309  // scalar elements along one side of a full block on the current level,
310  // for the row and column dimensions.
311  elem_size_m_cur = elem_sizes_m[0];
312  elem_size_n_cur = elem_sizes_n[0];
313 
314  // Compute the number of rows and columns in the current hierarchical
315  // level of blocking.
316  num_m = m / elem_size_m_cur + ( (m % elem_size_m_cur) ? 1 : 0 );
317  num_n = n / elem_size_n_cur + ( (n % elem_size_n_cur) ? 1 : 0 );
318 
319  // The total number of scalar elements contained within/below this level
320  // of the hierarchy. (The edge cases are handled by the computation of
321  // next_m and next_n below, since they are passed in as the new m and n
322  // for the next recursive call.)
323  m_inner = m;
324  n_inner = n;
325 
326  // Create a matrix whose elements are FLA_Objs for the current level of
327  // blocking.
328  FLA_Obj_create_ext( datatype, FLA_MATRIX, num_m, num_n, m_inner, n_inner, 0, 0, H );
329 
330  if ( depth == depth_overall )
331  id = H->base->id;
332  else
333  H->base->id = id;
334 
335  // Grab the buffer from the new hierarchical object. This is an array of
336  // FLA_Objs.
337  buffer_H = ( FLA_Obj* ) FLA_Obj_buffer_at_view( *H );
338 
339  // Prepare to partition through the flat matrix so we can further allocate
340  // segments of it to the various hierarchical sub-matrices. (The second
341  // case occurs when the current function is called with a flat_matrix
342  // argument that was created without a buffer.)
343  if ( FLA_Obj_buffer_at_view( flat_matrix ) != NULL )
344  FLA_Part_1x2( flat_matrix, &FL, &FR, 0, FLA_LEFT );
345  else
346  FLA_Obj_create_without_buffer( datatype, 0, 0, &F1 );
347 
348  for ( j = 0; j < num_n; ++j )
349  {
350  // Determine the number of elements along the column dimension
351  // that will be contained within the submatrix referenced by
352  // the (i,j)th FLA_MATRIX element in the current matrix.
353  if ( j != num_n-1 || (n % elem_size_n_cur) == 0 )
354  next_n = elem_size_n_cur;
355  else
356  next_n = n % elem_size_n_cur;
357 
358  n_offsets[depth_overall-depth] = j;
359 
360  for ( i = 0; i < num_m; ++i )
361  {
362  // Determine the number of elements along the row dimension
363  // that will be contained within the submatrix referenced by
364  // the (i,j)th FLA_MATRIX element in the current matrix.
365  if ( i != num_m-1 || (m % elem_size_m_cur) == 0 )
366  next_m = elem_size_m_cur;
367  else
368  next_m = m % elem_size_m_cur;
369 
370  m_offsets[depth_overall-depth] = i;
371 
372  // Partition the next m*n elements from the flat matrix so we can
373  // "attach" them to the hierarchical matrices contained within the
374  // (i,j)th FLA_MATRIX object.
375  if ( FLA_Obj_buffer_at_view( flat_matrix ) != NULL )
376  {
377  b = min( FLA_Obj_width( FR ), next_m * next_n );
378  FLA_Repart_1x2_to_1x3( FL, /**/ FR, &F0, /**/ &F1, &F2,
379  b, FLA_RIGHT );
380  }
381 
382  // Recursively call ourselves, with the appropriate parameters for
383  // the next deeper level in the matrix hierarchy.
384  FLASH_Obj_create_hierarchy( datatype, next_m, next_n, depth-1, &elem_sizes_m[1], &elem_sizes_n[1], F1, &buffer_H[j*num_m + i], id, depth_overall, depth_sizes_m, depth_sizes_n, m_offsets, n_offsets );
385 
386  // Continue with the repartitioning.
387  if ( FLA_Obj_buffer_at_view( flat_matrix ) != NULL )
388  {
389  FLA_Cont_with_1x3_to_1x2( &FL, /**/ &FR, F0, F1, /**/ F2,
390  FLA_LEFT );
391  }
392  }
393  }
394 
395  // Free the temporary flat matrix subpartition object, but only if it was
396  // created to begin with. Since it would have been created without a
397  // buffer, we must free it in a similar manner.
398  if ( FLA_Obj_buffer_at_view( flat_matrix ) == NULL )
400  }
401 
402  return FLA_SUCCESS;
403 }
FLA_Error FLASH_Obj_create_hierarchy_check(FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *elem_sizes_m, dim_t *elem_sizes_n, FLA_Obj flat_matrix, FLA_Obj *H, unsigned long id, dim_t depth_overall, dim_t *depth_sizes_m, dim_t *depth_sizes_n, dim_t *m_offsets, dim_t *n_offsets)
Definition: FLASH_Obj_create_hierarchy_check.c:13
void FLASH_Queue_set_block_size(dim_t size)
Definition: FLASH_Queue.c:461
dim_t FLA_Obj_datatype_size(FLA_Datatype datatype)
Definition: FLA_Query.c:61
FLA_Error FLA_Obj_create_ext(FLA_Datatype datatype, FLA_Elemtype elemtype, dim_t m, dim_t n, dim_t m_inner, dim_t n_inner, dim_t rs, dim_t cs, FLA_Obj *obj)
Definition: FLA_Obj.c:64
dim_t m_index
Definition: FLA_type_defs.h:134
dim_t n_index
Definition: FLA_type_defs.h:135

References FLA_Obj_view::base, FLA_Check_error_level(), FLA_Cont_with_1x3_to_1x2(), FLA_Obj_attach_buffer(), FLA_Obj_buffer_at_view(), FLA_Obj_create_ext(), FLA_Obj_create_without_buffer(), FLA_Obj_datatype_size(), FLA_Obj_free_without_buffer(), FLA_Obj_width(), FLA_Part_1x2(), FLA_Repart_1x2_to_1x3(), FLASH_Obj_create_hierarchy(), FLASH_Obj_create_hierarchy_check(), FLASH_Queue_set_block_size(), i, FLA_Obj_struct::id, FLA_Obj_struct::m_index, and FLA_Obj_struct::n_index.

Referenced by FLASH_Obj_create_helper(), and FLASH_Obj_create_hierarchy().

◆ FLASH_Obj_create_hierarchy_check()

FLA_Error FLASH_Obj_create_hierarchy_check ( FLA_Datatype  datatype,
dim_t  m,
dim_t  n,
dim_t  depth,
dim_t elem_sizes_m,
dim_t elem_sizes_n,
FLA_Obj  flat_matrix,
FLA_Obj H,
unsigned long  id,
dim_t  depth_overall,
dim_t depth_sizes_m,
dim_t depth_sizes_n,
dim_t m_offsets,
dim_t n_offsets 
)
14 {
15  FLA_Error e_val;
16 
17  e_val = FLA_Check_valid_datatype( datatype );
18  FLA_Check_error_code( e_val );
19 
20  e_val = FLA_Check_null_pointer( elem_sizes_m );
21  FLA_Check_error_code( e_val );
22 
23  e_val = FLA_Check_null_pointer( elem_sizes_n );
24  FLA_Check_error_code( e_val );
25 
26  e_val = FLA_Check_null_pointer( H );
27  FLA_Check_error_code( e_val );
28 
29  e_val = FLA_Check_null_pointer( depth_sizes_m );
30  FLA_Check_error_code( e_val );
31 
32  e_val = FLA_Check_null_pointer( depth_sizes_n );
33  FLA_Check_error_code( e_val );
34 
35  e_val = FLA_Check_null_pointer( m_offsets );
36  FLA_Check_error_code( e_val );
37 
38  e_val = FLA_Check_null_pointer( n_offsets );
39  FLA_Check_error_code( e_val );
40 
41  // A value of depth < 0 should cause an error.
42 
43  // Values of m < 1, n < 1 should cause an error. (or < 0?)
44 
45  // First depth entries in depth_sizes_m,_n elem_sizes_m,_n m_,n_offsets should be checked; values < 1 should cause error.
46 
47  return FLA_SUCCESS;
48 }

References FLA_Check_null_pointer(), and FLA_Check_valid_datatype().

Referenced by FLASH_Obj_create_hierarchy().

◆ FLASH_Obj_create_without_buffer()

FLA_Error FLASH_Obj_create_without_buffer ( FLA_Datatype  datatype,
dim_t  m,
dim_t  n,
dim_t  depth,
dim_t b_mn,
FLA_Obj H 
)
160 {
161  FLASH_Obj_create_helper( TRUE, datatype, m, n, depth, b_mn, b_mn, H );
162 
163  return FLA_SUCCESS;
164 }

References FLASH_Obj_create_helper().

◆ FLASH_Obj_create_without_buffer_ext()

FLA_Error FLASH_Obj_create_without_buffer_ext ( FLA_Datatype  datatype,
dim_t  m,
dim_t  n,
dim_t  depth,
dim_t b_m,
dim_t b_n,
FLA_Obj H 
)
168 {
169  FLASH_Obj_create_helper( TRUE, datatype, m, n, depth, b_m, b_n, H );
170 
171  return FLA_SUCCESS;
172 }

References FLASH_Obj_create_helper().

Referenced by FLASH_Part_create_1x2(), FLASH_Part_create_2x1(), and FLASH_Part_create_2x2().

◆ FLASH_Obj_datatype()

FLA_Datatype FLASH_Obj_datatype ( FLA_Obj  H)

◆ FLASH_Obj_depth()

dim_t FLASH_Obj_depth ( FLA_Obj  H)
21 {
22  FLA_Elemtype elemtype;
23  FLA_Obj* buffer_H;
24  dim_t depth = 0;
25 
26  // Recurse through the hierarchy to the first leaf node. We initialize
27  // the recursion here:
28  elemtype = FLA_Obj_elemtype( H );
29  buffer_H = ( FLA_Obj* ) FLA_Obj_base_buffer( H );
30 
31  while ( elemtype == FLA_MATRIX )
32  {
33  ++depth;
34 
35  // Get the element type of the top-leftmost underlying object. Also,
36  // get a pointer to the first element of the top-leftmost object and
37  // assume that it is of type FLA_Obj* in case elemtype is once again
38  // FLA_MATRIX.
39  elemtype = FLA_Obj_elemtype( buffer_H[0] );
40  buffer_H = ( FLA_Obj * ) FLA_Obj_base_buffer( buffer_H[0] );
41  }
42 
43  // At this point, the value of depth represents the depth of the matrix
44  // hierarchy.
45  return depth;
46 }

References FLA_Obj_base_buffer(), and FLA_Obj_elemtype().

Referenced by FLASH_Apply_CAQ_UT_inc_create_workspace(), FLASH_Apply_pivots(), FLASH_Apply_Q_UT_create_workspace(), FLASH_Apply_Q_UT_inc_create_workspace(), FLASH_Apply_QUD_UT_inc_create_workspace(), FLASH_FS_incpiv(), FLASH_LQ_UT(), FLASH_LU_incpiv(), FLASH_LU_piv(), FLASH_Obj_create_conf_to(), FLASH_Part_create_1x2(), FLASH_Part_create_2x1(), FLASH_Part_create_2x2(), and FLASH_QR_UT().

◆ FLASH_Obj_extract_buffer()

void* FLASH_Obj_extract_buffer ( FLA_Obj  H)
742 {
743  FLA_Elemtype elemtype;
744  FLA_Obj* buffer_H;
745 
746  // Recurse through the hierarchy to the first leaf node to gain access
747  // to the address of the actual numerical data buffer (ie: the "flat"
748  // matrix object used in FLASH_Obj_create()). We initialize the search
749  // here:
750  elemtype = FLA_Obj_elemtype( H );
751  buffer_H = ( FLA_Obj* ) FLA_Obj_base_buffer( H );
752 
753  while ( elemtype == FLA_MATRIX )
754  {
755  elemtype = FLA_Obj_elemtype( buffer_H[0] );
756  buffer_H = ( FLA_Obj* ) FLA_Obj_base_buffer( buffer_H[0] );
757  }
758 
759  // At this point, the value in buffer_H is a pointer to the array that
760  // holds the numerical data.
761  return ( void* ) buffer_H;
762 }

References FLA_Obj_base_buffer(), and FLA_Obj_elemtype().

Referenced by FLASH_Obj_free().

◆ FLASH_Obj_flatten()

FLA_Error FLASH_Obj_flatten ( FLA_Obj  H,
FLA_Obj  F 
)
766 {
767  FLASH_Copy_hier_to_flat( 0, 0, H, F );
768 
769  return FLA_SUCCESS;
770 }

References FLASH_Copy_hier_to_flat().

◆ FLASH_Obj_free()

void FLASH_Obj_free ( FLA_Obj H)
639 {
640  FLA_Obj* buffer_H;
641 
642  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
644 
645  // Free the object according to whether it contains a hierarchy.
646  if ( FLA_Obj_elemtype( *H ) == FLA_MATRIX )
647  {
648  // Extract a pointer to the data buffer that was parititioned across all
649  // leaf-level submatrices.
650  buffer_H = ( FLA_Obj * ) FLASH_Obj_extract_buffer( *H );
651 
652  // Free the data buffer. This works because FLASH_Obj_extract_buffer()
653  // returns the starting address of the first element's buffer, which is
654  // also the starting address of the entire buffer.
655 #ifdef FLA_ENABLE_SCC
656  FLA_shfree( buffer_H );
657 #else
658  FLA_free( buffer_H );
659 #endif
660 
661  // All that remains now is to free the interior of the matrix hierarchy.
662  // This includes non-leaf buffers and their corresponding base objects
663  // as well as leaf-level base objects.
665  }
666  else
667  {
668  // If the matrix has no hierarchy, treat it like a flat object.
669  FLA_Obj_free( H );
670  }
671 }
void FLASH_Obj_free_hierarchy(FLA_Obj *H)
Definition: FLASH_Obj.c:699
void * FLASH_Obj_extract_buffer(FLA_Obj H)
Definition: FLASH_Obj.c:741
FLA_Error FLASH_Obj_free_check(FLA_Obj *H)
Definition: FLASH_Obj_free_check.c:13
void FLA_shfree(void *ptr)
Definition: FLA_Obj.c:27

References FLA_Check_error_level(), FLA_free(), FLA_Obj_elemtype(), FLA_Obj_free(), FLA_shfree(), FLASH_Obj_extract_buffer(), FLASH_Obj_free_check(), and FLASH_Obj_free_hierarchy().

Referenced by FLASH_CAQR_UT_inc_solve(), FLASH_Eig_gest(), FLASH_LQ_UT_solve(), FLASH_LU_incpiv_opt1(), FLASH_QR_UT_inc_opt1(), FLASH_QR_UT_inc_solve(), FLASH_QR_UT_solve(), FLASH_Random_spd_matrix(), and FLASH_UDdate_UT_inc_update_rhs().

◆ FLASH_Obj_free_check()

FLA_Error FLASH_Obj_free_check ( FLA_Obj H)
14 {
15  FLA_Error e_val;
16 
17  e_val = FLA_Check_null_pointer( H );
18  FLA_Check_error_code( e_val );
19 
20  return FLA_SUCCESS;
21 }

References FLA_Check_null_pointer().

Referenced by FLASH_Obj_free().

◆ FLASH_Obj_free_hierarchy()

void FLASH_Obj_free_hierarchy ( FLA_Obj H)
700 {
701  //dim_t m_H, n_H, rs, cs, i, j;
702  dim_t i;
703  dim_t n_elem_alloc;
704  FLA_Obj* buffer_H;
705 
706  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
708 
709  // If the element type of H is FLA_SCALAR, then it has no children to
710  // free, so free the base object. In order to avoid freeing the object's
711  // data buffer, which would have already been freed en masse by now if
712  // the calling function is FLASH_Obj_free(), we will call
713  // FLA_Obj_free_without_buffer().
714  if ( FLA_Obj_elemtype( *H ) == FLA_SCALAR )
715  {
717  return;
718  }
719  else
720  {
721  // Acquire the number of elements allocated when this node was
722  // created.
723  n_elem_alloc = FLA_Obj_num_elem_alloc( *H );
724 
725  // Acquire the array of objects contained inside of H.
726  buffer_H = ( FLA_Obj* ) FLA_Obj_base_buffer( *H );
727 
728  // For each allocated submatrix in H...
729  for ( i = 0; i < n_elem_alloc; ++i )
730  {
731  // Recurse with the ith element of the allocated buffer.
732  FLASH_Obj_free_hierarchy( &buffer_H[i] );
733  }
734 
735  // Finally, free the internal array of objects.
736  FLA_Obj_free( H );
737  }
738 }
FLA_Error FLASH_Obj_free_hierarchy_check(FLA_Obj *H)
Definition: FLASH_Obj_free_hierachy_check.c:13
dim_t FLA_Obj_num_elem_alloc(FLA_Obj obj)
Definition: FLA_Query.c:204

References FLA_Check_error_level(), FLA_Obj_base_buffer(), FLA_Obj_elemtype(), FLA_Obj_free(), FLA_Obj_free_without_buffer(), FLA_Obj_num_elem_alloc(), FLASH_Obj_free_hierarchy(), FLASH_Obj_free_hierarchy_check(), and i.

Referenced by FLASH_Obj_free(), FLASH_Obj_free_hierarchy(), and FLASH_Obj_free_without_buffer().

◆ FLASH_Obj_free_hierarchy_check()

FLA_Error FLASH_Obj_free_hierarchy_check ( FLA_Obj H)
14 {
15  FLA_Error e_val;
16 
17  e_val = FLA_Check_null_pointer( H );
18  FLA_Check_error_code( e_val );
19 
20  return FLA_SUCCESS;
21 }

References FLA_Check_null_pointer().

Referenced by FLASH_Obj_free_hierarchy().

◆ FLASH_Obj_free_without_buffer()

void FLASH_Obj_free_without_buffer ( FLA_Obj H)
675 {
676  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
678 
679  // Free the object according to whether it contains a hierarchy.
680  if ( FLA_Obj_elemtype( *H ) == FLA_MATRIX )
681  {
682  // Skip freeing the numerical data buffer, since the object was
683  // presumably created with FLASH_Obj_create_without_buffer().
684 
685  // Free the interior of the matrix hierarchy. This includes non-leaf
686  // buffers and their corresponding base objects as well as leaf-level
687  // base objects.
689  }
690  else
691  {
692  // If the matrix has no hierarchy, treat it like a flat object with
693  // no internal data buffer.
695  }
696 }
FLA_Error FLASH_Obj_free_without_buffer_check(FLA_Obj *H)
Definition: FLASH_Obj_free_without_buffer_check.c:13

References FLA_Check_error_level(), FLA_Obj_elemtype(), FLA_Obj_free_without_buffer(), FLASH_Obj_free_hierarchy(), and FLASH_Obj_free_without_buffer_check().

Referenced by FLASH_Part_free_1x2(), FLASH_Part_free_2x1(), and FLASH_Part_free_2x2().

◆ FLASH_Obj_free_without_buffer_check()

FLA_Error FLASH_Obj_free_without_buffer_check ( FLA_Obj H)
14 {
15  FLA_Error e_val;
16 
17  e_val = FLA_Check_null_pointer( H );
18  FLA_Check_error_code( e_val );
19 
20  return FLA_SUCCESS;
21 }

References FLA_Check_null_pointer().

Referenced by FLASH_Obj_free_without_buffer().

◆ FLASH_Obj_hierarchify()

FLA_Error FLASH_Obj_hierarchify ( FLA_Obj  F,
FLA_Obj  H 
)

◆ FLASH_Obj_scalar_col_offset()

dim_t FLASH_Obj_scalar_col_offset ( FLA_Obj  H)
709 {
710  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
711  {
712  return FLA_Obj_col_offset( H );
713  }
714  else
715  {
716  dim_t b_n = FLASH_Obj_scalar_width_tl( H );
717 
718  return FLA_Obj_col_offset( H ) * b_n +
719  FLASH_Obj_scalar_col_offset( *FLASH_OBJ_PTR_AT( H ) );
720  }
721 }
dim_t FLASH_Obj_scalar_col_offset(FLA_Obj H)
Definition: FLASH_View.c:708

References FLA_Obj_col_offset(), FLA_Obj_elemtype(), FLASH_Obj_scalar_col_offset(), and FLASH_Obj_scalar_width_tl().

Referenced by FLASH_Obj_create_conf_to(), FLASH_Obj_scalar_col_offset(), FLASH_Part_create_1x2(), FLASH_Part_create_2x1(), and FLASH_Part_create_2x2().

◆ FLASH_Obj_scalar_length()

dim_t FLASH_Obj_scalar_length ( FLA_Obj  H)
601 {
602  FLA_Obj HT, H0,
603  HB, H1,
604  H2;
605  FLA_Obj* H1p;
606 
607  dim_t b = 0;
608 
609  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
610  return FLA_Obj_length( H );
611 
612  if ( FLA_Obj_length( H ) == 0 )
613  return 0;
614 
615  FLA_Part_2x1( H, &HT,
616  &HB, 0, FLA_TOP );
617 
618  while ( FLA_Obj_length( HT ) < FLA_Obj_length( H ) )
619  {
620  FLA_Repart_2x1_to_3x1( HT, &H0,
621  /* ** */ /* ** */
622  &H1,
623  HB, &H2, 1, FLA_BOTTOM );
624 
625  /*------------------------------------------------------------*/
626 
627  H1p = FLASH_OBJ_PTR_AT( H1 );
628  b += H1p->m_inner;
629 
630  /*------------------------------------------------------------*/
631 
632  FLA_Cont_with_3x1_to_2x1( &HT, H0,
633  H1,
634  /* ** */ /* ** */
635  &HB, H2, FLA_TOP );
636  }
637 
638  return b;
639 }

References FLA_Cont_with_3x1_to_2x1(), FLA_Obj_elemtype(), FLA_Obj_length(), FLA_Part_2x1(), FLA_Repart_2x1_to_3x1(), and FLA_Obj_view::m_inner.

Referenced by FLA_Check_submatrix_dims_and_offset(), FLA_Obj_copy_view(), FLASH_Axpy_hierarchy(), FLASH_Copy_hierarchy(), FLASH_LU_find_zero_on_diagonal(), FLASH_Obj_create_conf_to(), FLASH_Obj_create_flat_conf_to_hier(), FLASH_Obj_scalar_max_dim(), FLASH_Obj_scalar_min_dim(), FLASH_Obj_scalar_vector_dim(), FLASH_Obj_show(), FLASH_Part_create_1x2(), FLASH_Part_create_2x1(), and FLASH_Part_create_2x2().

◆ FLASH_Obj_scalar_length_tl()

dim_t FLASH_Obj_scalar_length_tl ( FLA_Obj  H)

◆ FLASH_Obj_scalar_max_dim()

dim_t FLASH_Obj_scalar_max_dim ( FLA_Obj  H)
682 {
683  return max( FLASH_Obj_scalar_length( H ),
684  FLASH_Obj_scalar_width( H ) );
685 }
dim_t FLASH_Obj_scalar_length(FLA_Obj H)
Definition: FLASH_View.c:600
dim_t FLASH_Obj_scalar_width(FLA_Obj H)
Definition: FLASH_View.c:641

References FLASH_Obj_scalar_length(), and FLASH_Obj_scalar_width().

◆ FLASH_Obj_scalar_min_dim()

dim_t FLASH_Obj_scalar_min_dim ( FLA_Obj  H)

◆ FLASH_Obj_scalar_row_offset()

dim_t FLASH_Obj_scalar_row_offset ( FLA_Obj  H)
694 {
695  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
696  {
697  return FLA_Obj_row_offset( H );
698  }
699  else
700  {
702 
703  return FLA_Obj_row_offset( H ) * b_m +
704  FLASH_Obj_scalar_row_offset( *FLASH_OBJ_PTR_AT( H ) );
705  }
706 }
dim_t FLASH_Obj_scalar_row_offset(FLA_Obj H)
Definition: FLASH_View.c:693

References FLA_Obj_elemtype(), FLA_Obj_row_offset(), FLASH_Obj_scalar_length_tl(), and FLASH_Obj_scalar_row_offset().

Referenced by FLASH_Obj_create_conf_to(), FLASH_Obj_scalar_row_offset(), FLASH_Obj_show(), FLASH_Part_create_1x2(), FLASH_Part_create_2x1(), and FLASH_Part_create_2x2().

◆ FLASH_Obj_scalar_vector_dim()

dim_t FLASH_Obj_scalar_vector_dim ( FLA_Obj  H)
688 {
689  return ( FLASH_Obj_scalar_length( H ) == 1 ? FLASH_Obj_scalar_width( H )
690  : FLASH_Obj_scalar_length( H ) );
691 }

References FLASH_Obj_scalar_length(), and FLASH_Obj_scalar_width().

◆ FLASH_Obj_scalar_width()

dim_t FLASH_Obj_scalar_width ( FLA_Obj  H)
642 {
643  FLA_Obj HL, HR, H0, H1, H2;
644  FLA_Obj* H1p;
645 
646  dim_t b = 0;
647 
648  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
649  return FLA_Obj_width( H );
650 
651  if ( FLA_Obj_width( H ) == 0 )
652  return 0;
653 
654  FLA_Part_1x2( H, &HL, &HR, 0, FLA_LEFT );
655 
656  while ( FLA_Obj_width( HL ) < FLA_Obj_width( H ) )
657  {
658  FLA_Repart_1x2_to_1x3( HL, /**/ HR, &H0, /**/ &H1, &H2,
659  1, FLA_RIGHT );
660 
661  /*------------------------------------------------------------*/
662 
663  H1p = FLASH_OBJ_PTR_AT( H1 );
664  b += H1p->n_inner;
665 
666  /*------------------------------------------------------------*/
667 
668  FLA_Cont_with_1x3_to_1x2( &HL, /**/ &HR, H0, H1, /**/ H2,
669  FLA_LEFT );
670  }
671 
672  return b;
673 }

References FLA_Cont_with_1x3_to_1x2(), FLA_Obj_elemtype(), FLA_Obj_width(), FLA_Part_1x2(), FLA_Repart_1x2_to_1x3(), and FLA_Obj_view::n_inner.

Referenced by FLA_Check_submatrix_dims_and_offset(), FLA_Obj_copy_view(), FLASH_Apply_Q_UT_create_workspace(), FLASH_Axpy_hierarchy(), FLASH_CAQR_UT_inc_adjust_views(), FLASH_CAQR_UT_inc_solve(), FLASH_Copy_hierarchy(), FLASH_Obj_create_conf_to(), FLASH_Obj_create_flat_conf_to_hier(), FLASH_Obj_scalar_max_dim(), FLASH_Obj_scalar_min_dim(), FLASH_Obj_scalar_vector_dim(), FLASH_Part_create_1x2(), FLASH_Part_create_2x1(), FLASH_Part_create_2x2(), FLASH_QR_UT_inc_create_hier_matrices(), and FLASH_QR_UT_inc_solve().

◆ FLASH_Obj_scalar_width_tl()

dim_t FLASH_Obj_scalar_width_tl ( FLA_Obj  H)

◆ FLASH_Obj_show()

FLA_Error FLASH_Obj_show ( char *  header,
FLA_Obj  H,
char *  elem_format,
char *  footer 
)
752 {
753  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
754  {
755  // Display the flat object.
756  FLA_Obj_show( header, H, elem_format, footer );
757  }
758  else
759  {
760  dim_t m_scalar;
761  dim_t i_view;
762  dim_t i_abs;
763  dim_t offm_scalar;
764 
765  // We want to print all m rows in the FLASH view.
766  m_scalar = FLASH_Obj_scalar_length( H );
767 
768  // Get the scalar offset of the overall FLASH view relative to the
769  // top-left corner of the overall object to which the view belongs.
770  offm_scalar = FLASH_Obj_scalar_row_offset( H );
771 
772 //printf( "flash_view_show: %d\n", m_scalar );
773 //printf( "flash_view_show: %d\n", offm_scalar );
774 
775  printf( "%s\n", header );
776 
777  for ( i_view = 0; i_view < m_scalar; ++i_view )
778  {
779  // Convert the relative view index to an absolute index.
780  i_abs = offm_scalar + i_view;
781 
782  // Print the ith row of the FLASH object H.
783  FLASH_Obj_show_hierarchy( H, i_abs, elem_format );
784  printf( "\n" );
785  }
786 
787  printf( "%s\n", footer );
788  }
789 
790  return FLA_SUCCESS;
791 }
FLA_Error FLASH_Obj_show_hierarchy(FLA_Obj H, dim_t i, char *elem_format)
Definition: FLASH_View.c:793
FLA_Error FLA_Obj_show(char *s1, FLA_Obj A, char *format, char *s2)
Definition: FLA_Misc.c:420

References FLA_Obj_elemtype(), FLA_Obj_show(), FLASH_Obj_scalar_length(), FLASH_Obj_scalar_row_offset(), and FLASH_Obj_show_hierarchy().

◆ FLASH_Obj_show_hierarchy()

FLA_Error FLASH_Obj_show_hierarchy ( FLA_Obj  H,
dim_t  i,
char *  elem_format 
)
794 {
795  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
796  {
797  FLA_Datatype datatype = FLA_Obj_datatype( H );
798  dim_t m = FLA_Obj_width( H );
799  dim_t rs = FLA_Obj_row_stride( H );
800  dim_t cs = FLA_Obj_col_stride( H );
801  dim_t j;
802 
803  // At this point, i is an absolute row index. We subtract out the
804  // row offset of the view so that the index is relative to the view.
805  i = i - FLA_Obj_row_offset( H );
806 
807  if ( datatype == FLA_INT )
808  {
809  int* buffer = FLA_Obj_buffer_at_view( H );
810 
811  for ( j = 0; j < m; ++j )
812  {
813  printf( elem_format, buffer[ j*cs + i*rs ] );
814  printf( " " );
815  }
816  }
817  else if ( datatype == FLA_FLOAT )
818  {
819  float* buffer = FLA_Obj_buffer_at_view( H );
820 
821  for ( j = 0; j < m; ++j )
822  {
823  printf( elem_format, buffer[ j*cs + i*rs ] );
824  printf( " " );
825  }
826  }
827  else if ( datatype == FLA_DOUBLE )
828  {
829  double* buffer = FLA_Obj_buffer_at_view( H );
830 
831  for ( j = 0; j < m; ++j )
832  {
833  printf( elem_format, buffer[ j*cs + i*rs ] );
834  printf( " " );
835  }
836  }
837  else if ( datatype == FLA_COMPLEX )
838  {
839  scomplex* buffer = FLA_Obj_buffer_at_view( H );
840 
841  for ( j = 0; j < m; ++j )
842  {
843  printf( elem_format, buffer[ j*cs + i*rs ].real,
844  buffer[ j*cs + i*rs ].imag );
845  printf( " " );
846  }
847  }
848  else if ( datatype == FLA_DOUBLE_COMPLEX )
849  {
850  dcomplex* buffer = FLA_Obj_buffer_at_view( H );
851 
852  for ( j = 0; j < m; ++j )
853  {
854  printf( elem_format, buffer[ j*cs + i*rs ].real,
855  buffer[ j*cs + i*rs ].imag );
856  printf( " " );
857  }
858  }
859  else
860  {
861  FLA_Check_error_code( FLA_NOT_YET_IMPLEMENTED );
862  }
863  }
864  else
865  {
866  FLA_Obj HT,
867  HB;
868  FLA_Obj HBL, HBR, H10, H11, H12;
869  dim_t b_m_scalar;
870  dim_t offm_local;
871  dim_t i_next;
872 
873  // Get the scalar length of the top-left block.
874  b_m_scalar = FLASH_Obj_scalar_length_tl( H );
875 
876 #if 0
877 printf( "\n------------------------\n" );
878 printf( "b_m_scalar %d\n", b_m_scalar );
879 printf( "i %d\n", i );
880 #endif
881 
882  // Compute the offset of the matrix block, relative to the current
883  // view, that contains the ith row of the matrix.
884  offm_local = ( i ) / b_m_scalar - FLA_Obj_row_offset( H );
885  i_next = ( i ) % b_m_scalar;
886 
887 #if 0
888 printf( "row offset %d\n", FLA_Obj_row_offset( H ) );
889 printf( "offm_local %d\n", offm_local );
890 printf( "i_next %d\n", i_next );
891 #endif
892 
893  FLA_Part_2x1( H, &HT,
894  &HB, offm_local, FLA_TOP );
895 
896  FLA_Part_1x2( HB, &HBL, &HBR, 0, FLA_LEFT );
897 
898  while ( FLA_Obj_width( HBL ) < FLA_Obj_width( HB ) )
899  {
900  FLA_Repart_1x2_to_1x3( HBL, /**/ HBR, &H10, /**/ &H11, &H12,
901  1, FLA_RIGHT );
902 
903  // ------------------------------------------------------
904 
905  FLASH_Obj_show_hierarchy( *FLASH_OBJ_PTR_AT( H11 ),
906  i_next, elem_format );
907 
908  // ------------------------------------------------------
909 
910  FLA_Cont_with_1x3_to_1x2( &HBL, /**/ &HBR, H10, H11, /**/ H12,
911  FLA_LEFT );
912  }
913  }
914 
915  return FLA_SUCCESS;
916 }
float real
Definition: FLA_f2c.h:30
rho_c imag
Definition: bl1_axpyv2bdotaxpy.c:483
Definition: blis_type_defs.h:138
Definition: blis_type_defs.h:133

References FLA_Cont_with_1x3_to_1x2(), FLA_Obj_buffer_at_view(), FLA_Obj_col_stride(), FLA_Obj_datatype(), FLA_Obj_elemtype(), FLA_Obj_row_offset(), FLA_Obj_row_stride(), FLA_Obj_width(), FLA_Part_1x2(), FLA_Part_2x1(), FLA_Repart_1x2_to_1x3(), FLASH_Obj_scalar_length_tl(), FLASH_Obj_show_hierarchy(), i, and imag.

Referenced by FLASH_Obj_show(), and FLASH_Obj_show_hierarchy().

◆ FLASH_Part_create_1x2()

FLA_Error FLASH_Part_create_1x2 ( FLA_Obj  A,
FLA_Obj AL,
FLA_Obj AR,
dim_t  n_cols,
FLA_Side  side 
)
105 {
106  FLA_Datatype dt_A;
107  dim_t m_A, n_A;
108  dim_t m_A_base, n_A_base;
109  dim_t m_AL, n_AL;
110  dim_t m_AR, n_AR;
111  dim_t depth;
112  dim_t* b_m;
113  dim_t* b_n;
114  dim_t offm_A, offn_A;
115  dim_t offm_AL, offn_AL;
116  dim_t offm_AR, offn_AR;
117 
118  if ( FLA_Check_error_level() == FLA_FULL_ERROR_CHECKING )
119  FLA_Part_1x2_check( A, AL, AR, n_cols, side );
120 
121  // Safeguard: if n_cols > n, reduce n_cols to n.
122  if ( n_cols > FLASH_Obj_scalar_width( A ) )
123  n_cols = FLASH_Obj_scalar_width( A );
124 
125  // Acquire various properties of the hierarchical matrix object.
126  dt_A = FLASH_Obj_datatype( A );
127  m_A = FLASH_Obj_scalar_length( A );
128  n_A = FLASH_Obj_scalar_width( A );
129  offm_A = FLASH_Obj_scalar_row_offset( A );
130  offn_A = FLASH_Obj_scalar_col_offset( A );
131  m_A_base = FLASH_Obj_base_scalar_length( A );
132  n_A_base = FLASH_Obj_base_scalar_width( A );
133  depth = FLASH_Obj_depth( A );
134 
135  // Allocate a pair of temporary arrays for the blocksizes, whose lengths
136  // are equal to the object's hierarchical depth.
137  b_m = ( dim_t* ) FLA_malloc( depth * sizeof( dim_t ) );
138  b_n = ( dim_t* ) FLA_malloc( depth * sizeof( dim_t ) );
139 
140  // Accumulate the blocksizes into the blocksize buffers.
141  FLASH_Obj_blocksizes( A, b_m, b_n );
142 
143  // Adjust n_cols to be (n - n_cols) if the side specified is on the
144  // right so that the right values get assigned below.
145  if ( side == FLA_RIGHT ) n_cols = n_A - n_cols;
146 
147  // Set the dimensions of the partitions.
148  m_AL = m_A;
149  n_AL = n_cols;
150  m_AR = m_A;
151  n_AR = n_A - n_cols;
152 
153  // Set the offsets.
154  offm_AL = offm_A + 0;
155  offn_AL = offn_A + 0;
156  offm_AR = offm_A + 0;
157  offn_AR = offn_A + n_AL;
158 
159  // Create bufferless hierarhical objects that have the desired dimensions
160  // for the views.
161  FLASH_Obj_create_without_buffer_ext( dt_A, m_A_base, n_A_base, depth, b_m, b_n, AL );
162  FLASH_Obj_create_without_buffer_ext( dt_A, m_A_base, n_A_base, depth, b_m, b_n, AR );
163 
164  // Recursively walk the hierarchy and adjust the views so that they
165  // collectively refer to the absolute offsets given, and attach the
166  // leaf-level numerical buffers of A to the new views.
167  FLASH_Obj_adjust_views( TRUE, offm_AL, offn_AL, m_AL, n_AL, A, AL );
168  FLASH_Obj_adjust_views( TRUE, offm_AR, offn_AR, m_AR, n_AR, A, AR );
169 
170  // Free the temporary blocksize buffers.
171  FLA_free( b_m );
172  FLA_free( b_n );
173 
174  return FLA_SUCCESS;
175 }
FLA_Error FLASH_Obj_adjust_views(FLA_Bool attach_buffer, dim_t offm, dim_t offn, dim_t m, dim_t n, FLA_Obj A, FLA_Obj *S)
Definition: FLASH_View.c:275
dim_t FLASH_Obj_blocksizes(FLA_Obj H, dim_t *b_m, dim_t *b_n)
Definition: FLASH_Obj.c:49
FLA_Error FLASH_Obj_create_without_buffer_ext(FLA_Datatype datatype, dim_t m, dim_t n, dim_t depth, dim_t *b_m, dim_t *b_n, FLA_Obj *H)
Definition: FLASH_Obj.c:167
dim_t FLASH_Obj_depth(FLA_Obj H)
Definition: FLASH_Obj.c:20
FLA_Error FLA_Part_1x2_check(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t nb, FLA_Side side)
Definition: FLA_Part_1x2_check.c:13

References FLA_Check_error_level(), FLA_free(), FLA_malloc(), FLA_Part_1x2_check(), FLASH_Obj_adjust_views(), FLASH_Obj_base_scalar_length(), FLASH_Obj_base_scalar_width(), FLASH_Obj_blocksizes(), FLASH_Obj_create_without_buffer_ext(), FLASH_Obj_datatype(), FLASH_Obj_depth(), FLASH_Obj_scalar_col_offset(), FLASH_Obj_scalar_length(), FLASH_Obj_scalar_row_offset(), and FLASH_Obj_scalar_width().

◆ FLASH_Part_create_2x1()

FLA_Error FLASH_Part_create_2x1 ( FLA_Obj  A,
FLA_Obj AT,
FLA_Obj AB,
dim_t  n_rows,
FLA_Side  side 
)
16 {
17  FLA_Datatype dt_A;
18  dim_t m_A, n_A;
19  dim_t m_A_base, n_A_base;
20  dim_t m_AT, n_AT;
21  dim_t m_AB, n_AB;
22  dim_t depth;
23  dim_t* b_m;
24  dim_t* b_n;
25  dim_t offm_A, offn_A;
26  dim_t offm_AT, offn_AT;
27  dim_t offm_AB, offn_AB;
28 
29  if ( FLA_Check_error_level() == FLA_FULL_ERROR_CHECKING )
30  FLA_Part_2x1_check( A, AT,
31  AB, n_rows, side );
32 
33  // Safeguard: if n_rows > m, reduce n_rows to m.
34  if ( n_rows > FLASH_Obj_scalar_length( A ) )
35  n_rows = FLASH_Obj_scalar_length( A );
36 
37  // Acquire various properties of the hierarchical matrix view.
38  dt_A = FLASH_Obj_datatype( A );
39  m_A = FLASH_Obj_scalar_length( A );
40  n_A = FLASH_Obj_scalar_width( A );
41  offm_A = FLASH_Obj_scalar_row_offset( A );
42  offn_A = FLASH_Obj_scalar_col_offset( A );
43  m_A_base = FLASH_Obj_base_scalar_length( A );
44  n_A_base = FLASH_Obj_base_scalar_width( A );
45  depth = FLASH_Obj_depth( A );
46 
47  // Allocate a pair of temporary arrays for the blocksizes, whose lengths
48  // are equal to the object's hierarchical depth.
49  b_m = ( dim_t* ) FLA_malloc( depth * sizeof( dim_t ) );
50  b_n = ( dim_t* ) FLA_malloc( depth * sizeof( dim_t ) );
51 
52  // Accumulate the blocksizes into the blocksize buffers.
53  FLASH_Obj_blocksizes( A, b_m, b_n );
54 
55  // Adjust n_rows to be (m - n_rows) if the side specified is on the
56  // bottom so that the right values get assigned below.
57  if ( side == FLA_BOTTOM ) n_rows = m_A - n_rows;
58 
59  // Set the dimensions of the partitions.
60  m_AT = n_rows;
61  n_AT = n_A;
62  m_AB = m_A - n_rows;
63  n_AB = n_A;
64 
65  // Set the offsets.
66  offm_AT = offm_A + 0;
67  offn_AT = offn_A + 0;
68  offm_AB = offm_A + m_AT;
69  offn_AB = offn_A + 0;
70 
71  // Create bufferless hierarhical objects that have the desired dimensions
72  // for the views.
73  FLASH_Obj_create_without_buffer_ext( dt_A, m_A_base, n_A_base, depth, b_m, b_n, AT );
74  FLASH_Obj_create_without_buffer_ext( dt_A, m_A_base, n_A_base, depth, b_m, b_n, AB );
75 
76 /*
77 printf( "depth %d\n", depth );
78 printf( "b_m/n[0] %d %d\n", b_m[0], b_n[0] );
79 printf( "b_m/n_tl %d %d\n", FLASH_Obj_scalar_length_tl( A ), FLASH_Obj_scalar_width_tl( A ) );
80 printf( "m/n_A_base %d %d\n", m_A_base, n_A_base );
81 printf( "offm/n_AT: %d %d\n", offm_AT, offn_AT );
82 printf( "m/n_AT: %d %d\n", m_AT, n_AT );
83 printf( "offm/n_AB: %d %d\n", offm_AB, offn_AB );
84 printf( "m/n_AB: %d %d\n", m_AB, n_AB );
85 printf( "A is %d %d\n", FLA_Obj_length( A ), FLA_Obj_width( A ) );
86 printf( "AT is %d %d\n", FLA_Obj_length( *AT ), FLA_Obj_width( *AT ) );
87 printf( "AB is %d %d\n", FLA_Obj_length( *AB ), FLA_Obj_width( *AB ) );
88 */
89 
90  // Recursively walk the hierarchy and adjust the views so that they
91  // collectively refer to the absolute offsets given, and attach the
92  // leaf-level numerical buffers of A to the new views.
93  FLASH_Obj_adjust_views( TRUE, offm_AT, offn_AT, m_AT, n_AT, A, AT );
94  FLASH_Obj_adjust_views( TRUE, offm_AB, offn_AB, m_AB, n_AB, A, AB );
95 
96  // Free the temporary blocksize buffers.
97  FLA_free( b_m );
98  FLA_free( b_n );
99 
100  return FLA_SUCCESS;
101 }
FLA_Error FLA_Part_2x1_check(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t mb, FLA_Side side)
Definition: FLA_Part_2x1_check.c:13

References FLA_Check_error_level(), FLA_free(), FLA_malloc(), FLA_Part_2x1_check(), FLASH_Obj_adjust_views(), FLASH_Obj_base_scalar_length(), FLASH_Obj_base_scalar_width(), FLASH_Obj_blocksizes(), FLASH_Obj_create_without_buffer_ext(), FLASH_Obj_datatype(), FLASH_Obj_depth(), FLASH_Obj_scalar_col_offset(), FLASH_Obj_scalar_length(), FLASH_Obj_scalar_row_offset(), and FLASH_Obj_scalar_width().

Referenced by FLASH_CAQR_UT_inc_solve(), and FLASH_QR_UT_inc_solve().

◆ FLASH_Part_create_2x2()

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 
)
180 {
181  FLA_Datatype dt_A;
182  dim_t m_A_base, n_A_base;
183  dim_t m_A, n_A;
184  dim_t m_ATL, n_ATL;
185  dim_t m_ABL, n_ABL;
186  dim_t m_ATR, n_ATR;
187  dim_t m_ABR, n_ABR;
188  dim_t depth;
189  dim_t* b_m;
190  dim_t* b_n;
191  dim_t offm_A, offn_A;
192  dim_t offm_ATL, offn_ATL;
193  dim_t offm_ABL, offn_ABL;
194  dim_t offm_ATR, offn_ATR;
195  dim_t offm_ABR, offn_ABR;
196 
197  if ( FLA_Check_error_level() == FLA_FULL_ERROR_CHECKING )
198  FLA_Part_2x2_check( A, ATL, ATR,
199  ABL, ABR, n_rows, n_cols, side );
200 
201  // Safeguard: if n_rows > m, reduce n_rows to m.
202  if ( n_rows > FLASH_Obj_scalar_length( A ) )
203  n_rows = FLASH_Obj_scalar_length( A );
204 
205  // Safeguard: if n_cols > n, reduce n_cols to n.
206  if ( n_cols > FLASH_Obj_scalar_width( A ) )
207  n_cols = FLASH_Obj_scalar_width( A );
208 
209  // Acquire various properties of the hierarchical matrix object.
210  dt_A = FLASH_Obj_datatype( A );
211  m_A = FLASH_Obj_scalar_length( A );
212  n_A = FLASH_Obj_scalar_width( A );
213  offm_A = FLASH_Obj_scalar_row_offset( A );
214  offn_A = FLASH_Obj_scalar_col_offset( A );
215  m_A_base = FLASH_Obj_base_scalar_length( A );
216  n_A_base = FLASH_Obj_base_scalar_width( A );
217  depth = FLASH_Obj_depth( A );
218 
219  // Allocate a pair of temporary arrays for the blocksizes, whose lengths
220  // are equal to the object's hierarchical depth.
221  b_m = ( dim_t* ) FLA_malloc( depth * sizeof( dim_t ) );
222  b_n = ( dim_t* ) FLA_malloc( depth * sizeof( dim_t ) );
223 
224  // Accumulate the blocksizes into the blocksize buffers.
225  FLASH_Obj_blocksizes( A, b_m, b_n );
226 
227  // Adjust n_rows to be (m - n_rows) if the quadrant specified is on
228  // the bottom so that the right values get assigned below. Do the same
229  // for n_cols.
230  if ( side == FLA_BL || side == FLA_BR ) n_rows = m_A - n_rows;
231  if ( side == FLA_TR || side == FLA_BR ) n_cols = n_A - n_cols;
232 
233  // Set the dimensions of the partitions.
234  m_ATL = n_rows;
235  n_ATL = n_cols;
236  m_ABL = m_A - n_rows;
237  n_ABL = n_cols;
238  m_ATR = n_rows;
239  n_ATR = n_A - n_cols;
240  m_ABR = m_A - n_rows;
241  n_ABR = n_A - n_cols;
242 
243  // Set the offsets.
244  offm_ATL = offm_A + 0;
245  offn_ATL = offn_A + 0;
246  offm_ABL = offm_A + m_ATL;
247  offn_ABL = offn_A + 0;
248  offm_ATR = offm_A + 0;
249  offn_ATR = offn_A + n_ATL;
250  offm_ABR = offm_A + m_ATL;
251  offn_ABR = offn_A + n_ATL;
252 
253  // Create bufferless hierarhical objects that have the desired dimensions
254  // for the views.
255  FLASH_Obj_create_without_buffer_ext( dt_A, m_A_base, n_A_base, depth, b_m, b_n, ATL );
256  FLASH_Obj_create_without_buffer_ext( dt_A, m_A_base, n_A_base, depth, b_m, b_n, ABL );
257  FLASH_Obj_create_without_buffer_ext( dt_A, m_A_base, n_A_base, depth, b_m, b_n, ATR );
258  FLASH_Obj_create_without_buffer_ext( dt_A, m_A_base, n_A_base, depth, b_m, b_n, ABR );
259 
260  // Recursively walk the hierarchy and adjust the views so that they
261  // collectively refer to the absolute offsets given, and attach the
262  // leaf-level numerical buffers of A to the new views.
263  FLASH_Obj_adjust_views( TRUE, offm_ATL, offn_ATL, m_ATL, n_ATL, A, ATL );
264  FLASH_Obj_adjust_views( TRUE, offm_ABL, offn_ABL, m_ABL, n_ABL, A, ABL );
265  FLASH_Obj_adjust_views( TRUE, offm_ATR, offn_ATR, m_ATR, n_ATR, A, ATR );
266  FLASH_Obj_adjust_views( TRUE, offm_ABR, offn_ABR, m_ABR, n_ABR, A, ABR );
267 
268  // Free the temporary blocksize buffers.
269  FLA_free( b_m );
270  FLA_free( b_n );
271 
272  return FLA_SUCCESS;
273 }
FLA_Error FLA_Part_2x2_check(FLA_Obj A, FLA_Obj *A11, FLA_Obj *A12, FLA_Obj *A21, FLA_Obj *A22, dim_t mb, dim_t nb, FLA_Quadrant quadrant)
Definition: FLA_Part_2x2_check.c:13

References FLA_Check_error_level(), FLA_free(), FLA_malloc(), FLA_Part_2x2_check(), FLASH_Obj_adjust_views(), FLASH_Obj_base_scalar_length(), FLASH_Obj_base_scalar_width(), FLASH_Obj_blocksizes(), FLASH_Obj_create_without_buffer_ext(), FLASH_Obj_datatype(), FLASH_Obj_depth(), FLASH_Obj_scalar_col_offset(), FLASH_Obj_scalar_length(), FLASH_Obj_scalar_row_offset(), and FLASH_Obj_scalar_width().

Referenced by FLASH_Axpy_flat_to_hier(), FLASH_Axpy_hier_to_flat(), FLASH_Copy_flat_to_hier(), and FLASH_Copy_hier_to_flat().

◆ FLASH_Part_free_1x2()

FLA_Error FLASH_Part_free_1x2 ( FLA_Obj AL,
FLA_Obj AR 
)
582 {
585 
586  return FLA_SUCCESS;
587 }
void FLASH_Obj_free_without_buffer(FLA_Obj *H)
Definition: FLASH_Obj.c:674

References FLASH_Obj_free_without_buffer().

◆ FLASH_Part_free_2x1()

FLA_Error FLASH_Part_free_2x1 ( FLA_Obj AT,
FLA_Obj AB 
)
574 {
577 
578  return FLA_SUCCESS;
579 }

References FLASH_Obj_free_without_buffer().

Referenced by FLASH_CAQR_UT_inc_solve(), and FLASH_QR_UT_inc_solve().

◆ FLASH_Part_free_2x2()

FLA_Error FLASH_Part_free_2x2 ( FLA_Obj ATL,
FLA_Obj ATR,
FLA_Obj ABL,
FLA_Obj ABR 
)

◆ FLASH_print_struct()

void FLASH_print_struct ( FLA_Obj  H)
918 {
919  dim_t m_H, n_H, rs, cs, i, j;
920  FLA_Obj* buffer_temp;
921 
922  m_H = FLA_Obj_length( H );
923  n_H = FLA_Obj_width( H );
924  rs = FLA_Obj_row_stride( H );
925  cs = FLA_Obj_col_stride( H );
926 
927  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
929  else
930  {
931  for ( j = 0; j < n_H; ++j )
932  {
933  for ( i = 0; i < m_H; ++i )
934  {
935  buffer_temp = ( FLA_Obj* ) FLA_Obj_buffer_at_view( H );
936 
937  FLASH_print_struct_helper( buffer_temp[ j*cs + i*rs ], 0 );
938  }
939  }
940  }
941 }
void FLASH_print_struct_helper(FLA_Obj H, int indent)
Definition: FLASH_Obj.c:944

References FLA_Obj_buffer_at_view(), FLA_Obj_col_stride(), FLA_Obj_elemtype(), FLA_Obj_length(), FLA_Obj_row_stride(), FLA_Obj_width(), FLASH_print_struct_helper(), and i.

◆ FLASH_print_struct_helper()

void FLASH_print_struct_helper ( FLA_Obj  H,
int  indent 
)
945 {
946  dim_t m_H, n_H, rs, cs, i, j, k;
947  FLA_Obj* buffer_temp;
948 
949  for ( i = 0; i < indent; ++i )
950  fprintf( stdout, " " );
951 
952  if ( FLA_Obj_elemtype( H ) == FLA_SCALAR )
953  {
954  fprintf( stdout, "LEAF (%3d | rs %3lu | cs %3lu | %3lu x %3lu | addr %p)\n",
955  FLA_Obj_datatype( H ),
957  FLA_Obj_length( H ), FLA_Obj_width( H ),
958  FLA_Obj_buffer_at_view( H ) );
959  fflush( stdout );
960  }
961  else
962  {
963  m_H = FLA_Obj_length( H );
964  n_H = FLA_Obj_width( H );
965  rs = FLA_Obj_row_stride( H );
966  cs = FLA_Obj_col_stride( H );
967 
968  fprintf( stdout, "MATRIX (%lux%lu):%d - %p\n",
969  m_H, n_H,
970  FLA_Obj_datatype( H ),
971  FLA_Obj_buffer_at_view( H ) );
972  fflush( stdout );
973 
974  for ( j = 0; j < n_H; ++j )
975  {
976  for ( i = 0; i < m_H; ++i )
977  {
978  for ( k = 0; k < indent; ++k )
979  fprintf( stdout, " " );
980 
981  buffer_temp = ( FLA_Obj* ) FLA_Obj_buffer_at_view( H );
982 
983  FLASH_print_struct_helper( buffer_temp[ j*cs + i*rs ],
984  indent + 1 );
985  }
986  }
987  }
988 }

References FLA_Obj_buffer_at_view(), FLA_Obj_col_stride(), FLA_Obj_datatype(), FLA_Obj_elemtype(), FLA_Obj_length(), FLA_Obj_row_stride(), FLA_Obj_width(), FLASH_print_struct_helper(), and i.

Referenced by FLASH_print_struct(), and FLASH_print_struct_helper().