libflame revision_anchor
FLASH_Copy_other.c File Reference

(r)

Functions

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)
 

Function Documentation

◆ 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
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_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_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_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
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_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}
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_Copy_external(FLA_Obj A, FLA_Obj B)
Definition FLA_Copy_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_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().