/*! * \file main.cpp * \brief Main application file * * \author * Christos Choutouridis AEM:8997 * */ #include #include #include #include #include // Global session data session_t session; Log logger; /*! * A small command line argument parser * \return The status of the operation */ bool get_options(int argc, char* argv[]){ bool status =true; // iterate over the passed arguments for (int i=1 ; i (session.mtxFile)) throw std::runtime_error("Error: Matrix is not strictly upper or lower"); if (!Mtx::load (A, session.mtxFile)) { throw std::runtime_error("Error: fail to load matrix"); } timer.stop(); logger << "Matrix size: " << A.size() << " and capacity: " << A.capacity() << logger.endl; timer.print_dt("load matrix"); } if (session.verbose && session.mtx_print) { logger << "\nMatrix:" << logger.endl; print_graph (A); } } /* * main program */ int main(int argc, char* argv[]) try { Timing timer; matrix A; std::vector c; index_t s; // try to read command line if (!get_options(argc, argv)) exit(1); prepare_matrix(A, timer); threads_info(); logger << "Create count vector" << logger.endl; timer.start(); c = triang_v (A); timer.stop(); timer.print_dt("create count vector"); if (session.print_count) { logger << "Calculate total triangles" << logger.endl; timer.start(); s = triang_count(c); timer.stop(); logger << "There are " << s << " triangles" << logger.endl; timer.print_dt("calculate sum"); } // output results if (session.print_count) triangle_out (s, (session.outputMode == OutputMode::FILE) ? session.outFile : std::cout); else vector_out (c, (session.outputMode == OutputMode::FILE) ? session.outFile : std::cout); return 0; } catch (std::exception& e) { //we probably pollute the user's screen. Comment `cerr << ...` if you don't like it. std::cerr << e.what() << '\n'; exit(1); }