Skip to content
Snippets Groups Projects
Commit 74d2ab4d authored by Tom Fischer's avatar Tom Fischer
Browse files

[file SimpleTest/MatrixTests/MatMult.cpp]

- switched format specifiers for LOGOG

[file SimpleTest/MatrixTests/MatVecMultPerm.cpp]
- using TCLAP library to parse command line
parent b20b04e6
No related branches found
No related tags found
No related merge requests found
......@@ -46,12 +46,12 @@ int main(int argc, char *argv[])
timer.start();
CS_read(in, n, iA, jA, A);
timer.stop();
DBUG("ok, %n s", timer.elapsed());
DBUG("ok, %e s", timer.elapsed());
} else {
ERR("error reading matrix from %s", fname_mat.c_str());
}
unsigned nnz(iA[n]);
INFO("Parameters read: n=%n, nnz=%n", n, nnz);
INFO("Parameters read: n=%i, nnz=%i", n, nnz);
#ifdef _OPENMP
omp_set_num_threads(n_threads);
......@@ -60,7 +60,7 @@ int main(int argc, char *argv[])
MathLib::CRSMatrix<double, unsigned> mat (n, iA, jA, A);
#endif
// CRSMatrixPThreads<double> mat (n, iA, jA, A, n_threads);
INFO("%n x %n", mat.getNRows(), mat.getNCols());
INFO("%i x %i", mat.getNRows(), mat.getNCols());
double *x(new double[n]);
double *y(new double[n]);
......@@ -68,7 +68,7 @@ int main(int argc, char *argv[])
for (unsigned k(0); k<n; ++k)
x[k] = 1.0;
DBUG("matrix vector multiplication with Toms amuxCRS (%n threads) ...", n_threads);
DBUG("matrix vector multiplication with Toms amuxCRS (%i threads) ...", n_threads);
BaseLib::RunTime run_timer;
BaseLib::CPUTime cpu_timer;
run_timer.start();
......@@ -79,9 +79,9 @@ int main(int argc, char *argv[])
cpu_timer.stop();
run_timer.stop();
DBUG("done [%n sec cpu time], [%n sec run time]", cpu_timer.elapsed(), run_timer.elapsed());
DBUG("CPU time: %n", cpu_timer.elapsed());
DBUG("wclock time: %n", run_timer.elapsed());
DBUG("done [%e sec cpu time], [%e sec run time]", cpu_timer.elapsed(), run_timer.elapsed());
DBUG("CPU time: %e", cpu_timer.elapsed());
DBUG("wclock time: %e", run_timer.elapsed());
if (argc == 5) {
std::ofstream result_os (argv[4], std::ios::app);
......@@ -90,7 +90,7 @@ int main(int argc, char *argv[])
}
result_os.close();
} else {
INFO("%n \t %n", cpu_timer.elapsed(), run_timer.elapsed());
INFO("%e \t %e", cpu_timer.elapsed(), run_timer.elapsed());
}
......
......@@ -10,6 +10,7 @@
// BaseLib
#include "RunTime.h"
#include "CPUTime.h"
#include "tclap/CmdLine.h"
// MathLib
#include "sparse.h"
......@@ -21,18 +22,35 @@
int main(int argc, char *argv[])
{
if (argc < 4) {
std::cout << "Usage: " << argv[0] << " matrix number_of_multiplications resultfile" << std::endl;
return 1;
}
TCLAP::CmdLine cmd("Simple matrix vector multiplication test", ' ', "0.1");
// read the number of multiplication to execute
unsigned n_mults (0);
n_mults = atoi (argv[2]);
// Define a value argument and add it to the command line.
// A value arg defines a flag and a type of value that it expects,
// such as "-m matrix".
TCLAP::ValueArg<std::string> matrix_arg("m","matrix","input matrix file",true,"","string");
// Add the argument mesh_arg to the CmdLine object. The CmdLine object
// uses this Arg to parse the command line.
cmd.add( matrix_arg );
// TCLAP::ValueArg<unsigned> n_cores_arg("n", "number-cores", "number of cores to use", true, "1", "number");
// cmd.add( n_cores_arg );
std::string fname_mat (argv[1]);
TCLAP::ValueArg<unsigned> n_mults_arg("n", "number-of-multiplications", "number of multiplications to perform", true, 10, "unsigned");
cmd.add( n_mults_arg );
bool verbose (false);
TCLAP::ValueArg<std::string> output_arg("o", "output", "output file", false, "", "string");
cmd.add( output_arg );
TCLAP::ValueArg<unsigned> verbosity_arg("v", "verbose", "level of verbosity [0 very low information, 1 much information]", false, 0, "string");
cmd.add( verbosity_arg );
cmd.parse( argc, argv );
// read the number of multiplication to execute
unsigned n_mults (n_mults_arg.getValue());
std::string fname_mat (matrix_arg.getValue());
bool verbose (verbosity_arg.getValue());
// *** reading matrix in crs format from file
std::ifstream in(fname_mat.c_str(), std::ios::in | std::ios::binary);
......@@ -87,8 +105,8 @@ int main(int argc, char *argv[])
if (verbose) {
std::cout << cpu_timer.elapsed() << "\t" << run_timer.elapsed() << std::endl;
} else {
if (argc == 4) {
std::ofstream result_os(argv[3], std::ios::app);
if (! output_arg.getValue().empty()) {
std::ofstream result_os(output_arg.getValue().c_str(), std::ios::app);
if (result_os) {
result_os << cpu_timer.elapsed() << "\t" << run_timer.elapsed() << " calc nested dissection perm" << std::endl;
}
......@@ -110,8 +128,8 @@ int main(int argc, char *argv[])
run_timer.stop();
if (verbose) std::cout << cpu_timer.elapsed() << "\t" << run_timer.elapsed() << std::endl;
else {
if (argc == 4) {
std::ofstream result_os(argv[3], std::ios::app);
if (! ((output_arg.getValue()).empty())) {
std::ofstream result_os((output_arg.getValue()).c_str(), std::ios::app);
if (result_os) {
result_os << cpu_timer.elapsed() << "\t" << run_timer.elapsed() << " applying nested dissection perm" << std::endl;
}
......@@ -153,8 +171,8 @@ int main(int argc, char *argv[])
std::cout << "done [" << cpu_timer.elapsed() << " sec cpu time], [wclock: "
<< run_timer.elapsed() << " sec]" << std::endl;
} else {
if (argc == 4) {
std::ofstream result_os (argv[3], std::ios::app);
if (! output_arg.getValue().empty()) {
std::ofstream result_os (output_arg.getValue().c_str(), std::ios::app);
if (result_os) {
result_os << cpu_timer.elapsed() << "\t" << run_timer.elapsed() << " " << n_mults << " MatVecMults, matrix " << fname_mat << std::endl;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment