/**********************************************************************************************/ /* This program is part of the Barcelona OpenMP Tasks Suite */ /* Copyright (C) 2009 Barcelona Supercomputing Center - Centro Nacional de Supercomputacion */ /* Copyright (C) 2009 Universitat Politecnica de Catalunya */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /* This program is distributed in the hope that it will be useful, */ /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ /* GNU General Public License for more details. */ /* */ /* You should have received a copy of the GNU General Public License */ /* along with this program; if not, write to the Free Software */ /* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /**********************************************************************************************/ /*********************************************************************** * main function & common behaviour of the benchmark. **********************************************************************/ #include #include "strassen.hpp" void strassen_alg( const std::string& model, const unsigned num_threads, const unsigned num_rounds ) { std::cout << std::setw(12) << "runtime" << std::endl; double runtime {0.0}; for(unsigned j=0; jcheck([] (const std::string& m) { if(m != "tbb" && m != "tf" && m != "omp") { return "model name should be \"tbb\", \"omp\", or \"tf\""; } return ""; }); CLI11_PARSE(app, argc, argv); std::cout << "model=" << model << ' ' << "num_threads=" << num_threads << ' ' << "num_rounds=" << num_rounds << ' ' << "check result=" << check_result << ' ' << std::endl; init_ABC(); strassen_alg(model, num_threads, num_rounds); if(check_result) { // Compare against the sequential matrix multiplication double *D; D = alloc_matrix(MATRIX_SIZE); auto beg = std::chrono::high_resolution_clock::now(); //OptimizedStrassenMultiply_seq(D, MatrixA, MatrixB, MATRIX_SIZE, MATRIX_SIZE, MATRIX_SIZE, MATRIX_SIZE, 1); auto end = std::chrono::high_resolution_clock::now(); std::cout << "Seq: " << std::chrono::duration_cast(end - beg).count()/1e3 << std::endl; matrixmul(MATRIX_SIZE, MatrixA, MATRIX_SIZE, MatrixB, MATRIX_SIZE, D, MATRIX_SIZE); assert(compare_matrix(MATRIX_SIZE, MatrixC, MATRIX_SIZE, D, MATRIX_SIZE) == 1); std::cout << "Correct!\n"; free(D); } free(MatrixA); free(MatrixB); free(MatrixC); return 0; }