int main(int argc, char *argv[]) { LOGOG_INITIALIZE(); BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); logog::Cout *logogCout(new logog::Cout); logogCout->SetFormatter(*custom_format); TCLAP::CmdLine cmd("Simple mesh loading test", ' ', "0.1"); // 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 meshfile". TCLAP::ValueArg<std::string> mesh_arg("m","mesh","input mesh file",true,"homer","string"); // Add the argument mesh_arg to the CmdLine object. The CmdLine object // uses this Arg to parse the command line. cmd.add( mesh_arg ); cmd.parse( argc, argv ); std::string fname (mesh_arg.getValue()); #ifndef WIN32 BaseLib::MemWatch mem_watch; unsigned long mem_without_mesh (mem_watch.getVirtMemUsage()); #endif BaseLib::RunTime run_time; run_time.start(); MeshLib::Mesh* mesh = MeshLib::IO::readMeshFromFile(fname); #ifndef WIN32 unsigned long mem_with_mesh (mem_watch.getVirtMemUsage()); // std::cout << "mem for mesh: " << (mem_with_mesh - mem_without_mesh)/(1024*1024) << " MB" << std::endl; INFO ("mem for mesh: %i MB", (mem_with_mesh - mem_without_mesh)/(1024*1024)); #endif // std::cout << "time for reading: " << run_time.elapsed() << " s" << std::endl; INFO ("time for reading: %f s", run_time.elapsed()); /* unsigned elem_id = 25000; const MeshLib::Element* e = mesh->getElement(elem_id); const std::size_t nElems = mesh->getNumberOfElements(); for (unsigned i=0; i< e->getNumberOfNeighbors(); i++) { for (unsigned j=0; j< nElems; j++) if (mesh->getElement(j) == e->getNeighbor(i)) std::cout << "neighbour of element " << elem_id << " : " << j << std::endl; } */ delete mesh; delete logogCout; delete custom_format; LOGOG_SHUTDOWN(); }
int main(int argc, char *argv[]) { LOGOG_INITIALIZE(); BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); logog::Cout *logogCout(new logog::Cout); logogCout->SetFormatter(*custom_format); TCLAP::CmdLine cmd("Collapse mesh nodes and, if necessary, remove elements", ' ', "0.1"); // 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 meshfile". TCLAP::ValueArg<std::string> input_mesh_arg("m","mesh","input mesh file name",true,"","string"); // Add the argument mesh_arg to the CmdLine object. The CmdLine object // uses this Arg to parse the command line. cmd.add( input_mesh_arg ); TCLAP::ValueArg<std::string> output_mesh_arg("","out-mesh","mesh file name for output",false,"","string"); cmd.add( output_mesh_arg ); TCLAP::ValueArg<double> distance_arg("d","collapse-distance","maximal distance two nodes are collapsed",false,0.01,"for example you can set this parameter to 10^{-6} times maximal area length"); cmd.add( distance_arg ); cmd.parse( argc, argv ); std::string fname (input_mesh_arg.getValue()); FileIO::MeshIO mesh_io; #ifndef WIN32 BaseLib::MemWatch mem_watch; unsigned long mem_without_mesh (mem_watch.getVirtMemUsage()); BaseLib::RunTime run_time; run_time.start(); #endif MeshLib::Mesh* mesh = mesh_io.loadMeshFromFile(fname); #ifndef WIN32 if (mesh) { unsigned long mem_with_mesh (mem_watch.getVirtMemUsage()); INFO ("mem for mesh: %i MB", (mem_with_mesh - mem_without_mesh)/(1024*1024)); } run_time.stop(); if (mesh) { INFO ("time for reading: %f s", run_time.elapsed()); } #endif #ifndef WIN32 unsigned long mem_without_meshgrid (mem_watch.getVirtMemUsage()); run_time.start(); #endif MeshLib::MeshCoarsener mesh_coarsener(mesh); MeshLib::Mesh *collapsed_mesh(mesh_coarsener (distance_arg.getValue())); #ifndef WIN32 run_time.stop(); unsigned long mem_with_meshgrid (mem_watch.getVirtMemUsage()); INFO ("mem for meshgrid: %i MB", (mem_with_meshgrid - mem_without_meshgrid)/(1024*1024)); INFO ("time for collapsing: %f s", run_time.elapsed()); #endif mesh_io.setMesh(collapsed_mesh); std::string out_fname (output_mesh_arg.getValue()); if (out_fname.empty()) { out_fname = "/home/fischeth/workspace/OGS-6/Build/CollapsedMesh.msh"; } INFO ("writing collapsed mesh to %s", out_fname.c_str()); mesh_io.writeToFile(out_fname); INFO ("done"); delete mesh; delete collapsed_mesh; delete custom_format; delete logogCout; LOGOG_SHUTDOWN(); return 0; }
int main(int argc, char *argv[]) { LOGOG_INITIALIZE(); BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); logog::Cout *logogCout(new logog::Cout); logogCout->SetFormatter(*custom_format); TCLAP::CmdLine cmd("Moves the mesh nodes using the given displacement vector or if no displacement vector is given, moves the mesh nodes such that the centroid of the given mesh is in the origin.", ' ', "0.1"); // 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 meshfile". TCLAP::ValueArg<std::string> mesh_arg("m","mesh","input mesh 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( mesh_arg ); TCLAP::ValueArg<double> x_arg("x","x","displacement in x direction", false, 0.0,"floating point number"); cmd.add(x_arg); TCLAP::ValueArg<double> y_arg("y","y","displacement in y direction", false, 0.0,"floating point number"); cmd.add(y_arg); TCLAP::ValueArg<double> z_arg("z","z","displacement in z direction", false, 0.0,"floating point number"); cmd.add(z_arg); TCLAP::ValueArg<std::string> mesh_out_arg("o","output-mesh","output mesh file", false, "", "string"); cmd.add(mesh_out_arg); cmd.parse( argc, argv ); std::string fname (mesh_arg.getValue()); MeshLib::Mesh* mesh = FileIO::readMeshFromFile(fname); MeshLib::Node displacement(0.0, 0.0, 0.0); if (fabs(x_arg.getValue()) < std::numeric_limits<double>::epsilon() && fabs(y_arg.getValue()) < std::numeric_limits<double>::epsilon() && fabs(z_arg.getValue()) < std::numeric_limits<double>::epsilon()) { GeoLib::AABB<MeshLib::Node> aabb(mesh->getNodes().begin(), mesh->getNodes().end()); displacement[0] = -(aabb.getMaxPoint()[0] + aabb.getMinPoint()[0])/2.0; displacement[1] = -(aabb.getMaxPoint()[1] + aabb.getMinPoint()[1])/2.0; displacement[2] = -(aabb.getMaxPoint()[2] + aabb.getMinPoint()[2])/2.0; } else { displacement[0] = x_arg.getValue(); displacement[1] = y_arg.getValue(); displacement[2] = z_arg.getValue(); } INFO("translate model (%f, %f, %f).", displacement[0], displacement[1], displacement[2]); MeshLib::moveMeshNodes( mesh->getNodes().begin(), mesh->getNodes().end(), displacement); std::string out_fname(mesh_out_arg.getValue()); if (out_fname.empty()) { out_fname = BaseLib::dropFileExtension(mesh_out_arg.getValue()); out_fname += "_displaced.vtu"; } FileIO::VtuInterface mesh_io(mesh); mesh_io.writeToFile(out_fname); delete mesh; delete logogCout; delete custom_format; LOGOG_SHUTDOWN(); }
int main(int argc, char *argv[]) { LOGOG_INITIALIZE(); TCLAP::CmdLine cmd("The purpose of this program is the speed test of sparse matrix vector multiplication (MVM), where the matrix is stored in CRS format. Before executing the MVM a nested dissection reordering is performed.", ' ', "0.1"); // 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 in CRS format",true,"","file name of the matrix in CRS format"); // Add the argument matrix_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 ); TCLAP::ValueArg<unsigned> n_mults_arg("n", "number-of-multiplications", "number of multiplications to perform", true, 10, "number of multiplications"); cmd.add( n_mults_arg ); TCLAP::ValueArg<std::string> output_arg("o", "output", "output file", false, "", "string"); cmd.add( output_arg ); TCLAP::ValueArg<bool> 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()); BaseLib::LogogSimpleFormatter *custom_format (new BaseLib::LogogSimpleFormatter); logog::Cout *logogCout(new logog::Cout); logogCout->SetFormatter(*custom_format); INFO("%s was build with compiler %s", argv[0], BaseLib::BuildInfo::cmake_cxx_compiler.c_str()); #ifdef NDEBUG INFO("CXX_FLAGS: %s %s", BaseLib::BuildInfo::cmake_cxx_flags.c_str(), BaseLib::BuildInfo::cmake_cxx_flags_release.c_str()); #else INFO("CXX_FLAGS: %s %s", BaseLib::BuildInfo::cmake_cxx_flags.c_str(), BaseLib::BuildInfo::cmake_cxx_flags_debug.c_str()); #endif #ifdef UNIX const std::size_t length(256); char *hostname(new char[length]); gethostname (hostname, length); INFO("hostname: %s", hostname); delete [] hostname; #endif // *** reading matrix in crs format from file std::ifstream in(fname_mat.c_str(), std::ios::in | std::ios::binary); double *A(NULL); unsigned *iA(NULL), *jA(NULL), n; if (in) { if (verbose) { INFO("reading matrix from %s ...", fname_mat.c_str()); } BaseLib::RunTime timer; timer.start(); CS_read(in, n, iA, jA, A); if (verbose) { INFO("\t- took %e s", timer.elapsed()); } } else { ERR("error reading matrix from %s", fname_mat.c_str()); return -1; } unsigned nnz(iA[n]); if (verbose) { INFO("\tParameters read: n=%d, nnz=%d", n, nnz); } MathLib::CRSMatrixReordered mat(n, iA, jA, A); double *x(new double[n]); double *y(new double[n]); for (unsigned k(0); k<n; ++k) x[k] = 1.0; // create time measurement objects BaseLib::RunTime run_timer; BaseLib::CPUTime cpu_timer; // calculate the nested dissection reordering if (verbose) { INFO("*** calculating nested dissection (ND) permutation of matrix ..."); } run_timer.start(); cpu_timer.start(); MathLib::Cluster cluster_tree(n, iA, jA); unsigned *op_perm(new unsigned[n]); unsigned *po_perm(new unsigned[n]); for (unsigned k(0); k<n; k++) op_perm[k] = po_perm[k] = k; cluster_tree.createClusterTree(op_perm, po_perm, 1000); if (verbose) { INFO("\t[ND] - took %e sec \t%e sec", cpu_timer.elapsed(), run_timer.elapsed()); } // applying the nested dissection reordering if (verbose) { INFO("\t[ND] applying nested dissection permutation to FEM matrix ... "); } run_timer.start(); cpu_timer.start(); mat.reorderMatrix(op_perm, po_perm); if (verbose) { INFO("\t[ND]: - took %e sec\t%e sec", cpu_timer.elapsed(), run_timer.elapsed()); } #ifndef NDEBUG // std::string fname_mat_out(fname_mat.substr(0,fname_mat.length()-4)+"-reordered.bin"); // std::ofstream os (fname_mat_out.c_str(), std::ios::binary); // if (os) { // std::cout << "writing matrix to " << fname_mat_out << " ... " << std::flush; // CS_write(os, n, mat.getRowPtrArray(), mat.getColIdxArray(), mat.getEntryArray()); // std::cout << "done" << std::endl; // } #endif if (verbose) { INFO("*** %d matrix vector multiplications (MVM) with Toms amuxCRS ... ", n_mults); } run_timer.start(); cpu_timer.start(); for (std::size_t k(0); k<n_mults; k++) { mat.amux (1.0, x, y); } if (verbose) { INFO("\t[MVM] - took %e sec\t %e sec", cpu_timer.elapsed(), run_timer.elapsed()); } delete [] x; delete [] y; delete custom_format; delete logogCout; LOGOG_SHUTDOWN(); return 0; }
int main(int argc, char *argv[]) { LOGOG_INITIALIZE(); TCLAP::CmdLine cmd("Simple matrix vector multiplication test", ' ', "0.1"); // 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("p", "number-cores", "number of cores to use", false, 1, "number"); cmd.add( n_cores_arg ); TCLAP::ValueArg<unsigned> n_mults_arg("n", "number-of-multiplications", "number of multiplications to perform", true, 10, "number"); cmd.add( n_mults_arg ); 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()); FormatterCustom *custom_format (new FormatterCustom); logog::Cout *logogCout(new logog::Cout); logogCout->SetFormatter(*custom_format); logog::LogFile *logog_file(NULL); if (! output_arg.getValue().empty()) { logog_file = new logog::LogFile(output_arg.getValue().c_str()); logog_file->SetFormatter( *custom_format ); } // read number of threads unsigned n_threads (n_cores_arg.getValue()); INFO("%s was build with compiler %s", argv[0], BaseLib::BuildInfo::cmake_cxx_compiler.c_str()); #ifdef NDEBUG INFO("CXX_FLAGS: %s %s", BaseLib::BuildInfo::cmake_cxx_flags.c_str(), BaseLib::BuildInfo::cmake_cxx_flags_release.c_str()); #else INFO("CXX_FLAGS: %s %s", BaseLib::BuildInfo::cmake_cxx_flags.c_str(), BaseLib::BuildInfo::cmake_cxx_flags_debug.c_str()); #endif #ifdef UNIX const int max_host_name_len (255); char *hostname(new char[max_host_name_len]); if (gethostname(hostname, max_host_name_len) == 0) INFO("hostname: %s", hostname); delete [] host_name_len; #endif // *** reading matrix in crs format from file std::ifstream in(fname_mat.c_str(), std::ios::in | std::ios::binary); double *A(NULL); unsigned *iA(NULL), *jA(NULL), n; if (in) { INFO("reading matrix from %s ...", fname_mat.c_str()); BaseLib::RunTime timer; timer.start(); CS_read(in, n, iA, jA, A); INFO("\t- took %e s", timer.elapsed()); } else { INFO("error reading matrix from %s", fname_mat.c_str()); return -1; } unsigned nnz(iA[n]); INFO("\tParameters read: n=%d, nnz=%d", n, nnz); #ifdef _OPENMP omp_set_num_threads(n_threads); unsigned *mat_entries_per_core(new unsigned[n_threads]); for (unsigned k(0); k<n_threads; k++) { mat_entries_per_core[k] = 0; } OPENMP_LOOP_TYPE i; { #pragma omp parallel for for (i = 0; i < n; i++) { mat_entries_per_core[omp_get_thread_num()] += iA[i + 1] - iA[i]; } } INFO("*** work per core ***"); for (unsigned k(0); k<n_threads; k++) { INFO("\t%d\t%d", k, mat_entries_per_core[k]); } #endif #ifdef _OPENMP omp_set_num_threads(n_threads); MathLib::CRSMatrixOpenMP<double, unsigned> mat (n, iA, jA, A); #else MathLib::CRSMatrix<double, unsigned> mat (n, iA, jA, A); #endif double *x(new double[n]); double *y(new double[n]); for (unsigned k(0); k<n; ++k) x[k] = 1.0; INFO("*** %d matrix vector multiplications (MVM) with Toms amuxCRS (%d threads) ...", n_mults, n_threads); BaseLib::RunTime run_timer; BaseLib::CPUTime cpu_timer; run_timer.start(); cpu_timer.start(); for (std::size_t k(0); k<n_mults; k++) { mat.amux (1.0, x, y); } INFO("\t[MVM] - took %e sec cpu time, %e sec run time", cpu_timer.elapsed(), run_timer.elapsed()); delete [] x; delete [] y; delete custom_format; delete logogCout; delete logog_file; LOGOG_SHUTDOWN(); return 0; }
int main(int argc, char *argv[]) { LOGOG_INITIALIZE(); TCLAP::CmdLine cmd("The purpose of this program is the speed test of sparse matrix vector multiplication (MVM) employing OpenMP technique, where the matrix is stored in CRS format. Before executing the MVM a nested dissection reordering is performed.", ' ', "0.1"); // 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 in CRS format",true,"","file name of the matrix in CRS format"); // Add the argument matrix_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("p", "number-cores", "number of cores to use", true, 1, "number of cores"); cmd.add( n_cores_arg ); TCLAP::ValueArg<unsigned> n_mults_arg("n", "number-of-multiplications", "number of multiplications to perform", true, 10, "number of multiplications"); cmd.add( n_mults_arg ); TCLAP::ValueArg<std::string> output_arg("o", "output", "output file", false, "", "string"); cmd.add( output_arg ); TCLAP::ValueArg<bool> 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()); FormatterCustom *custom_format (new FormatterCustom); logog::Cout *logogCout(new logog::Cout); logogCout->SetFormatter(*custom_format); // read number of threads unsigned n_threads (n_cores_arg.getValue()); #ifdef OGS_BUILD_INFO INFO("%s was build with compiler %s", argv[0], CMAKE_CXX_COMPILER); if (std::string(CMAKE_BUILD_TYPE).compare("Release") == 0) { INFO("CXX_FLAGS: %s %s", CMAKE_CXX_FLAGS, CMAKE_CXX_FLAGS_RELEASE); } else { INFO("CXX_FLAGS: %s %s", CMAKE_CXX_FLAGS, CMAKE_CXX_FLAGS_DEBUG); } #endif #ifdef UNIX const size_t length(256); char *hostname(new char[length]); gethostname (hostname, length); INFO("hostname: %s", hostname); delete [] hostname; #endif // *** reading matrix in crs format from file std::ifstream in(fname_mat.c_str(), std::ios::in | std::ios::binary); double *A(NULL); unsigned *iA(NULL), *jA(NULL), n; if (in) { if (verbose) { INFO("reading matrix from %s ...", fname_mat.c_str()); } BaseLib::RunTime timer; timer.start(); CS_read(in, n, iA, jA, A); timer.stop(); if (verbose) { INFO("\t- took %e s", timer.elapsed()); } } else { ERR("error reading matrix from %s", fname_mat.c_str()); return -1; } unsigned nnz(iA[n]); if (verbose) { INFO("\tParameters read: n=%d, nnz=%d", n, nnz); } #ifdef _OPENMP omp_set_num_threads(n_threads); MathLib::CRSMatrixReorderedOpenMP mat(n, iA, jA, A); #else delete [] iA; delete [] jA; delete [] A; ERROR("program is not using OpenMP"); return -1; #endif double *x(new double[n]); double *y(new double[n]); for (unsigned k(0); k<n; ++k) x[k] = 1.0; // create time measurement objects BaseLib::RunTime run_timer; BaseLib::CPUTime cpu_timer; // calculate the nested dissection reordering if (verbose) { INFO("*** calculating nested dissection (ND) permutation of matrix ..."); } run_timer.start(); cpu_timer.start(); MathLib::Cluster cluster_tree(n, iA, jA); unsigned *op_perm(new unsigned[n]); unsigned *po_perm(new unsigned[n]); for (unsigned k(0); k<n; k++) op_perm[k] = po_perm[k] = k; cluster_tree.createClusterTree(op_perm, po_perm, 1000); cpu_timer.stop(); run_timer.stop(); if (verbose) { INFO("\t[ND] - took %e sec \t%e sec", cpu_timer.elapsed(), run_timer.elapsed()); } // applying the nested dissection reordering if (verbose) { INFO("\t[ND] applying nested dissection permutation to FEM matrix ... "); } run_timer.start(); cpu_timer.start(); mat.reorderMatrix(op_perm, po_perm); cpu_timer.stop(); run_timer.stop(); if (verbose) { INFO("\t[ND]: - took %e sec\t%e sec", cpu_timer.elapsed(), run_timer.elapsed()); } if (verbose) { INFO("*** %d matrix vector multiplications (MVM) with Toms amuxCRS (%d threads)... ", n_mults, n_threads); } run_timer.start(); cpu_timer.start(); for (size_t k(0); k<n_mults; k++) { mat.amux (1.0, x, y); } cpu_timer.stop(); run_timer.stop(); if (verbose) { INFO("\t[MVM] - took %e sec cpu time, %e sec run time", cpu_timer.elapsed(), run_timer.elapsed()); } delete [] x; delete [] y; delete custom_format; delete logogCout; LOGOG_SHUTDOWN(); return 0; }
int main(int argc, char *argv[]) { LOGOG_INITIALIZE(); TCLAP::CmdLine cmd("Simple matrix vector multiplication test employing pthreads", ' ', "0.1"); // 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("p", "number-cores", "number of cores to use", false, 1, "number"); cmd.add( n_cores_arg ); TCLAP::ValueArg<unsigned> n_mults_arg("n", "number-of-multiplications", "number of multiplications to perform", true, 10, "number"); cmd.add( n_mults_arg ); TCLAP::ValueArg<std::string> output_arg("o", "output", "output file", false, "", "string"); cmd.add( output_arg ); TCLAP::ValueArg<bool> 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 ); std::string fname_mat (matrix_arg.getValue()); FormatterCustom *custom_format (new FormatterCustom); logog::Cout *logogCout(new logog::Cout); logogCout->SetFormatter(*custom_format); logog::LogFile *logog_file(NULL); if (! output_arg.getValue().empty()) { logog_file = new logog::LogFile(output_arg.getValue().c_str()); logog_file->SetFormatter( *custom_format ); } #ifdef OGS_BUILD_INFO INFO("%s was build with compiler %s", argv[0], CMAKE_CXX_COMPILER); #ifdef CMAKE_BUILD_TYPE if (std::string(CMAKE_BUILD_TYPE).compare("Release") == 0) { INFO("CXX_FLAGS: %s %s", CMAKE_CXX_FLAGS, CMAKE_CXX_FLAGS_RELEASE); } else { INFO("CXX_FLAGS: %s %s", CMAKE_CXX_FLAGS, CMAKE_CXX_FLAGS_DEBUG); } #else INFO("CXX_FLAGS: %s", CMAKE_CXX_FLAGS); #endif #endif #ifdef UNIX const int max_host_name_len (255); char *hostname(new char[max_host_name_len]); if (gethostname(hostname, max_host_name_len) == 0) INFO("hostname: %s", hostname); delete [] host_name_len; #endif // *** reading matrix in crs format from file std::ifstream in(fname_mat.c_str(), std::ios::in | std::ios::binary); double *A(NULL); unsigned *iA(NULL), *jA(NULL), n; if (in) { INFO("reading matrix from %s ...", fname_mat.c_str()); BaseLib::RunTime timer; timer.start(); CS_read(in, n, iA, jA, A); timer.stop(); INFO("\t- took %e s", timer.elapsed()); } else { ERR("error reading matrix from %s", fname_mat.c_str()); return -1; } unsigned nnz(iA[n]); INFO("\tParameters read: n=%d, nnz=%d", n, nnz); #ifdef HAVE_PTHREADS unsigned n_threads(n_cores_arg.getValue()); MathLib::CRSMatrixPThreads<double> mat (n, iA, jA, A, n_threads); double *x(new double[n]); double *y(new double[n]); for (unsigned k(0); k<n; ++k) x[k] = 1.0; // read the number of multiplication to execute unsigned n_mults (n_mults_arg.getValue()); INFO("*** %d matrix vector multiplications (MVM) with Toms amuxCRS (%d threads) ...", n_mults, n_threads); BaseLib::RunTime run_timer; BaseLib::CPUTime cpu_timer; run_timer.start(); cpu_timer.start(); for (size_t k(0); k<n_mults; k++) { mat.amux (1.0, x, y); } cpu_timer.stop(); run_timer.stop(); INFO("\t[MVM] - took %e sec cpu time, %e sec run time", cpu_timer.elapsed(), run_timer.elapsed()); delete [] x; delete [] y; #endif delete custom_format; delete logogCout; delete logog_file; LOGOG_SHUTDOWN(); return 0; }