libflame  revision_anchor
Functions
FLASH_CAQR_UT_inc_create_hier_matrices.c File Reference

(r)

Functions

FLA_Error FLASH_CAQR_UT_inc_create_hier_matrices (dim_t p, FLA_Obj A_flat, dim_t depth, dim_t *b_flash, dim_t b_alg, FLA_Obj *A, FLA_Obj *ATW, FLA_Obj *R, FLA_Obj *RTW)
 
FLA_Error FLASH_CAQR_UT_inc_adjust_views (FLA_Obj A, FLA_Obj TW)
 
dim_t FLASH_CAQR_UT_inc_determine_alg_blocksize (FLA_Obj A)
 

Function Documentation

◆ FLASH_CAQR_UT_inc_adjust_views()

FLA_Error FLASH_CAQR_UT_inc_adjust_views ( FLA_Obj  A,
FLA_Obj  TW 
)
76 {
77  dim_t b_flash;
78  dim_t n, n_last;
79 
80  // We can query b_flash as the width of the top-left element of TW.
81  b_flash = FLASH_Obj_scalar_width_tl( TW );
82 
83  // Query the element (not scalar) n dimension of A.
84  n = FLA_Obj_width( A );
85 
86  // If the bottom-right-most block along the diagonal is a partial block,
87  // adjust the view of the corresponding T block.
88  n_last = FLASH_Obj_scalar_width( A ) % b_flash;
89 
90  if ( n_last > 0 )
91  {
92  FLA_Obj TWTL, TWTR,
93  TWBL, TWBR;
94  FLA_Obj TWL, TWR;
95  FLA_Obj TWT, TW0,
96  TWB, TW1,
97  TW2;
98  FLA_Obj* TW1p;
99 
100  FLA_Part_2x2( TW, &TWTL, &TWTR,
101  &TWBL, &TWBR, n-1, n-1, FLA_TL );
102 
103  FLA_Part_2x1( TWBR, &TWT,
104  &TWB, 0, FLA_TOP );
105 
106  while ( FLA_Obj_length( TWB ) > 0 )
107  {
108  FLA_Repart_2x1_to_3x1( TWT, &TW0,
109  /* *** */ /* *** */
110  &TW1,
111  TWB, &TW2, 1, FLA_BOTTOM );
112 
113  // -----------------------------------------------------------
114 
115  TW1p = FLASH_OBJ_PTR_AT( TW1 );
116 
117  FLA_Part_1x2( *TW1p, &TWL, &TWR, n_last, FLA_LEFT );
118 
119  *TW1p = TWL;
120  TW1p->m_inner = TW1p->m;
121  TW1p->n_inner = TW1p->n;
122 
123  // -----------------------------------------------------------
124 
125  FLA_Cont_with_3x1_to_2x1( &TWT, TW0,
126  TW1,
127  /* *** */ /* *** */
128  &TWB, TW2, FLA_TOP );
129  }
130  }
131 
132  return FLA_SUCCESS;
133 }
dim_t FLASH_Obj_scalar_width(FLA_Obj H)
Definition: FLASH_View.c:641
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
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
dim_t FLA_Obj_width(FLA_Obj obj)
Definition: FLA_Query.c:123
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
dim_t FLA_Obj_length(FLA_Obj obj)
Definition: FLA_Query.c:116
unsigned long dim_t
Definition: FLA_type_defs.h:71
Definition: FLA_type_defs.h:159
dim_t n_inner
Definition: FLA_type_defs.h:166
dim_t m
Definition: FLA_type_defs.h:163
dim_t m_inner
Definition: FLA_type_defs.h:165
dim_t n
Definition: FLA_type_defs.h:164

References FLA_Cont_with_3x1_to_2x1(), FLA_Obj_length(), FLA_Obj_width(), FLA_Part_1x2(), FLA_Part_2x1(), FLA_Part_2x2(), FLA_Repart_2x1_to_3x1(), FLASH_Obj_scalar_width(), FLASH_Obj_scalar_width_tl(), FLA_Obj_view::m, FLA_Obj_view::m_inner, FLA_Obj_view::n, and FLA_Obj_view::n_inner.

Referenced by FLASH_CAQR_UT_inc_create_hier_matrices().

◆ FLASH_CAQR_UT_inc_create_hier_matrices()

