Functions | |
FLA_Error | FLASH_Copy_submatrix_to_global (dim_t m, dim_t n, void *buffer, dim_t ldim, dim_t i, dim_t j, FLA_Obj H) |
FLA_Error | FLASH_Copy_global_to_submatrix (dim_t i, dim_t j, FLA_Obj H, dim_t m, dim_t n, void *buffer, dim_t ldim) |
FLA_Error | FLASH_Copy_subobject_to_global (FLA_Obj F, dim_t i, dim_t j, FLA_Obj H) |
FLA_Error | FLASH_Copy_global_to_subobject (dim_t i, dim_t j, FLA_Obj H, FLA_Obj F) |
FLA_Error | FLASH_Copy_hierarchy (int direction, FLA_Obj F, dim_t i, dim_t j, FLA_Obj *H) |
FLA_Error | FLASH_Copy_hierarchy_r (int direction, FLA_Obj F, dim_t i, dim_t j, FLA_Obj *H, FLASH_Obj_queue *queue) |
FLA_Error FLASH_Copy_global_to_submatrix | ( | dim_t | i, | |
dim_t | j, | |||
FLA_Obj | H, | |||
dim_t | m, | |||
dim_t | n, | |||
void * | buffer, | |||
dim_t | ldim | |||
) |
References FLA_Check_error_level(), FLA_Check_submatrix_dims_and_offset(), FLA_Obj_attach_buffer(), FLA_Obj_create_without_buffer(), FLA_Obj_free_without_buffer(), FLASH_Copy_hierarchy(), and FLASH_Obj_datatype().
00067 { 00068 FLA_Obj flat_matrix; 00069 FLA_Datatype datatype; 00070 FLA_Error e_val; 00071 00072 if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING ) 00073 { 00074 e_val = FLA_Check_submatrix_dims_and_offset( m, n, i, j, H ); 00075 FLA_Check_error_code( e_val ); 00076 } 00077 00078 // Acquire the datatype from the hierarchical matrix object. 00079 datatype = FLASH_Obj_datatype( H ); 00080 00081 // Create a temporary conventional matrix object of the requested datatype 00082 // and dimensions and attach the given buffer containing the incoming data. 00083 FLA_Obj_create_without_buffer( datatype, m, n, &flat_matrix ); 00084 FLA_Obj_attach_buffer( buffer, ldim, &flat_matrix ); 00085 00086 // Recurse through H, adding in the corresponding elements of flat_matrix, 00087 // starting at the (i,j) element offset. 00088 FLASH_Copy_hierarchy( FLA_HIER_TO_FLAT, flat_matrix, i, j, &H ); 00089 00090 // Free the object (but don't free the buffer!). 00091 FLA_Obj_free_without_buffer( &flat_matrix ); 00092 00093 return FLA_SUCCESS; 00094 }
References FLASH_Copy_hierarchy().
Referenced by FLASH_Obj_create_flat_copy_of_hier(), and FLASH_Obj_flatten().
00106 { 00107 FLASH_Copy_hierarchy( FLA_HIER_TO_FLAT, F, i, j, &H ); 00108 00109 return FLA_SUCCESS; 00110 }
References FLASH_Copy_hierarchy(), FLASH_Copy_hierarchy_r(), FLASH_Obj_exec(), FLASH_Obj_queue_s::head, FLASH_Obj_queue_s::n_tasks, and FLASH_Obj_queue_s::tail.
Referenced by FLASH_Copy_global_to_submatrix(), FLASH_Copy_global_to_subobject(), FLASH_Copy_hierarchy(), FLASH_Copy_submatrix_to_global(), FLASH_Copy_subobject_to_global(), and FLASH_Obj_exec_parallel().
00114 { 00115 FLA_Error e_val; 00116 FLASH_Obj_queue queue; 00117 00118 queue.n_tasks = 0; 00119 queue.head = NULL; 00120 queue.tail = NULL; 00121 00122 e_val = FLASH_Copy_hierarchy_r( direction, F, i, j, H, &queue ); 00123 00124 #ifdef FLA_ENABLE_MULTITHREADING 00125 FLASH_Obj_exec( ( void* ) FLASH_Copy_hierarchy, &queue ); 00126 #endif 00127 return e_val; 00128 }
FLA_Error FLASH_Copy_hierarchy_r | ( | int | direction, | |
FLA_Obj | F, | |||
dim_t | i, | |||
dim_t | j, | |||
FLA_Obj * | H, | |||
FLASH_Obj_queue * | queue | |||
) |
References FLA_Cont_with_1x3_to_1x2(), FLA_Cont_with_3x1_to_2x1(), FLA_Copy_external(), FLA_Obj_buffer(), FLA_Obj_elemtype(), FLA_Obj_length(), FLA_Obj_width(), FLA_ONE, FLA_Part_1x2(), FLA_Part_2x1(), FLA_Part_2x2(), FLA_Repart_1x2_to_1x3(), FLA_Repart_2x1_to_3x1(), FLA_Repart_2x2_to_3x3(), FLASH_Copy_hierarchy_r(), FLASH_Obj_push(), FLASH_Obj_scalar_length(), FLASH_Obj_scalar_width(), and FLASH_Queue_get_num_threads().
Referenced by FLASH_Copy_hierarchy(), and FLASH_Copy_hierarchy_r().
00132 { 00133 dim_t m_scal, n_scal; 00134 dim_t row_offset, col_offset; 00135 dim_t b_m, b_n; 00136 FLA_Obj* buffer; 00137 FLA_Obj* h11p; 00138 00139 FLA_Obj HTL, HTR, H00, H01, H02, 00140 HBL, HBR, H10, H11, H12, 00141 H20, H21, H22; 00142 00143 FLA_Obj F1T, F01, 00144 F1B, F11, 00145 F21; 00146 00147 FLA_Obj hT, h01, 00148 hB, h11, 00149 h21; 00150 00151 FLA_Obj FL, FR, F0, F1, F2; 00152 00153 FLA_Obj HBR_L, HBR_R, h0, h1, h2; 00154 00155 // Once we get down to a submatrix whose elements are scalars, we are down 00156 // to our base case. 00157 if ( FLA_Obj_elemtype( *H ) == FLA_SCALAR ) 00158 { 00159 dim_t m_flat, n_flat; 00160 00161 // Grab the length and width of the conventional matrix argument. 00162 m_flat = FLA_Obj_length( F ); 00163 n_flat = FLA_Obj_width( F ); 00164 00165 // Advance to the (i,j) offset of the hierarchical matrix. 00166 FLA_Part_2x2( *H, &HTL, &HTR, 00167 &HBL, &HBR, i, j, FLA_TL ); 00168 00169 // Repartition the destination submatrix, H, such that H11 is conformal 00170 // to dimensions of the flat conventional matrix F. 00171 FLA_Repart_2x2_to_3x3( HTL, /**/ HTR, &H00, /**/ &H01, &H02, 00172 /* ************* */ /* ******************** */ 00173 &H10, /**/ &H11, &H12, 00174 HBL, /**/ HBR, &H20, /**/ &H21, &H22, 00175 m_flat, n_flat, FLA_BR ); 00176 00177 #ifdef FLA_ENABLE_MULTITHREADING 00178 if ( FLASH_Queue_get_num_threads() > 1 ) 00179 { 00180 FLASH_Obj_push( direction, FLA_ONE, F, H11, queue ); 00181 } 00182 else 00183 #endif 00184 { 00185 // Depending on which top-level function invoked us, we either add the 00186 // the source data in the flat matrix to the leaf-level submatrix of the 00187 // hierarchical matrix, or add the data in the hierarchical submatrix to 00188 // the appropriate place in the flat matrix. 00189 if ( direction == FLA_FLAT_TO_HIER ) 00190 { 00191 FLA_Copy_external( F, H11 ); 00192 } 00193 else if ( direction == FLA_HIER_TO_FLAT ) 00194 { 00195 FLA_Copy_external( H11, F ); 00196 } 00197 } 00198 00199 // Return, since we're done for this leaf. 00200 return FLA_SUCCESS; 00201 } 00202 00203 // If the above conditional did not hold, then we proceed. 00204 00205 // Grab the buffer of H, whose elemtype we know must be FLA_MATRIX. The 00206 // elements of this buffer are objects. 00207 buffer = ( FLA_Obj* ) FLA_Obj_buffer( *H ); 00208 00209 // Extract the overall scalar dimensions of the first (top-left) matrix 00210 // referenced in the hierarchical matrix's buffer. 00211 m_scal = FLASH_Obj_scalar_length( buffer[0] ); 00212 n_scal = FLASH_Obj_scalar_width( buffer[0] ); 00213 00214 // The i and j offsets given to the current function are relative to the 00215 // entire matrix, which is represented by H. Since the elemtype of H is 00216 // FLA_MATRIX, we now compute the number of submatrix elements we will skip 00217 // in both the m and n dimensions to advance ourselves to the proper 00218 // hierarchical submatrix within H, the one that contains the destination 00219 // for the data (or at least the top-left most portion of the data) in the 00220 // raw buffer matrix. Notice that integer division is performed here. 00221 b_m = i / m_scal; 00222 b_n = j / n_scal; 00223 00224 // We use the indices computed above to advance through H such that the 00225 // (i,j) element represented by the (i,j) values passed to the current 00226 // function is situated at the top-left of HBR. 00227 FLA_Part_2x2( *H, &HTL, &HTR, 00228 &HBL, &HBR, b_m, b_n, FLA_TL ); 00229 00230 // Prepare to march laterally through HBR. 00231 FLA_Part_1x2( HBR, &HBR_L, &HBR_R, 0, FLA_LEFT); 00232 00233 // Prepare to march laterally through the conventional flat matrix. 00234 FLA_Part_1x2( F, &FL, &FR, 0, FLA_LEFT ); 00235 00236 // Iterate laterally through F. 00237 while ( FLA_Obj_width( FL ) < FLA_Obj_width( F ) ) 00238 { 00239 // Handle the initial edge case and "interior" cases differently. 00240 if ( FLA_Obj_width( FL ) == 0 ) 00241 { 00242 // Compute the width of the matrix that we will recurse into. 00243 // Since this is the first iteration of the while loop, this 00244 // blocksize may be smaller than subsequent full blocks if the 00245 // j offset passed to this routine is non-zero. 00246 b_n = n_scal - (j % n_scal); 00247 00248 // Reduce the blocksize if the width of F is smaller than the 00249 // value computed above. 00250 b_n = min( FLA_Obj_width( FR ), b_n ); 00251 00252 // If the j offset is non-zero, we must modulo it to the 00253 // hierarchical blocksize for the element submatrices of H 00254 // in preparation for our recursion. 00255 col_offset = j % n_scal; 00256 } 00257 else 00258 { 00259 // The width of the matrix into which we will recursve may be 00260 // assumed to be the same as the width of the element submatrices 00261 // of H. 00262 b_n = n_scal; 00263 00264 // Reduce the blocksize if the width of F is smaller than the 00265 // element submatrices. 00266 b_n = min( FLA_Obj_width( FR ), b_n ); 00267 00268 // The column offset will be zero because we will be starting from 00269 // the left edge of the submatrix. 00270 col_offset = 0; 00271 } 00272 00273 // Expose one column of hierarchical submatrices within HBR. 00274 FLA_Repart_1x2_to_1x3( HBR_L, /**/ HBR_R, &h0, /**/ &h1, &h2, 00275 1, FLA_RIGHT ); 00276 00277 // Expose one panel of F of width b_n, computed above. 00278 FLA_Repart_1x2_to_1x3( FL, /**/ FR, &F0, /**/ &F1, &F2, 00279 b_n, FLA_RIGHT ); 00280 00281 /*------------------------------------------------------------*/ 00282 00283 // Prepare to march vertically through h1 (the first submatrix column 00284 // of HBR). 00285 FLA_Part_2x1( h1, &hT, 00286 &hB, 0, FLA_TOP ); 00287 00288 // Prepare to march vertically through F. 00289 FLA_Part_2x1( F1, &F1T, 00290 &F1B, 0, FLA_TOP ); 00291 00292 // Iterate vertically through the current column-panel of F, F1. 00293 while ( FLA_Obj_length( F1T ) < FLA_Obj_length( F1 ) ) 00294 { 00295 00296 if ( FLA_Obj_length( F1T ) == 0 ) 00297 { 00298 // Compute the length of the matrix that we will recurse into. 00299 // Since this is the first iteration of the while loop, this 00300 // blocksize may be smaller than subsequent full blocks if the 00301 // i offset passed to this routine is non-zero. 00302 b_m = m_scal - (i % m_scal); 00303 00304 // Reduce the blocksize if the length of F is smaller than the 00305 // value computed above. 00306 b_m = min( FLA_Obj_length( F1B ), b_m ); 00307 00308 // If the i offset is non-zero, we must modulo it to the 00309 // hierarchical blocksize for the element submatrices of H 00310 // in preparation for our recursion. 00311 row_offset = i % m_scal; 00312 } 00313 else 00314 { 00315 // The length of the matrix into which we will recursve may be 00316 // assumed to be the same as the length of the element submatrices 00317 // of H. 00318 b_m = m_scal; 00319 00320 // Reduce the blocksize if the length of the first panel of 00321 // F is smaller than the the element submatrices. 00322 b_m = min( FLA_Obj_length( F1B ), b_m ); 00323 00324 // The column offset will be zero because we will be starting from 00325 // the top edge of the submatrix. 00326 row_offset = 0; 00327 } 00328 00329 // Expose one hierarchical submatrix within the current column of h1. 00330 FLA_Repart_2x1_to_3x1( hT, &h01, 00331 /* ** */ /* ** */ 00332 &h11, 00333 hB, &h21, 1, FLA_BOTTOM ); 00334 00335 // Expose one block of F1 (the current panel of F) of length b_m, 00336 // computed above. 00337 FLA_Repart_2x1_to_3x1( F1T, &F01, 00338 /* ** */ /* ** */ 00339 &F11, 00340 F1B, &F21, b_m, FLA_BOTTOM ); 00341 00342 /*------------------------------------------------------------*/ 00343 00344 // This is a pointer to the FLA_Obj element referenced by h11. 00345 h11p = ( FLA_Obj* ) FLA_Obj_buffer( h11 ); 00346 00347 // Recurse with new (i,j) offset parameters, a narrowed block of 00348 // F, and a corresponding hierarchical block of H. 00349 FLASH_Copy_hierarchy_r( direction, F11, row_offset, col_offset, h11p, queue ); 00350 00351 /*------------------------------------------------------------*/ 00352 00353 FLA_Cont_with_3x1_to_2x1( &hT, h01, 00354 h11, 00355 /* ** */ /* ** */ 00356 &hB, h21, FLA_TOP ); 00357 00358 FLA_Cont_with_3x1_to_2x1( &F1T, F01, 00359 F11, 00360 /* ** */ /* ** */ 00361 &F1B, F21, FLA_TOP ); 00362 } 00363 00364 /*------------------------------------------------------------*/ 00365 00366 FLA_Cont_with_1x3_to_1x2( &FL, /**/ &FR, F0, F1, /**/ F2, 00367 FLA_LEFT ); 00368 00369 FLA_Cont_with_1x3_to_1x2( &HBR_L, /**/ &HBR_R, h0, h1, /**/ h2, 00370 FLA_LEFT ); 00371 } 00372 00373 return FLA_SUCCESS; 00374 00375 }
FLA_Error FLASH_Copy_submatrix_to_global | ( | dim_t | m, | |
dim_t | n, | |||
void * | buffer, | |||
dim_t | ldim, | |||
dim_t | i, | |||
dim_t | j, | |||
FLA_Obj | H | |||
) |
References FLA_Check_error_level(), FLA_Check_submatrix_dims_and_offset(), FLA_Obj_attach_buffer(), FLA_Obj_create_without_buffer(), FLA_Obj_free_without_buffer(), FLASH_Copy_hierarchy(), and FLASH_Obj_datatype().
00036 { 00037 FLA_Obj flat_matrix; 00038 FLA_Datatype datatype; 00039 FLA_Error e_val; 00040 00041 if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING ) 00042 { 00043 e_val = FLA_Check_submatrix_dims_and_offset( m, n, i, j, H ); 00044 FLA_Check_error_code( e_val ); 00045 } 00046 00047 // Acquire the datatype from the hierarchical matrix object. 00048 datatype = FLASH_Obj_datatype( H ); 00049 00050 // Create a temporary conventional matrix object of the requested datatype 00051 // and dimensions and attach the given buffer containing the incoming data. 00052 FLA_Obj_create_without_buffer( datatype, m, n, &flat_matrix ); 00053 FLA_Obj_attach_buffer( buffer, ldim, &flat_matrix ); 00054 00055 // Recurse through H, adding in the corresponding elements of flat_matrix, 00056 // starting at the (i,j) element offset. 00057 FLASH_Copy_hierarchy( FLA_FLAT_TO_HIER, flat_matrix, i, j, &H ); 00058 00059 // Free the object (but don't free the buffer!). 00060 FLA_Obj_free_without_buffer( &flat_matrix ); 00061 00062 return FLA_SUCCESS; 00063 }
References FLASH_Copy_hierarchy().
Referenced by FLASH_Obj_create_hier_copy_of_flat(), FLASH_Obj_create_hier_copy_of_flat_ext(), and FLASH_Obj_hierarchify().
00098 { 00099 FLASH_Copy_hierarchy( FLA_FLAT_TO_HIER, F, i, j, &H ); 00100 00101 return FLA_SUCCESS; 00102 }