]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/numeric/ublas/benchmarks/mv_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/vector.hpp>
10 #include <boost/numeric/ublas/matrix.hpp>
11 #include <boost/program_options.hpp>
16 namespace po
= boost::program_options
;
17 namespace ublas
= boost::numeric::ublas
;
18 namespace bm
= boost::numeric::ublas::benchmark
;
21 void benchmark(std::string
const &type
)
23 using matrix
= ublas::matrix
<T
, ublas::basic_row_major
<>>;
24 using vector
= ublas::vector
<T
>;
25 bm::prod
<vector(matrix
, vector
)> p("prod(matrix<" + type
+ ">, vector<" + type
+ ">)");
26 p
.run(std::vector
<long>({1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096}));
29 int main(int argc
, char **argv
)
34 po::options_description
desc("Matrix-vector product\n"
36 desc
.add_options()("help,h", "produce help message");
37 desc
.add_options()("type,t", po::value
<std::string
>(), "select value-type (float, double, fcomplex, dcomplex)");
39 po::store(po::parse_command_line(argc
, argv
, desc
), vm
);
44 std::cout
<< desc
<< std::endl
;
48 catch(std::exception
&e
)
50 std::cerr
<< "error: " << e
.what() << std::endl
;
53 std::string type
= vm
.count("type") ? vm
["type"].as
<std::string
>() : "float";
55 benchmark
<float>("float");
56 else if (type
== "double")
57 benchmark
<double>("double");
58 else if (type
== "fcomplex")
59 benchmark
<std::complex<float>>("std::complex<float>");
60 else if (type
== "dcomplex")
61 benchmark
<std::complex<double>>("std::complex<double>");
63 std::cerr
<< "unsupported value-type \"" << vm
["type"].as
<std::string
>() << '\"' << std::endl
;