libflame  revision_anchor
Functions
FLASH_UDdate_UT_inc_create_hier_matrices.c File Reference

(r)

Functions

FLA_Error FLASH_UDdate_UT_inc_create_hier_matrices (FLA_Obj R_flat, FLA_Obj C_flat, FLA_Obj D_flat, dim_t depth, dim_t *b_flash, dim_t b_alg, FLA_Obj *R, FLA_Obj *C, FLA_Obj *D, FLA_Obj *T, FLA_Obj *W)
 
dim_t FLASH_UDdate_UT_inc_determine_alg_blocksize (FLA_Obj R)
 

Function Documentation

◆ FLASH_UDdate_UT_inc_create_hier_matrices()

FLA_Error FLASH_UDdate_UT_inc_create_hier_matrices ( FLA_Obj  R_flat,
FLA_Obj  C_flat,
FLA_Obj  D_flat,
dim_t  depth,
dim_t b_flash,
dim_t  b_alg,
FLA_Obj R,
FLA_Obj C,
FLA_Obj D,
FLA_Obj T,
FLA_Obj W 
)

References FLA_Abort(), FLA_Obj_datatype(), FLA_Obj_length(), FLA_Obj_width(), FLA_Print_message(), FLASH_Obj_create_ext(), FLASH_Obj_create_hier_copy_of_flat(), and FLASH_UDdate_UT_inc_determine_alg_blocksize().

14 {
15  FLA_Datatype datatype;
16  dim_t m_T, n_T;
17  dim_t m_W, n_W;
18  dim_t m_C;
19  dim_t m_D;
20 
21  // *** The current UDdate_UT_inc algorithm implemented assumes that
22  // the matrix has a hierarchical depth of 1. We check for that here
23  // because we anticipate that we'll use a more general algorithm in the
24  // future, and we don't want to forget to remove the constraint. ***
25  if ( depth != 1 )
26  {
27  FLA_Print_message( "FLASH_UDdate_UT_inc() currently only supports matrices of depth 1",
28  __FILE__, __LINE__ );
29  FLA_Abort();
30  }
31 
32  // Create hierarchical copy of matrices R_flat, C_flat, and D_flat.
33  FLASH_Obj_create_hier_copy_of_flat( R_flat, depth, b_flash, R );
34  FLASH_Obj_create_hier_copy_of_flat( C_flat, depth, b_flash, C );
35  FLASH_Obj_create_hier_copy_of_flat( D_flat, depth, b_flash, D );
36 
37  // Query the datatype of matrix R_flat.
38  datatype = FLA_Obj_datatype( R_flat );
39 
40  // If the user passed in zero for b_alg, then we need to set the
41  // algorithmic (inner) blocksize to a reasonable default value.
42  if ( b_alg == 0 )
43  {
45  }
46 
47  // Determine the element (not scalar) dimensions of the new hierarchical
48  // matrix T. By using the element dimensions, we will probably allocate
49  // more storage than we actually need (at the bottom and right edge cases)
50  // but this is simpler than computing the exact amount and the excess
51  // storage is usually small in practice.
52  n_T = FLA_Obj_width( *R );
53  m_C = FLA_Obj_length( *C );
54  m_D = FLA_Obj_length( *D );
55  m_T = max( m_C, m_D );
56 
57  // Create hierarchical matrix T, with element dimensions conformal to the
58  // the larger of C and D, where each block is b_alg-by-b_flash.
59  FLASH_Obj_create_ext( datatype, m_T * b_alg, n_T * b_flash[0],
60  depth, &b_alg, b_flash,
61  T );
62 
63  // Determine the element (not scalar) dimensions of the new hierarchical
64  // matrix W. The element length and width will be identical to that of R.
65  // Once again, we will probably allocate excess storage, but we consider
66  // this to be small.
67  m_W = FLA_Obj_length( *R );
68  n_W = FLA_Obj_width( *R );
69 
70  // Create hierarchical matrix W, with element dimensions conformal to R,
71  // where each block is b_alg-by-b_flash.
72  FLASH_Obj_create_ext( datatype, m_W * b_alg, n_W * b_flash[0],
73  depth, &b_alg, b_flash,
74  W );
75 
76  return FLA_SUCCESS;
77 }
unsigned long dim_t
Definition: FLA_type_defs.h:71
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_Datatype FLA_Obj_datatype(FLA_Obj obj)
Definition: FLA_Query.c:13
dim_t FLA_Obj_width(FLA_Obj obj)
Definition: FLA_Query.c:123
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_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
int FLA_Datatype
Definition: FLA_type_defs.h:49
dim_t FLASH_UDdate_UT_inc_determine_alg_blocksize(FLA_Obj R)
Definition: FLASH_UDdate_UT_inc_create_hier_matrices.c:80
dim_t FLA_Obj_length(FLA_Obj obj)
Definition: FLA_Query.c:116

◆ FLASH_UDdate_UT_inc_determine_alg_blocksize()

dim_t FLASH_UDdate_UT_inc_determine_alg_blocksize ( FLA_Obj  R)

References FLA_Obj_length().

Referenced by FLASH_UDdate_UT_inc_create_hier_matrices().

81 {
82  dim_t b_alg;
83  dim_t b_flash;
84 
85  // Acquire the storage blocksize.
86  b_flash = FLA_Obj_length( *FLASH_OBJ_PTR_AT( R ) );
87 
88  // Scale the storage blocksize by a pre-defined scalar to arrive at a
89  // reasonable algorithmic blocksize, but make sure it's at least 1.
90  b_alg = ( dim_t ) max( ( double ) b_flash * FLA_UDDATE_INNER_TO_OUTER_B_RATIO, 1 );
91 
92  return b_alg;
93 }
unsigned long dim_t
Definition: FLA_type_defs.h:71
dim_t FLA_Obj_length(FLA_Obj obj)
Definition: FLA_Query.c:116