FLA_Error FLASH_CAQR_UT_inc_create_hier_matrices ( dim_t  p,
FLA_Obj  A_flat,
dim_t  depth,
dim_t b_flash,
dim_t  b_alg,
FLA_Obj A,
FLA_Obj ATW,
FLA_Obj R,
FLA_Obj RTW 
)
14 {
15  FLA_Datatype datatype;
16  dim_t m, n;
17  dim_t nb_part;
18 
19  // *** The current CAQR_UT_inc algorithm implemented assumes that
20  // the matrix has a hierarchical depth of 1.
21  if ( depth != 1 )
22  {
23  FLA_Print_message( "FLASH_CAQR_UT_inc() currently only supports matrices of depth 1",
24  __FILE__, __LINE__ );
25  FLA_Abort();
26  }
27 
28  // Create hierarchical copy of matrix A_flat.
29  FLASH_Obj_create_hier_copy_of_flat( A_flat, depth, b_flash, A );
30 
31  // Create hierarchical copy of matrix A_flat.
32  FLASH_Obj_create_conf_to( FLA_NO_TRANSPOSE, *A, R );
33 
34  // Query the datatype of matrix A_flat.
35  datatype = FLA_Obj_datatype( A_flat );
36 
37  // If the user passed in zero for b_alg, then we need to set the
38  // algorithmic (inner) blocksize to a reasonable default value.
39  if ( b_alg == 0 )
40  {
42  }
43 
44  // Query the element (not scalar) dimensions of the new hierarchical
45  // matrix. This is done so we can create T with full blocks for the
46  // bottom and right "edge cases" of A.
47  m = FLA_Obj_length( *A );
48  n = FLA_Obj_width( *A );
49 
50  // Create hierarchical matrices T and W for both A and R. T is lower
51  // triangular where each block is b_alg-by-b_flash and W is strictly
52  // upper triangular where each block is b_alg-by-b_flash. So we can
53  // create them simultaneously as part of the same hierarchical matrix.
54  FLASH_Obj_create_ext( datatype, m * b_alg, n * b_flash[0],
55  depth, &b_alg, b_flash,
56  ATW );
57  FLASH_Obj_create_ext( datatype, m * b_alg, n * b_flash[0],
58  depth, &b_alg, b_flash,
59  RTW );
60 
61  // If the bottom-right-most block along the diagonal is a partial block,
62  // adjust the view of the corresponding T block.
65 
66  // Compute the partition length from the number of partitions.
67  nb_part = FLA_CAQR_UT_inc_compute_blocks_per_part( p, *A );
68 
69  // Encode block structure (upper tri, full, or zero) into blocks of R.
70  FLA_CAQR_UT_inc_init_structure( p, nb_part, *R );
71 
72  return FLA_SUCCESS;
73 }
dim_t FLASH_CAQR_UT_inc_determine_alg_blocksize(FLA_Obj A)
Definition: FLASH_CAQR_UT_inc_create_hier_matrices.c:136
FLA_Error FLASH_CAQR_UT_inc_adjust_views(FLA_Obj A, FLA_Obj TW)
Definition: FLASH_CAQR_UT_inc_create_hier_matrices.c:75
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
FLA_Error FLASH_Obj_create_conf_to(FLA_Trans trans, FLA_Obj H_cur, FLA_Obj *H_new)
Definition: FLASH_Obj.c:406
FLA_Error FLASH_Obj_create_hier_copy_of_flat(FLA_Obj F, dim_t depth, dim_t *b_mn, FLA_Obj *H)
Definition: FLASH_Obj.c:591
void FLA_CAQR_UT_inc_init_structure(dim_t p, dim_t nb_part, FLA_Obj R)
Definition: FLA_CAQR_UT_inc_init_structure.c:13
dim_t FLA_CAQR_UT_inc_compute_blocks_per_part(dim_t p, FLA_Obj A)
Definition: FLA_CAQR_UT_inc_compute_p_length.c:13
void FLA_Abort(void)
Definition: FLA_Error.c:248
void FLA_Print_message(char *str, char *file, int line)
Definition: FLA_Error.c:234
FLA_Datatype FLA_Obj_datatype(FLA_Obj obj)
Definition: FLA_Query.c:13
int FLA_Datatype
Definition: FLA_type_defs.h:49

References FLA_Abort(), FLA_CAQR_UT_inc_compute_blocks_per_part(), FLA_CAQR_UT_inc_init_structure(), FLA_Obj_datatype(), FLA_Obj_length(), FLA_Obj_width(), FLA_Print_message(), FLASH_CAQR_UT_inc_adjust_views(), FLASH_CAQR_UT_inc_determine_alg_blocksize(), FLASH_Obj_create_conf_to(), FLASH_Obj_create_ext(), and FLASH_Obj_create_hier_copy_of_flat().

◆ FLASH_CAQR_UT_inc_determine_alg_blocksize()

dim_t FLASH_CAQR_UT_inc_determine_alg_blocksize ( FLA_Obj  A)
137 {
138  dim_t b_alg;
139  dim_t b_flash;
140 
141  // Acquire the storage blocksize.
142  b_flash = FLA_Obj_length( *FLASH_OBJ_PTR_AT( A ) );
143 
144  // Scale the storage blocksize by a pre-defined scalar to arrive at a
145  // reasonable algorithmic blocksize, but make sure it's at least 1.
146  b_alg = ( dim_t ) max( ( double ) b_flash * FLA_CAQR_INNER_TO_OUTER_B_RATIO, 1 );
147 
148  return b_alg;
149 }

References FLA_Obj_length().

Referenced by FLASH_CAQR_UT_inc_create_hier_matrices().