]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/ublas/benchmarks/mm_prod.cpp
2 // Copyright (c) 2018 Stefan Seefeld
3 // All rights reserved.
5 // This file is part of Boost.uBLAS. It is made available under the
6 // Boost Software License, Version 1.0.
7 // (Consult LICENSE or http://www.boost.org/LICENSE_1_0.txt)
9 #include <boost/numeric/ublas/matrix.hpp>
10 #include <boost/program_options.hpp>
15 namespace po
= boost::program_options
;
16 namespace ublas
= boost::numeric::ublas
;
17 namespace bm
= boost::numeric::ublas::benchmark
;
20 void benchmark(std::string
const &type
)
22 using matrix
= ublas::matrix
<T
, ublas::basic_row_major
<>>;
23 bm::prod
<matrix(matrix
, matrix
)> p("prod(matrix<" + type
+ ">)");
24 p
.run(std::vector
<long>({1, 2, 4, 8, 16, 32, 64, 128, 256, 512}));//, 1024}));
27 int main(int argc
, char **argv
)
32 po::options_description
desc("Matrix product\n"
34 desc
.add_options()("help,h", "produce help message");
35 desc
.add_options()("type,t", po::value
<std::string
>(), "select value-type (float, double, fcomplex, dcomplex)");
37 po::store(po::parse_command_line(argc
, argv
, desc
), vm
);
42 std::cout
<< desc
<< std::endl
;
46 catch(std::exception
&e
)
48 std::cerr
<< "error: " << e
.what() << std::endl
;
51 std::string type
= vm
.count("type") ? vm
["type"].as
<std::string
>() : "float";
53 benchmark
<float>("float");
54 else if (type
== "double")
55 benchmark
<double>("double");
56 else if (type
== "fcomplex")
57 benchmark
<std::complex<float>>("std::complex<float>");
58 else if (type
== "dcomplex")
59 benchmark
<std::complex<double>>("std::complex<double>");
61 std::cerr
<< "unsupported value-type \"" << vm
["type"].as
<std::string
>() << '\"' << std::endl
;