1 /*
2
3 Copyright (C) 2014, The University of Texas at Austin
4
5 This file is part of libflame and is available under the 3-Clause
6 BSD license, which can be found in the LICENSE file at the top-level
7 directory, or at http://opensource.org/licenses/BSD-3-Clause
8
9 */
10
11 #include "FLAME.h"
12
13 #define N_PARAM_COMBOS 4
14
15 #define FLA_ALG_REFERENCE 0
16 #define FLA_ALG_FRONT 1
17
18 char* pc_str[N_PARAM_COMBOS] = { "il", "iu", "nl", "nu" };
19
20 void time_Eig_gest(
21 int param_combo, int type, int n_repeats, int n,
22 FLA_Inv inv, FLA_Uplo uplo, FLA_Obj A, FLA_Obj B, FLA_Obj norm,
23 double *dtime, double *diff, double *gflops );
24
25
main(int argc,char * argv[])26 int main(int argc, char *argv[])
27 {
28 int
29 m_input,
30 m,
31 p_first, p_last, p_inc,
32 p,
33 n_repeats,
34 param_combo,
35 i,
36 n_param_combos = N_PARAM_COMBOS;
37
38 FLA_Datatype datatype;
39 FLA_Uplo uplo;
40 FLA_Inv inv;
41
42 char *colors = "brkgmcbrkg";
43 char *ticks = "o+*xso+*xs";
44 char m_dim_desc[14];
45 char m_dim_tag[10];
46
47 double max_gflops=6.0;
48
49 double
50 dtime,
51 gflops,
52 diff;
53
54 FLA_Obj
55 A, B, norm;
56
57
58 FLA_Init();
59
60
61 fprintf( stdout, "%c number of repeats: ", '%' );
62 scanf( "%d", &n_repeats );
63 fprintf( stdout, "%c %d\n", '%', n_repeats );
64
65 fprintf( stdout, "%c enter problem size first, last, inc: ", '%' );
66 scanf( "%d%d%d", &p_first, &p_last, &p_inc );
67 fprintf( stdout, "%c %d %d %d\n", '%', p_first, p_last, p_inc );
68
69 fprintf( stdout, "%c enter m (-1 means bind to problem size): ", '%' );
70 scanf( "%d", &m_input );
71 fprintf( stdout, "%c %d\n", '%', m_input );
72
73
74 fprintf( stdout, "\n" );
75
76
77 if ( m_input > 0 ) {
78 sprintf( m_dim_desc, "m = %d", m_input );
79 sprintf( m_dim_tag, "m%dc", m_input);
80 }
81 else if( m_input < -1 ) {
82 sprintf( m_dim_desc, "m = p/%d", -m_input );
83 sprintf( m_dim_tag, "m%dp", -m_input );
84 }
85 else if( m_input == -1 ) {
86 sprintf( m_dim_desc, "m = p" );
87 sprintf( m_dim_tag, "m%dp", 1 );
88 }
89
90
91 //datatype = FLA_FLOAT;
92 //datatype = FLA_DOUBLE;
93 //datatype = FLA_COMPLEX;
94 datatype = FLA_DOUBLE_COMPLEX;
95
96 for ( p = p_first, i = 1; p <= p_last; p += p_inc, i += 1 )
97 {
98 m = m_input;
99
100 if( m < 0 ) m = p / f2c_abs(m_input);
101
102 for ( param_combo = 0; param_combo < n_param_combos; param_combo++ ){
103
104 if ( pc_str[param_combo][0] == 'i' ) inv = FLA_INVERSE;
105 else inv = FLA_NO_INVERSE;
106
107 if ( pc_str[param_combo][1] == 'l' ) uplo = FLA_LOWER_TRIANGULAR;
108 else uplo = FLA_UPPER_TRIANGULAR;
109
110 FLA_Obj_create( datatype, m, m, 0, 0, &A );
111 FLA_Obj_create( datatype, m, m, 0, 0, &B );
112
113 FLA_Obj_create( FLA_Obj_datatype_proj_to_real( A ), 1, 1, 0, 0, &norm );
114
115 FLA_Random_spd_matrix( uplo, A );
116 FLA_Hermitianize( uplo, A );
117
118 FLA_Random_spd_matrix( uplo, B );
119 FLA_Chol( uplo, B );
120
121
122 fprintf( stdout, "data_eig_gest_%s( %d, 1:5 ) = [ %d ", pc_str[param_combo], i, p );
123 fflush( stdout );
124
125 time_Eig_gest( param_combo, FLA_ALG_REFERENCE, n_repeats, m,
126 inv, uplo, A, B, norm, &dtime, &diff, &gflops );
127
128 fprintf( stdout, "%6.3lf %6.2le ", gflops, diff );
129 fflush( stdout );
130
131 time_Eig_gest( param_combo, FLA_ALG_FRONT, n_repeats, m,
132 inv, uplo, A, B, norm, &dtime, &diff, &gflops );
133
134 fprintf( stdout, "%6.3lf %6.2le ", gflops, diff );
135 fflush( stdout );
136
137
138 fprintf( stdout, " ]; \n" );
139 fflush( stdout );
140
141 FLA_Obj_free( &A );
142 FLA_Obj_free( &B );
143 FLA_Obj_free( &norm );
144 }
145
146 fprintf( stdout, "\n" );
147 }
148
149 /*
150 fprintf( stdout, "figure;\n" );
151
152 fprintf( stdout, "hold on;\n" );
153
154 for ( i = 0; i < n_param_combos; i++ ) {
155 fprintf( stdout, "plot( data_eig_gest_%s( :,1 ), data_eig_gest_%s( :, 2 ), '%c:%c' ); \n",
156 pc_str[i], pc_str[i], colors[ i ], ticks[ i ] );
157 fprintf( stdout, "plot( data_eig_gest_%s( :,1 ), data_eig_gest_%s( :, 4 ), '%c-.%c' ); \n",
158 pc_str[i], pc_str[i], colors[ i ], ticks[ i ] );
159 }
160
161 fprintf( stdout, "legend( ... \n" );
162
163 for ( i = 0; i < n_param_combos; i++ )
164 fprintf( stdout, "'ref\\_eig_gest\\_%s', 'fla\\_eig_gest\\_%s', ... \n", pc_str[i], pc_str[i] );
165
166 fprintf( stdout, "'Location', 'SouthEast' ); \n" );
167
168 fprintf( stdout, "xlabel( 'problem size p' );\n" );
169 fprintf( stdout, "ylabel( 'GFLOPS/sec.' );\n" );
170 fprintf( stdout, "axis( [ 0 %d 0 %.2f ] ); \n", p_last, max_gflops );
171 fprintf( stdout, "title( 'FLAME eig_gest front-end performance (%s)' );\n", m_dim_desc );
172 fprintf( stdout, "print -depsc eig_gest_front_%s.eps\n", m_dim_tag );
173 fprintf( stdout, "hold off;\n");
174 fflush( stdout );
175 */
176
177 FLA_Finalize();
178
179 return 0;
180 }
181
182