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 #define PARAMETERS_FILENAME      "input.global.general"
12 #define OPERATIONS_FILENAME      "input.global.operations"
13 #define COMMENT_CHAR             '#'
14 #define MAX_BINARY_NAME_LENGTH   256
15 #define INPUT_BUFFER_SIZE        256
16 #define MAX_DT_STRING_LENGTH     32
17 #define MAX_STOR_STRING_LENGTH   32
18 #define MAX_FUNC_STRING_LENGTH   32
19 #define MAX_NUM_STORAGE          4
20 #define MAX_NUM_DATATYPES        4
21 #define FLOPS_PER_UNIT_PERF      1e9
22 
23 #define DISABLE_ALL              0
24 #define SPECIFY                  1
25 #define DISABLE                  0
26 #define ENABLE                   1
27 
28 #define MAX_PASS_STRING_LENGTH   32
29 #define FLA_TEST_FAIL_STRING     "FAILURE"
30 #define FLA_TEST_WARN_STRING     "MARGINAL PASS"
31 #define FLA_TEST_PASS_STRING     "PASS"
32 
33 #define FLA_TEST_HIER_FRONT_END  (-1)
34 #define FLA_TEST_FLAT_FRONT_END  0
35 #define FLA_TEST_FLAT_UNB_VAR    1
36 #define FLA_TEST_FLAT_OPT_VAR    2
37 #define FLA_TEST_FLAT_BLK_VAR    3
38 #define FLA_TEST_FLAT_UNB_EXT    4
39 #define FLA_TEST_FLAT_BLK_EXT    5
40 
41 #define NUM_STORAGE_CHARS        3
42 #define STORAGE_SCHEME_CHARS     "crg"
43 
44 #define ON_FAILURE_IGNORE_CHAR   'i'
45 #define ON_FAILURE_SLEEP_CHAR    's'
46 #define ON_FAILURE_ABORT_CHAR    'a'
47 
48 #define SECONDS_TO_SLEEP         5
49 
50 
51 typedef struct
52 {
53 	unsigned int  n_repeats;
54 	unsigned int  n_storage;
55 	char          storage[ MAX_NUM_STORAGE + 1 ];
56 	unsigned int  n_datatypes;
57 	char          datatype_char[ MAX_NUM_DATATYPES + 1 ];
58 	FLA_Datatype  datatype[ MAX_NUM_DATATYPES + 1 ];
59 	dim_t         b_flash;
60 	dim_t         b_alg_hier;
61 	dim_t         b_alg_flat;
62 	dim_t         p_first;
63 	dim_t         p_max;
64 	dim_t         p_inc;
65 	unsigned int  n_threads;
66 	char          reaction_to_failure;
67 } test_params_t;
68 
69 
70 typedef struct
71 {
72 	int flash_front;
73 	int fla_front;
74 	int fla_unb_vars;
75 	int fla_opt_vars;
76 	int fla_blk_vars;
77 	int fla_unb_ext;
78 	int fla_blk_ext;
79 } test_op_t;
80 
81 
82 typedef struct
83 {
84 	// BLAS level-3
85 	test_op_t gemm;
86 	test_op_t hemm;
87 	test_op_t herk;
88 	test_op_t her2k;
89 	test_op_t symm;
90 	test_op_t syrk;
91 	test_op_t syr2k;
92 	test_op_t trmm;
93 	test_op_t trsm;
94 
95 	// LAPACK-level
96 	test_op_t chol;
97 	test_op_t lu_nopiv;
98 	test_op_t lu_piv;
99 	test_op_t lu_incpiv;
100 	test_op_t qrut;
101 	test_op_t qrutinc;
102 	test_op_t lqut;
103 	test_op_t apqut;
104 	test_op_t apqutinc;
105 	test_op_t caqrutinc;
106 	test_op_t apcaqutinc;
107 	test_op_t uddateut;
108 	test_op_t uddateutinc;
109 	test_op_t apqudut;
110 	test_op_t apqudutinc;
111 	test_op_t hessut;
112 	test_op_t tridiagut;
113 	test_op_t bidiagut;
114 	test_op_t eig_gest;
115 	test_op_t trinv;
116 	test_op_t spdinv;
117 	test_op_t sylv;
118 	test_op_t lyap;
119 } test_ops_t;
120 
121 
122 typedef struct
123 {
124 	double failwarn_s;
125 	double warnpass_s;
126 	double failwarn_d;
127 	double warnpass_d;
128 	double failwarn_c;
129 	double warnpass_c;
130 	double failwarn_z;
131 	double warnpass_z;
132 } test_thresh_t;
133 
134 
135 
136 // Prototypes.
137 char* libfla_test_get_string_for_datatype( FLA_Datatype datatype );
138 char* libfla_test_get_string_for_storage( char storage );
139 char* libfla_test_get_string_for_result( double         residual,
140                                          FLA_Datatype   datatype,
141                                          test_thresh_t* thresh );
142 void libfla_test_init_strings( void );
143 
144 void libfla_test_fill_storage_strings( char** sc_str, unsigned int n_storage_runs,
145                                                       unsigned int n_matrices );
146 void carryover( unsigned int* c, unsigned int n_matrices );
147 
148 void libfla_test_parse_command_line( int argc, char** argv );
149 
150 void libfla_test_output_op_struct( char* op_str, test_op_t op );
151 void libfla_test_output_op_struct_fla_only( char* op_str, test_op_t op );
152 void libfla_test_output_op_struct_flash_only( char* op_str, test_op_t op );
153 void libfla_test_output_op_struct_front_only( char* op_str, test_op_t op );
154 void libfla_test_output_op_struct_front_fla_only( char* op_str, test_op_t op );
155 void libfla_test_output_op_struct_blas3( char* op_str, test_op_t op );
156 
157 void libfla_test_output_info( char* message, ... );
158 void libfla_test_output_error( char* message, ... );
159 void libfla_test_parse_message( FILE* output_stream, char* message, va_list args );
160 
161 void libfla_test_read_next_line( char* buffer, FILE* input_stream );
162 
163 void libfla_test_read_parameter_file( char* input_filename, test_params_t* params );
164 
165 void libfla_test_read_operation_file( char* input_filename, test_ops_t* ops );
166 void libfla_test_read_tests_for_op( FILE* input_stream, test_op_t* op );
167 void libfla_test_read_tests_for_op_fla_only( FILE* input_stream, test_op_t* op );
168 void libfla_test_read_tests_for_op_flash_only( FILE* input_stream, test_op_t* op );
169 void libfla_test_read_tests_for_op_front_only( FILE* input_stream, test_op_t* op );
170 void libfla_test_read_tests_for_op_front_fla_only( FILE* input_stream, test_op_t* op );
171 void libfla_test_read_tests_for_op_blas3( FILE* input_stream, test_op_t* op );
172 
173 void libfla_test_blas3_suite( FILE* output_stream, test_params_t params, test_ops_t ops );
174 void libfla_test_lapack_suite( FILE* output_stream, test_params_t params, test_ops_t ops );
175 
176 void libfla_test_op_driver( char*         func_str,
177                             char*         impl_var_str,
178                             unsigned int  first_var,
179                             unsigned int  last_var,
180                             unsigned int  n_pc,
181                             char**        pc_str,
182                             unsigned int  n_matrices,
183                             signed int    impl,
184                             test_params_t params,
185                             test_thresh_t thresh,
186                             void (*f_exp) (test_params_t, // params
187                                            unsigned int,  // var
188                                            char*,         // sc_cur_str (current storage string)
189                                            FLA_Datatype,  // datatype
190                                            unsigned int,  // p_cur
191                                            unsigned int,  // pci (param combo counter)
192                                            unsigned int,  // n_repeats
193                                            signed int,    // impl
194                                            double*,       // perf
195                                            double* ) );   // residual
196 
197 void libfla_test_build_function_string( char*        func_base_str,
198                                         signed int   impl,
199                                         char*        impl_var_str,
200                                         unsigned int var,
201                                         unsigned int n_pc,
202                                         char*        pc_str,
203                                         char*        func_str );
204 
205 void fill_string_with_n_spaces( char* str, unsigned int n_spaces );
206 void libfla_test_obj_create( FLA_Datatype dt, FLA_Trans trans, char storage, dim_t m, dim_t n, FLA_Obj* A );
207 void libfla_test_sleep( void );
208 void libfla_test_abort( void );
209