本文整理汇总了C++中FLA_Random_matrix函数的典型用法代码示例。如果您正苦于以下问题:C++ FLA_Random_matrix函数的具体用法?C++ FLA_Random_matrix怎么用?C++ FLA_Random_matrix使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FLA_Random_matrix函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FLASH_Random_matrix
FLA_Error FLASH_Random_matrix( FLA_Obj H )
{
FLA_Obj F;
// Exit early if one dimension is zero.
if ( FLA_Obj_has_zero_dim( H ) ) return FLA_SUCCESS;
// Create a temporary flat copy of the hierarchical object.
FLASH_Obj_create_flat_copy_of_hier( H, &F );
// Randomize the flat matrix object.
FLA_Random_matrix( F );
// Copy the flat object's contents back to the hierarchical object.
FLASH_Obj_hierarchify( F, H );
// Free the temporary flat object.
FLA_Obj_free( &F );
return FLA_SUCCESS;
}
示例2: main
int main( int argc, char** argv ) {
FLA_Datatype testtype = TESTTYPE;
FLA_Datatype realtype = REALTYPE;
dim_t m;
FLA_Obj a, b;
FLA_Error init_result;
if ( argc == 2 ) {
m = atoi(argv[1]);
} else {
fprintf(stderr, " \n");
fprintf(stderr, "Usage: %s m\n", argv[0]);
fprintf(stderr, " m : test vector length\n");
fprintf(stderr, " \n");
return -1;
}
if ( m == 0 )
return 0;
FLA_Init_safe( &init_result );
FLA_Obj_create( testtype, m, 1, 0, 0, &a );
FLA_Random_matrix( a );
FLA_Obj_fshow( stdout, "- a -", a, "% 6.4e", "--" );
FLA_Obj_create( realtype, 1, m, 0, 0, &b );
FLA_Obj_extract_real_part( a, b );
FLA_Obj_fshow( stdout, "- a real -", b, "% 6.4e", "--" );
FLA_Obj_extract_imag_part( a, b );
FLA_Obj_fshow( stdout, "- a imag -", b, "% 6.4e", "--" );
FLA_Obj_free( &b );
FLA_Obj_free( &a );
FLA_Finalize_safe( init_result );
}
示例3: main
//.........这里部分代码省略.........
sprintf( n_dim_tag, "n%dp", -n_input );
}
else if( n_input == -1 ) {
sprintf( n_dim_desc, "n = p" );
sprintf( n_dim_tag, "n%dp", 1 );
}
//datatype = FLA_FLOAT;
//datatype = FLA_DOUBLE;
//datatype = FLA_COMPLEX;
datatype = FLA_DOUBLE_COMPLEX;
for ( p = p_first, i = 1; p <= p_last; p += p_inc, i += 1 )
{
m = m_input;
n = n_input;
if( m < 0 ) m = p / abs(m_input);
if( n < 0 ) n = p / abs(n_input);
for ( param_combo = 0; param_combo < n_param_combos; param_combo++ ){
// If multiplying A on the left, A is m x m; ...on the right, A is n x n.
if ( pc_str[param_combo][0] == 'l' )
FLA_Obj_create( datatype, m, m, 0, 0, &A );
else
FLA_Obj_create( datatype, n, n, 0, 0, &A );
FLA_Obj_create( datatype, m, n, 0, 0, &B );
FLA_Obj_create( datatype, m, n, 0, 0, &C );
FLA_Obj_create( datatype, m, n, 0, 0, &C_ref );
FLA_Random_matrix( A );
FLA_Random_matrix( B );
FLA_Random_matrix( C );
FLA_Copy_external( C, C_ref );
fprintf( stdout, "data_symm_%s( %d, 1:5 ) = [ %d ", pc_str[param_combo], i, p );
fflush( stdout );
time_Symm( param_combo, FLA_ALG_REFERENCE, n_repeats, m, n,
A, B, C, C_ref, &dtime, &diff, &gflops );
fprintf( stdout, "%6.3lf %6.2le ", gflops, diff );
fflush( stdout );
time_Symm( param_combo, FLA_ALG_FRONT, n_repeats, m, n,
A, B, C, C_ref, &dtime, &diff, &gflops );
fprintf( stdout, "%6.3lf %6.2le ", gflops, diff );
fflush( stdout );
fprintf( stdout, " ]; \n" );
fflush( stdout );
FLA_Obj_free( &A );
FLA_Obj_free( &B );
FLA_Obj_free( &C );
FLA_Obj_free( &C_ref );
}
fprintf( stdout, "\n" );
}
示例4: main
int main(int argc, char *argv[])
{
int
datatype,
m_input,
m,
p_first, p_last, p_inc,
p,
nb_alg,
variant,
n_repeats,
i, j,
n_variants = N_VARIANTS;
char *colors = "brkgmcbrkg";
char *ticks = "o+*xso+*xs";
char m_dim_desc[14];
char m_dim_tag[10];
double max_gflops=6.0;
double
dtime,
gflops,
diff;
FLA_Obj
A, b, b_orig, norm;
FLA_Init();
fprintf( stdout, "%c number of repeats:", '%' );
scanf( "%d", &n_repeats );
fprintf( stdout, "%c %d\n", '%', n_repeats );
fprintf( stdout, "%c Enter blocking size:", '%' );
scanf( "%d", &nb_alg );
fprintf( stdout, "%c %d\n", '%', nb_alg );
fprintf( stdout, "%c enter problem size first, last, inc:", '%' );
scanf( "%d%d%d", &p_first, &p_last, &p_inc );
fprintf( stdout, "%c %d %d %d\n", '%', p_first, p_last, p_inc );
fprintf( stdout, "%c enter m (-1 means bind to problem size): ", '%' );
scanf( "%d", &m_input );
fprintf( stdout, "%c %d\n", '%', m_input );
fprintf( stdout, "\nclear all;\n\n" );
if ( m_input > 0 ) {
sprintf( m_dim_desc, "m = %d", m_input );
sprintf( m_dim_tag, "m%dc", m_input);
}
else if( m_input < -1 ) {
sprintf( m_dim_desc, "m = p/%d", -m_input );
sprintf( m_dim_tag, "m%dp", -m_input );
}
else if( m_input == -1 ) {
sprintf( m_dim_desc, "m = p" );
sprintf( m_dim_tag, "m%dp", 1 );
}
//datatype = FLA_FLOAT;
//datatype = FLA_DOUBLE;
//datatype = FLA_COMPLEX;
datatype = FLA_DOUBLE_COMPLEX;
for ( p = p_first, i = 1; p <= p_last; p += p_inc, i += 1 )
{
m = m_input;
if( m < 0 ) m = p / f2c_abs(m_input);
FLA_Obj_create( datatype, m, m, 0, 0, &A );
FLA_Obj_create( datatype, m, 1, 0, 0, &b );
FLA_Obj_create( datatype, m, 1, 0, 0, &b_orig );
/*
FLA_Obj_create( datatype, m, m, m, 1, &A );
FLA_Obj_create( datatype, m, 1, 1, 1, &b );
FLA_Obj_create( datatype, m, 1, 1, 1, &b_orig );
*/
if ( FLA_Obj_is_single_precision( A ) )
FLA_Obj_create( FLA_FLOAT, 1, 1, 0, 0, &norm );
else
FLA_Obj_create( FLA_DOUBLE, 1, 1, 0, 0, &norm );
FLA_Random_tri_matrix( FLA_UPPER_TRIANGULAR, FLA_NONUNIT_DIAG, A );
FLA_Random_matrix( b );
FLA_Copy_external( b, b_orig );
/*
time_Trinv_un( 0, FLA_ALG_REFERENCE, n_repeats, m, nb_alg,
A, b, b_orig, norm, &dtime, &diff, &gflops );
//.........这里部分代码省略.........
示例5: main
//.........这里部分代码省略.........
else if( n_input < -1 ) {
sprintf( n_dim_desc, "n = p/%d", -n_input );
sprintf( n_dim_tag, "n%dp", -n_input );
}
else if( n_input == -1 ) {
sprintf( n_dim_desc, "n = p" );
sprintf( n_dim_tag, "n%dp", 1 );
}
//datatype = FLA_FLOAT;
//datatype = FLA_DOUBLE;
//datatype = FLA_COMPLEX;
datatype = FLA_DOUBLE_COMPLEX;
for ( pp = p_first, i = 1; pp <= p_last; pp += p_inc, i += 1 )
{
m = m_input;
n = n_input;
if( m < 0 ) m = pp / abs(m_input);
if( n < 0 ) n = pp / abs(n_input);
min_m_n = min( m, n );
for ( pivot_combo = 0; pivot_combo < n_pivot_combos; pivot_combo++ ){
FLA_Obj_create( datatype, m, n, 0, 0, &C );
FLA_Obj_create( datatype, m, 1, 0, 0, &b );
FLA_Obj_create( datatype, m, 1, 0, 0, &b_orig );
if ( FLA_Obj_is_single_precision( C ) )
FLA_Obj_create( FLA_FLOAT, 1, 1, 0, 0, &b_norm );
else
FLA_Obj_create( FLA_DOUBLE, 1, 1, 0, 0, &b_norm );
FLA_Random_matrix( C );
FLA_Random_matrix( b );
FLA_Copy_external( b, b_orig );
fprintf( stdout, "data_lu_%s( %d, 1:5 ) = [ %d ", pc_str[pivot_combo], i, pp );
fflush( stdout );
//time_LU( pivot_combo, FLA_ALG_REFERENCE, n_repeats, m, n,
// C, b, b_orig, b_norm, &dtime, &diff, &gflops );
//fprintf( stdout, "%6.3lf %6.2le ", gflops, diff );
//fflush( stdout );
time_LU( pivot_combo, FLA_ALG_FRONT, n_repeats, m, n,
C, b, b_orig, b_norm, &dtime, &diff, &gflops );
fprintf( stdout, "%6.3lf %6.2le ", gflops, diff );
fflush( stdout );
fprintf( stdout, " ]; \n" );
fflush( stdout );
FLA_Obj_free( &C );
FLA_Obj_free( &b );
FLA_Obj_free( &b_orig );
FLA_Obj_free( &b_norm );
}
fprintf( stdout, "\n" );
}
/*
fprintf( stdout, "figure;\n" );
fprintf( stdout, "hold on;\n" );
for ( i = 0; i < n_pivot_combos; i++ ) {
fprintf( stdout, "plot( data_lu_%s( :,1 ), data_lu_%s( :, 2 ), '%c:%c' ); \n",
pc_str[i], pc_str[i], colors[ i ], ticks[ i ] );
fprintf( stdout, "plot( data_lu_%s( :,1 ), data_lu_%s( :, 4 ), '%c-.%c' ); \n",
pc_str[i], pc_str[i], colors[ i ], ticks[ i ] );
}
fprintf( stdout, "legend( ... \n" );
for ( i = 0; i < n_pivot_combos; i++ )
fprintf( stdout, "'ref\\_lu\\_%s', 'fla\\_lu\\_%s', ... \n", pc_str[i], pc_str[i] );
fprintf( stdout, "'Location', 'SouthEast' ); \n" );
fprintf( stdout, "xlabel( 'problem size p' );\n" );
fprintf( stdout, "ylabel( 'GFLOPS/sec.' );\n" );
fprintf( stdout, "axis( [ 0 %d 0 %.2f ] ); \n", p_last, max_gflops );
fprintf( stdout, "title( 'FLAME LU front-end performance (%s, %s)' );\n",
m_dim_desc, n_dim_desc );
fprintf( stdout, "print -depsc lu_front_%s_%s.eps\n", m_dim_tag, n_dim_tag );
fprintf( stdout, "hold off;\n");
fflush( stdout );
*/
FLA_Finalize( );
return 0;
}
示例6: main
//.........这里部分代码省略.........
// Determine datatype based on trans argument.
if ( pc_str[param_combo][0] == 'c' ||
pc_str[param_combo][1] == 'c' )
{
if ( precision == FLA_SINGLE_PRECISION )
datatype = FLA_COMPLEX;
else
datatype = FLA_DOUBLE_COMPLEX;
}
else
{
if ( precision == FLA_SINGLE_PRECISION )
datatype = FLA_FLOAT;
else
datatype = FLA_DOUBLE;
}
// If transposing A, switch dimensions.
if ( pc_str[param_combo][0] == 'n' )
FLA_Obj_create( datatype, m, k, 0, 0, &A );
else
FLA_Obj_create( datatype, k, m, 0, 0, &A );
// If transposing B, switch dimensions.
if ( pc_str[param_combo][1] == 'n' )
FLA_Obj_create( datatype, k, n, 0, 0, &B );
else
FLA_Obj_create( datatype, n, k, 0, 0, &B );
FLA_Obj_create( datatype, m, n, 0, 0, &C );
FLA_Obj_create( datatype, m, n, 0, 0, &C_ref );
FLA_Random_matrix( A );
FLA_Random_matrix( B );
FLA_Random_matrix( C );
FLA_Copy_external( C, C_ref );
fprintf( stdout, "data_gemm_%s( %d, 1:5 ) = [ %4d %4d %4d ", pc_str[param_combo], i, m, k, n );
fflush( stdout );
time_Gemm( param_combo, FLA_ALG_REFERENCE, n_repeats, m, k, n,
A, B, C, C_ref, &dtime, &diff, &gflops );
fprintf( stdout, "%6.3lf %6.2le ", gflops, diff );
fflush( stdout );
/*
time_Gemm( param_combo, FLA_ALG_FRONT, n_repeats, m, k, n,
A, B, C, C_ref, &dtime, &diff, &gflops );
fprintf( stdout, "%6.3lf %6.2le ", gflops, diff );
fflush( stdout );
*/
fprintf( stdout, " ]; \n" );
fflush( stdout );
FLA_Obj_free( &A );
FLA_Obj_free( &B );
FLA_Obj_free( &C );
FLA_Obj_free( &C_ref );
}
fprintf( stdout, "\n" );
示例7: main
int main(int argc, char *argv[])
{
int
datatype,
n_input,
mB_input, mC_input, mD_input,
mB, mC, mD, n,
p_first, p_last, p_inc,
p,
b_alg,
variant,
n_repeats,
i,
n_variants = 1;
double max_gflops=6.0;
double
dtime,
gflops,
diff;
FLA_Obj
B, C, D, T, R, E;
FLA_Init();
fprintf( stdout, "%c number of repeats:", '%' );
scanf( "%d", &n_repeats );
fprintf( stdout, "%c %d\n", '%', n_repeats );
fprintf( stdout, "%c enter algorithmic blocksize:", '%' );
scanf( "%d", &b_alg );
fprintf( stdout, "%c %d\n", '%', b_alg );
fprintf( stdout, "%c enter problem size first, last, inc:", '%' );
scanf( "%d%d%d", &p_first, &p_last, &p_inc );
fprintf( stdout, "%c %d %d %d\n", '%', p_first, p_last, p_inc );
fprintf( stdout, "%c enter n (-1 means bind to problem size): ", '%' );
scanf( "%d", &n_input );
fprintf( stdout, "%c %d\n", '%', n_input );
fprintf( stdout, "%c enter mB mC mD (-1 means bind to problem size): ", '%' );
scanf( "%d %d %d", &mB_input, &mC_input, &mD_input );
fprintf( stdout, "%c %d %d %d\n", '%', mB_input, mC_input, mD_input );
fprintf( stdout, "\nclear all;\n\n" );
//datatype = FLA_FLOAT;
//datatype = FLA_DOUBLE;
//datatype = FLA_COMPLEX;
datatype = FLA_DOUBLE_COMPLEX;
for ( p = p_first, i = 1; p <= p_last; p += p_inc, i += 1 )
{
mB = mB_input;
mC = mC_input;
mD = mD_input;
n = n_input;
if( mB < 0 ) mB = p / abs(mB_input);
if( mC < 0 ) mC = p / abs(mC_input);
if( mD < 0 ) mD = p / abs(mD_input);
if( n < 0 ) n = p / abs(n_input);
for ( variant = 0; variant < n_variants; variant++ ){
FLA_Obj_create( datatype, mB, n, 0, 0, &B );
FLA_Obj_create( datatype, mC, n, 0, 0, &C );
FLA_Obj_create( datatype, mD, n, 0, 0, &D );
FLA_Obj_create( datatype, b_alg, n, 0, 0, &T );
FLA_Obj_create( datatype, n, n, 0, 0, &R );
FLA_Obj_create( datatype, n, n, 0, 0, &E );
FLA_Random_matrix( B );
FLA_Random_matrix( C );
FLA_Random_matrix( D );
FLA_Set( FLA_ZERO, R );
FLA_Herk_external( FLA_UPPER_TRIANGULAR, FLA_CONJ_TRANSPOSE, FLA_ONE, B, FLA_ONE, R );
FLA_Herk_external( FLA_UPPER_TRIANGULAR, FLA_CONJ_TRANSPOSE, FLA_ONE, D, FLA_ONE, R );
FLA_Chol( FLA_UPPER_TRIANGULAR, R );
FLA_Set( FLA_ZERO, E );
FLA_Herk_external( FLA_UPPER_TRIANGULAR, FLA_CONJ_TRANSPOSE, FLA_ONE, B, FLA_ONE, E );
FLA_Herk_external( FLA_UPPER_TRIANGULAR, FLA_CONJ_TRANSPOSE, FLA_ONE, C, FLA_ONE, E );
FLA_Chol( FLA_UPPER_TRIANGULAR, E );
fprintf( stdout, "data_uddate_ut( %d, 1:5 ) = [ %d ", i, p );
fflush( stdout );
time_UDdate_UT( variant, FLA_ALG_FRONT, n_repeats, mB, mC, mD, n,
B, C, D, T, R, E, &dtime, &diff, &gflops );
//.........这里部分代码省略.........
示例8: main
//.........这里部分代码省略.........
m = p_last;
k = p_last;
n = p_last;
sprintf( nth_str, "OMP_NUM_THREADS=%d", n_threads_exp[ n_thread_experiments-1 ] );
putenv( nth_str );
blas_cpu_number = n_threads_exp[ n_thread_experiments-1 ];
blas_thread_init();
for ( p = p_first, i = 1; p <= p_last; p += p_inc, i += 1 )
{
m = m_input;
k = k_input;
n = n_input;
if( m < 0 ) m = p / abs(m_input);
if( k < 0 ) k = p / abs(k_input);
if( n < 0 ) n = p / abs(n_input);
FLA_Obj_create( FLA_DOUBLE, m, k, &A );
FLA_Obj_create( FLA_DOUBLE, k, n, &B );
FLA_Obj_create( FLA_DOUBLE, m, n, &C );
FLA_Obj_create( FLA_DOUBLE, m, n, &C_ref );
/* Generate random matrices A, C */
if( p > 4000 ){
FLA_Random_matrix( A );
FLA_Random_matrix( B );
FLA_Random_matrix( C );
FLA_Copy_external( C, C_ref );
}
blas_cpu_number = 1;
//time_Gemm_nn( 0, FLA_ALG_REFERENCE, n_repeats, p, nb_alg,
// A, B, C, C_ref, &dtime, &diff, &gflops );
//fprintf( stdout, "data_REF( %d, 1:2 ) = [ %d %6.3lf ]; \n", i, p, gflops );
//fflush( stdout );
for ( j = 0; j < n_thread_experiments; j++ ){
n_threads = n_threads_exp[j];
blas_cpu_number = n_threads;
fprintf( stdout, "data_nth%d( %d, 1:3 ) = [ %d ", n_threads, i, p );
fflush( stdout );
time_Gemm_nn( 0, FLA_ALG_REFERENCE, n_repeats, p, nb_alg,
A, B, C, C_ref, &dtime, &diff, &gflops );
fprintf( stdout, "%6.3lf %6.2le ", gflops, diff );
fflush( stdout );
fprintf( stdout, " ]; \n" );
fflush( stdout );
示例9: libfla_test_apqut_experiment
void libfla_test_apqut_experiment( test_params_t params,
unsigned int var,
char* sc_str,
FLA_Datatype datatype,
unsigned int p_cur,
unsigned int pci,
unsigned int n_repeats,
signed int impl,
double* perf,
double* residual )
{
dim_t b_flash = params.b_flash;
dim_t b_alg_flat = params.b_alg_flat;
double time_min = 1e9;
double time;
unsigned int i;
unsigned int m, n;
unsigned int min_m_n;
signed int m_input;
signed int n_input;
FLA_Side side;
FLA_Trans trans;
FLA_Direct direct;
FLA_Store storev;
FLA_Obj A, T, W, B, eye, norm;
FLA_Obj B_save;
FLA_Obj A_test, T_test, W_test, B_test;
// Translate parameter characters to libflame constants.
FLA_Param_map_char_to_flame_side( &pc_str[pci][0], &side );
FLA_Param_map_char_to_flame_trans( &pc_str[pci][1], &trans );
FLA_Param_map_char_to_flame_direct( &pc_str[pci][2], &direct );
FLA_Param_map_char_to_flame_storev( &pc_str[pci][3], &storev );
// We want to make sure the Apply_Q_UT routines work with rectangular
// matrices. So we use m > n when testing with column-wise storage (via
// QR factorization) and m < n when testing with row-wise storage (via
// LQ factorization).
if ( storev == FLA_COLUMNWISE )
{
m_input = -1;
n_input = -1;
//m_input = -1;
//n_input = -1;
}
else // if ( storev == FLA_ROWWISE )
{
m_input = -1;
n_input = -1;
//m_input = -1;
//n_input = -1;
}
// Determine the dimensions.
if ( m_input < 0 ) m = p_cur * abs(m_input);
else m = p_cur;
if ( n_input < 0 ) n = p_cur * abs(n_input);
else n = p_cur;
// Compute the minimum dimension.
min_m_n = min( m, n );
// Create the matrices for the current operation.
libfla_test_obj_create( datatype, FLA_NO_TRANSPOSE, sc_str[0], m, n, &A );
libfla_test_obj_create( datatype, FLA_NO_TRANSPOSE, sc_str[1], b_alg_flat, min_m_n, &T );
if ( storev == FLA_COLUMNWISE )
libfla_test_obj_create( datatype, FLA_NO_TRANSPOSE, sc_str[2], m, m, &B );
else
libfla_test_obj_create( datatype, FLA_NO_TRANSPOSE, sc_str[2], n, n, &B );
FLA_Obj_create_conf_to( FLA_NO_TRANSPOSE, B, &eye );
FLA_Apply_Q_UT_create_workspace( T, B, &W );
// Create a real scalar object to hold the norm of A.
FLA_Obj_create( FLA_Obj_datatype_proj_to_real( A ), 1, 1, 0, 0, &norm );
// Initialize the test matrices.
FLA_Random_matrix( A );
FLA_Set_to_identity( B );
FLA_Set_to_identity( eye );
// Save the original object contents in a temporary object.
FLA_Obj_create_copy_of( FLA_NO_TRANSPOSE, B, &B_save );
// Use hierarchical matrices if we're testing the FLASH front-end.
if ( impl == FLA_TEST_HIER_FRONT_END )
{
if ( storev == FLA_COLUMNWISE )
FLASH_QR_UT_create_hier_matrices( A, 1, &b_flash, &A_test, &T_test );
else // if ( storev == FLA_ROWWISE )
FLASH_LQ_UT_create_hier_matrices( A, 1, &b_flash, &A_test, &T_test );
FLASH_Obj_create_hier_copy_of_flat( B, 1, &b_flash, &B_test );
FLASH_Apply_Q_UT_create_workspace( T_test, B_test, &W_test );
}
else // if ( impl == FLA_TEST_FLAT_FRONT_END )
{
A_test = A;
T_test = T;
W_test = W;
//.........这里部分代码省略.........
示例10: main
int main( int argc, char** argv ) {
FLA_Datatype datatype = TESTTYPE;
FLA_Obj A, Ak, T, Tk, D, Dk, A_copy, A_recovered, L, Q, Qk, W, x, y, z;
dim_t m, n, k;
dim_t min_m_n;
FLA_Error init_result;
double residual_A, residual_Axy;
int use_form_q = 1;
if ( argc == 4 ) {
m = atoi(argv[1]);
n = atoi(argv[2]);
k = atoi(argv[3]);
min_m_n = min(m,n);
} else {
fprintf(stderr, " \n");
fprintf(stderr, "Usage: %s m n k\n", argv[0]);
fprintf(stderr, " m : matrix length\n");
fprintf(stderr, " n : matrix width\n");
fprintf(stderr, " k : number of house holder vectors applied for testing\n");
fprintf(stderr, " \n");
return -1;
}
if ( m == 0 || n == 0 )
return 0;
FLA_Init_safe( &init_result );
// FLAME LQ^H setup
FLA_Obj_create( datatype, m, n, 0, 0, &A );
FLA_LQ_UT_create_T( A, &T );
// Rand A and create A_copy.
FLA_Random_matrix( A );
FLA_Obj_create_conf_to( FLA_NO_TRANSPOSE, A, &A_copy );
FLA_Obj_create_conf_to( FLA_NO_TRANSPOSE, A, &A_recovered );
FLA_Copy( A, A_copy );
// LQ test ( A = L Q^H )
FLA_LQ_UT( A, T );
// Create Q (identity), L (A_copy)
FLA_Obj_create( datatype, m, n, 0, 0, &Q ); FLA_Set_to_identity( Q );
FLA_Obj_create( datatype, m, m, 0, 0, &D );
FLA_Obj_create( datatype, k, n, 0, 0, &Qk ); FLA_Set_to_identity( Qk );
FLA_Obj_create( datatype, k, k, 0, 0, &Dk );
FLA_Obj_create( datatype, m, m, 0, 0, &L );
// Q^H := I H_{0}^H ... H_{k-1}^H
if ( use_form_q ) {
FLA_LQ_UT_form_Q( A, T, Q );
} else {
FLA_Apply_Q_UT_create_workspace_side( FLA_RIGHT, T, Q, &W );
FLA_Apply_Q_UT( FLA_RIGHT, FLA_CONJ_TRANSPOSE, FLA_FORWARD, FLA_ROWWISE,
A, T, W, Q );
FLA_Obj_free( &W );
}
// D := Q^T Q
FLA_Gemm_external( FLA_NO_TRANSPOSE, FLA_CONJ_TRANSPOSE,
FLA_ONE, Q, Q, FLA_ZERO, D );
// Qk := I H0 ... Hk
FLA_Part_1x2( T, &Tk, &W, k, FLA_LEFT );
FLA_Part_2x1( A, &Ak, &W, k, FLA_TOP );
if ( use_form_q ) {
// Overwrite the result to test FLAME API
FLA_Set( FLA_ZERO, Qk );
FLA_Copy( Ak, Qk );
FLA_LQ_UT_form_Q( Ak, Tk, Qk );
} else {
FLA_Apply_Q_UT_create_workspace( Tk, Qk, &W );
FLA_Apply_Q_UT( FLA_LEFT, FLA_NO_TRANSPOSE, FLA_FORWARD, FLA_ROWWISE,
Ak, Tk, W, Qk );
FLA_Obj_free( &W );
}
// Dk := Qk^T Qk
FLA_Gemm_external( FLA_NO_TRANSPOSE, FLA_CONJ_TRANSPOSE,
FLA_ONE, Qk, Qk, FLA_ZERO, Dk );
// L := A (Q^H)^H
if ( use_form_q ) {
// Note that the formed Q is actually Q^H; transb should be carefully assigned.
FLA_Gemm_external( FLA_NO_TRANSPOSE, FLA_CONJ_TRANSPOSE,
FLA_ONE, A_copy, Q, FLA_ZERO, L );
} else {
FLA_Apply_Q_UT_create_workspace( T, L, &W );
FLA_Apply_Q_UT( FLA_RIGHT, FLA_NO_TRANSPOSE, FLA_FORWARD, FLA_ROWWISE,
A, T, W, L );
FLA_Obj_free( &W );
}
FLA_Gemm_external( FLA_NO_TRANSPOSE, FLA_NO_TRANSPOSE,
FLA_ONE, L, Q, FLA_ZERO, A_recovered );
//.........这里部分代码省略.........
示例11: main
//.........这里部分代码省略.........
FLA_Obj_create( datatype, m, n, n, 1, &T );
FLA_Obj_create( datatype, nb_alg, n, n, 1, &TT );
FLA_Obj_create( datatype, 1, 1, 0, 0, &w );
FLA_Obj_create( datatype, m, 1, 1, 1, &W );
FLA_Obj_create( datatype, nb_alg, 1, 1, 1, &WW );
FLA_Obj_create( datatype, m, 1, 1, 1, &b );
FLA_Obj_create( datatype, m, 1, 1, 1, &b_ref );
*/
/*
FLA_Obj_create( datatype, m, n, n, 1, &A );
//FLA_Obj_create( datatype, 1, min_m_n, 0, 0, &t );
//FLA_Obj_create( datatype, m, n, n, 1, &T );
//FLA_Obj_create( datatype, nb_alg, n, n, 1, &TT );
//FLA_Obj_create( datatype, 1, 1, 0, 0, &w );
//FLA_Obj_create( datatype, m, 1, 1, 1, &W );
//FLA_Obj_create( datatype, nb_alg, 1, 1, 1, &WW );
//FLA_Obj_create( datatype, m, 1, 1, 1, &b );
//FLA_Obj_create( datatype, m, 1, 1, 1, &b_ref );
*/
//FLA_Obj_create( datatype, m, n, 0, 0, &A );
FLA_Obj_create( datatype, m, n, n, 1, &A );
FLA_Obj_create( datatype, 1, min_m_n, 0, 0, &t );
FLA_Obj_create( datatype, m, n, 0, 0, &T );
//FLA_Obj_create( datatype, m, n, n, 1, &T );
FLA_Obj_create( datatype, nb_alg, n, 0, 0, &TT );
FLA_Obj_create( datatype, 1, 1, 0, 0, &w );
FLA_Obj_create( datatype, m, 1, 0, 0, &W );
FLA_Obj_create( datatype, nb_alg, 1, 0, 0, &WW );
FLA_Obj_create( datatype, m, 1, 0, 0, &b );
FLA_Obj_create( datatype, m, 1, 0, 0, &b_ref );
FLA_Random_matrix( A );
FLA_Random_matrix( b );
/*
time_LQ( 0, FLA_ALG_REFERENCE, n_repeats, m, n, nb_alg,
A, A_ref, t, T, W, b, b_ref, &dtime, &diff, &gflops );
fprintf( stdout, "data_REF( %d, 1:2 ) = [ %d %6.3lf %6.2le ]; \n", i, p, gflops, diff );
fflush( stdout );
*/
for ( variant = 1; variant <= n_variants; variant++ ){
fprintf( stdout, "data_var%d( %d, 1:3 ) = [ %d ", variant, i, p );
fflush( stdout );
time_LQ( variant, FLA_ALG_UNBLOCKED, n_repeats, m, n, nb_alg,
A, t, T, TT, w, W, WW, b, b_ref, &dtime, &diff, &gflops );
fprintf( stdout, "%6.3lf %6.2le ", gflops, diff );
fflush( stdout );
time_LQ( variant, FLA_ALG_UNB_OPT1, n_repeats, m, n, nb_alg,
A, t, T, TT, w, W, WW, b, b_ref, &dtime, &diff, &gflops );
fprintf( stdout, "%6.3lf %6.2le ", gflops, diff );
fflush( stdout );
time_LQ( variant, FLA_ALG_BLOCKED, n_repeats, m, n, nb_alg,
A, t, T, TT, w, W, WW, b, b_ref, &dtime, &diff, &gflops );
fprintf( stdout, "%6.3lf %6.2le ", gflops, diff );
fflush( stdout );
示例12: main
int main(int argc, char *argv[])
{
int
m_input,
m,
p_first, p_last, p_inc,
p,
b_alg,
variant,
n_repeats,
i,
datatype,
n_variants = 1;
char *colors = "brkgmcbrkg";
char *ticks = "o+*xso+*xs";
char m_dim_desc[14];
char m_dim_tag[10];
double max_gflops=6.0;
double safemin;
double
dtime,
gflops,
diff;
FLA_Obj
A, l, Q, T, W;
FLA_Init();
fprintf( stdout, "%c number of repeats:", '%' );
scanf( "%d", &n_repeats );
fprintf( stdout, "%c %d\n", '%', n_repeats );
fprintf( stdout, "%c Enter blocking size:", '%' );
scanf( "%d", &b_alg );
fprintf( stdout, "%c %d\n", '%', b_alg );
fprintf( stdout, "%c enter problem size first, last, inc:", '%' );
scanf( "%d%d%d", &p_first, &p_last, &p_inc );
fprintf( stdout, "%c %d %d %d\n", '%', p_first, p_last, p_inc );
fprintf( stdout, "%c enter m (-1 means bind to problem size): ", '%' );
scanf( "%d", &m_input );
fprintf( stdout, "%c %d\n", '%', m_input );
fprintf( stdout, "\n" );
if ( m_input > 0 ) {
sprintf( m_dim_desc, "m = %d", m_input );
sprintf( m_dim_tag, "m%dc", m_input);
}
else if( m_input < -1 ) {
sprintf( m_dim_desc, "m = p/%d", -m_input );
sprintf( m_dim_tag, "m%dp", -m_input );
}
else if( m_input == -1 ) {
sprintf( m_dim_desc, "m = p" );
sprintf( m_dim_tag, "m%dp", 1 );
}
/*
char ch = 's';
safemin = dlamch_( &ch );
printf( "safemin = %23.15e\n", safemin );
ch = 'e';
double eps = dlamch_( &ch );
printf( "eps dla = %23.15e\n", eps );
printf( "eps fla = %23.15e\n", FLA_EPSILON_D );
*/
for ( p = p_first, i = 1; p <= p_last; p += p_inc, i += 1 )
{
m = m_input;
if( m < 0 ) m = p / f2c_abs(m_input);
//datatype = FLA_FLOAT;
//datatype = FLA_DOUBLE;
//datatype = FLA_COMPLEX;
datatype = FLA_DOUBLE_COMPLEX;
FLA_Obj_create( datatype, m, m, 0, 0, &A );
FLA_Obj_create( datatype, m, m, 0, 0, &Q );
FLA_Obj_create( datatype, 32, m, 0, 0, &T );
FLA_Obj_create( datatype, 32, m, 0, 0, &W );
FLA_Obj_create( FLA_Obj_datatype_proj_to_real( A ), m, 1, 0, 0, &l );
//FLA_Random_herm_matrix( FLA_LOWER_TRIANGULAR, A );
//FLA_Random_spd_matrix( FLA_LOWER_TRIANGULAR, A );
FLA_Random_matrix( A );
FLA_Obj_set_to_identity( Q );
FLA_QR_UT( A, T );
//.........这里部分代码省略.........
示例13: main
int main(int argc, char *argv[])
{
int
datatype,
m_input,
m,
p_first, p_last, p_inc,
p,
variant,
n_repeats,
i, j,
nb_alg,
nfc, nlc,
n_variants = 1;
char *colors = "brkgmcbrkg";
char *ticks = "o+*xso+*xs";
char m_dim_desc[14];
char m_dim_tag[10];
double max_gflops=6.0;
double
dtime,
gflops,
diff;
FLA_Obj
C, C_ref, t;
FLA_Init();
fprintf( stdout, "%c number of repeats:", '%' );
scanf( "%d", &n_repeats );
fprintf( stdout, "%c %d\n", '%', n_repeats );
fprintf( stdout, "%c enter problem size first, last, inc:", '%' );
scanf( "%d%d%d", &p_first, &p_last, &p_inc );
fprintf( stdout, "%c %d %d %d\n", '%', p_first, p_last, p_inc );
fprintf( stdout, "%c enter m (-1 means bind to problem size): ", '%' );
scanf( "%d", &m_input );
fprintf( stdout, "%c %d\n", '%', m_input );
fprintf( stdout, "%c enter nfc, nlc (number of columns, initial and trailing, not processed): ", '%' );
scanf( "%d %d", &nfc, &nlc );
fprintf( stdout, "%c %d %d\n", '%', nfc, nlc );
fprintf( stdout, "\nclear all;\n\n" );
if ( m_input > 0 ) {
sprintf( m_dim_desc, "m = %d", m_input );
sprintf( m_dim_tag, "m%dc", m_input);
}
else if( m_input < -1 ) {
sprintf( m_dim_desc, "m = p/%d", -m_input );
sprintf( m_dim_tag, "m%dp", -m_input );
}
else if( m_input == -1 ) {
sprintf( m_dim_desc, "m = p" );
sprintf( m_dim_tag, "m%dp", 1 );
}
//datatype = FLA_FLOAT;
datatype = FLA_DOUBLE;
//datatype = FLA_COMPLEX;
//datatype = FLA_DOUBLE_COMPLEX;
for ( p = p_first, i = 1; p <= p_last; p += p_inc, i += 1 )
{
m = m_input;
if( m < 0 ) m = p / abs(m_input);
for ( variant = 0; variant < n_variants; variant++ ){
FLA_Obj_create( datatype, m, m, &C );
FLA_Obj_create( datatype, m, m, &C_ref );
FLA_Obj_create( datatype, m, 1, &t );
FLA_Random_matrix( C );
FLA_Copy_external( C, C_ref );
fprintf( stdout, "data_hess( %d, 1:5 ) = [ %d ", i, p );
fflush( stdout );
time_Hess( variant, FLA_ALG_REFERENCE, n_repeats, m, nfc, nlc,
C, C_ref, t, &dtime, &diff, &gflops );
fprintf( stdout, "%6.3lf %6.2le ", gflops, diff );
fflush( stdout );
time_Hess( variant, FLA_ALG_FRONT, n_repeats, m, nfc, nlc,
C, C_ref, t, &dtime, &diff, &gflops );
//.........这里部分代码省略.........
示例14: main
int main(int argc, char *argv[])
{
int
datatype,
n_threads,
m_input,
m,
n_input,
n,
p_first, p_last, p_inc,
p,
n_repeats,
param_combo,
i,
n_param_combos = N_PARAM_COMBOS;
dim_t
n_panels,
nb_flash,
nb_alg;
double
dtime,
gflops,
diff;
FLA_Obj A, ATW, R, RTW, b, x;
FLA_Obj A_flat, b_flat, x_flat;
FLA_Init( );
fprintf( stdout, "%c number of repeats: ", '%' );
scanf( "%d", &n_repeats );
fprintf( stdout, "%c %d\n", '%', n_repeats );
fprintf( stdout, "%c enter algorithmic blocksize: ", '%' );
scanf( "%u", &nb_alg );
fprintf( stdout, "%c %u\n", '%', nb_alg );
fprintf( stdout, "%c enter FLASH blocksize: ", '%' );
scanf( "%u", &nb_flash );
fprintf( stdout, "%c %u\n", '%', nb_flash );
fprintf( stdout, "%c enter problem size first, last, inc: ", '%' );
scanf( "%d%d%d", &p_first, &p_last, &p_inc );
fprintf( stdout, "%c %d %d %d\n", '%', p_first, p_last, p_inc );
fprintf( stdout, "%c enter m n (-1 means bind to problem size): ", '%' );
scanf( "%d %d", &m_input, &n_input );
fprintf( stdout, "%c %d %d\n", '%', m_input, n_input );
fprintf( stdout, "%c enter the number of QR subproblem panels: ", '%' );
scanf( "%u", &n_panels );
fprintf( stdout, "%c %u\n", '%', n_panels );
fprintf( stdout, "%c enter the number of SuperMatrix threads: ", '%' );
scanf( "%d", &n_threads );
fprintf( stdout, "%c %d\n", '%', n_threads );
//datatype = FLA_FLOAT;
datatype = FLA_DOUBLE;
//datatype = FLA_COMPLEX;
//datatype = FLA_DOUBLE_COMPLEX;
//FLASH_Queue_disable();
FLASH_Queue_set_num_threads( n_threads );
//FLASH_Queue_set_verbose_output( TRUE );
// FLA_Check_error_level_set( FLA_NO_ERROR_CHECKING );
for ( p = p_first, i = 1; p <= p_last; p += p_inc, i += 1 )
{
m = m_input;
n = n_input;
if ( m < 0 ) m = p * f2c_abs(m_input);
if ( n < 0 ) n = p * f2c_abs(n_input);
for ( param_combo = 0; param_combo < n_param_combos; param_combo++ )
{
FLA_Obj_create( datatype, m, n, 0, 0, &A_flat );
FLA_Obj_create( datatype, n, 1, 0, 0, &x_flat );
FLA_Obj_create( datatype, m, 1, 0, 0, &b_flat );
FLA_Random_matrix( A_flat );
FLA_Random_matrix( b_flat );
FLASH_CAQR_UT_inc_create_hier_matrices( n_panels, A_flat, 1, &nb_flash, nb_alg,
&A, &ATW, &R, &RTW );
FLASH_Obj_create_hier_copy_of_flat( b_flat, 1, &nb_flash, &b );
FLASH_Obj_create_hier_copy_of_flat( x_flat, 1, &nb_flash, &x );
fprintf( stdout, "data_caqrutinc_%s( %d, 1:3 ) = [ %d ", pc_str[param_combo], i, p );
fflush( stdout );
time_CAQR_UT_inc( param_combo, FLA_ALG_FRONT, n_repeats, m, n, n_panels,
A, ATW, R, RTW, b, x, &dtime, &diff, &gflops );
//.........这里部分代码省略.........
示例15: main
int main( int argc, char *argv[] )
{
int
i, j,
size,
n_threads,
n_repeats,
n_trials,
nb_alg,
increment,
begin;
FLA_Datatype
datatype = FLA_DOUBLE;
FLA_Obj
A;
double
b_norm_value = 0.0,
dtime,
*dtimes,
*flops,
*T;
char
output_file_m[100];
FILE
*fpp;
fprintf( stdout, "%c Enter number of repeats: ", '%' );
scanf( "%d", &n_repeats );
fprintf( stdout, "%c %d\n", '%', n_repeats );
fprintf( stdout, "%c Enter blocksize: ", '%' );
scanf( "%d", &nb_alg );
fprintf( stdout, "%c %d\n", '%', nb_alg );
fprintf( stdout, "%c Enter problem size parameters: first, inc, num: ", '%' );
scanf( "%d%d%d", &begin, &increment, &n_trials );
fprintf( stdout, "%c %d %d %d\n", '%', begin, increment, n_trials );
fprintf( stdout, "%c Enter number of threads: ", '%' );
scanf( "%d", &n_threads );
fprintf( stdout, "%c %d\n\n", '%', n_threads );
sprintf( output_file_m, "%s/%s_output.m", OUTPUT_PATH, OUTPUT_FILE );
fpp = fopen( output_file_m, "a" );
fprintf( fpp, "%%\n" );
fprintf( fpp, "%% | Matrix Size | PLASMA |\n" );
fprintf( fpp, "%% | n x n | GFlops |\n" );
fprintf( fpp, "%% -----------------------------\n" );
FLA_Init();
PLASMA_Init( n_threads );
PLASMA_Disable( PLASMA_AUTOTUNING );
PLASMA_Set( PLASMA_TILE_SIZE, nb_alg );
PLASMA_Set( PLASMA_INNER_BLOCK_SIZE, nb_alg / 4 );
dtimes = ( double * ) FLA_malloc( n_repeats * sizeof( double ) );
flops = ( double * ) FLA_malloc( n_trials * sizeof( double ) );
fprintf( fpp, "%s = [\n", OUTPUT_FILE );
for ( i = 0; i < n_trials; i++ )
{
size = begin + i * increment;
FLA_Obj_create( datatype, size, size, 0, 0, &A );
for ( j = 0; j < n_repeats; j++ )
{
FLA_Random_matrix( A );
PLASMA_Alloc_Workspace_dgeqrf( size, size, &T );
dtime = FLA_Clock();
PLASMA_dgeqrf( size, size, FLA_Obj_buffer_at_view( A ), size, T );
dtime = FLA_Clock() - dtime;
dtimes[j] = dtime;
free( T );
}
dtime = dtimes[0];
for ( j = 1; j < n_repeats; j++ )
dtime = min( dtime, dtimes[j] );
flops[i] = 4.0 / 3.0 * size * size * size / dtime / 1e9;
fprintf( fpp, " %d %6.3f\n", size, flops[i] );
printf( "Time: %e | GFlops: %6.3f\n",
dtime, flops[i] );
printf( "Matrix size: %d x %d | nb_alg: %d\n",
size, size, nb_alg );
//.........这里部分代码省略.........