15 #include "pzbfilestream.h" 22 #include "tbb/task_scheduler_init.h" 35 cout <<
"Execute performance tests for skylmatrices" << endl;
37 cout <<
"Usage: " << prg <<
"-op operation -[m|bm] matrixfn [-[m|bm]2 matrixfn] [-v level] [-perf_rdt rdt_file] [-h]";
38 cout <<
"[extra_arguments] [-h]" << endl << endl;
39 cout <<
"operation:" << endl;
40 cout <<
" 0: dump skyline matrix statistics" << endl;
41 cout <<
" 1: decompose matrix using Decompose_Cholesky()" << endl;
42 cout <<
" 2: decompose matrix using Decompose_LDLt()" << endl;
54 #define VERBOSE(level,...) if (level <= verbose) cout << __VA_ARGS__ 71 int main(
int argc,
char *argv[])
74 task_scheduler_init init;
79 cerr <<
"Error when parsing the arguments!" << endl;
85 cout <<
"- Arguments -----------------------" << endl;
87 cout <<
"-----------------------------------" << endl;
96 cerr <<
"You must provide the operation -op." << endl;
114 cerr <<
"ERROR: Invalid matrix operation type." << endl;
119 cerr <<
"ERROR when executing the experiment." << endl;
171 cerr <<
"Both -res_chk_t and -res_chk_b were set. Use only one option." << endl;
183 VERBOSE(1,
"Checking result using reference matrix : " << filename << endl);
188 ref_matrix.
Read(file,0);
190 int max_j = matrix.
Cols();
191 if (max_j != ref_matrix.
Cols()) {
192 cerr <<
"Result matrix has " << max_j
193 <<
" cols while reference matrix has " 194 << ref_matrix.
Cols() << endl;
195 VERBOSE(1,
"Checking result using reference matrix : " << filename <<
"[FAILED]" << endl);
200 REAL max_error = 0.0;
202 for (
int j=0; j<max_j; j++) {
204 if (col_height != ref_matrix.
SkyHeight(j)) {
205 cerr <<
"Column " << j <<
" of result matrix has " << col_height
206 <<
" non zero rows while reference matrix has " 208 VERBOSE(1,
"Checking result using reference matrix : " << filename <<
"[FAILED]" << endl);
212 int min_i = (j+1) - col_height;
213 for (
int i=min_i; i<=j; i++) {
214 REAL dm_ij = matrix.
s(i,j);
215 REAL rm_ij = ref_matrix.
s(i,j);
216 if (dm_ij != rm_ij) {
217 REAL diff =
abs(dm_ij - rm_ij);
218 if (diff >= error_tolerance) {
219 VERBOSE(1,
"diff(" << diff <<
") tolerance (" << error_tolerance
220 <<
"). dm[" << i <<
"][" << j <<
"] (" << dm_ij
221 <<
") != rm[" << i <<
"][" << j <<
"] (" << rm_ij
224 max_error = (max_error < diff)?diff:max_error;
230 cerr <<
"Error ("<< max_error <<
") > error tolerance (" 231 << error_tolerance <<
")" << endl;
232 VERBOSE(1,
"Checking result using reference matrix : " << filename <<
"[FAILED]" << endl);
235 VERBOSE(1,
"Checking result using reference matrix : " << filename <<
"[OK]" << endl);
249 cerr <<
"Both -res_dump_t and -res_dump_b were set. Use only one option." << endl;
261 VERBOSE(1,
"Dumping result to : " << filename << endl);
264 matrix.
Write(file,0);
265 VERBOSE(1,
"Dumping result to : " << filename <<
"[DONE]" << endl);
274 cerr <<
"Please provide an input matrix using -m or -bm." << endl;
279 cerr <<
"Both -m and -bm were set. Use only one option." << endl;
291 VERBOSE(1,
"Reading input file: " << inputfn << endl);
294 matrix.
Read(input_file,0);
295 VERBOSE(1,
"Reading input file: " << inputfn <<
"[DONE]" << endl);
307 unsigned n = matrix.
Dim();
308 uint64_t n_sky_items = 0;
309 uint64_t max_height = 0;
310 for (
unsigned i=0; i<n; i++) {
313 cout <<
"col " << i <<
" height = " << height << endl;
315 n_sky_items += height;
316 if (height > max_height) max_height = height;
319 double av_height = (double) n_sky_items / (
double) n;
320 cout <<
"N = " << n << endl;
321 cout <<
"N^2 = " << n2 << endl;
322 cout <<
"Sky items = " << n_sky_items << endl;
323 cout <<
"N^2 / Sky items = " << (double) n2 / (
double) n_sky_items << endl;
324 cout <<
"Avg. Height = " << av_height << endl;
325 cout <<
"Max. Height = " << max_height << endl;
Contains a class to record running statistics on CSV tables.
clarg::argInt verb_level("-v", "verbosity level", 0)
clarg::argString m2("-m2", "argument matrix file name (text format)", "matrix2.txt")
int read_input_matrix(TPZSkylMatrix< REAL > &matrix)
Contains declaration of the TPZMD5Stream class which implements the interface to write and check md5 ...
clarg::argString bm2("-bm2", "argument matrix file name (binary format)", "matrix2.bin")
void values(ostream &os, bool defined_only)
void OpenRead(const std::string &fn)
int main(int argc, char *argv[])
void Write(TPZStream &buf, int withclassid) const override
Packs the object structure in a stream of bytes.
int64_t SkyHeight(int64_t col)
return the height of the skyline for a given column
TinyFad< 8, T > abs(const TinyFad< 8, T > &in)
void OpenWrite(const std::string &fn)
#define VERBOSE(level,...)
Implements a skyline storage format. A Skyline matrix is symmetric so square. Matrix.
TPZSkylMatrix< REAL > matrix
virtual TVar & s(const int64_t row, const int64_t col) override
The operators check on the bounds if the DEBUG variable is defined.
int res_check(TPZSkylMatrix< REAL > &matrix)
clarg::argString res_dump_b("-res_dump_b", "write final results to a binary file.", "dump_matrix.bin")
void help(const char *prg)
Implements reading from and writing to an ascii file. Persistency.
int run_decompose_cholesky()
int parse_arguments(int argc, char *argv[])
clarg::argString res_chk_b("-res_chk_b", "check the results using a reference data (binary format)","")
Contains TPZSkyline class which implements a skyline storage format.
void arguments_descriptions(ostream &os, string prefix, string suffix)
virtual int64_t Dim() const
Returns the dimension of the matrix if the matrix is square.
clarg::argString bm("-bm", "input matrix file name (binary format)", "matrix.bin")
void Read(TPZStream &buf, void *context) override
Unpacks the object structure from a stream of bytes.
FileStreamWrapper(bool b)
RunStatsTable operation_rst("-perf_rdt", "Raw data table file to add matrix operation performance statistics")
const T & get_value() const
clarg::argDouble res_chk_tol("-res_chk_tol", "error tolerance when checking results.", 1.e-12)
void OpenWrite(const string &fn)
clarg::argString res_chk_t("-res_chk_t", "check the results using a reference data (text format)","")
int res_dump(TPZSkylMatrix< REAL > &matrix)
int64_t Cols() const
Returns number of cols.
clarg::argInt mop("-op", "Matrix operation", 1)
Defines the interface for saving and reading data. Persistency.
clarg::argString m("-m", "input matrix file name (text format)", "matrix.txt")
void OpenRead(const string &fn)
clarg::argString res_dump_t("-res_dump_t", "write final results to a text file.", "dump_matrix.txt")
clarg::argBool h("-h", "help message", false)